add confirm dialog when saving a transaction whose amount is 0

This commit is contained in:
MaysWind
2021-01-09 22:30:39 +08:00
parent e2d6325805
commit daf030e7ef
3 changed files with 33 additions and 21 deletions
+1
View File
@@ -565,6 +565,7 @@ export default {
'Transaction Time': 'Transaction Time', 'Transaction Time': 'Transaction Time',
'Tags': 'Tags', 'Tags': 'Tags',
'Your transaction description (optional)': 'Your transaction description (optional)', 'Your transaction description (optional)': 'Your transaction description (optional)',
'Are you sure you want to save this transaction whose amount is 0?': 'Are you sure you want to save this transaction whose amount is 0?',
'Unable to get transaction': 'Unable to get transaction', 'Unable to get transaction': 'Unable to get transaction',
'Unable to add transaction': 'Unable to add transaction', 'Unable to add transaction': 'Unable to add transaction',
'Unable to save transaction': 'Unable to save transaction', 'Unable to save transaction': 'Unable to save transaction',
+1
View File
@@ -565,6 +565,7 @@ export default {
'Transaction Time': '交易时间', 'Transaction Time': '交易时间',
'Tags': '标签', 'Tags': '标签',
'Your transaction description (optional)': '你的交易描述 (可选)', 'Your transaction description (optional)': '你的交易描述 (可选)',
'Are you sure you want to save this transaction whose amount is 0?': '您确定要保存这个金额为0的交易?',
'Unable to get transaction': '无法获取交易', 'Unable to get transaction': '无法获取交易',
'Unable to add transaction': '无法添加交易', 'Unable to add transaction': '无法添加交易',
'Unable to save transaction': '无法保存交易', 'Unable to save transaction': '无法保存交易',
+13 -3
View File
@@ -640,9 +640,6 @@ export default {
return; return;
} }
self.submitting = true;
self.$showLoading(() => self.submitting);
const submitTransaction = { const submitTransaction = {
type: self.transaction.type, type: self.transaction.type,
time: self.transaction.unixTime, time: self.transaction.unixTime,
@@ -671,6 +668,10 @@ export default {
submitTransaction.id = self.transaction.id; submitTransaction.id = self.transaction.id;
} }
const doSubmit = function () {
self.submitting = true;
self.$showLoading(() => self.submitting);
self.$store.dispatch('saveTransaction', { self.$store.dispatch('saveTransaction', {
transaction: submitTransaction transaction: submitTransaction
}).then(() => { }).then(() => {
@@ -692,6 +693,15 @@ export default {
self.$toast(error.message || error); self.$toast(error.message || error);
} }
}); });
};
if (submitTransaction.sourceAmount === 0) {
self.$confirm('Are you sure you want to save this transaction whose amount is 0?', () => {
doSubmit();
});
} else {
doSubmit();
}
}, },
autoChangeCommentTextareaSize() { autoChangeCommentTextareaSize() {
const app = this.$f7; const app = this.$f7;