From 54e232e57a0fb0f072e1f05c33e56b378afb4af1 Mon Sep 17 00:00:00 2001 From: Boubaker Khanfir Date: Mon, 20 May 2024 17:30:19 +0100 Subject: [PATCH] feat: Sort Page Templates List with Intl.Collator - MEED-6887 - Meeds-io/MIPs#133 (#74) --- .../components/list/PageTemplates.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/layout-webapp/src/main/webapp/vue-app/page-templates-management/components/list/PageTemplates.vue b/layout-webapp/src/main/webapp/vue-app/page-templates-management/components/list/PageTemplates.vue index 18835edf9..31b90becb 100644 --- a/layout-webapp/src/main/webapp/vue-app/page-templates-management/components/list/PageTemplates.vue +++ b/layout-webapp/src/main/webapp/vue-app/page-templates-management/components/list/PageTemplates.vue @@ -37,6 +37,7 @@ export default { pageTemplates: [], pageTemplateToDelete: null, loading: false, + collator: new Intl.Collator(eXo.env.portal.language, {numeric: true, sensitivity: 'base'}), }), computed: { headers() { @@ -109,7 +110,9 @@ export default { ]; }, noEmptyPageTemplates() { - return this.pageTemplates?.filter?.(t => t.name); + const pageTemplates = this.pageTemplates?.filter?.(t => t.name) || []; + pageTemplates.sort((a, b) => this.collator.compare(a.name.toLowerCase(), b.name.toLowerCase())); + return pageTemplates; }, filteredPageTemplates() { return this.keyword?.length && this.noEmptyPageTemplates.filter(t => { @@ -129,6 +132,7 @@ export default { this.$root.$on('page-templates-updated', this.refreshPageTemplates); this.$root.$on('page-templates-enabled', this.refreshPageTemplates); this.$root.$on('page-templates-disabled', this.refreshPageTemplates); + this.$root.$on('page-templates-saved', this.refreshPageTemplates); this.$root.$on('page-templates-delete', this.deletePageTemplateConfirm); this.$root.$on('page-templates-create', this.createPageTemplate); this.refreshPageTemplates(); @@ -139,6 +143,7 @@ export default { this.$root.$off('page-templates-updated', this.refreshPageTemplates); this.$root.$off('page-templates-enabled', this.refreshPageTemplates); this.$root.$off('page-templates-disabled', this.refreshPageTemplates); + this.$root.$off('page-templates-saved', this.refreshPageTemplates); this.$root.$off('page-templates-delete', this.deletePageTemplateConfirm); this.$root.$off('page-templates-create', this.createPageTemplate); },