feat: support reordering standard fields in Form Builder (#21297)

This commit is contained in:
Sagar Vora 2023-06-09 12:19:30 +05:30 committed by GitHub
parent 5fbdce888d
commit 345da6e314
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 18 deletions

View file

@ -166,8 +166,7 @@ onMounted(() => {
}
}
:deep([data-has-std-field="false"]),
:deep([data-is-custom="1"]) {
:deep([data-is-user-generated="1"]) {
background-color: var(--yellow-highlight-color);
}
}
@ -175,7 +174,7 @@ onMounted(() => {
:deep(.preview) {
--field-placeholder-color: var(--fg-bg-color);
.tab, .column, .field, [data-is-custom="1"] {
.tab, .column, .field {
background-color: var(--fg-color);
}

View file

@ -148,8 +148,6 @@ function move_columns_to_section() {
:style="{ backgroundColor: column.fields.length ? '' : 'var(--field-placeholder-color)' }"
v-model="column.fields"
group="fields"
filter="[data-is-custom='0']"
:prevent-on-filter="false"
:animation="200"
:easing="store.get_animation"
item-key="id"
@ -159,7 +157,7 @@ function move_columns_to_section() {
<Field
:column="column"
:field="element"
:data-is-custom="element.df.is_custom_field"
:data-is-user-generated="store.is_user_generated_field(element)"
/>
</template>
</draggable>

View file

@ -160,8 +160,6 @@ function move_sections_to_tab() {
backgroundColor: section.columns.length ? null : 'var(--field-placeholder-color)'
}"
v-model="section.columns"
filter="[data-has-std-field='true']"
:prevent-on-filter="false"
group="columns"
item-key="id"
:animation="200"
@ -172,8 +170,7 @@ function move_sections_to_tab() {
<Column
:section="section"
:column="element"
:data-is-custom="element.df.is_custom_field"
:data-has-std-field="store.has_standard_field(element)"
:data-is-user-generated="store.is_user_generated_field(element)"
/>
</template>
</draggable>

View file

@ -114,8 +114,6 @@ function delete_tab(with_children) {
class="tabs"
v-model="store.form.layout.tabs"
group="tabs"
filter="[data-has-std-field='true']"
:prevent-on-filter="false"
:animation="200"
:easing="store.get_animation"
item-key="id"
@ -125,8 +123,7 @@ function delete_tab(with_children) {
<div
:class="['tab', store.form.active_tab == element.df.name ? 'active' : '']"
:title="element.df.fieldname"
:data-is-custom="element.df.is_custom_field"
:data-has-std-field="store.has_standard_field(element)"
:data-is-user-generated="store.is_user_generated_field(element)"
@click.stop="activate_tab(element)"
@dragstart="dragged = true"
@dragend="dragged = false"
@ -174,8 +171,6 @@ function delete_tab(with_children) {
class="tab-content-container"
v-model="tab.sections"
group="sections"
filter="[data-has-std-field='true']"
:prevent-on-filter="false"
:animation="200"
:easing="store.get_animation"
item-key="id"
@ -185,8 +180,7 @@ function delete_tab(with_children) {
<Section
:tab="tab"
:section="element"
:data-is-custom="element.df.is_custom_field"
:data-has-std-field="store.has_standard_field(element)"
:data-is-user-generated="store.is_user_generated_field(element)"
/>
</template>
</draggable>

View file

@ -64,6 +64,10 @@ export const useStore = defineStore("form-builder-store", () => {
});
}
function is_user_generated_field(field) {
return cint(field.df.is_custom_field && !field.df.is_system_generated);
}
async function fetch() {
await frappe.model.clear_doc("DocType", doctype.value);
await frappe.model.with_doctype(doctype.value);
@ -320,6 +324,7 @@ export const useStore = defineStore("form-builder-store", () => {
selected,
get_df,
has_standard_field,
is_user_generated_field,
fetch,
reset_changes,
validate_fields,