support hide/unhide account

This commit is contained in:
MaysWind
2020-11-14 14:11:36 +08:00
parent c2a7b3d686
commit d8424b8848
8 changed files with 105 additions and 3 deletions
+6
View File
@@ -174,6 +174,12 @@ export default {
subAccounts
});
},
hideAccount: ({ id, hidden }) => {
return axios.post('v1/accounts/hide.json', {
id,
hidden
});
},
moveAccount: ({ newDisplayOrders }) => {
return axios.post('v1/accounts/move.json', {
newDisplayOrders,
+2
View File
@@ -324,6 +324,8 @@ export default {
'Account currency cannot be empty': 'Account currency cannot be empty',
'You have added a new account': 'You have added a new account',
'Unable to add account': 'Unable to add account',
'Unable to hide this account': 'Unable to hide this account',
'Unable to unhide this account': 'Unable to unhide this account',
'Unable to move account': 'Unable to move account',
'Are you sure you want to delete this account?': 'Are you sure you want to delete this account?',
'Unable to delete this account': 'Unable to delete this account',
+2
View File
@@ -324,6 +324,8 @@ export default {
'Account currency cannot be empty': '账户货币不能为空',
'You have added a new account': '您已经添加新账户',
'Unable to add account': '无法添加账户',
'Unable to hide this account': '无法隐藏账户',
'Unable to unhide this account': '无法取消隐藏账户',
'Unable to move account': '无法移动账户',
'Are you sure you want to delete this account?': '您确定要删除该账户吗?',
'Unable to delete this account': '无法删除该账户',
+43 -1
View File
@@ -55,7 +55,12 @@
:title="account.name" :after="account.balance | currency(account.currency)"
link="#" swipeout @taphold.native="setSortable()"
>
<f7-swipeout-actions right>
<f7-swipeout-actions left v-if="sortable">
<f7-swipeout-button :color="account.hidden ? 'blue' : 'gray'" class="padding-left padding-right" @click="hide(account, !account.hidden)">
<f7-icon :f7="account.hidden ? 'eye' : 'eye_slash'"></f7-icon>
</f7-swipeout-button>
</f7-swipeout-actions>
<f7-swipeout-actions right v-if="!sortable">
<f7-swipeout-button color="orange" :text="$t('Edit')" @click="edit(account)"></f7-swipeout-button>
<f7-swipeout-button color="red" class="padding-left padding-right" @click="remove(account)">
<f7-icon f7="trash"></f7-icon>
@@ -278,6 +283,43 @@ export default {
},
edit() {
},
hide(account, hidden) {
const self = this;
self.$showLoading();
self.$services.hideAccount({
id: account.id,
hidden: hidden
}).then(response => {
self.$hideLoading();
const data = response.data;
if (!data || !data.success || !data.result) {
if (hidden) {
self.$toast('Unable to hide this account');
} else {
self.$toast('Unable to unhide this account');
}
return;
}
account.hidden = hidden;
}).catch(error => {
self.$hideLoading();
if (error.response && error.response.data && error.response.data.errorMessage) {
self.$toast({ error: error.response.data });
} else if (!error.processed) {
if (hidden) {
self.$toast('Unable to hide this account');
} else {
self.$toast('Unable to unhide this account');
}
}
});
},
remove(account) {
const self = this;