account list page supports dragging to change display order

This commit is contained in:
MaysWind
2023-07-19 02:28:50 +08:00
parent 107c9fce94
commit 2cbd8684cf
10 changed files with 231 additions and 91 deletions
+17 -6
View File
@@ -86,16 +86,26 @@ function updateAccountToAccountList(state, account) {
}
}
function updateAccountDisplayOrderInAccountList(state, { account, from, to }) {
function updateAccountDisplayOrderInAccountList(state, { account, from, to, onlyUpdateGlobalList }) {
let fromAccount = null;
let toAccount = null;
if (state.allCategorizedAccounts[account.category]) {
const accountList = state.allCategorizedAccounts[account.category].accounts;
fromAccount = accountList[from];
toAccount = accountList[to];
accountList.splice(to, 0, accountList.splice(from, 1)[0]);
if (!onlyUpdateGlobalList) {
fromAccount = accountList[from];
toAccount = accountList[to];
accountList.splice(to, 0, accountList.splice(from, 1)[0]);
} else {
fromAccount = accountList[to];
if (from < to) {
toAccount = accountList[to - 1];
} else if (from > to) {
toAccount = accountList[to + 1];
}
}
}
if (fromAccount && toAccount) {
@@ -746,7 +756,7 @@ export const useAccountsStore = defineStore('accounts', {
});
});
},
changeAccountDisplayOrder({ accountId, from, to }) {
changeAccountDisplayOrder({ accountId, from, to, onlyUpdateGlobalList }) {
const self = this;
const account = self.allAccountsMap[accountId];
@@ -766,7 +776,8 @@ export const useAccountsStore = defineStore('accounts', {
updateAccountDisplayOrderInAccountList(self, {
account: account,
from: from,
to: to
to: to,
onlyUpdateGlobalList: onlyUpdateGlobalList
});
resolve();