diff --git a/frappe/public/js/form_builder/components/Section.vue b/frappe/public/js/form_builder/components/Section.vue index 16caf98de5..2ab308ce8d 100644 --- a/frappe/public/js/form_builder/components/Section.vue +++ b/frappe/public/js/form_builder/components/Section.vue @@ -93,7 +93,7 @@ function remove_section() { backgroundColor: section.columns.length ? null : 'var(--gray-50)' }" v-model="section.columns" - filter="[data-is-custom='0']" + filter="[data-has-std-field='true']" group="columns" item-key="id" :disabled="store.read_only" @@ -103,6 +103,7 @@ function remove_section() { :section="section" :column="element" :data-is-custom="store.is_custom(element)" + :data-has-std-field="store.has_standard_field(element)" /> @@ -181,7 +182,7 @@ function remove_section() { .section-columns-container { display: flex; - min-height: 4rem; + min-height: 2rem; border-radius: var(--border-radius); } } diff --git a/frappe/public/js/form_builder/components/Tabs.vue b/frappe/public/js/form_builder/components/Tabs.vue index 25b94949b9..0290da41cd 100644 --- a/frappe/public/js/form_builder/components/Tabs.vue +++ b/frappe/public/js/form_builder/components/Tabs.vue @@ -121,6 +121,7 @@ function remove_tab() { :class="['tab', store.active_tab == element.df.name ? 'active' : '']" :title="element.df.fieldname" :data-is-custom="store.is_custom(element)" + :data-has-std-field="store.has_standard_field(element)" @click.stop="activate_tab(element)" @dragstart="dragged = true" @dragend="dragged = false" @@ -165,7 +166,7 @@ function remove_tab() { class="tab-content-container" v-model="tab.sections" group="sections" - filter="[data-is-custom='0']" + filter="[data-has-std-field='true']" :animation="200" item-key="id" :disabled="store.read_only" @@ -175,6 +176,7 @@ function remove_tab() { :tab="tab" :section="element" :data-is-custom="store.is_custom(element)" + :data-has-std-field="store.has_standard_field(element)" /> diff --git a/frappe/public/js/form_builder/store.js b/frappe/public/js/form_builder/store.js index 4ac52b474f..ac45b85a6c 100644 --- a/frappe/public/js/form_builder/store.js +++ b/frappe/public/js/form_builder/store.js @@ -41,6 +41,25 @@ export const useStore = defineStore("store", { return field.df.is_custom_field; }; }, + has_standard_field: (state) => { + return (field) => { + if (!state.is_customize_form) return; + if (!field.df.is_custom_field) return true; + + let children = { + "Tab Break": "sections", + "Section Break": "columns", + "Column Break": "fields", + }[field.df.fieldtype]; + + if (!children) return false; + + return field[children].some((child) => { + if (!child.df.is_custom_field) return true; + return state.has_standard_field(child); + }); + }; + }, }, actions: { async fetch() { @@ -70,17 +89,16 @@ export const useStore = defineStore("store", { this.layout = this.get_layout(); this.active_tab = this.layout.tabs[0].df.name; + this.selected_field = null; + nextTick(() => { this.dirty = false; this.read_only = !this.is_customize_form && !frappe.boot.developer_mode && !this.doc.custom; }); }, - async reset_changes() { - await this.fetch(); - let first_tab = this.layout.tabs[0]; - this.active_tab = first_tab.df.name; - this.selected_field = null; + reset_changes() { + this.fetch(); }, async save_changes() { if (!this.dirty) {