doc.set('companyLogo', value)"
+ @change="value => setValue('companyLogo', value)"
/>
doc.set('companyName', value)"
+ @change="value => setValue('companyName', value)"
:input-class="
classes => [
'bg-transparent font-semibold text-xl text-white placeholder-blue-200 focus:outline-none focus:bg-blue-600 px-3 rounded py-1'
@@ -29,7 +29,7 @@
doc.set('email', value)"
+ @change="value => setValue('email', value)"
:input-class="
classes => [
'text-base bg-transparent text-white placeholder-blue-200 focus:bg-blue-600 focus:outline-none rounded px-3 py-1'
@@ -45,7 +45,7 @@
@click="submit"
type="primary"
class="text-white text-sm"
- :disabled="loading"
+ :disabled="!valuesFilled || loading"
>
{{ 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();
},