Skip to content

Commit 49fe15f

Browse files
committed
MAGETWO-47285: Admin Panel, Categories: Reset of product assignments occurs after filter is applied
1 parent ee8ba2a commit 49fe15f

File tree

1 file changed

+35
-3
lines changed
  • app/code/Magento/Ui/view/base/web/js/grid/columns

1 file changed

+35
-3
lines changed

app/code/Magento/Ui/view/base/web/js/grid/columns/onoff.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,38 @@ define([
4141
*/
4242
setDefaultSelections: function () {
4343
var positionCacheValid = registry.get('position_cache_valid'),
44+
selectedFromCache = registry.get('selected_cache'),
4445
key,
4546
i;
4647

47-
registry.set('position_cache_valid', true);
48+
if (positionCacheValid && this.selected().length === 0) {
49+
// Check selected data
50+
selectedFromCache = JSON.parse(selectedFromCache);
51+
52+
for (i = 0; i < selectedFromCache.length; i++) {
53+
this.selected.push(selectedFromCache[i]);
54+
}
55+
56+
registry.set('position_cache_valid', true);
57+
registry.set('selected_cache', JSON.stringify(this.selected()));
4858

49-
if (this.selectedData.length === 0 || positionCacheValid) {
5059
return;
5160
}
61+
62+
if (positionCacheValid && this.selected().length > 0) {
63+
registry.set('position_cache_valid', true);
64+
registry.set('selected_cache', JSON.stringify(this.selected()));
65+
66+
return;
67+
}
68+
69+
if (this.selectedData.length === 0) {
70+
registry.set('position_cache_valid', true);
71+
registry.set('selected_cache', JSON.stringify([]));
72+
73+
return;
74+
}
75+
5276
// Check selected data
5377
for (key in this.selectedData) {
5478
if (this.selectedData.hasOwnProperty(key) && this.selected().indexOf(key) === -1) {
@@ -61,6 +85,8 @@ define([
6185
this.selectedData.hasOwnProperty(key) || this.selected.splice(this.selected().indexOf(key), 1);
6286
this.selectedData.hasOwnProperty(key) || i--;
6387
}
88+
registry.set('position_cache_valid', true);
89+
registry.set('selected_cache', JSON.stringify(this.selected()));
6490
},
6591

6692
/**
@@ -91,12 +117,18 @@ define([
91117
* @returns {Object} Chainable.
92118
*/
93119
updateState: function () {
94-
var totalRecords = this.totalRecords(),
120+
var positionCacheValid = registry.get('position_cache_valid'),
121+
totalRecords = this.totalRecords(),
95122
selected = this.selected().length,
96123
excluded = this.excluded().length,
97124
totalSelected = this.totalSelected(),
98125
allSelected;
99126

127+
if (positionCacheValid && this.selected().length > 0) {
128+
registry.set('position_cache_valid', true);
129+
registry.set('selected_cache', JSON.stringify(this.selected()));
130+
}
131+
100132
// When filters are enabled then totalRecords is unknown
101133
if (this.getFiltering()) {
102134
if (this.getFiltering().search !== '') {

0 commit comments

Comments
 (0)