Skip to content

Commit b1cf094

Browse files
author
Oleksandr Iegorov
committed
MAGETWO-50460: User Defined qty available for 'Checkbox' bundle option
1 parent 445fd11 commit b1cf094

File tree

2 files changed

+23
-35
lines changed

2 files changed

+23
-35
lines changed

app/code/Magento/Bundle/Ui/DataProvider/Product/Form/Modifier/BundlePanel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ protected function getOptionInfo()
458458
'component' => 'Magento_Bundle/js/components/bundle-input-type',
459459
'parentContainer' => 'product_bundle_container',
460460
'selections' => 'bundle_selections',
461-
'targetIndex' => 'is_default',
462-
'targetCheckbox' => 'selection_can_change_qty',
461+
'isDefaultIndex' => 'is_default',
462+
'userDefinedIndex' => 'selection_can_change_qty',
463463
'dataScope' => 'type',
464464
'label' => __('Input Type'),
465465
'sortOrder' => 20,

app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-input-type.js

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,54 +26,42 @@ define([
2626

2727
if (type !== this.previousType) {
2828
this.previousType = type;
29-
30-
if (type === 'radio') {
31-
this.clearValues();
32-
}
29+
this.processSelections(type === 'radio');
3330
}
3431

35-
this.toggleCheckbox(type === 'radio');
36-
3732
this._super();
3833
},
3934

4035
/**
41-
* Toggle 'User Defined' checkbox in selections
42-
* @param {Boolean} visibility
36+
* Toggle 'User Defined' column and clears values
37+
* @param {Boolean} isRadio
4338
*/
44-
toggleCheckbox: function (visibility) {
45-
var records = registry.get(this.retrieveParentName(this.parentContainer) + '.' + this.selections);
39+
processSelections: function (isRadio) {
40+
var records = registry.get(this.retrieveParentName(this.parentContainer) + '.' + this.selections),
41+
checkedFound = false;
4642

4743
records.elems.each(function (record) {
4844
record.elems.filter(function (comp) {
49-
return comp.index === this.targetCheckbox;
45+
return comp.index === this.userDefinedIndex;
5046
}, this).each(function (comp) {
51-
comp.visible(visibility);
47+
comp.visible(isRadio);
5248
});
53-
}, this);
54-
},
5549

56-
/**
57-
* Clears values in components like this.
58-
*/
59-
clearValues: function () {
60-
var records = registry.get(this.retrieveParentName(this.parentContainer) + '.' + this.selections),
61-
checkedFound = false;
50+
if (isRadio) {
51+
record.elems.filter(function (comp) {
52+
return comp.index === this.isDefaultIndex;
53+
}, this).each(function (comp) {
54+
if (comp.checked()) {
55+
if (checkedFound) {
56+
comp.clearing = true;
57+
comp.clear();
58+
comp.clearing = false;
59+
}
6260

63-
records.elems.each(function (record) {
64-
record.elems.filter(function (comp) {
65-
return comp.index === this.targetIndex;
66-
}, this).each(function (comp) {
67-
if (comp.checked()) {
68-
if (checkedFound) {
69-
comp.clearing = true;
70-
comp.clear();
71-
comp.clearing = false;
61+
checkedFound = true;
7262
}
73-
74-
checkedFound = true;
75-
}
76-
});
63+
});
64+
}
7765
}, this);
7866
},
7967

0 commit comments

Comments
 (0)