fix: handle columns in side panel layout editor
This commit is contained in:
parent
37f357ac08
commit
ca487d5676
@ -34,6 +34,8 @@ def get_fields_layout(doctype: str, type: str):
|
|||||||
allowed_fields = []
|
allowed_fields = []
|
||||||
for tab in tabs:
|
for tab in tabs:
|
||||||
for section in tab.get("sections"):
|
for section in tab.get("sections"):
|
||||||
|
if "columns" not in section:
|
||||||
|
continue
|
||||||
for column in section.get("columns"):
|
for column in section.get("columns"):
|
||||||
if not column.get("fields"):
|
if not column.get("fields"):
|
||||||
continue
|
continue
|
||||||
|
|||||||
@ -129,6 +129,7 @@ function saveChanges() {
|
|||||||
let _tabs = JSON.parse(JSON.stringify(tabs.data))
|
let _tabs = JSON.parse(JSON.stringify(tabs.data))
|
||||||
_tabs.forEach((tab) => {
|
_tabs.forEach((tab) => {
|
||||||
tab.sections.forEach((section) => {
|
tab.sections.forEach((section) => {
|
||||||
|
if (!section.columns) return
|
||||||
section.columns.forEach((column) => {
|
section.columns.forEach((column) => {
|
||||||
if (!column.fields) return
|
if (!column.fields) return
|
||||||
column.fields = column.fields
|
column.fields = column.fields
|
||||||
|
|||||||
@ -54,7 +54,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-show="section.opened">
|
<div v-show="section.opened">
|
||||||
<Draggable
|
<Draggable
|
||||||
:list="section.fields"
|
:list="section.columns?.[0].fields || []"
|
||||||
group="fields"
|
group="fields"
|
||||||
item-key="label"
|
item-key="label"
|
||||||
class="flex flex-col gap-1.5"
|
class="flex flex-col gap-1.5"
|
||||||
@ -73,7 +73,10 @@
|
|||||||
icon="x"
|
icon="x"
|
||||||
class="!size-4 rounded-sm"
|
class="!size-4 rounded-sm"
|
||||||
@click="
|
@click="
|
||||||
section.fields.splice(section.fields.indexOf(field), 1)
|
section.columns[0].fields.splice(
|
||||||
|
section.columns[0].fields.indexOf(field),
|
||||||
|
1,
|
||||||
|
)
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -124,7 +127,11 @@
|
|||||||
variant="subtle"
|
variant="subtle"
|
||||||
:label="__('Add Section')"
|
:label="__('Add Section')"
|
||||||
@click="
|
@click="
|
||||||
sections.push({ label: __('New Section'), opened: true, fields: [] })
|
sections.push({
|
||||||
|
label: __('New Section'),
|
||||||
|
opened: true,
|
||||||
|
columns: [{ fields: [] }],
|
||||||
|
})
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
@ -173,7 +180,7 @@ const fields = createResource({
|
|||||||
|
|
||||||
function addField(section, field) {
|
function addField(section, field) {
|
||||||
if (!field) return
|
if (!field) return
|
||||||
section.fields.push(field)
|
section.columns[0].fields.push(field)
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user