Order categories by translated label

Closes #1082

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2022-10-28 10:39:42 +02:00
parent dfd8094017
commit 09fce90c6a
2 changed files with 15 additions and 3 deletions

View File

@@ -33,7 +33,7 @@
<div class="flex flex-wrap gap-4">
<o-field
v-if="eventCategories"
v-if="orderedCategories"
:label="t('Category')"
label-for="categoryField"
class="w-full md:max-w-fit"
@@ -45,7 +45,7 @@
expanded
>
<option
v-for="category in eventCategories"
v-for="category in orderedCategories"
:value="category.id"
:key="category.id"
>
@@ -595,6 +595,7 @@ import { Notifier } from "@/plugins/notifier";
import { useHead } from "@vueuse/head";
import { useProgrammatic } from "@oruga-ui/oruga-next";
import type { Locale } from "date-fns";
import sortBy from "lodash/sortBy";
const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10;
@@ -1331,6 +1332,11 @@ watch(group, () => {
event.value.visibility = EventVisibility.PUBLIC;
}
});
const orderedCategories = computed(() => {
if (!eventCategories.value) return undefined;
return sortBy(eventCategories.value, ["label"]);
});
</script>
<style lang="scss">