Skip to content

Commit 984dab1

Browse files
author
Gabriel Galvao da Gama
committed
Simplified PR to a JS only approach
1 parent be428f7 commit 984dab1

File tree

8 files changed

+31
-81
lines changed

8 files changed

+31
-81
lines changed

app/code/Magento/Ui/Component/UrlFilterApplier.php

Lines changed: 0 additions & 44 deletions
This file was deleted.

app/code/Magento/Ui/etc/ui_components.xsd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,4 @@
6262
<xs:include schemaLocation="urn:magento:module:Magento_Ui:view/base/ui_component/etc/definition/exportButton.xsd"/>
6363
<xs:include schemaLocation="urn:magento:module:Magento_Ui:view/base/ui_component/etc/definition/listingToolbar.xsd"/>
6464
<xs:include schemaLocation="urn:magento:module:Magento_Ui:view/base/ui_component/etc/definition/dataProvider.xsd"/>
65-
<xs:include schemaLocation="urn:magento:module:Magento_Ui:view/base/ui_component/etc/definition/urlFilterApplier.xsd"/>
6665
</xs:schema>

app/code/Magento/Ui/etc/ui_configuration.xsd

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
<xs:element ref="text" maxOccurs="unbounded"/>
108108
<xs:element ref="textarea" maxOccurs="unbounded"/>
109109
<xs:element ref="wysiwyg" maxOccurs="unbounded"/>
110-
<xs:element ref="urlFilterApplier" maxOccurs="unbounded" />
111110
</xs:choice>
112111
</xs:group>
113112
<xs:group name="fieldsetElements">
@@ -207,7 +206,6 @@
207206
<xs:element ref="text" maxOccurs="unbounded"/>
208207
<xs:element ref="textarea" maxOccurs="unbounded"/>
209208
<xs:element ref="wysiwyg" maxOccurs="unbounded"/>
210-
<xs:element ref="urlFilterApplier" maxOccurs="unbounded" />
211209
</xs:choice>
212210
</xs:group>
213211

@@ -826,12 +824,4 @@
826824
</xs:documentation>
827825
</xs:annotation>
828826
</xs:element>
829-
<xs:element name="urlFilterApplier" type="componentUrlFilterApplier">
830-
<xs:annotation>
831-
<xs:documentation>
832-
The Url Filter Applier component retrieves the values from the "filters" GET parameter and applies it
833-
to the grid.
834-
</xs:documentation>
835-
</xs:annotation>
836-
</xs:element>
837827
</xs:schema>

app/code/Magento/Ui/etc/ui_definition.xsd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
<xs:element name="wysiwyg" type="componentWysiwyg"/>
7878
<xs:element name="inlineEditing" type="componentInlineEditing"/>
7979
<xs:element name="urlInput" type="componentUrlInput"/>
80-
<xs:element name="urlFilterApplier" type="componentUrlFilterApplier" />
8180
</xs:choice>
8281
</xs:complexType>
8382
</xs:schema>

app/code/Magento/Ui/view/base/ui_component/etc/definition.map.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,6 @@
499499
</argument>
500500
</schema>
501501
</component>
502-
<component name="urlFilterApplier" include="uiElementSettings"/>
503502
<component name="filterSearch" include="uiElementSettings">
504503
<schema name="current">
505504
<argument name="data" xsi:type="array">

app/code/Magento/Ui/view/base/ui_component/etc/definition.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,4 @@
284284
</dynamicRows>
285285
<htmlContent class="Magento\Ui\Component\HtmlContent" component="Magento_Ui/js/form/components/html"/>
286286
<button class="Magento\Ui\Component\Container" component="Magento_Ui/js/form/components/button"/>
287-
<urlFilterApplier class="Magento\Ui\Component\UrlFilterApplier" component="Magento_Ui/js/grid/url-filter-applier" />
288287
</components>

app/code/Magento/Ui/view/base/ui_component/etc/definition/urlFilterApplier.xsd

Lines changed: 0 additions & 18 deletions
This file was deleted.

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

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ define([
1212
return Component.extend({
1313
defaults: {
1414
filterProvider: 'componentType = filters, ns = ${ $.ns }',
15-
filters: null,
15+
filterKey: 'filters',
1616
modules: {
1717
filterComponent: '${ $.filterProvider }',
1818
}
@@ -34,14 +34,40 @@ define([
3434
* Apply filter
3535
*/
3636
apply: function () {
37+
var urlFilter = this.getFilterParam();
38+
3739
if (_.isUndefined(this.filterComponent())) {
3840
setTimeout(function () {this.apply()}.bind(this), 100);
3941
} else {
40-
if (!_.isNull(this.filters)) {
41-
this.filterComponent().setData(this.filters, false);
42-
this.filterComponent().apply();
43-
}
42+
if (Object.keys(urlFilter).length) {
43+
this.filterComponent().setData(urlFilter, false);
44+
this.filterComponent().apply();
45+
}
4446
}
47+
},
48+
49+
/**
50+
* Get filter param from url
51+
*
52+
* @returns {Object}
53+
*/
54+
getFilterParam: function () {
55+
var searchString = decodeURI(location.search);
56+
57+
return _.chain(searchString.slice(1).split('&'))
58+
.map(function (item) {
59+
if (item && item.search(this.filterKey) !== -1) {
60+
var itemArray = item.split('=');
61+
62+
itemArray[0] = itemArray[0].replace(this.filterKey, '')
63+
.replace(/[\[\]]/g, '');
64+
65+
return itemArray
66+
}
67+
}.bind(this))
68+
.compact()
69+
.object()
70+
.value();
4571
}
4672
});
4773
});

0 commit comments

Comments
 (0)