Skip to content

Commit

Permalink
Merge pull request #286 from magento-south/MAGETWO-45429-mb
Browse files Browse the repository at this point in the history
[SOUTH] MAGETWO-45429
  • Loading branch information
slavvka committed Jan 13, 2016
2 parents 880ad3a + 94783f9 commit 9bc1996
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
type="checkbox"
<?php if ($_option->getRequired()) echo 'data-validate="{\'validate-one-required-by-name\':\'input[name^=&quot;bundle_option[' . $_option->getId() . ']&quot;]:checked\'}"'?>
name="bundle_option[<?php echo $_option->getId() ?>][<?php echo $_selection->getId() ?>]"
data-selector="bundle_option[<?php echo $_option->getId() ?>][<?php echo $_selection->getId() ?>]"
<?php if ($block->isSelected($_selection)) echo ' checked="checked"' ?>
<?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>
value="<?php echo $_selection->getSelectionId() ?>"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
size="5"
id="bundle-option-<?php echo $_option->getId() ?>"
name="bundle_option[<?php echo $_option->getId() ?>][]"
data-selector="bundle_option[<?php echo $_option->getId() ?>][]"
class="bundle-option-<?php echo $_option->getId() ?> multiselect product bundle option change-container-classname"
<?php if ($_option->getRequired()) echo 'data-validate={required:true}' ?>>
<?php if(!$_option->getRequired()): ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
class="radio product bundle option"
id="bundle-option-<?php echo $_option->getId() ?>"
name="bundle_option[<?php echo $_option->getId() ?>]"
data-selector="bundle_option[<?php echo $_option->getId() ?>]"
<?php echo ($_default && $_default->isSalable())?'':' checked="checked" ' ?>
value=""/>
<label class="label" for="bundle-option-<?php echo $_option->getId() ?>">
Expand All @@ -46,6 +47,7 @@
id="bundle-option-<?php echo $_option->getId() ?>-<?php echo $_selection->getSelectionId() ?>"
<?php if ($_option->getRequired()) echo 'data-validate="{\'validate-one-required-by-name\':true}"'?>
name="bundle_option[<?php echo $_option->getId() ?>]"
data-selector="bundle_option[<?php echo $_option->getId() ?>]"
<?php if ($block->isSelected($_selection)) echo ' checked="checked"' ?>
<?php if (!$_selection->isSaleable()) echo ' disabled="disabled"' ?>
value="<?php echo $_selection->getSelectionId() ?>"/>
Expand All @@ -67,6 +69,7 @@
class="input-text qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>"
type="number"
name="bundle_option_qty[<?php echo $_option->getId() ?>]"
data-selector="bundle_option_qty[<?php echo $_option->getId() ?>]"
value="<?php echo $_defaultQty ?>"/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<?php else:?>
<select id="bundle-option-<?php echo $_option->getId() ?>"
name="bundle_option[<?php echo $_option->getId() ?>]"
data-selector="bundle_option[<?php echo $_option->getId() ?>]"
class="bundle-option-<?php echo $_option->getId() ?> product bundle option bundle-option-select change-container-classname"
<?php if ($_option->getRequired()) echo 'data-validate = {required:true}' ?>>
<option value=""><?php echo __('Choose a selection...') ?></option>
Expand All @@ -50,6 +51,7 @@
class="input-text qty<?php if (!$_canChangeQty) echo ' qty-disabled' ?>"
type="number"
name="bundle_option_qty[<?php echo $_option->getId() ?>]"
data-selector="bundle_option_qty[<?php echo $_option->getId() ?>]"
value="<?php echo $_defaultQty ?>"/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ protected function _getHtmlSelect($name, $value = null)
$extraParams .= ' onchange="opConfig.reloadPrice()"';
}
$extraParams .= ' data-role="calendar-dropdown" data-calendar-role="' . $name . '"';
$extraParams .= ' data-selector="' . $select->getName() . '"';
$select->setExtraParams($extraParams);

