Skip to content

Commit e64104c

Browse files
author
Denys Rul
committed
MAGETWO-59322: Incorrect scope filter caching in UI grids
- Rename dataNamespace to dataScope
1 parent 5bd3747 commit e64104c

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
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"/>
2626
<item name="storageConfig" xsi:type="array">
27-
<item name="dataNamespace" xsi:type="string">filters.store_id</item>
27+
<item name="dataScope" xsi:type="string">filters.store_id</item>
2828
</item>
2929
</item>
3030
</argument>

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ define([
2020
method: 'GET',
2121
dataType: 'json'
2222
},
23-
dataNamespace: '',
23+
dataScope: '',
2424
data: {}
2525
},
2626

@@ -30,14 +30,14 @@ define([
3030
* @returns {DataStorage} Chainable.
3131
*/
3232
initConfig: function () {
33-
var namespace;
33+
var scope;
3434

3535
this._super();
3636

37-
namespace = this.dataNamespace;
37+
scope = this.dataScope;
3838

39-
if (typeof namespace === 'string') {
40-
this.dataNamespace = namespace ? [namespace] : [];
39+
if (typeof scope === 'string') {
40+
this.dataScope = scope ? [scope] : [];
4141
}
4242

4343
this._requests = [];
@@ -88,7 +88,7 @@ define([
8888
getData: function (params, options) {
8989
var cachedRequest;
9090

91-
if (this.hasNamespaceChanged(params)) {
91+
if (this.hasScopeChanged(params)) {
9292
this.clearRequests();
9393
} else {
9494
cachedRequest = this.getRequest(params);
@@ -102,25 +102,27 @@ define([
102102
},
103103

104104
/**
105-
* Tells whether one of the parameters defined in the "dataNamespace" has
105+
* Tells whether one of the parameters defined in the "dataScope" has
106106
* changed since the last request.
107107
*
108108
* @param {Object} params - Request parameters.
109109
* @returns {Boolean}
110110
*/
111-
hasNamespaceChanged: function (params) {
111+
hasScopeChanged: function (params) {
112112
var lastRequest = _.last(this._requests),
113-
paths,
113+
keys,
114114
diff;
115115

116116
if (!lastRequest) {
117117
return false;
118118
}
119119

120120
diff = utils.compare(lastRequest.params, params);
121-
paths = _.pluck(diff.changes, 'path').concat(_.keys(diff.containers));
122121

123-
return _.intersection(this.dataNamespace, paths).length > 0;
122+
keys = _.pluck(diff.changes, 'path');
123+
keys = keys.concat(Object.keys(diff.containers));
124+
125+
return _.intersection(this.dataScope, keys).length > 0;
124126
},
125127

126128
/**

0 commit comments

Comments
 (0)