code refactor
This commit is contained in:
+1
-1
@@ -373,7 +373,7 @@ app.use(router);
|
||||
app.component('VChart', VChart);
|
||||
app.component('PerfectScrollbar', PerfectScrollbar);
|
||||
app.component('VueDatePicker', VueDatePicker);
|
||||
app.component('draggable', draggable);
|
||||
app.component('DraggableList', draggable);
|
||||
|
||||
app.component('PinCodeInput', PinCodeInput);
|
||||
|
||||
|
||||
@@ -86,14 +86,14 @@ function updateAccountToAccountList(state, account) {
|
||||
}
|
||||
}
|
||||
|
||||
function updateAccountDisplayOrderInAccountList(state, { account, from, to, onlyUpdateGlobalList }) {
|
||||
function updateAccountDisplayOrderInAccountList(state, { account, from, to, updateListOrder, updateGlobalListOrder }) {
|
||||
let fromAccount = null;
|
||||
let toAccount = null;
|
||||
|
||||
if (state.allCategorizedAccounts[account.category]) {
|
||||
const accountList = state.allCategorizedAccounts[account.category].accounts;
|
||||
|
||||
if (!onlyUpdateGlobalList) {
|
||||
if (updateListOrder) {
|
||||
fromAccount = accountList[from];
|
||||
toAccount = accountList[to];
|
||||
accountList.splice(to, 0, accountList.splice(from, 1)[0]);
|
||||
@@ -108,7 +108,7 @@ function updateAccountDisplayOrderInAccountList(state, { account, from, to, only
|
||||
}
|
||||
}
|
||||
|
||||
if (fromAccount && toAccount) {
|
||||
if (updateGlobalListOrder && fromAccount && toAccount) {
|
||||
let globalFromIndex = -1;
|
||||
let globalToIndex = -1;
|
||||
|
||||
@@ -756,7 +756,7 @@ export const useAccountsStore = defineStore('accounts', {
|
||||
});
|
||||
});
|
||||
},
|
||||
changeAccountDisplayOrder({ accountId, from, to, onlyUpdateGlobalList }) {
|
||||
changeAccountDisplayOrder({ accountId, from, to, updateListOrder, updateGlobalListOrder }) {
|
||||
const self = this;
|
||||
const account = self.allAccountsMap[accountId];
|
||||
|
||||
@@ -777,7 +777,8 @@ export const useAccountsStore = defineStore('accounts', {
|
||||
account: account,
|
||||
from: from,
|
||||
to: to,
|
||||
onlyUpdateGlobalList: onlyUpdateGlobalList
|
||||
updateListOrder: updateListOrder,
|
||||
updateGlobalListOrder: updateGlobalListOrder
|
||||
});
|
||||
|
||||
resolve();
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
|
||||
<v-row class="pl-4 pr-8" v-if="categorizedAccounts[activeAccountCategory.id] && categorizedAccounts[activeAccountCategory.id].accounts && categorizedAccounts[activeAccountCategory.id].accounts.length">
|
||||
<v-col cols="12">
|
||||
<draggable
|
||||
<draggable-list
|
||||
class="list-group"
|
||||
item-key="id"
|
||||
handle=".drag-handle"
|
||||
@@ -197,7 +197,7 @@
|
||||
</v-card>
|
||||
</div>
|
||||
</template>
|
||||
</draggable>
|
||||
</draggable-list>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
@@ -417,7 +417,8 @@ export default {
|
||||
accountId: moveEvent.element.id,
|
||||
from: moveEvent.oldIndex,
|
||||
to: moveEvent.newIndex,
|
||||
onlyUpdateGlobalList: true
|
||||
updateListOrder: false,
|
||||
updateGlobalListOrder: true
|
||||
}).then(() => {
|
||||
self.displayOrderModified = true;
|
||||
}).catch(error => {
|
||||
@@ -440,7 +441,7 @@ export default {
|
||||
self.loading = false;
|
||||
|
||||
if (!error.processed) {
|
||||
self.$toast(error.message || error);
|
||||
self.$refs.snackbar.showError(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -338,7 +338,9 @@ export default {
|
||||
self.accountsStore.changeAccountDisplayOrder({
|
||||
accountId: id,
|
||||
from: event.from - 1, // first item in the list is title, so the index need minus one
|
||||
to: event.to - 1
|
||||
to: event.to - 1,
|
||||
updateListOrder: true,
|
||||
updateGlobalListOrder: true
|
||||
}).then(() => {
|
||||
self.displayOrderModified = true;
|
||||
}).catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user