fix: error if section is removed and saved

This commit is contained in:
Shariq Ansari 2025-05-12 11:18:47 +05:30
parent 89fd754efc
commit 35a27101c1
3 changed files with 13 additions and 11 deletions

View File

@ -27,7 +27,9 @@ def get_fields_layout(doctype: str, type: str, parent_doctype: str | None = None
if not tabs and type != "Required Fields":
tabs = get_default_layout(doctype)
has_tabs = tabs[0].get("sections") if tabs and tabs[0] else False
has_tabs = False
if isinstance(tabs, list) and len(tabs) > 0 and isinstance(tabs[0], dict):
has_tabs = any("sections" in tab for tab in tabs)
if not has_tabs:
tabs = [{"name": "first_tab", "sections": tabs}]

View File

@ -277,13 +277,13 @@ const fields = createResource({
]
let existingFields = []
for (let tab of props.tabs) {
for (let section of tab.sections) {
for (let column of section.columns) {
props.tabs?.forEach((tab) => {
tab.sections?.forEach((section) => {
section.columns?.forEach((column) => {
existingFields = existingFields.concat(column.fields)
}
}
}
})
})
})
return data.filter((field) => {
return (

View File

@ -706,10 +706,10 @@ const dealTabs = createResource({
auto: true,
transform: (_tabs) => {
let hasFields = false
let parsedTabs = _tabs.forEach((tab) => {
tab.sections.forEach((section) => {
section.columns.forEach((column) => {
column.fields.forEach((field) => {
let parsedTabs = _tabs?.forEach((tab) => {
tab.sections?.forEach((section) => {
section.columns?.forEach((column) => {
column.fields?.forEach((field) => {
hasFields = true
if (field.fieldname == 'status') {
field.fieldtype = 'Select'