mirror of
https://github.com/frappe/books.git
synced 2024-11-12 16:36:27 +00:00
feat: allow emitting change from two column form
This commit is contained in:
parent
a708a14881
commit
b1ace5c248
@ -105,6 +105,10 @@ let TwoColumnForm = {
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: () => [1, 1],
|
default: () => [1, 1],
|
||||||
},
|
},
|
||||||
|
emitChange: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
noBorder: Boolean,
|
noBorder: Boolean,
|
||||||
focusFirstInput: Boolean,
|
focusFirstInput: Boolean,
|
||||||
},
|
},
|
||||||
@ -167,6 +171,10 @@ let TwoColumnForm = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.emitChange && !df.inline) {
|
||||||
|
this.$emit('change', df, value, oldValue);
|
||||||
|
}
|
||||||
|
|
||||||
// handle rename
|
// handle rename
|
||||||
if (this.autosave && df.fieldname === 'name' && !this.doc.isNew()) {
|
if (this.autosave && df.fieldname === 'name' && !this.doc.isNew()) {
|
||||||
return this.doc.rename(value);
|
return this.doc.rename(value);
|
||||||
@ -197,27 +205,36 @@ let TwoColumnForm = {
|
|||||||
handleErrorWithDialog(e, this.doc);
|
handleErrorWithDialog(e, this.doc);
|
||||||
},
|
},
|
||||||
async activateInlineEditing(df) {
|
async activateInlineEditing(df) {
|
||||||
if (df.inline) {
|
if (!df.inline) {
|
||||||
this.inlineEditField = df;
|
return;
|
||||||
if (!this.doc[df.fieldname]) {
|
|
||||||
this.inlineEditDoc = await frappe.getNewDoc(df.target);
|
|
||||||
this.inlineEditDoc.once('afterInsert', () => {
|
|
||||||
this.onChange(df, this.inlineEditDoc.name);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.inlineEditDoc = this.doc.getLink(df.fieldname);
|
|
||||||
}
|
|
||||||
this.inlineEditDisplayField =
|
|
||||||
this.doc.meta.inlineEditDisplayField || 'name';
|
|
||||||
this.inlineEditFields = frappe.getMeta(df.target).getQuickEditFields();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.inlineEditField = df;
|
||||||
|
if (!this.doc[df.fieldname]) {
|
||||||
|
this.inlineEditDoc = await frappe.getNewDoc(df.target);
|
||||||
|
this.inlineEditDoc.once('afterInsert', () => {
|
||||||
|
this.onChange(df, this.inlineEditDoc.name);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.inlineEditDoc = this.doc.getLink(df.fieldname);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.inlineEditDisplayField =
|
||||||
|
this.doc.meta.inlineEditDisplayField || 'name';
|
||||||
|
this.inlineEditFields = frappe.getMeta(df.target).getQuickEditFields();
|
||||||
},
|
},
|
||||||
async saveInlineEditDoc() {
|
async saveInlineEditDoc() {
|
||||||
if (this.inlineEditDoc) {
|
if (!this.inlineEditDoc) {
|
||||||
await this.$refs.inlineEditForm[0].insertOrUpdate();
|
return;
|
||||||
await this.doc.loadLinks();
|
|
||||||
this.inlineEditField = null;
|
|
||||||
}
|
}
|
||||||
|
await this.$refs.inlineEditForm[0].insertOrUpdate();
|
||||||
|
await this.doc.loadLinks();
|
||||||
|
|
||||||
|
if (this.emitChange && df.inline) {
|
||||||
|
this.$emit('change', df.inlineEditField);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.inlineEditField = null;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
Loading…
Reference in New Issue
Block a user