if ($value === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function getValuesHtml()
if (!$this->getSkipJsReloadPrice()) {
$extraParams .= ' onchange="opConfig.reloadPrice()"';
}
$extraParams .= ' data-selector="' . $select->getName() . '"';
$select->setExtraParams($extraParams);

if ($configValue) {
Expand Down Expand Up @@ -97,6 +98,7 @@ public function getValuesHtml()
' product-custom-option" name="options[' .
$_option->getId() .
']"' .
' data-selector="options[' . $_option->getId() . ']"' .
($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"') .
' value="" checked="checked" /><label class="label admin__field-label" for="options_' .
$_option->getId() .
Expand Down Expand Up @@ -128,6 +130,11 @@ public function getValuesHtml()
$checked = $configValue == $htmlValue ? 'checked' : '';
}

$dataSelector = 'options[' . $_option->getId() . ']';
if ($arraySign) {
$dataSelector .= '[' . $htmlValue . ']';
}

$selectHtml .= '<div class="field choice admin__field admin__field-option' .
$require .
'">' .
Expand All @@ -151,6 +158,7 @@ public function getValuesHtml()
$htmlValue .
'" ' .
$checked .
' data-selector="' . $dataSelector . '"' .
' price="' .
$this->pricingHelper->currencyByStore($_value->getPrice(true), $store, false) .
'" />' .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ $class = ($_option->getIsRequire()) ? ' required' : '';
data-validate="<?php echo $block->escapeHtml(json_encode($_textValidate));?>"
<?php } ?>
name="options[<?php echo $_option->getId() ?>]"
data-selector="options[<?php echo $_option->getId() ?>]"
value="<?php echo $block->escapeHtml($block->getDefaultValue()) ?>"/>
<?php elseif ($_option->getType() == \Magento\Catalog\Model\Product\Option::OPTION_TYPE_AREA): ?>
<?php $_textAreaValidate = null;
Expand All @@ -53,6 +54,7 @@ $class = ($_option->getIsRequire()) ? ' required' : '';
data-validate="<?php echo $block->escapeHtml(json_encode($_textAreaValidate));?>"
<?php } ?>
name="options[<?php echo $_option->getId() ?>]"
data-selector="options[<?php echo $_option->getId() ?>]"
rows="5"
cols="25"><?php echo $block->escapeHtml($block->getDefaultValue()) ?></textarea>
<?php endif; ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ $_attributes = $block->decorateArray($block->getAllowAttributes());
</label>
<div class="control">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]"
data-selector="super_attribute[<?php echo $_attribute->getAttributeId() ?>]"
data-validate="{required:true}"
id="attribute<?php echo $_attribute->getAttributeId() ?>"
class="super-attribute-select">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<?php if ($_item->isSaleable()) : ?>
<div class="control qty">
<input type="number" name="super_group[<?php echo $_item->getId() ?>]"
data-selector="super_group[<?php echo $_item->getId() ?>]"
maxlength="12"
value="<?php echo $_item->getQty() * 1 ?>"
title="<?php echo __('Qty') ?>"
Expand Down
17 changes: 13 additions & 4 deletions app/code/Magento/Wishlist/view/frontend/web/js/add-to-wishlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ define([

$.widget('mage.addToWishlist', {
options: {
bundleInfo: 'div.control [name^=bundle_option]:not([name*=qty])',
bundleInfo: 'div.control [name^=bundle_option]',
configurableInfo: '.super-attribute-select',
groupedInfo: '#super-product-table input',
downloadableInfo: '#downloadable-links-list input',
Expand Down Expand Up @@ -43,10 +43,12 @@ define([
$(event.handleObj.selector).each(function(index, element){
if ($(element).is('input[type=text]')
|| $(element).is('input[type=email]')
|| $(element).is('input[type=number]')
|| $(element).is('input[type=hidden]')
|| $(element).is('input[type=checkbox]:checked')
|| $(element).is('input[type=radio]:checked')
|| $('#' + element.id + ' option:selected').length
|| $(element).is('textarea')
|| $('#' + element.id + ' option:selected').length
) {
dataToAdd = $.extend({}, dataToAdd, self._getElementData(element));
return;
Expand All @@ -66,7 +68,7 @@ define([
$('[data-action="add-to-wishlist"]').each(function(index, element) {
var params = $(element).data('post');
if (!params)
params = {};
params = {'data': {}};

if (!$.isEmptyObject(dataToAdd)) {
self._removeExcessiveData(params, dataToAdd);
Expand All @@ -89,7 +91,7 @@ define([
},
_getElementData: function(element) {
var data = {},
elementName = $(element).attr('name'),
elementName = $(element).data('selector'),
elementValue = $(element).val();
if ($(element).is('select[multiple]') && elementValue !== null) {
if (elementName.substr(elementName.length - 2) == '[]') {
Expand Down Expand Up @@ -121,6 +123,13 @@ define([
params = $(event.currentTarget).data('post'),
form = $(element).closest('form'),
action = params.action;
if (params.data.id) {
$('<input>', {
type: 'hidden',
name: 'id',
value: params.data.id
}).appendTo(form);
}
if (params.data.uenc) {
action += 'uenc/' + params.data.uenc;
}
Expand Down

0 comments on commit 9bc1996

Please sign in to comment.