-
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.
Merge pull request #539 from magento-dragons/DRAGONS-PR-BUGS-2.2
[Dragons] Bug fixes for 2.2
- Loading branch information
Showing
53 changed files
with
2,097 additions
and
500 deletions.
There are no files selected for viewing
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
59 changes: 59 additions & 0 deletions
59
app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-dynamic-rows-grid.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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'underscore', | ||
'Magento_Ui/js/dynamic-rows/dynamic-rows-grid' | ||
], function (_, dynamicRowsGrid) { | ||
'use strict'; | ||
|
||
return dynamicRowsGrid.extend({ | ||
defaults: { | ||
label: '', | ||
columnsHeader: false, | ||
columnsHeaderAfterRender: true, | ||
addButton: false | ||
}, | ||
|
||
/** | ||
* Initialize elements from grid | ||
* | ||
* @param {Array} data | ||
* | ||
* @returns {Object} Chainable. | ||
*/ | ||
initElements: function (data) { | ||
var newData = this.getNewData(data), | ||
recordIndex; | ||
|
||
this.parsePagesData(data); | ||
|
||
if (newData.length) { | ||
if (this.insertData().length) { | ||
recordIndex = data.length - newData.length - 1; | ||
|
||
_.each(newData, function (newRecord) { | ||
this.processingAddChild(newRecord, ++recordIndex, newRecord[this.identificationProperty]); | ||
}, this); | ||
} | ||
} | ||
|
||
return this; | ||
}, | ||
|
||
/** | ||
* Mapping value from grid | ||
* | ||
* @param {Array} data | ||
*/ | ||
mappingValue: function (data) { | ||
if (_.isEmpty(data)) { | ||
return; | ||
} | ||
|
||
this._super(); | ||
} | ||
}); | ||
}); |
98 changes: 98 additions & 0 deletions
98
app/code/Magento/Bundle/view/adminhtml/web/js/components/bundle-dynamic-rows.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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* Copyright © 2016 Magento. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
define([ | ||
'underscore', | ||
'mageUtils', | ||
'uiRegistry', | ||
'Magento_Ui/js/dynamic-rows/dynamic-rows' | ||
], function (_, utils, registry, dynamicRows) { | ||
'use strict'; | ||
|
||
return dynamicRows.extend({ | ||
defaults: { | ||
label: '', | ||
collapsibleHeader: true, | ||
columnsHeader: false, | ||
deleteProperty: false, | ||
addButton: false | ||
}, | ||
|
||
/** | ||
* Set new data to dataSource, | ||
* delete element | ||
* | ||
* @param {Array} data - record data | ||
*/ | ||
_updateData: function (data) { | ||
var elems = _.clone(this.elems()), | ||
path, | ||
dataArr, | ||
optionBaseData; | ||
|
||
dataArr = this.recordData.splice(this.startIndex, this.recordData().length - this.startIndex); | ||
dataArr.splice(0, this.pageSize); | ||
elems = _.sortBy(this.elems(), function (elem) { | ||
return ~~elem.index; | ||
}); | ||
|
||
data.concat(dataArr).forEach(function (rec, idx) { | ||
if (elems[idx]) { | ||
elems[idx].recordId = rec[this.identificationProperty]; | ||
} | ||
|
||
if (!rec.position) { | ||
rec.position = this.maxPosition; | ||
this.setMaxPosition(); | ||
} | ||
|
||
path = this.dataScope + '.' + this.index + '.' + (this.startIndex + idx); | ||
optionBaseData = _.pick(rec, function (value) { | ||
return !_.isObject(value); | ||
}); | ||
this.source.set(path, optionBaseData); | ||
this.source.set(path + '.bundle_button_proxy', []); | ||
this.source.set(path + '.bundle_selections', []); | ||
this.removeBundleItemsFromOption(idx); | ||
_.each(rec['bundle_selections'], function (obj, index) { | ||
this.source.set(path + '.bundle_button_proxy' + '.' + index, rec['bundle_button_proxy'][index]); | ||
this.source.set(path + '.bundle_selections' + '.' + index, obj); | ||
}, this); | ||
}, this); | ||
|
||
this.elems(elems); | ||
}, | ||
|
||
/** | ||
* Removes nested dynamic-rows-grid rendered records from option | ||
* | ||
* @param {Number|String} index - element index | ||
*/ | ||
removeBundleItemsFromOption: function (index) { | ||
var bundleSelections = registry.get(this.name + '.' + index + '.' + this.bundleSelectionsName), | ||
bundleSelectionsLength = (bundleSelections.elems() || []).length, | ||
i; | ||
|
||
if (bundleSelectionsLength) { | ||
for (i = 0; i < bundleSelectionsLength; i++) { | ||
bundleSelections.elems()[0].destroy(); | ||
} | ||
} | ||
}, | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
processingAddChild: function (ctx, index, prop) { | ||
var recordIds = _.map(this.recordData(), function (rec) { | ||
return parseInt(rec['record_id'], 10); | ||
}), | ||
maxRecordId = _.max(recordIds); | ||
|
||
prop = maxRecordId > -1 ? maxRecordId + 1 : prop; | ||
this._super(ctx, index, prop); | ||
} | ||
}); | ||
}); |
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
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
Oops, something went wrong.