-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-50396: Is Default checkbox is not selected if Dropdown fronte…
…nd input is selected in New Attribute form
- Loading branch information
vpaladiychuk
committed
Mar 19, 2016
1 parent
ae33eab
commit 509fd9d
Showing
1 changed file
with
87 additions
and
87 deletions.
There are no files selected for viewing
174 changes: 87 additions & 87 deletions
174
app/code/Magento/Catalog/view/adminhtml/web/js/form/element/checkbox.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,87 +1,87 @@ | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'Magento_Ui/js/form/element/single-checkbox' | ||
], function (Checkbox) { | ||
'use strict'; | ||
|
||
return Checkbox.extend({ | ||
defaults: { | ||
inputCheckBoxName: '', | ||
prefixElementName: '', | ||
parentDynamicRowName: 'visual_swatch' | ||
}, | ||
|
||
/** | ||
* Parses options and merges the result with instance | ||
* | ||
* @returns {Object} Chainable. | ||
*/ | ||
initConfig: function () { | ||
this._super(); | ||
this.configureDataScope(); | ||
|
||
return this; | ||
}, | ||
|
||
/** @inheritdoc */ | ||
initialize: function () { | ||
this._super(); | ||
|
||
if (this.rows && this.rows().elems().length === 1) { | ||
this.checked(true); | ||
} | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Configure data scope. | ||
*/ | ||
configureDataScope: function () { | ||
var recordId, | ||
value; | ||
|
||
recordId = this.parentName.split('.').last(); | ||
value = this.prefixElementName + recordId; | ||
|
||
this.dataScope = 'data.' + this.inputCheckBoxName; | ||
this.inputName = this.dataScopeToHtmlArray(this.inputCheckBoxName); | ||
|
||
this.initialValue = value; | ||
|
||
this.links.value = this.provider + ':' + this.dataScope; | ||
}, | ||
|
||
/** | ||
* Get HTML array from data scope. | ||
* | ||
* @param {String} dataScopeString | ||
* @returns {String} | ||
*/ | ||
dataScopeToHtmlArray: function (dataScopeString) { | ||
var dataScopeArray, dataScope, reduceFunction; | ||
|
||
/** | ||
* Add new level of nesting. | ||
* | ||
* @param {String} prev | ||
* @param {String} curr | ||
* @returns {String} | ||
*/ | ||
reduceFunction = function (prev, curr) { | ||
return prev + '[' + curr + ']'; | ||
}; | ||
|
||
dataScopeArray = dataScopeString.split('.'); | ||
|
||
dataScope = dataScopeArray.shift(); | ||
dataScope += dataScopeArray.reduce(reduceFunction, ''); | ||
|
||
return dataScope; | ||
} | ||
}); | ||
}); | ||
/** | ||
* Copyright © 2015 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'Magento_Ui/js/form/element/single-checkbox' | ||
], function (Checkbox) { | ||
'use strict'; | ||
|
||
return Checkbox.extend({ | ||
defaults: { | ||
inputCheckBoxName: '', | ||
prefixElementName: '', | ||
parentDynamicRowName: 'visual_swatch' | ||
}, | ||
|
||
/** | ||
* Parses options and merges the result with instance | ||
* | ||
* @returns {Object} Chainable. | ||
*/ | ||
initConfig: function () { | ||
this._super(); | ||
this.configureDataScope(); | ||
|
||
return this; | ||
}, | ||
|
||
/** @inheritdoc */ | ||
initialize: function () { | ||
this._super(); | ||
|
||
if (this.rows && this.rows().elems().length === 0) { | ||
this.checked(true); | ||
} | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Configure data scope. | ||
*/ | ||
configureDataScope: function () { | ||
var recordId, | ||
value; | ||
|
||
recordId = this.parentName.split('.').last(); | ||
value = this.prefixElementName + recordId; | ||
|
||
this.dataScope = 'data.' + this.inputCheckBoxName; | ||
this.inputName = this.dataScopeToHtmlArray(this.inputCheckBoxName); | ||
|
||
this.initialValue = value; | ||
|
||
this.links.value = this.provider + ':' + this.dataScope; | ||
}, | ||
|
||
/** | ||
* Get HTML array from data scope. | ||
* | ||
* @param {String} dataScopeString | ||
* @returns {String} | ||
*/ | ||
dataScopeToHtmlArray: function (dataScopeString) { | ||
var dataScopeArray, dataScope, reduceFunction; | ||
|
||
/** | ||
* Add new level of nesting. | ||
* | ||
* @param {String} prev | ||
* @param {String} curr | ||
* @returns {String} | ||
*/ | ||
reduceFunction = function (prev, curr) { | ||
return prev + '[' + curr + ']'; | ||
}; | ||
|
||
dataScopeArray = dataScopeString.split('.'); | ||
|
||
dataScope = dataScopeArray.shift(); | ||
dataScope += dataScopeArray.reduce(reduceFunction, ''); | ||
|
||
return dataScope; | ||
} | ||
}); | ||
}); |