Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Sort Page Templates List with Intl.Collator - MEED-6887 - Meeds-io/MIPs#133 #74

Merged
merged 1 commit into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading