Skip to content

Commit

Permalink
MOL-879: subscriptions admin list should be searchable (#526)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
daniel-memo-ict authored Sep 25, 2023
1 parent 7ce939f commit 4bd58ca
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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,
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% block sw_search_bar_item_cms_page %}
{% parent %}

<router-link v-else-if="type === 'mollie_subscription'"
:to="{ name: 'mollie.payments.subscription', params: { id: item.id } }"
ref="routerLink"
class="sw-search-bar-item__link">
{% block sw_search_bar_item_mollie_subscription_label %}
<span class="sw-search-bar-item__label">
<sw-highlight-text :searchTerm="searchTerm"
:text="item.description">
</sw-highlight-text>
</span>
{% endblock %}
</router-link>

{% endblock %}
11 changes: 11 additions & 0 deletions src/Resources/app/administration/src/init/api-service.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

1 change: 1 addition & 0 deletions src/Resources/app/administration/src/main.js
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const defaultSearchConfiguration = {
_searchable: true,
description: {
_searchable: true,
_score: 500,
},
};

export default defaultSearchConfiguration;
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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',
Expand All @@ -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: {
Expand Down Expand Up @@ -76,7 +78,9 @@ systemConfig.getValues('MolliePayments').then(config => {
},
},

navigation: navigationRoutes,
navigation,

defaultSearchConfiguration,
});

// Now tell Shopware it's okay to load the administration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Component.register('mollie-subscriptions-list', {
sortDirection: 'DESC',
naturalSorting: true,
showHelp: false,
searchConfigEntity: 'mollie_subscription',
}
},

Expand Down Expand Up @@ -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: {
Expand All @@ -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');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{% block mollie_payments_subscription_list %}
<sw-page class="mollie-subscriptions">
{% block mollie_payments_subscription_list_search_bar %}
<template #search-bar>
<sw-search-bar initialSearchType="mollie_subscription"
:initialSearch="term"
@search="onSearch">
</sw-search-bar>
</template>
{% endblock %}

{% block mollie_payments_subscription_list_smart_bar_header %}
<template slot="smart-bar-header">
{% block mollie_payments_subscription_list_smart_bar_header_title %}
Expand Down Expand Up @@ -105,5 +114,15 @@
</sw-entity-listing>
{% endblock %}
</template>

<template #sidebar>
<sw-sidebar>
<sw-sidebar-item
:icon="compatibilityIcons.refresh"
:title="$tc('sw-product.list.titleSidebarItemRefresh')"
@click="onRefresh"
/>
</sw-sidebar>
</template>
</sw-page>
{% endblock %}
13 changes: 13 additions & 0 deletions src/Resources/app/administration/src/snippet/de-DE.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -28,6 +31,7 @@
"mollie-payments": {
"pluginTitle": "Mollie",
"pluginDescription": "Mollie Module",
"searchPlaceholder": "In Abonnements suchen...",
"general": {
"mainMenuItemGeneral": "Mollie Payments Zahlungen",
"descriptionTextModule": "Mollie Payments Zahlungen",
Expand Down Expand Up @@ -445,6 +449,15 @@
}
}
},
"sw-profile": {
"tabSearchPreferences": {
"modules": {
"mollie_subscription": {
"description": "Beschreibung"
}
}
}
},
"sw-flow": {
"triggers": {
"mollie": "Mollie",
Expand Down
15 changes: 14 additions & 1 deletion src/Resources/app/administration/src/snippet/en-GB.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -27,7 +30,8 @@
},
"mollie-payments": {
"pluginTitle": "Mollie",
"pluginDescription": "Mollie Modul",
"pluginDescription": "Mollie Module",
"searchPlaceholder": "Search subscriptions...",
"general": {
"mainMenuItemGeneral": "Mollie Payments",
"descriptionTextModule": "Mollie Payments",
Expand Down Expand Up @@ -445,6 +449,15 @@
}
}
},
"sw-profile": {
"tabSearchPreferences": {
"modules": {
"mollie_subscription": {
"description": "Description"
}
}
}
},
"sw-flow": {
"triggers": {
"mollie": "Mollie",
Expand Down
16 changes: 15 additions & 1 deletion src/Resources/app/administration/src/snippet/nl-NL.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -20,14 +23,15 @@
"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"
}
},
"mollie-payments": {
"pluginTitle": "Mollie",
"pluginDescription": "Mollie Module",
"searchPlaceholder": "Zoek in abonnementen...",
"general": {
"mainMenuItemGeneral": "Mollie betalingen",
"descriptionTextModule": "Mollie betalingen",
Expand Down Expand Up @@ -274,6 +278,7 @@
"cancelButton": "Niet verzenden"
}
},

"sw-flow": {
"actions": {
"shipOrder": {
Expand Down Expand Up @@ -445,6 +450,15 @@
}
}
},
"sw-profile": {
"tabSearchPreferences": {
"modules": {
"mollie_subscription": {
"description": "Beschrijving"
}
}
}
},
"sw-flow": {
"triggers": {
"mollie": "Mollie",
Expand Down
1 change: 1 addition & 0 deletions src/Resources/config/services/subscription/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<service id="Kiener\MolliePayments\Components\Subscription\DAL\Subscription\SubscriptionDefinition">
<tag name="shopware.entity.definition" entity="mollie_subscription"/>
<tag name="shopware.composite_search.definition" priority="1500"/>
</service>

<service id="Kiener\MolliePayments\Components\Subscription\DAL\Subscription\Aggregate\SubscriptionAddress\SubscriptionAddressDefinition">
Expand Down

0 comments on commit 4bd58ca

Please sign in to comment.