diff --git a/src/locales/de.json b/src/locales/de.json index 8106a7d8..6613a75c 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -1496,6 +1496,8 @@ "Delete": "Löschen", "Duplicate": "Duplizieren", "Sort": "Sortieren", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Datum", "Time": "Zeit", "Color": "Farbe", diff --git a/src/locales/en.json b/src/locales/en.json index 4b1c01de..de2867da 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1496,6 +1496,8 @@ "Delete": "Delete", "Duplicate": "Duplicate", "Sort": "Sort", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Date", "Time": "Time", "Color": "Color", diff --git a/src/locales/es.json b/src/locales/es.json index 5cc6b427..ff5e230a 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -1496,6 +1496,8 @@ "Delete": "Borrar", "Duplicate": "Duplicar", "Sort": "Ordenar", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Fecha", "Time": "Hora", "Color": "Color", diff --git a/src/locales/fr.json b/src/locales/fr.json index c0a9fed9..a18d92c9 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -1496,6 +1496,8 @@ "Delete": "Supprimer", "Duplicate": "Dupliquer", "Sort": "Trier", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Date", "Time": "Heure", "Color": "Couleur", diff --git a/src/locales/it.json b/src/locales/it.json index 27eac78f..4f3531bb 100644 --- a/src/locales/it.json +++ b/src/locales/it.json @@ -1496,6 +1496,8 @@ "Delete": "Elimina", "Duplicate": "Duplica", "Sort": "Ordina", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Data", "Time": "Ora", "Color": "Colore", diff --git a/src/locales/ja.json b/src/locales/ja.json index aa0ea3a1..ad096602 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -1496,6 +1496,8 @@ "Delete": "削除", "Duplicate": "複製", "Sort": "並べ替え", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "日付", "Time": "時間", "Color": "色", diff --git a/src/locales/kn.json b/src/locales/kn.json index 7cf971bd..5fac012f 100644 --- a/src/locales/kn.json +++ b/src/locales/kn.json @@ -1496,6 +1496,8 @@ "Delete": "ಅಳಿಸು", "Duplicate": "ನಕಲು ಮಾಡು", "Sort": "ವಿಂಗಡಿಸು", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "ದಿನಾಂಕ", "Time": "ಸಮಯ", "Color": "ಬಣ್ಣ", diff --git a/src/locales/ko.json b/src/locales/ko.json index 09f46f90..50e9c875 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -1496,6 +1496,8 @@ "Delete": "삭제", "Duplicate": "복제", "Sort": "정렬", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "날짜", "Time": "시간", "Color": "색상", diff --git a/src/locales/nl.json b/src/locales/nl.json index 59ba56ad..3d7f2c1d 100644 --- a/src/locales/nl.json +++ b/src/locales/nl.json @@ -1496,6 +1496,8 @@ "Delete": "Verwijderen", "Duplicate": "Dupliceren", "Sort": "Sorteren", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Datum", "Time": "Tijd", "Color": "Kleur", diff --git a/src/locales/pt_BR.json b/src/locales/pt_BR.json index 006eb3b8..136b3414 100644 --- a/src/locales/pt_BR.json +++ b/src/locales/pt_BR.json @@ -1496,6 +1496,8 @@ "Delete": "Excluir", "Duplicate": "Duplicar", "Sort": "Classificar", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Data", "Time": "Hora", "Color": "Cor", diff --git a/src/locales/ru.json b/src/locales/ru.json index 2a04dcf4..01b9ba5e 100644 --- a/src/locales/ru.json +++ b/src/locales/ru.json @@ -1496,6 +1496,8 @@ "Delete": "Удалить", "Duplicate": "Дублировать", "Sort": "Сортировать", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Дата", "Time": "Время", "Color": "Цвет", diff --git a/src/locales/sl.json b/src/locales/sl.json index 8d5b1b59..0ccde5da 100644 --- a/src/locales/sl.json +++ b/src/locales/sl.json @@ -1496,6 +1496,8 @@ "Delete": "Izbriši", "Duplicate": "Podvoji", "Sort": "Razvrsti", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Datum", "Time": "Čas", "Color": "Barva", diff --git a/src/locales/ta.json b/src/locales/ta.json index 501a82a6..3fd3af85 100644 --- a/src/locales/ta.json +++ b/src/locales/ta.json @@ -1496,6 +1496,8 @@ "Delete": "நீக்கு", "Duplicate": "நகலெடு", "Sort": "வரிசைப்படுத்து", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "தேதி", "Time": "நேரம்", "Color": "நிறம்", diff --git a/src/locales/th.json b/src/locales/th.json index e0281c9e..171b669c 100644 --- a/src/locales/th.json +++ b/src/locales/th.json @@ -1496,6 +1496,8 @@ "Delete": "ลบ", "Duplicate": "ทำสำเนา", "Sort": "จัดเรียง", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "วันที่", "Time": "เวลา", "Color": "สี", diff --git a/src/locales/tr.json b/src/locales/tr.json index 9f6cab11..3a9e5f02 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -1496,6 +1496,8 @@ "Delete": "Sil", "Duplicate": "Çoğalt", "Sort": "Sırala", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Tarih", "Time": "Zaman", "Color": "Renk", diff --git a/src/locales/uk.json b/src/locales/uk.json index f2a1c7b6..8ebf85a3 100644 --- a/src/locales/uk.json +++ b/src/locales/uk.json @@ -1496,6 +1496,8 @@ "Delete": "Видалити", "Duplicate": "Дублювати", "Sort": "Сортувати", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Дата", "Time": "Час", "Color": "Колір", diff --git a/src/locales/vi.json b/src/locales/vi.json index 6e5d2c3a..2a42d31a 100644 --- a/src/locales/vi.json +++ b/src/locales/vi.json @@ -1496,6 +1496,8 @@ "Delete": "Xóa", "Duplicate": "Nhân đôi", "Sort": "Sắp xếp", + "Sort by Name (A to Z)": "Sort by Name (A to Z)", + "Sort by Name (Z to A)": "Sort by Name (Z to A)", "Date": "Ngày", "Time": "Thời gian", "Color": "Màu sắc", diff --git a/src/locales/zh_Hans.json b/src/locales/zh_Hans.json index e7b8bf99..398132a4 100644 --- a/src/locales/zh_Hans.json +++ b/src/locales/zh_Hans.json @@ -1496,6 +1496,8 @@ "Delete": "删除", "Duplicate": "复制", "Sort": "排序", + "Sort by Name (A to Z)": "按名称排序(正序)", + "Sort by Name (Z to A)": "按名称排序(倒序)", "Date": "日期", "Time": "时间", "Color": "颜色", diff --git a/src/locales/zh_Hant.json b/src/locales/zh_Hant.json index c8dadf15..d7eb4385 100644 --- a/src/locales/zh_Hant.json +++ b/src/locales/zh_Hant.json @@ -1496,6 +1496,8 @@ "Delete": "刪除", "Duplicate": "複製", "Sort": "排序", + "Sort by Name (A to Z)": "依名稱排序(正序)", + "Sort by Name (Z to A)": "依名稱排序(倒序)", "Date": "日期", "Time": "時間", "Color": "顏色", diff --git a/src/stores/transactionTag.ts b/src/stores/transactionTag.ts index 168c0b0f..61e64ef4 100644 --- a/src/stores/transactionTag.ts +++ b/src/stores/transactionTag.ts @@ -151,6 +151,57 @@ export const useTransactionTagsStore = defineStore('transactionTags', () => { allTransactionTagGroups.value.splice(to, 0, allTransactionTagGroups.value.splice(from, 1)[0] as TransactionTagGroup); } + function sortTagDisplayOrderByTagName(groupId: string, desc: boolean): boolean { + // update in the group list + const tagsInGroup = allTransactionTagsByGroupMap.value[groupId]; + + if (!tagsInGroup) { + return false; + } + + const oldTagsInGroup: TransactionTag[] = [...tagsInGroup]; + + if (!desc) { + tagsInGroup.sort((a, b) => a.name.localeCompare(b.name, undefined, { // asc + numeric: true, + sensitivity: 'base' + })); + } else { + tagsInGroup.sort((a, b) => b.name.localeCompare(a.name, undefined, { // desc + numeric: true, + sensitivity: 'base' + })); + } + + const isOrderChanged = !isEquals(oldTagsInGroup, tagsInGroup); + + if (!isOrderChanged) { + return false; + } + + // update in the main list + for (const [oldTag, oldIndex] of itemAndIndex(oldTagsInGroup)) { + const newTag = tagsInGroup[oldIndex]; + + if (!newTag || newTag.id === oldTag.id) { + continue; + } + + for (const [tag, index] of itemAndIndex(allTransactionTags.value)) { + if (tag.id === oldTag.id) { + allTransactionTags.value.splice(index, 1, newTag); + break; + } + } + } + + if (!transactionTagListStateInvalid.value) { + updateTransactionTagListInvalidState(true); + } + + return true; + } + function updateTagDisplayOrderInTransactionTagList({ groupId, from, to }: { groupId: string, from: number, to: number }): void { // update in the group list const tagsInGroup = allTransactionTagsByGroupMap.value[groupId]; @@ -757,6 +808,7 @@ export const useTransactionTagsStore = defineStore('transactionTags', () => { // computed states allAvailableTagsCount, // functions + sortTagDisplayOrderByTagName, updateTransactionTagListInvalidState, resetTransactionTags, loadAllTagGroups, diff --git a/src/views/desktop/tags/ListPage.vue b/src/views/desktop/tags/ListPage.vue index f3fbd177..a6f00b50 100644 --- a/src/views/desktop/tags/ListPage.vue +++ b/src/views/desktop/tags/ListPage.vue @@ -83,6 +83,15 @@ :title="tt('Change Group Display Order')" v-if="allTagGroupsWithDefault.length >= 2" @click="showChangeGroupDisplayOrderDialog"> + + + {{ tt('Change Group Display Order') }} - + {{ tt('Sort') }} + {{ tt('Sort by Name (A to Z)') }} + {{ tt('Sort by Name (Z to A)') }} {{ tt('Show Hidden Transaction Tags') }} {{ tt('Hide Hidden Transaction Tags') }} @@ -462,6 +464,17 @@ function remove(tag: TransactionTag | null, confirm: boolean): void { }); } +function sortByName(desc: boolean): void { + showHidden.value = true; + sortable.value = true; + + const changed = transactionTagsStore.sortTagDisplayOrderByTagName(activeTagGroupId.value, desc); + + if (changed) { + displayOrderModified.value = true; + } +} + function setSortable(): void { if (sortable.value || hasEditingTag.value) { return;