From b383e426a05201a3947b45222174838cb417edcc Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Mon, 25 Apr 2022 14:27:05 +0530 Subject: [PATCH] fix: update setup wizard --- fyo/model/doc.ts | 11 ++++++++++- schemas/app/SetupWizard.json | 13 +++++++------ src/components/TwoColumnForm.vue | 21 +++++++++++++++++---- src/pages/SetupWizard/SetupWizard.vue | 11 +++++------ 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/fyo/model/doc.ts b/fyo/model/doc.ts index 7710aa1e..2eaddc6f 100644 --- a/fyo/model/doc.ts +++ b/fyo/model/doc.ts @@ -102,7 +102,16 @@ export class Doc extends Observable { } get quickEditFields() { - const fieldnames = this.schema.quickEditFields ?? ['name']; + let fieldnames = this.schema.quickEditFields; + + if (fieldnames === undefined) { + fieldnames = []; + } + + if (fieldnames.length === 0 && this.fieldMap['name']) { + fieldnames = ['name']; + } + return fieldnames.map((f) => this.fieldMap[f]); } diff --git a/schemas/app/SetupWizard.json b/schemas/app/SetupWizard.json index b712b4a7..230c5f7d 100644 --- a/schemas/app/SetupWizard.json +++ b/schemas/app/SetupWizard.json @@ -66,17 +66,18 @@ "placeholder": "Currency", "required": true }, + { + "fieldname": "chartOfAccounts", + "label": "Chart of Accounts", + "fieldtype": "AutoComplete", + "placeholder": "Select CoA", + "required": true + }, { "fieldname": "completed", "label": "Completed", "fieldtype": "Check", "readOnly": true - }, - { - "fieldname": "chartOfAccounts", - "label": "Chart of Accounts", - "fieldtype": "AutoComplete", - "placeholder": "Select CoA" } ], "quickEditFields": [ diff --git a/src/components/TwoColumnForm.vue b/src/components/TwoColumnForm.vue index a723005a..6e6e95ec 100644 --- a/src/components/TwoColumnForm.vue +++ b/src/components/TwoColumnForm.vue @@ -99,7 +99,7 @@ export default { emits: ['error', 'change'], props: { doc: Doc, - fields: Array, + fields: { type: Array, default: () => [] }, autosave: Boolean, columnRatio: { type: Array, @@ -137,7 +137,10 @@ export default { if (this.focusFirstInput) { this.$refs['controls'][0].focus(); } - window.tcf = this; + + if (fyo.store.isDevelopment) { + window.tcf = this; + } }, methods: { getRegularValue(df) { @@ -248,8 +251,18 @@ export default { }, computed: { formFields() { - return (this.fields || this.doc.quickEditFields).filter( - (field) => !evaluateHidden(field, this.doc) + let fieldList = this.fields; + + if (fieldList.length === 0) { + fieldList = this.doc.quickEditFields; + } + + if (fieldList.length === 0) { + fieldList = this.doc.schema.fields.filter((f) => f.required); + } + + return fieldList.filter( + (field) => field && !evaluateHidden(field, this.doc) ); }, style() { diff --git a/src/pages/SetupWizard/SetupWizard.vue b/src/pages/SetupWizard/SetupWizard.vue index 300b4fe0..e9a367a7 100644 --- a/src/pages/SetupWizard/SetupWizard.vue +++ b/src/pages/SetupWizard/SetupWizard.vue @@ -57,7 +57,7 @@ @change="(value) => setValue('companyName', value)" :input-class=" () => [ - 'bg-transparent font-semibold text-xl text-white placeholder-blue-200 focus:outline-none focus:bg-blue-600 px-3 rounded py-1', + 'bg-transparent font-semibold text-xl text-white placeholder-blue-400 focus:outline-none focus:bg-blue-600 px-3 rounded py-1', ] " :autofocus="true" @@ -68,7 +68,7 @@ @change="(value) => setValue('email', value)" :input-class=" () => [ - 'text-base bg-transparent text-white placeholder-blue-200 focus:bg-blue-600 focus:outline-none rounded px-3 py-1', + 'text-base bg-transparent text-white placeholder-blue-400 focus:bg-blue-600 focus:outline-none rounded px-3 py-1', ] " /> @@ -163,16 +163,15 @@ export default { setValue(fieldname, value) { this.emailError = null; this.doc.set(fieldname, value).catch((e) => { - // set error if (fieldname === 'email') { this.emailError = getErrorMessage(e, this.doc); } }); }, allValuesFilled() { - const values = this.doc.schema.quickEditFields.map( - (fieldname) => this.doc[fieldname] - ); + const values = this.doc.schema.fields + .filter((f) => f.required) + .map((f) => this.doc[f.fieldname]); return values.every(Boolean); }, async submit() {