Skip to content

Commit 6e22488

Browse files
author
Karpenko, Oleksandr
committed
Merge remote-tracking branch 'origin/MAGETWO-59322' into pr-develop
2 parents 1af98b5 + 8b47980 commit 6e22488

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

app/code/Magento/Catalog/view/adminhtml/ui_component/product_listing.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
<item name="config" xsi:type="array">
2424
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
2525
<item name="update_url" xsi:type="url" path="mui/index/render"/>
26+
<item name="storageConfig" xsi:type="array">
27+
<item name="dataScope" xsi:type="string">filters.store_id</item>
28+
</item>
2629
</item>
2730
</argument>
2831
</argument>

app/code/Magento/Ui/view/base/web/js/grid/data-storage.js

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ define([
2020
method: 'GET',
2121
dataType: 'json'
2222
},
23+
dataScope: '',
2324
data: {}
2425
},
2526

@@ -29,8 +30,16 @@ define([
2930
* @returns {DataStorage} Chainable.
3031
*/
3132
initConfig: function () {
33+
var scope;
34+
3235
this._super();
3336

37+
scope = this.dataScope;
38+
39+
if (typeof scope === 'string') {
40+
this.dataScope = scope ? [scope] : [];
41+
}
42+
3443
this._requests = [];
3544

3645
return this;
@@ -77,10 +86,12 @@ define([
7786
* @returns {jQueryPromise}
7887
*/
7988
getData: function (params, options) {
80-
var cachedRequest = this.getRequest(params);
89+
var cachedRequest;
8190

82-
if (params && params.filters && params.filters['store_id']) {
83-
cachedRequest = false;
91+
if (this.hasScopeChanged(params)) {
92+
this.clearRequests();
93+
} else {
94+
cachedRequest = this.getRequest(params);
8495
}
8596

8697
options = options || {};
@@ -90,6 +101,30 @@ define([
90101
this.requestData(params);
91102
},
92103

104+
/**
105+
* Tells whether one of the parameters defined in the "dataScope" has
106+
* changed since the last request.
107+
*
108+
* @param {Object} params - Request parameters.
109+
* @returns {Boolean}
110+
*/
111+
hasScopeChanged: function (params) {
112+
var lastRequest = _.last(this._requests),
113+
keys,
114+
diff;
115+
116+
if (!lastRequest) {
117+
return false;
118+
}
119+
120+
diff = utils.compare(lastRequest.params, params);
121+
122+
keys = _.pluck(diff.changes, 'path');
123+
keys = keys.concat(Object.keys(diff.containers));
124+
125+
return _.intersection(this.dataScope, keys).length > 0;
126+
},
127+
93128
/**
94129
* Extends records of current data object
95130
* with the provided records collection.

0 commit comments

Comments
 (0)