Merge branch 'develop' into connection-filter

This commit is contained in:
Shariq Ansari 2023-07-04 14:49:04 +05:30 committed by GitHub
commit 5984bbbc46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 8 deletions

View file

@ -76,6 +76,7 @@ def _make_access_log(
if frappe.flags.read_only:
access_log.deferred_insert()
return
else:
access_log.db_insert()

View file

@ -191,12 +191,14 @@ frappe.ui.form.Layout = class Layout {
replace_field(fieldname, df, render) {
df.fieldname = fieldname; // change of fieldname is avoided
if (this.fields_dict[fieldname] && this.fields_dict[fieldname].df) {
const fieldobj = this.init_field(df, render);
this.fields_dict[fieldname].$wrapper.remove();
this.fields_list.splice(this.fields_dict[fieldname], 1, fieldobj);
const prev_fieldobj = this.fields_dict[fieldname];
const fieldobj = this.init_field(df, prev_fieldobj.parent, render);
prev_fieldobj.$wrapper.replaceWith(fieldobj.$wrapper);
const idx = this.fields_list.findIndex((e) => e == prev_fieldobj);
this.fields_list.splice(idx, 1, fieldobj);
this.fields_dict[fieldname] = fieldobj;
this.section.fields_list.splice(this.section.fields_dict[fieldname], 1, fieldobj);
this.section.fields_dict[fieldname] = fieldobj;
this.sections.forEach((section) => section.replace_field(fieldname, fieldobj));
prev_fieldobj.tab?.replace_field(fieldobj);
this.refresh_fields([df]);
}
}
@ -205,7 +207,8 @@ frappe.ui.form.Layout = class Layout {
!this.section && this.make_section();
!this.column && this.make_column();
const fieldobj = this.init_field(df, render);
const parent = this.column.form.get(0);
const fieldobj = this.init_field(df, parent, render);
this.fields_list.push(fieldobj);
this.fields_dict[df.fieldname] = fieldobj;
@ -217,11 +220,11 @@ frappe.ui.form.Layout = class Layout {
}
}
init_field(df, render = false) {
init_field(df, parent, render = false) {
const fieldobj = frappe.ui.form.make_control({
df: df,
doctype: this.doctype,
parent: this.column.form.get(0),
parent: parent,
frm: this.frm,
render_input: render,
doc: this.doc,

View file

@ -82,6 +82,16 @@ export default class Section {
}
}
replace_field(fieldname, fieldobj) {
if (this.fields_dict[fieldname]?.df) {
const olfldobj = this.fields_dict[fieldname];
const idx = this.fields_list.findIndex((e) => e == olfldobj);
this.fields_list.splice(idx, 1, fieldobj);
this.fields_dict[fieldname] = fieldobj;
fieldobj.section = this;
}
}
add_field(fieldobj) {
this.fields_list.push(fieldobj);
this.fields_dict[fieldobj.df.fieldname] = fieldobj;

View file

@ -76,6 +76,9 @@ export default class Tab {
add_field(fieldobj) {
fieldobj.tab = this;
}
replace_field(fieldobj) {
fieldobj.tab = this;
}
set_active() {
this.tab_link.find(".nav-link").tab("show");