Prompt to update client details on invoice when closing client modal.

This commit is contained in:
HenriT
2021-04-13 15:28:12 +03:00
parent 580fd9aa5a
commit 0a5d45e64b
3 changed files with 52 additions and 39 deletions

View File

@ -33,6 +33,7 @@ export default {
},
...mapGetters({
client: 'clients/client',
invoice: 'invoices/invoice',
}),
},
watch: {
@ -56,9 +57,26 @@ export default {
this.$store.commit('clients/isModalOpen', false);
}
},
close() {
async close() {
await this.promptUpdateInvoice();
this.isOpen = false;
},
async promptUpdateInvoice() {
if (this.$route.name === 'invoice' && this.invoice.client_id === this.client.id) {
const confirmed = await this.$bvModal.msgBoxConfirm('Update client details on invoice?', {
okTitle: 'Update',
cancelTitle: 'Dismiss',
cancelVariant: 'btn-link',
contentClass: 'bg-base dp--24',
});
if (confirmed) {
this.$store.dispatch('invoices/prefillClient', {
client: this.client,
invoice: this.invoice,
});
}
}
},
},
};
</script>