A continuation of HomeBox the inventory and organization system built for the Home User
fix: use logical sorting for locations
tonyaellie018f1f5977e4
diff --git a/frontend/components/Location/Tree/Node.vue b/frontend/components/Location/Tree/Node.vueindex 6dd2a98c..f5ac6e3f 100644--- a/frontend/components/Location/Tree/Node.vue+++ b/frontend/components/Location/Tree/Node.vue@@ -22,6 +22,13 @@const state = useTreeState(props.treeId);+ const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });++ const sortedChildren = computed(() => {+ const children = props.item.children ?? [];+ return [...children].sort((a, b) => collator.compare(a.name, b.name));+ });+const openRef = computed({get() {return state.value[nodeHash.value] ?? false;@@ -66,7 +73,7 @@<NuxtLink class="text-lg hover:underline" :to="link" @click.stop>{{ item.name }} </NuxtLink></div><div v-if="openRef" class="ml-4">- <LocationTreeNode v-for="child in item.children" :key="child.id" :item="child" :tree-id="treeId" />+ <LocationTreeNode v-for="child in sortedChildren" :key="child.id" :item="child" :tree-id="treeId" /></div></div></template>diff --git a/frontend/components/Location/Tree/Root.vue b/frontend/components/Location/Tree/Root.vueindex 469b1613..445f7bf3 100644--- a/frontend/components/Location/Tree/Root.vue+++ b/frontend/components/Location/Tree/Root.vue@@ -7,14 +7,21 @@treeId: string;};- defineProps<Props>();+ const props = defineProps<Props>();++ const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" });++ const sortedLocs = computed(() => {+ const list = props.locs ?? [];+ return [...list].sort((a, b) => collator.compare(a.name, b.name));+ });</script><template><div>- <p v-if="locs.length === 0" class="text-center text-sm">+ <p v-if="sortedLocs.length === 0" class="text-center text-sm">{{ $t("location.tree.no_locations") }}</p>- <LocationTreeNode v-for="item in locs" :key="item.id" :item="item" :tree-id="treeId" />+ <LocationTreeNode v-for="item in sortedLocs" :key="item.id" :item="item" :tree-id="treeId" /></div></template>