From ff81cc96086f92451ace796e1b1e2ef7dea866da Mon Sep 17 00:00:00 2001 From: Quynh Nguyen Date: Tue, 26 Jul 2022 20:27:30 +0700 Subject: [PATCH] NEXT-22222 - Refactor filter options for plugin --- ...2-07-26-refactor-filter-options-for-plugin.md | 16 ++++++++++++++++ .../sw-customer/page/sw-customer-list/index.js | 10 +++++++--- .../module/sw-order/page/sw-order-list/index.js | 14 +++++++++----- .../sw-product/page/sw-product-list/index.js | 10 +++++++--- 4 files changed, 39 insertions(+), 11 deletions(-) create mode 100644 changelog/_unreleased/2022-07-26-refactor-filter-options-for-plugin.md diff --git a/changelog/_unreleased/2022-07-26-refactor-filter-options-for-plugin.md b/changelog/_unreleased/2022-07-26-refactor-filter-options-for-plugin.md new file mode 100644 index 00000000000..22b3945c911 --- /dev/null +++ b/changelog/_unreleased/2022-07-26-refactor-filter-options-for-plugin.md @@ -0,0 +1,16 @@ +--- +title: Refactor filter options for plugin +issue: NEXT-22222 +--- +# Administration +* Changed in `src/module/sw-order/page/sw-order-list/index.js` + * Added computed `listFilterOptions` to allow third party developers customize order filter options. + * Changed computed `listFilters` to use filter options with `listFilterOptions`. + +* Changed in `src/module/sw-product/page/sw-product-list/index.js` + * Added computed `listFilterOptions` to allow third party developers customize order filter options. + * Changed computed `listFilters` to use filter options with `listFilterOptions`. + +* Changed in `src/module/sw-customer/page/sw-customer-list/index.js` + * Added computed `listFilterOptions` in `src/module/sw-order/page/sw-order-list/index.js` to allow third party developers customize order filter options. + * Changed computed `listFilters` to use filter options with `listFilterOptions`. diff --git a/src/Administration/Resources/app/administration/src/module/sw-customer/page/sw-customer-list/index.js b/src/Administration/Resources/app/administration/src/module/sw-customer/page/sw-customer-list/index.js index 589e2ddbfc9..e2f3a2ce433 100644 --- a/src/Administration/Resources/app/administration/src/module/sw-customer/page/sw-customer-list/index.js +++ b/src/Administration/Resources/app/administration/src/module/sw-customer/page/sw-customer-list/index.js @@ -107,8 +107,8 @@ Component.register('sw-customer-list', { return criteria; }, - listFilters() { - return this.filterFactory.create('customer', { + listFilterOptions() { + return { 'affiliate-code-filter': { property: 'affiliateCode', type: 'multi-select-filter', @@ -171,7 +171,11 @@ Component.register('sw-customer-list', { label: this.$tc('sw-customer.filter.tags.label'), placeholder: this.$tc('sw-customer.filter.tags.placeholder'), }, - }); + }; + }, + + listFilters() { + return this.filterFactory.create('customer', this.listFilterOptions); }, }, diff --git a/src/Administration/Resources/app/administration/src/module/sw-order/page/sw-order-list/index.js b/src/Administration/Resources/app/administration/src/module/sw-order/page/sw-order-list/index.js index 0050567dcdd..f9b4bdca2ed 100644 --- a/src/Administration/Resources/app/administration/src/module/sw-order/page/sw-order-list/index.js +++ b/src/Administration/Resources/app/administration/src/module/sw-order/page/sw-order-list/index.js @@ -116,9 +116,9 @@ Component.register('sw-order-list', { return criteria; }, - listFilters() { + listFilterOptions() { if (this.feature.isActive('FEATURE_NEXT_7530')) { - return this.filterFactory.create('order', { + return { 'sales-channel-filter': { property: 'salesChannel', label: this.$tc('sw-order.filters.salesChannelFilter.label'), @@ -221,10 +221,10 @@ Component.register('sw-order-list', { criteria: this.productCriteria, displayVariants: true, }, - }); + }; } - return this.filterFactory.create('order', { + return { 'affiliate-code-filter': { property: 'affiliateCode', type: 'multi-select-filter', @@ -315,7 +315,11 @@ Component.register('sw-order-list', { criteria: this.productCriteria, displayVariants: true, }, - }); + }; + }, + + listFilters() { + return this.filterFactory.create('order', this.listFilterOptions); }, productCriteria() { diff --git a/src/Administration/Resources/app/administration/src/module/sw-product/page/sw-product-list/index.js b/src/Administration/Resources/app/administration/src/module/sw-product/page/sw-product-list/index.js index b225604754e..09351c048d9 100644 --- a/src/Administration/Resources/app/administration/src/module/sw-product/page/sw-product-list/index.js +++ b/src/Administration/Resources/app/administration/src/module/sw-product/page/sw-product-list/index.js @@ -116,8 +116,8 @@ Component.register('sw-product-list', { return !!this.productEntityVariantModal; }, - listFilters() { - return this.filterFactory.create('product', { + listFilterOptions() { + return { 'active-filter': { property: 'active', label: this.$tc('sw-product.filters.activeFilter.label'), @@ -176,7 +176,11 @@ Component.register('sw-product-list', { toFieldLabel: null, showTimeframe: true, }, - }); + }; + }, + + listFilters() { + return this.filterFactory.create('product', this.listFilterOptions); }, productBulkEditColumns() {