chore(table): simplify logic

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-04-09 12:37:11 +05:30
parent 0832f3b01d
commit 13aed45308
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F

View file

@ -46,12 +46,8 @@ frappe.ui.form.ControlTable = class ControlTable extends frappe.ui.form.Control
if (this.get_field(data[0][0])) {
data[0].forEach((column) => {
fieldnames.push(this.get_field(column));
var df = frappe.meta.get_docfield(doctype, this.get_field(column));
if (df) {
fieldtypes.push(df.fieldtype);
} else {
fieldtypes.push("");
}
const df = frappe.meta.get_docfield(doctype, this.get_field(column));
fieldtypes.push(df ? df.fieldtype : "");
});
data.shift();
} else {
@ -65,12 +61,8 @@ frappe.ui.form.ControlTable = class ControlTable extends frappe.ui.form.Control
column.fieldname === $(e.target).data("fieldname")
) {
fieldnames.push(column.fieldname);
var df = frappe.meta.get_docfield(doctype, column.fieldname);
if (df) {
fieldtypes.push(df.fieldtype);
} else {
fieldtypes.push("");
}
const df = frappe.meta.get_docfield(doctype, column.fieldname);
fieldtypes.push(df ? df.fieldtype : "");
target_column_matched = true;
}
});