2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

fix: update setup wizard

This commit is contained in:
18alantom 2022-04-25 14:27:05 +05:30
parent 1b85fee5e6
commit b383e426a0
4 changed files with 39 additions and 17 deletions

View File

@ -102,7 +102,16 @@ export class Doc extends Observable<DocValue | Doc[]> {
} }
get quickEditFields() { 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]); return fieldnames.map((f) => this.fieldMap[f]);
} }

View File

@ -66,17 +66,18 @@
"placeholder": "Currency", "placeholder": "Currency",
"required": true "required": true
}, },
{
"fieldname": "chartOfAccounts",
"label": "Chart of Accounts",
"fieldtype": "AutoComplete",
"placeholder": "Select CoA",
"required": true
},
{ {
"fieldname": "completed", "fieldname": "completed",
"label": "Completed", "label": "Completed",
"fieldtype": "Check", "fieldtype": "Check",
"readOnly": true "readOnly": true
},
{
"fieldname": "chartOfAccounts",
"label": "Chart of Accounts",
"fieldtype": "AutoComplete",
"placeholder": "Select CoA"
} }
], ],
"quickEditFields": [ "quickEditFields": [

View File

@ -99,7 +99,7 @@ export default {
emits: ['error', 'change'], emits: ['error', 'change'],
props: { props: {
doc: Doc, doc: Doc,
fields: Array, fields: { type: Array, default: () => [] },
autosave: Boolean, autosave: Boolean,
columnRatio: { columnRatio: {
type: Array, type: Array,
@ -137,7 +137,10 @@ export default {
if (this.focusFirstInput) { if (this.focusFirstInput) {
this.$refs['controls'][0].focus(); this.$refs['controls'][0].focus();
} }
window.tcf = this;
if (fyo.store.isDevelopment) {
window.tcf = this;
}
}, },
methods: { methods: {
getRegularValue(df) { getRegularValue(df) {
@ -248,8 +251,18 @@ export default {
}, },
computed: { computed: {
formFields() { formFields() {
return (this.fields || this.doc.quickEditFields).filter( let fieldList = this.fields;
(field) => !evaluateHidden(field, this.doc)
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() { style() {

View File

@ -57,7 +57,7 @@
@change="(value) => setValue('companyName', value)" @change="(value) => setValue('companyName', value)"
:input-class=" :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" :autofocus="true"
@ -68,7 +68,7 @@
@change="(value) => setValue('email', value)" @change="(value) => setValue('email', value)"
:input-class=" :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) { setValue(fieldname, value) {
this.emailError = null; this.emailError = null;
this.doc.set(fieldname, value).catch((e) => { this.doc.set(fieldname, value).catch((e) => {
// set error
if (fieldname === 'email') { if (fieldname === 'email') {
this.emailError = getErrorMessage(e, this.doc); this.emailError = getErrorMessage(e, this.doc);
} }
}); });
}, },
allValuesFilled() { allValuesFilled() {
const values = this.doc.schema.quickEditFields.map( const values = this.doc.schema.fields
(fieldname) => this.doc[fieldname] .filter((f) => f.required)
); .map((f) => this.doc[f.fieldname]);
return values.every(Boolean); return values.every(Boolean);
}, },
async submit() { async submit() {