Skip to content

Commit

Permalink
MAGETWO-50396: Is Default checkbox is not selected if Dropdown fronte…
Browse files Browse the repository at this point in the history
…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.
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;
}
});
});

0 comments on commit 509fd9d

Please sign in to comment.