Skip to content

Commit 706c572

Browse files
Merge branch 'MAGETWO-48913' of https://github.corp.magento.com/magento-vanilla/magento2ce into MAGETWO-48913
2 parents 26438dd + e265adf commit 706c572

File tree

11 files changed

+213
-28
lines changed

11 files changed

+213
-28
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ protected function getBundleSelections()
521521
'arguments' => [
522522
'data' => [
523523
'config' => [
524+
'component' => 'Magento_Bundle/js/components/bundle-checkbox',
524525
'componentType' => Form\Field::NAME,
525526
'dataType' => Form\Element\DataType\Boolean::NAME,
526527
'formElement' => Form\Element\Checkbox::NAME,
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/**
2+
* Copyright © 2015 Magento. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'Magento_Ui/js/form/element/single-checkbox',
8+
'uiRegistry'
9+
], function (Checkbox, registry) {
10+
'use strict';
11+
12+
return Checkbox.extend({
13+
defaults: {
14+
clearing: false,
15+
parentContainer: 'product_bundle_container',
16+
parentSelections: 'bundle_selections',
17+
changer: 'option_info.type'
18+
},
19+
20+
/**
21+
* @inheritdoc
22+
*/
23+
initObservable: function () {
24+
this._super().
25+
observe('elementTmpl');
26+
27+
return this;
28+
},
29+
30+
/**
31+
* @inheritdoc
32+
*/
33+
initConfig: function () {
34+
this._super();
35+
this.imports.changeType = this.getParentName(this.parentContainer) + '.' + this.changer + ':value';
36+
37+
return this;
38+
},
39+
40+
/**
41+
* @inheritdoc
42+
*/
43+
onUpdate: function () {
44+
if (this.prefer === 'radio' && !this.clearing) {
45+
this.clearValues();
46+
} else if (this.prefer === 'radio') {
47+
this.clearing = false;
48+
}
49+
50+
this._super();
51+
},
52+
53+
/**
54+
* Getter for parent name. Split string by provided parent name.
55+
*
56+
* @param {String} parent - parent name.
57+
* @returns {String}
58+
*/
59+
getParentName: function (parent) {
60+
return this.name.split(parent)[0] + parent;
61+
},
62+
63+
/**
64+
* Checkbox to radio type changer.
65+
*
66+
* @param {String} type - type to change.
67+
*/
68+
changeType: function (type) {
69+
if (type === 'select') {
70+
type = 'radio';
71+
} else if (type === 'multi') {
72+
type = 'checkbox';
73+
}
74+
75+
this.prefer = type;
76+
this.clear();
77+
this.elementTmpl(this.templates[type]);
78+
this.clearing = false;
79+
},
80+
81+
/**
82+
* Clears values in components like this.
83+
*/
84+
clearValues: function () {
85+
var records = registry.get(this.getParentName(this.parentSelections)),
86+
index = this.index,
87+
uid = this.uid;
88+
89+
this.clearing = true;
90+
records.elems.each(function (record) {
91+
record.elems.filter(function (comp) {
92+
return comp.index === index && comp.uid !== uid;
93+
}).each(function (comp) {
94+
comp.clear();
95+
});
96+
});
97+
}
98+
});
99+
});

