From ddbc07e9b3bf5fcaab8bcbdd62f222e913dc9e35 Mon Sep 17 00:00:00 2001 From: Olga Nakonechna <onakonechna@ebay.com> Date: Tue, 20 Oct 2015 19:17:28 +0300 Subject: [PATCH] MAGETWO-44340: required-option class value does not work --- .../catalog/product/attribute/text.phtml | 27 ++++++++++++------- .../catalog/product/attribute/visual.phtml | 27 ++++++++++++------- lib/web/mage/validation.js | 11 ++++++++ 3 files changed, 45 insertions(+), 20 deletions(-) diff --git a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml index 63af3ebae14..1cdb50d54a3 100644 --- a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml +++ b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/text.phtml @@ -8,7 +8,7 @@ /** @var $block \Magento\Swatches\Block\Adminhtml\Attribute\Edit\Options\Text */ ?> -<fieldset class="fieldset ignore-validate"> +<fieldset class="fieldset"> <legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Manage Swatch (values of your attribute)') ?></span></legend> <div id="swatch-text-options-panel"> <?php //@todo move style to css file ?> @@ -33,16 +33,23 @@ <th class="col-delete"> </th> </tr> </thead> - <tbody data-role="swatch-text-options-container"></tbody> + <tbody data-role="swatch-text-options-container" class="ignore-validate"></tbody> <tfoot> - <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="col-actions-add"> - <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?> - <button id="add_new_swatch_text_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Swatch'); ?>" - type="button" class="action- scalable add"> - <span><?php /* @escapeNotVerified */ echo __('Add Swatch'); ?></span> - </button> - <?php endif; ?> - </th> + <tr> + <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>"> + <input type="hidden" class="required-swatch-entry"/> + </th> + </tr> + <tr> + <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="col-actions-add"> + <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?> + <button id="add_new_swatch_text_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Swatch'); ?>" + type="button" class="action- scalable add"> + <span><?php /* @escapeNotVerified */ echo __('Add Swatch'); ?></span> + </button> + <?php endif; ?> + </th> + </tr> </tfoot> </table> <input type="hidden" id="swatch-text-option-count-check" value="" /> diff --git a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml index a236cf00dd1..3871ccda9a3 100644 --- a/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml +++ b/app/code/Magento/Swatches/view/adminhtml/templates/catalog/product/attribute/visual.phtml @@ -8,7 +8,7 @@ /** @var $block \Magento\Swatches\Block\Adminhtml\Attribute\Edit\Options\Visual */ ?> -<fieldset class="fieldset ignore-validate"> +<fieldset class="fieldset"> <legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Manage Swatch (values of your attribute)') ?></span></legend> <div id="swatch-visual-options-panel"> <?php //@todo move style to css file ?> @@ -29,16 +29,23 @@ <th class="col-delete"> </th> </tr> </thead> - <tbody data-role="swatch-visual-options-container"></tbody> + <tbody data-role="swatch-visual-options-container" class="ignore-validate"></tbody> <tfoot> - <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="col-actions-add"> - <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?> - <button id="add_new_swatch_visual_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Swatch'); ?>" - type="button" class="action- scalable add"> - <span><?php /* @escapeNotVerified */ echo __('Add Swatch'); ?></span> - </button> - <?php endif; ?> - </th> + <tr> + <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>"> + <input type="hidden" class="required-swatch-entry"/> + </th> + </tr> + <tr> + <th colspan="<?php /* @escapeNotVerified */ echo $storetotal; ?>" class="col-actions-add"> + <?php if (!$block->getReadOnly() && !$block->canManageOptionDefaultOnly()):?> + <button id="add_new_swatch_visual_option_button" title="<?php /* @escapeNotVerified */ echo __('Add Swatch'); ?>" + type="button" class="action- scalable add"> + <span><?php /* @escapeNotVerified */ echo __('Add Swatch'); ?></span> + </button> + <?php endif; ?> + </th> + </tr> </tfoot> </table> <input type="hidden" id="swatch-visual-option-count-check" value="" /> diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js index 98240eb8cfa..982a7ecf73e 100644 --- a/lib/web/mage/validation.js +++ b/lib/web/mage/validation.js @@ -1224,6 +1224,17 @@ }, 'Please enter a valid number.' ], + 'required-swatch-entry': [ + function (value, element) { + var empty = $(element).closest('table') + .find('input.required-option') + .filter(function(i, el){ + return $.mage.isEmpty(el.value); + }) + .length; + return empty === 0; + }, 'Admin is a required field in the each row.' + ], 'validate-item-quantity': [ function (value, element, params) { // obtain values for validation -- GitLab