Skip to content

Commit

Permalink
feat: Sort Page Templates List with Intl.Collator - MEED-6887 - Meeds…
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker committed May 21, 2024
1 parent da2996c commit 50538b0
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 => {
Expand All @@ -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();
Expand All @@ -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);
},
Expand Down

0 comments on commit 50538b0

Please sign in to comment.