From 16d49c4b9df6dbb536226d6d67a9b55a4f9591a4 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Tue, 31 Dec 2024 19:32:51 +0530 Subject: [PATCH] fix: render tabs, sections & columns --- .../crm_fields_layout/crm_fields_layout.json | 4 +- .../crm_fields_layout/crm_fields_layout.py | 36 +- frontend/src/components/FieldLayout.vue | 390 ++++++++++-------- 3 files changed, 229 insertions(+), 201 deletions(-) diff --git a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.json b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.json index 7094e58d..ef784e79 100644 --- a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.json +++ b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.json @@ -37,7 +37,7 @@ "fieldname": "layout", "fieldtype": "Code", "label": "Layout", - "options": "JS" + "options": "JSON" }, { "fieldname": "column_break_post", @@ -46,7 +46,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2024-12-29 12:58:54.280569", + "modified": "2024-12-31 19:06:24.679782", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Fields Layout", diff --git a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py index 23552e5c..bdd41568 100644 --- a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py +++ b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py @@ -34,29 +34,31 @@ def get_fields_layout(doctype: str, type: str): allowed_fields = [] for tab in tabs: for section in tab.get("sections"): - if not section.get("fields"): - continue - allowed_fields.extend(section.get("fields")) + for column in section.get("columns"): + if not column.get("fields"): + continue + allowed_fields.extend(column.get("fields")) fields = frappe.get_meta(doctype).fields fields = [field for field in fields if field.fieldname in allowed_fields] for tab in tabs: for section in tab.get("sections"): - for field in section.get("fields") if section.get("fields") else []: - field = next((f for f in fields if f.fieldname == field), None) - if field: - field = { - "label": _(field.label), - "name": field.fieldname, - "type": field.fieldtype, - "options": getOptions(field), - "mandatory": field.reqd, - "read_only": field.read_only, - "placeholder": field.get("placeholder"), - "filters": field.get("link_filters"), - } - section["fields"][section.get("fields").index(field["name"])] = field + for column in section.get("columns") if section.get("columns") else []: + for field in column.get("fields") if column.get("fields") else []: + field = next((f for f in fields if f.fieldname == field), None) + if field: + field = { + "label": _(field.label), + "name": field.fieldname, + "type": field.fieldtype, + "options": getOptions(field), + "mandatory": field.reqd, + "read_only": field.read_only, + "placeholder": field.get("placeholder"), + "filters": field.get("link_filters"), + } + column["fields"][column.get("fields").index(field["name"])] = field return tabs or [] diff --git a/frontend/src/components/FieldLayout.vue b/frontend/src/components/FieldLayout.vue index fa75b303..2da46961 100644 --- a/frontend/src/components/FieldLayout.vue +++ b/frontend/src/components/FieldLayout.vue @@ -36,196 +36,213 @@ collapseIconPosition="right" >
-
-
-
- {{ __(field.label) }} - * -
- - - - - -
- -
@@ -272,14 +289,23 @@ const hasTabs = computed(() => !props.tabs[0].no_tabs) const _tabs = computed(() => { return props.tabs.map((tab) => { tab.sections = tab.sections.map((section) => { - section.fields = section.fields.filter( - (field) => - (field.type == 'Check' || - (field.read_only && props.data[field.name]) || - !field.read_only) && - (!field.depends_on || field.display_via_depends_on) && - !field.hidden, - ) + section.columns = section.columns.map((column) => { + column.fields = column.fields.map((field) => { + if (field.type == 'Link' && field.options == 'User') { + field.type = 'User' + } + if ( + (field.type == 'Check' || + (field.read_only && props.data[field.name]) || + !field.read_only) && + (!field.depends_on || field.display_via_depends_on) && + !field.hidden + ) { + return field + } + }) + return column + }) return section }) return tab