From 4bd58cab124d730e9721c61569d4f775c987b280 Mon Sep 17 00:00:00 2001 From: Daniel Schipper <84572040+daniel-memo-ict@users.noreply.github.com> Date: Mon, 25 Sep 2023 13:32:54 +0200 Subject: [PATCH] MOL-879: subscriptions admin list should be searchable (#526) * Add subscriptions to search list * Update search bar * Update search * Add sidebar and refresh button * Add icon compatibility * Search compatibility * Make status sortable * Remove eslint line that prevents building * Update snippets * Fix eslint * fix snippetcheck --- .../structure/sw-search-bar-item/index.js | 6 +++++ .../sw-search-bar-item.html.twig | 17 +++++++++++++ .../src/init/api-service.init.js | 11 ++++++++ src/Resources/app/administration/src/main.js | 1 + .../default-search-configuration.js | 9 +++++++ .../src/module/mollie-payments/index.js | 14 +++++++---- .../grids/MollieSubscriptionGrid.js | 2 +- .../page/mollie-subscriptions-list/index.js | 25 ++++++++++++++++--- .../mollie-subscriptions-list.html.twig | 19 ++++++++++++++ .../app/administration/src/snippet/de-DE.json | 13 ++++++++++ .../app/administration/src/snippet/en-GB.json | 15 ++++++++++- .../app/administration/src/snippet/nl-NL.json | 16 +++++++++++- .../config/services/subscription/services.xml | 1 + 13 files changed, 138 insertions(+), 11 deletions(-) create mode 100644 src/Resources/app/administration/src/extension/structure/sw-search-bar-item/index.js create mode 100644 src/Resources/app/administration/src/extension/structure/sw-search-bar-item/sw-search-bar-item.html.twig create mode 100644 src/Resources/app/administration/src/module/mollie-payments/default-search-configuration.js diff --git a/src/Resources/app/administration/src/extension/structure/sw-search-bar-item/index.js b/src/Resources/app/administration/src/extension/structure/sw-search-bar-item/index.js new file mode 100644 index 000000000..3970376ac --- /dev/null +++ b/src/Resources/app/administration/src/extension/structure/sw-search-bar-item/index.js @@ -0,0 +1,6 @@ +import template from './sw-search-bar-item.html.twig'; + +// eslint-disable-next-line no-undef +Shopware.Component.override('sw-search-bar-item', { + template, +}) diff --git a/src/Resources/app/administration/src/extension/structure/sw-search-bar-item/sw-search-bar-item.html.twig b/src/Resources/app/administration/src/extension/structure/sw-search-bar-item/sw-search-bar-item.html.twig new file mode 100644 index 000000000..564f860d7 --- /dev/null +++ b/src/Resources/app/administration/src/extension/structure/sw-search-bar-item/sw-search-bar-item.html.twig @@ -0,0 +1,17 @@ +{% block sw_search_bar_item_cms_page %} + {% parent %} + + + {% block sw_search_bar_item_mollie_subscription_label %} + + + + + {% endblock %} + + +{% endblock %} diff --git a/src/Resources/app/administration/src/init/api-service.init.js b/src/Resources/app/administration/src/init/api-service.init.js index 64c38b33a..811a73f29 100644 --- a/src/Resources/app/administration/src/init/api-service.init.js +++ b/src/Resources/app/administration/src/init/api-service.init.js @@ -77,3 +77,14 @@ Application.addServiceProviderDecorator('ruleConditionDataProviderService', (rul return ruleConditionService; }); + +Application.addServiceProviderDecorator('searchTypeService', searchTypeService => { + searchTypeService.upsertType('mollie_subscription', { + entityName: 'mollie_subscription', + placeholderSnippet: 'mollie-payments.searchPlaceholder', + listingRoute: 'mollie.payments.subscriptions', + }); + + return searchTypeService; +}); + diff --git a/src/Resources/app/administration/src/main.js b/src/Resources/app/administration/src/main.js index e8b9074ec..b0133a117 100644 --- a/src/Resources/app/administration/src/main.js +++ b/src/Resources/app/administration/src/main.js @@ -1,6 +1,7 @@ import './init/api-service.init'; import './init/credit-card-components.init' import './extension/sw-flow-sequence-action'; +import './extension/structure/sw-search-bar-item'; import './component/flow-sequence/action-order-ship-modal'; import './component/flow-sequence/action-order-refund-modal'; import './component/credit-card-logo' diff --git a/src/Resources/app/administration/src/module/mollie-payments/default-search-configuration.js b/src/Resources/app/administration/src/module/mollie-payments/default-search-configuration.js new file mode 100644 index 000000000..954cd677b --- /dev/null +++ b/src/Resources/app/administration/src/module/mollie-payments/default-search-configuration.js @@ -0,0 +1,9 @@ +const defaultSearchConfiguration = { + _searchable: true, + description: { + _searchable: true, + _score: 500, + }, +}; + +export default defaultSearchConfiguration; diff --git a/src/Resources/app/administration/src/module/mollie-payments/index.js b/src/Resources/app/administration/src/module/mollie-payments/index.js index 08f8e2121..8af3c8318 100644 --- a/src/Resources/app/administration/src/module/mollie-payments/index.js +++ b/src/Resources/app/administration/src/module/mollie-payments/index.js @@ -17,6 +17,8 @@ import './components/mollie-ship-order'; import './page/mollie-subscriptions-list'; import './page/mollie-subscriptions-detail'; +import defaultSearchConfiguration from './default-search-configuration'; + // eslint-disable-next-line no-undef const {Module, ApiService, Plugin} = Shopware; @@ -27,10 +29,10 @@ const resolve = Plugin.addBootPromise(); const systemConfig = ApiService.getByName('systemConfigApiService') systemConfig.getValues('MolliePayments').then(config => { - const navigationRoutes = []; + const navigation = []; if(config['MolliePayments.config.subscriptionsEnabled']) { - navigationRoutes.push({ + navigation.push({ id: 'mollie-subscriptions', label: 'mollie-payments.subscriptions.navigation.title', path: 'mollie.payments.subscriptions', @@ -42,13 +44,13 @@ systemConfig.getValues('MolliePayments').then(config => { Module.register('mollie-payments', { type: 'plugin', - name: 'mollie-payments.pluginTitle', title: 'mollie-payments.general.mainMenuItemGeneral', description: 'mollie-payments.general.descriptionTextModule', version: '1.0.0', targetVersion: '1.0.0', color: '#333', - icon: 'default-action-settings', + icon: 'default-money-card', + entity: 'mollie_subscription', routes: { subscriptions: { @@ -76,7 +78,9 @@ systemConfig.getValues('MolliePayments').then(config => { }, }, - navigation: navigationRoutes, + navigation, + + defaultSearchConfiguration, }); // Now tell Shopware it's okay to load the administration diff --git a/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/grids/MollieSubscriptionGrid.js b/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/grids/MollieSubscriptionGrid.js index c4cd2da8e..3623d65cc 100644 --- a/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/grids/MollieSubscriptionGrid.js +++ b/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/grids/MollieSubscriptionGrid.js @@ -35,7 +35,7 @@ export default class MollieSubscriptionGrid { property: 'status', label: app.$tc('mollie-payments.subscriptions.list.columns.status'), allowResize: true, - sortable: false, // this data doesnt really existing in the database, so sorting would throw an error + sortable: true, }, { property: 'amount', diff --git a/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/index.js b/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/index.js index 950bfc2c4..91467c61d 100755 --- a/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/index.js +++ b/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/index.js @@ -38,6 +38,7 @@ Component.register('mollie-subscriptions-list', { sortDirection: 'DESC', naturalSorting: true, showHelp: false, + searchConfigEntity: 'mollie_subscription', } }, @@ -90,6 +91,17 @@ Component.register('mollie-subscriptions-list', { return this.subscriptions.length; }, + /** + * Provide icon compatibility for 6.4. Shopware's compatibility mapping will be removed in 6.5 + * @see vendor/shopware/administration/Resources/app/administration/src/app/component/base/sw-icon/legacy-icon-mapping.js + * @returns {object} + */ + compatibilityIcons() { + const map = Component.getComponentRegistry(); + return { + refresh: map.has('icons-regular-undo') ? 'regular-undo' : 'default-arrow-360-left', + }; + }, }, methods: { @@ -106,12 +118,19 @@ Component.register('mollie-subscriptions-list', { /** * */ - getList() { - + async getList() { this.isLoading = true; this.naturalSorting = this.sortBy === 'createdAt'; - const criteria = new Criteria(); + let criteria = new Criteria(); + + // Compatibility for 6.4.4, as admin search was improved in 6.4.5 + if('addQueryScores' in this) { + criteria = await this.addQueryScores(this.term, criteria); + } else { + criteria.setTerm(this.term); + } + criteria.addSorting(Criteria.sort(this.sortBy, this.sortDirection, this.naturalSorting)); criteria.addAssociation('customer'); diff --git a/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/mollie-subscriptions-list.html.twig b/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/mollie-subscriptions-list.html.twig index c98253f4b..053d90158 100755 --- a/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/mollie-subscriptions-list.html.twig +++ b/src/Resources/app/administration/src/module/mollie-payments/page/mollie-subscriptions-list/mollie-subscriptions-list.html.twig @@ -1,5 +1,14 @@ {% block mollie_payments_subscription_list %} + {% block mollie_payments_subscription_list_search_bar %} + + {% endblock %} + {% block mollie_payments_subscription_list_smart_bar_header %} + + {% endblock %} diff --git a/src/Resources/app/administration/src/snippet/de-DE.json b/src/Resources/app/administration/src/snippet/de-DE.json index 780f5d153..bd1d5813e 100644 --- a/src/Resources/app/administration/src/snippet/de-DE.json +++ b/src/Resources/app/administration/src/snippet/de-DE.json @@ -1,5 +1,8 @@ { "global": { + "entities": { + "mollie_subscription": "Mollie Abonnement | Mollie Abonnements" + }, "businessEvents": { "mollie_checkout_order_success": " Bestellung erfolgreich", "mollie_checkout_order_failed": " Bestellung fehlgeschlagen", @@ -28,6 +31,7 @@ "mollie-payments": { "pluginTitle": "Mollie", "pluginDescription": "Mollie Module", + "searchPlaceholder": "In Abonnements suchen...", "general": { "mainMenuItemGeneral": "Mollie Payments Zahlungen", "descriptionTextModule": "Mollie Payments Zahlungen", @@ -445,6 +449,15 @@ } } }, + "sw-profile": { + "tabSearchPreferences": { + "modules": { + "mollie_subscription": { + "description": "Beschreibung" + } + } + } + }, "sw-flow": { "triggers": { "mollie": "Mollie", diff --git a/src/Resources/app/administration/src/snippet/en-GB.json b/src/Resources/app/administration/src/snippet/en-GB.json index 2f5d41e23..d65fd1251 100644 --- a/src/Resources/app/administration/src/snippet/en-GB.json +++ b/src/Resources/app/administration/src/snippet/en-GB.json @@ -1,5 +1,8 @@ { "global": { + "entities": { + "mollie_subscription": "Mollie Subscription | Mollie Subscriptions" + }, "businessEvents": { "mollie_checkout_order_success": " Order successful", "mollie_checkout_order_failed": " Order failed", @@ -27,7 +30,8 @@ }, "mollie-payments": { "pluginTitle": "Mollie", - "pluginDescription": "Mollie Modul", + "pluginDescription": "Mollie Module", + "searchPlaceholder": "Search subscriptions...", "general": { "mainMenuItemGeneral": "Mollie Payments", "descriptionTextModule": "Mollie Payments", @@ -445,6 +449,15 @@ } } }, + "sw-profile": { + "tabSearchPreferences": { + "modules": { + "mollie_subscription": { + "description": "Description" + } + } + } + }, "sw-flow": { "triggers": { "mollie": "Mollie", diff --git a/src/Resources/app/administration/src/snippet/nl-NL.json b/src/Resources/app/administration/src/snippet/nl-NL.json index b95aaa30a..b6cbe2d1b 100644 --- a/src/Resources/app/administration/src/snippet/nl-NL.json +++ b/src/Resources/app/administration/src/snippet/nl-NL.json @@ -1,5 +1,8 @@ { "global": { + "entities": { + "mollie_subscription": "Mollie Abonnement | Mollie Abonnementen" + }, "businessEvents": { "mollie_checkout_order_success": " Bestelling succesvol", "mollie_checkout_order_failed": " Bestelling mislukt", @@ -20,7 +23,7 @@ "mollie_subscription_cancelled": " Mollie abonnement opgezegd", "mollie_subscription_paused": " Mollie abonnement gepauzeerd", "mollie_subscription_resumed": " Mollie abonnement hervat", - "mollie_subscription_skipped": " Mollie subscription overgeslagen", + "mollie_subscription_skipped": " Mollie abonnement overgeslagen", "mollie_subscription_renewed": " Mollie abonnement verlengd", "mollie_subscription_renewal_reminder": " Mollie herinnering voor abonnementsverlenging" } @@ -28,6 +31,7 @@ "mollie-payments": { "pluginTitle": "Mollie", "pluginDescription": "Mollie Module", + "searchPlaceholder": "Zoek in abonnementen...", "general": { "mainMenuItemGeneral": "Mollie betalingen", "descriptionTextModule": "Mollie betalingen", @@ -274,6 +278,7 @@ "cancelButton": "Niet verzenden" } }, + "sw-flow": { "actions": { "shipOrder": { @@ -445,6 +450,15 @@ } } }, + "sw-profile": { + "tabSearchPreferences": { + "modules": { + "mollie_subscription": { + "description": "Beschrijving" + } + } + } + }, "sw-flow": { "triggers": { "mollie": "Mollie", diff --git a/src/Resources/config/services/subscription/services.xml b/src/Resources/config/services/subscription/services.xml index 26114af10..4c1b0ef9a 100755 --- a/src/Resources/config/services/subscription/services.xml +++ b/src/Resources/config/services/subscription/services.xml @@ -10,6 +10,7 @@ +