UX: set tag sort based on siteSetting (#24147)

This commit is contained in:
Kris 2023-10-30 10:55:39 -04:00 committed by GitHub
parent 2e06cc1248
commit fbf8528814
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ export default Controller.extend({
modal: service(),
sortedByCount: true,
sortedByName: false,
sortAlphabetically: alias("siteSettings.tags_sort_alphabetically"),
canAdminTags: alias("currentUser.staff"),
groupedByCategory: notEmpty("model.extras.categories"),
groupedByTagGroup: notEmpty("model.extras.tag_groups"),
@ -20,7 +21,13 @@ export default Controller.extend({
init() {
this._super(...arguments);
this.sortProperties = ["totalCount:desc", "id"];
const isAlphaSort = this.sortAlphabetically;
this.setProperties({
sortedByCount: isAlphaSort ? false : true,
sortedByName: isAlphaSort ? true : false,
sortProperties: isAlphaSort ? ["id"] : ["totalCount:desc", "id"],
});
},
@discourseComputed("groupedByCategory", "groupedByTagGroup")