From 54e074329c6466470fc44a9cece34d627025c7ae Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 27 Dec 2019 15:54:50 +0530 Subject: [PATCH] fix: Disable Next button until values are filled --- src/pages/SetupWizard/SetupWizard.vue | 39 ++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/pages/SetupWizard/SetupWizard.vue b/src/pages/SetupWizard/SetupWizard.vue index 7175422a..b5b4ac6c 100644 --- a/src/pages/SetupWizard/SetupWizard.vue +++ b/src/pages/SetupWizard/SetupWizard.vue @@ -6,19 +6,19 @@ {{ _('These settings can be changed later') }}

-
+
{{ buttonText }} @@ -56,16 +56,16 @@ import frappe from 'frappejs'; import TwoColumnForm from '@/components/TwoColumnForm'; import FormControl from '@/components/Controls/FormControl'; - import Button from '@/components/Button'; +import { handleErrorWithDialog, showMessageDialog } from '@/utils'; export default { name: 'SetupWizard', data() { return { - meta: frappe.getMeta('SetupWizard'), + doc: null, loading: false, - doc: {} + valuesFilled: false }; }, provide() { @@ -79,11 +79,29 @@ export default { FormControl, Button }, - async beforeMount() { + async mounted() { this.doc = await frappe.newDoc({ doctype: 'SetupWizard' }); + this.doc.on('change', () => { + this.valuesFilled = this.allValuesFilled(); + }); }, methods: { + setValue(fieldname, value) { + this.doc + .set(fieldname, value) + .catch(e => handleErrorWithDialog(e, this.doc)); + }, + allValuesFilled() { + let values = this.meta.quickEditFields.map( + fieldname => this.doc[fieldname] + ); + return values.every(Boolean); + }, async submit() { + if (!this.allValuesFilled()) { + showMessageDialog({ message: this._('Please fill all values') }); + return; + } try { this.loading = true; frappe.events.trigger('SetupWizard:setup-complete', this.doc); @@ -94,6 +112,9 @@ export default { } }, computed: { + meta() { + return frappe.getMeta('SetupWizard'); + }, fields() { return this.meta.getQuickEditFields(); },