|
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 |
| -], function (Checkbox) { |
9 |
| - 'use strict'; |
10 |
| - |
11 |
| - return Checkbox.extend({ |
12 |
| - defaults: { |
13 |
| - inputCheckBoxName: '', |
14 |
| - prefixElementName: '', |
15 |
| - parentDynamicRowName: 'visual_swatch' |
16 |
| - }, |
17 |
| - |
18 |
| - /** |
19 |
| - * Parses options and merges the result with instance |
20 |
| - * |
21 |
| - * @returns {Object} Chainable. |
22 |
| - */ |
23 |
| - initConfig: function () { |
24 |
| - this._super(); |
25 |
| - this.configureDataScope(); |
26 |
| - |
27 |
| - return this; |
28 |
| - }, |
29 |
| - |
30 |
| - /** @inheritdoc */ |
31 |
| - initialize: function () { |
32 |
| - this._super(); |
33 |
| - |
34 |
| - if (this.rows && this.rows().elems().length === 1) { |
35 |
| - this.checked(true); |
36 |
| - } |
37 |
| - |
38 |
| - return this; |
39 |
| - }, |
40 |
| - |
41 |
| - /** |
42 |
| - * Configure data scope. |
43 |
| - */ |
44 |
| - configureDataScope: function () { |
45 |
| - var recordId, |
46 |
| - value; |
47 |
| - |
48 |
| - recordId = this.parentName.split('.').last(); |
49 |
| - value = this.prefixElementName + recordId; |
50 |
| - |
51 |
| - this.dataScope = 'data.' + this.inputCheckBoxName; |
52 |
| - this.inputName = this.dataScopeToHtmlArray(this.inputCheckBoxName); |
53 |
| - |
54 |
| - this.initialValue = value; |
55 |
| - |
56 |
| - this.links.value = this.provider + ':' + this.dataScope; |
57 |
| - }, |
58 |
| - |
59 |
| - /** |
60 |
| - * Get HTML array from data scope. |
61 |
| - * |
62 |
| - * @param {String} dataScopeString |
63 |
| - * @returns {String} |
64 |
| - */ |
65 |
| - dataScopeToHtmlArray: function (dataScopeString) { |
66 |
| - var dataScopeArray, dataScope, reduceFunction; |
67 |
| - |
68 |
| - /** |
69 |
| - * Add new level of nesting. |
70 |
| - * |
71 |
| - * @param {String} prev |
72 |
| - * @param {String} curr |
73 |
| - * @returns {String} |
74 |
| - */ |
75 |
| - reduceFunction = function (prev, curr) { |
76 |
| - return prev + '[' + curr + ']'; |
77 |
| - }; |
78 |
| - |
79 |
| - dataScopeArray = dataScopeString.split('.'); |
80 |
| - |
81 |
| - dataScope = dataScopeArray.shift(); |
82 |
| - dataScope += dataScopeArray.reduce(reduceFunction, ''); |
83 |
| - |
84 |
| - return dataScope; |
85 |
| - } |
86 |
| - }); |
87 |
| -}); |
| 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 | +], function (Checkbox) { |
| 9 | + 'use strict'; |
| 10 | + |
| 11 | + return Checkbox.extend({ |
| 12 | + defaults: { |
| 13 | + inputCheckBoxName: '', |
| 14 | + prefixElementName: '', |
| 15 | + parentDynamicRowName: 'visual_swatch' |
| 16 | + }, |
| 17 | + |
| 18 | + /** |
| 19 | + * Parses options and merges the result with instance |
| 20 | + * |
| 21 | + * @returns {Object} Chainable. |
| 22 | + */ |
| 23 | + initConfig: function () { |
| 24 | + this._super(); |
| 25 | + this.configureDataScope(); |
| 26 | + |
| 27 | + return this; |
| 28 | + }, |
| 29 | + |
| 30 | + /** @inheritdoc */ |
| 31 | + initialize: function () { |
| 32 | + this._super(); |
| 33 | + |
| 34 | + if (this.rows && this.rows().elems().length === 0) { |
| 35 | + this.checked(true); |
| 36 | + } |
| 37 | + |
| 38 | + return this; |
| 39 | + }, |
| 40 | + |
| 41 | + /** |
| 42 | + * Configure data scope. |
| 43 | + */ |
| 44 | + configureDataScope: function () { |
| 45 | + var recordId, |
| 46 | + value; |
| 47 | + |
| 48 | + recordId = this.parentName.split('.').last(); |
| 49 | + value = this.prefixElementName + recordId; |
| 50 | + |
| 51 | + this.dataScope = 'data.' + this.inputCheckBoxName; |
| 52 | + this.inputName = this.dataScopeToHtmlArray(this.inputCheckBoxName); |
| 53 | + |
| 54 | + this.initialValue = value; |
| 55 | + |
| 56 | + this.links.value = this.provider + ':' + this.dataScope; |
| 57 | + }, |
| 58 | + |
| 59 | + /** |
| 60 | + * Get HTML array from data scope. |
| 61 | + * |
| 62 | + * @param {String} dataScopeString |
| 63 | + * @returns {String} |
| 64 | + */ |
| 65 | + dataScopeToHtmlArray: function (dataScopeString) { |
| 66 | + var dataScopeArray, dataScope, reduceFunction; |
| 67 | + |
| 68 | + /** |
| 69 | + * Add new level of nesting. |
| 70 | + * |
| 71 | + * @param {String} prev |
| 72 | + * @param {String} curr |
| 73 | + * @returns {String} |
| 74 | + */ |
| 75 | + reduceFunction = function (prev, curr) { |
| 76 | + return prev + '[' + curr + ']'; |
| 77 | + }; |
| 78 | + |
| 79 | + dataScopeArray = dataScopeString.split('.'); |
| 80 | + |
| 81 | + dataScope = dataScopeArray.shift(); |
| 82 | + dataScope += dataScopeArray.reduce(reduceFunction, ''); |
| 83 | + |
| 84 | + return dataScope; |
| 85 | + } |
| 86 | + }); |
| 87 | +}); |
0 commit comments