sort transaction tags by name (#487)
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": "色",
|
||||
|
||||
@@ -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": "ಬಣ್ಣ",
|
||||
|
||||
@@ -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": "색상",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": "Цвет",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": "நிறம்",
|
||||
|
||||
@@ -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": "สี",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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": "Колір",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -1496,6 +1496,8 @@
|
||||
"Delete": "删除",
|
||||
"Duplicate": "复制",
|
||||
"Sort": "排序",
|
||||
"Sort by Name (A to Z)": "按名称排序(正序)",
|
||||
"Sort by Name (Z to A)": "按名称排序(倒序)",
|
||||
"Date": "日期",
|
||||
"Time": "时间",
|
||||
"Color": "颜色",
|
||||
|
||||
@@ -1496,6 +1496,8 @@
|
||||
"Delete": "刪除",
|
||||
"Duplicate": "複製",
|
||||
"Sort": "排序",
|
||||
"Sort by Name (A to Z)": "依名稱排序(正序)",
|
||||
"Sort by Name (Z to A)": "依名稱排序(倒序)",
|
||||
"Date": "日期",
|
||||
"Time": "時間",
|
||||
"Color": "顏色",
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -83,6 +83,15 @@
|
||||
:title="tt('Change Group Display Order')"
|
||||
v-if="allTagGroupsWithDefault.length >= 2"
|
||||
@click="showChangeGroupDisplayOrderDialog"></v-list-item>
|
||||
<v-divider class="my-2" v-if="tags.length > 1"/>
|
||||
<v-list-item :prepend-icon="mdiSortAlphabeticalAscending"
|
||||
:title="tt('Sort by Name (A to Z)')"
|
||||
@click="sortByName(false)"
|
||||
v-if="tags.length > 1"></v-list-item>
|
||||
<v-list-item :prepend-icon="mdiSortAlphabeticalDescending"
|
||||
:title="tt('Sort by Name (Z to A)')"
|
||||
@click="sortByName(true)"
|
||||
v-if="tags.length > 1"></v-list-item>
|
||||
<v-divider class="my-2"/>
|
||||
<v-list-item :prepend-icon="mdiEyeOutline"
|
||||
:title="tt('Show Hidden Transaction Tags')"
|
||||
@@ -347,6 +356,8 @@ import {
|
||||
mdiPencilOutline,
|
||||
mdiCheck,
|
||||
mdiClose,
|
||||
mdiSortAlphabeticalAscending,
|
||||
mdiSortAlphabeticalDescending,
|
||||
mdiEyeOffOutline,
|
||||
mdiEyeOutline,
|
||||
mdiSort,
|
||||
@@ -589,6 +600,14 @@ function cancelSave(tag: TransactionTag): void {
|
||||
}
|
||||
}
|
||||
|
||||
function sortByName(desc: boolean): void {
|
||||
const changed = transactionTagsStore.sortTagDisplayOrderByTagName(activeTagGroupId.value, desc);
|
||||
|
||||
if (changed) {
|
||||
displayOrderModified.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
function saveSortResult(): void {
|
||||
if (!displayOrderModified.value) {
|
||||
return;
|
||||
|
||||
@@ -194,8 +194,10 @@
|
||||
<f7-actions-group v-if="allTagGroupsWithDefault.length >= 2">
|
||||
<f7-actions-button @click="changeTagGroupDisplayOrder">{{ tt('Change Group Display Order') }}</f7-actions-button>
|
||||
</f7-actions-group>
|
||||
<f7-actions-group>
|
||||
<f7-actions-group v-if="tags.length > 1">
|
||||
<f7-actions-button @click="setSortable()">{{ tt('Sort') }}</f7-actions-button>
|
||||
<f7-actions-button @click="sortByName(false)">{{ tt('Sort by Name (A to Z)') }}</f7-actions-button>
|
||||
<f7-actions-button @click="sortByName(true)">{{ tt('Sort by Name (Z to A)') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="!showHidden" @click="showHidden = true">{{ tt('Show Hidden Transaction Tags') }}</f7-actions-button>
|
||||
<f7-actions-button v-if="showHidden" @click="showHidden = false">{{ tt('Hide Hidden Transaction Tags') }}</f7-actions-button>
|
||||
</f7-actions-group>
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user