fix: do not allow to move the custom tab/section/column if it has standard field inside
This commit is contained in:
parent
9d3840856f
commit
601062e7fd
3 changed files with 29 additions and 8 deletions
|
|
@ -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)"
|
||||
/>
|
||||
</template>
|
||||
</draggable>
|
||||
|
|
@ -181,7 +182,7 @@ function remove_section() {
|
|||
|
||||
.section-columns-container {
|
||||
display: flex;
|
||||
min-height: 4rem;
|
||||
min-height: 2rem;
|
||||
border-radius: var(--border-radius);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)"
|
||||
/>
|
||||
</template>
|
||||
</draggable>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue