2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 01:14:03 +00:00

feat: allow emitting change from two column form

This commit is contained in:
18alantom 2022-01-18 14:01:06 +05:30 committed by Alan
parent a708a14881
commit b1ace5c248

View File

@ -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,7 +205,10 @@ let TwoColumnForm = {
handleErrorWithDialog(e, this.doc); handleErrorWithDialog(e, this.doc);
}, },
async activateInlineEditing(df) { async activateInlineEditing(df) {
if (df.inline) { if (!df.inline) {
return;
}
this.inlineEditField = df; this.inlineEditField = df;
if (!this.doc[df.fieldname]) { if (!this.doc[df.fieldname]) {
this.inlineEditDoc = await frappe.getNewDoc(df.target); this.inlineEditDoc = await frappe.getNewDoc(df.target);
@ -207,17 +218,23 @@ let TwoColumnForm = {
} else { } else {
this.inlineEditDoc = this.doc.getLink(df.fieldname); this.inlineEditDoc = this.doc.getLink(df.fieldname);
} }
this.inlineEditDisplayField = this.inlineEditDisplayField =
this.doc.meta.inlineEditDisplayField || 'name'; this.doc.meta.inlineEditDisplayField || 'name';
this.inlineEditFields = frappe.getMeta(df.target).getQuickEditFields(); this.inlineEditFields = frappe.getMeta(df.target).getQuickEditFields();
}
}, },
async saveInlineEditDoc() { async saveInlineEditDoc() {
if (this.inlineEditDoc) { if (!this.inlineEditDoc) {
return;
}
await this.$refs.inlineEditForm[0].insertOrUpdate(); await this.$refs.inlineEditForm[0].insertOrUpdate();
await this.doc.loadLinks(); await this.doc.loadLinks();
this.inlineEditField = null;
if (this.emitChange && df.inline) {
this.$emit('change', df.inlineEditField);
} }
this.inlineEditField = null;
}, },
}, },
computed: { computed: {