app/code/Magento/Ui/view/base/web/js/form/adapter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ define([
99
'use strict';
1010

1111
var buttons = {
12-
'reset': '#reset',
13-
'save': '#save',
14-
'saveAndContinue': '#save_and_continue'
15-
},
12+
'reset': '#reset',
13+
'save': '#save',
14+
'saveAndContinue': '#save_and_continue'
15+
},
1616
selectorPrefix = '',
1717
eventPrefix;
1818

app/code/Magento/Ui/view/base/web/js/form/components/button.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ define([
1616
additionalClasses: {},
1717
displayArea: 'outsideGroup',
1818
displayAsLink: false,
19-
visible: true,
2019
elementTmpl: 'ui/form/element/button',
21-
template: 'ui/form/components/button/simple'
20+
template: 'ui/form/components/button/simple',
21+
visible: true,
22+
disabled: false
2223
},
2324

2425
/**
@@ -31,6 +32,15 @@ define([
3132
._setClasses();
3233
},
3334

35+
/** @inheritdoc */
36+
initObservable: function () {
37+
return this._super()
38+
.observe([
39+
'visible',
40+
'disabled'
41+
]);
42+
},
43+
3444
/**
3545
* Performs configured actions
3646
*/

app/code/Magento/Ui/view/base/web/js/form/element/select.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,6 @@ define([
144144

145145
_.extend(config, result);
146146

147-
if (config.caption !== false && config.caption !== null && typeof config.caption !== 'undefined') {
148-
config.options.unshift({
149-
value: '',
150-
label: config.caption.trim() === '' ? ' ' : config.caption
151-
});
152-
delete config.caption;
153-
}
154-
155147
this._super();
156148

157149
return this;
@@ -304,7 +296,9 @@ define([
304296
* @returns {Object} Chainable.
305297
*/
306298
clear: function () {
307-
this.value(findFirst(this.options));
299+
var value = this.caption ? '' : findFirst(this.options);
300+
301+
this.value(value);
308302

309303
return this;
310304
}

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/optgroup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ define([
270270

271271
obj[optionTitle] = applyToObject(option, optionsText + 'title', value);
272272

273-
label = label.replace(nbspRe, '');
273+
label = label.replace(nbspRe, '').trim();
274274

275275
if (Array.isArray(value)) {
276276
obj[optionsText] = strPad(' ', nestedOptionsLevel * 4) + label;

app/code/Magento/Ui/view/base/web/templates/form/components/button/simple.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
* See COPYING.txt for license details.
55
*/
66
-->
7-
<render args="elementTmpl"/>
7+
<render args="elementTmpl" if="visible"/>

app/code/Magento/Ui/view/base/web/templates/form/element/button.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
'action-secondary': !$data.displayAsLink
1111
"
1212
click="action"
13-
text="title"
13+
disable="disabled"
1414
attr="'data-index': index">
15-
</button>
15+
>
16+
<span text="title">
17+
</span>
18+
</button>

app/code/Magento/Ui/view/base/web/templates/form/element/select.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
hasFocus: focused,
1515
optgroup: options,
1616
value: value,
17+
optionsCaption: caption,
1718
optionsValue: 'value',
1819
optionsText: 'label'"
1920
/>

app/code/Magento/Weee/Ui/DataProvider/Product/Form/Modifier/Weee.php

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,54 @@ protected function modifyAttributeConfig($attributeCode, array $attributeConfig)
173173
],
174174
],
175175
'children' => [
176-
'country' => [
176+
'countryState' => [
177177
'arguments' => [
178178
'data' => [
179179
'config' => [
180-
'dataType' => Text::NAME,
181-
'formElement' => Select::NAME,
182-
'componentType' => Field::NAME,
183-
'dataScope' => 'country',
184-
'label' => __('Country/State'),
180+
'componentType' => Container::NAME,
181+
'component' => 'Magento_Ui/js/form/components/group',
185182
'visible' => true,
186-
'options' => $this->getCountries(),
187-
'validation' => [
188-
'required-entry' => true
183+
'label' => __('Country/State'),
184+
],
185+
],
186+
],
187+
'children' => [
188+
'country' => [
189+
'arguments' => [
190+
'data' => [
191+
'config' => [
192+
'dataType' => Text::NAME,
193+
'formElement' => Select::NAME,
194+
'componentType' => Field::NAME,
195+
'dataScope' => 'country',
196+
'visible' => true,
197+
'options' => $this->getCountries(),
198+
'validation' => [
199+
'required-entry' => true
200+
],
201+
],
202+
],
203+
],
204+
],
205+
'region' => [
206+
'arguments' => [
207+
'data' => [
208+
'config' => [
209+
'componentType' => Field::NAME,
210+
'dataType' => Text::NAME,
211+
'formElement' => Select::NAME,
212+
'component' => 'Magento_Weee/js/regions-tax-select',
213+
'dataScope' => 'region',
214+
'options' => $this->getRegions(),
215+
'filterBy' => [
216+
'field' => 'country'
217+
],
218+
'caption' => '*',
219+
'visible' => true,
220+
'validation' => [
221+
'required-entry' => true
222+
],
223+
],
189224
],
190225
],
191226
],

0 commit comments

Comments
 (0)