Skip to content

Commit 5151060

Browse files
committed
Refactor js url component
1 parent 97a951b commit 5151060

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

app/code/Magento/MediaGalleryUi/view/adminhtml/web/js/image/image-details.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ define([
162162
*/
163163
getFilterUrl: function (link) {
164164
return link + '?filters[asset_id]=[' + this.image().id + ']' +
165-
'&value=' + this.image().id +
166-
'&label=' + this.image().title +
167-
'&src=' + this.image()['image_url'];
165+
'&options[]=[value=' + this.image().id +
166+
',label=' + this.image().title +
167+
',src=' + this.image()['image_url'] + ']';
168168
},
169169

170170
/**

app/code/Magento/Ui/view/base/web/js/grid/url-filter-applier.js

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ define([
5454

5555
if (Object.keys(options).length) {
5656
this.selectComponent().options(options);
57-
this.selectComponent().cacheOptions.plain = [options];
57+
this.selectComponent().cacheOptions.plain = options;
5858
}
5959

6060
if (Object.keys(urlFilter).length) {
@@ -99,12 +99,32 @@ define([
9999
* @param {String} url
100100
*/
101101
getOptionsParam: function (url) {
102-
var searchString = decodeURI(url),
103-
options;
104-
options = Object.fromEntries(new URLSearchParams(searchString));
105-
delete options['filters[asset_id]'];
102+
var params = [],
103+
chunks,
104+
chunk,
105+
values = {},
106+
options,
107+
searchString = decodeURI(url);
108+
109+
_.chain(searchString.slice(1).split('&'))
110+
.map(function (item, k) {
111+
if (item && item.search(this.optionsKey) !== -1) {
112+
chunks = item.substring(item.indexOf('?') + 1).split('&');
113+
114+
for (var i = 0; i < chunks.length ; i++) {
115+
options = chunks[i].substring(item.indexOf('[]') + 3).replace(/[\[\]]/g, '').split(',');
116+
options.map(function (item) {
117+
chunk = item.split('=');
118+
values[chunk[0]] = chunk[1];
119+
}.bind(this));
120+
}
121+
params[k - 1] = values;
122+
values = {};
123+
}
124+
}.bind(this));
106125

107-
return options;
126+
return params;
108127
}
128+
109129
});
110130
});

0 commit comments

Comments
 (0)