diff --git a/src/locales/en.js b/src/locales/en.js index ccd978a6..f49e9261 100644 --- a/src/locales/en.js +++ b/src/locales/en.js @@ -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?': 'Are you sure you want to save this transaction whose amount is 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', diff --git a/src/locales/zh_Hans.js b/src/locales/zh_Hans.js index 1bd6f4e5..795a8244 100644 --- a/src/locales/zh_Hans.js +++ b/src/locales/zh_Hans.js @@ -565,6 +565,7 @@ export default { 'Transaction Time': '交易时间', 'Tags': '标签', 'Your transaction description (optional)': '你的交易描述 (可选)', + 'Are you sure you want to save this transaction whose amount is 0?': '您确定要保存这个金额为0的交易?', 'Unable to get transaction': '无法获取交易', 'Unable to add transaction': '无法添加交易', 'Unable to save transaction': '无法保存交易', diff --git a/src/views/mobile/transactions/Edit.vue b/src/views/mobile/transactions/Edit.vue index dfaefc4c..5013c464 100644 --- a/src/views/mobile/transactions/Edit.vue +++ b/src/views/mobile/transactions/Edit.vue @@ -640,9 +640,6 @@ export default { return; } - self.submitting = true; - self.$showLoading(() => self.submitting); - const submitTransaction = { type: self.transaction.type, time: self.transaction.unixTime, @@ -671,27 +668,40 @@ export default { submitTransaction.id = self.transaction.id; } - self.$store.dispatch('saveTransaction', { - transaction: submitTransaction - }).then(() => { - self.submitting = false; - self.$hideLoading(); + const doSubmit = function () { + self.submitting = true; + self.$showLoading(() => self.submitting); - if (self.mode === 'add') { - self.$toast('You have added a new transaction'); - } else if (self.mode === 'edit') { - self.$toast('You have saved this transaction'); - } + self.$store.dispatch('saveTransaction', { + transaction: submitTransaction + }).then(() => { + self.submitting = false; + self.$hideLoading(); - router.back(); - }).catch(error => { - self.submitting = false; - self.$hideLoading(); + if (self.mode === 'add') { + self.$toast('You have added a new transaction'); + } else if (self.mode === 'edit') { + self.$toast('You have saved this transaction'); + } - if (!error.processed) { - self.$toast(error.message || error); - } - }); + router.back(); + }).catch(error => { + self.submitting = false; + self.$hideLoading(); + + if (!error.processed) { + 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() { const app = this.$f7;