fix: get default field layout is not exist not returning options properly
This commit is contained in:
parent
4432e1b582
commit
3c7454d5c7
@ -46,15 +46,11 @@ def get_fields_layout(doctype: str, type: str):
|
||||
for field in section.get("fields") if section.get("fields") else []:
|
||||
field = next((f for f in fields if f.fieldname == field), None)
|
||||
if field:
|
||||
if field.fieldtype == "Select" and field.options:
|
||||
field.options = field.options.split("\n")
|
||||
field.options = [{"label": _(option), "value": option} for option in field.options]
|
||||
field.options.insert(0, {"label": "", "value": ""})
|
||||
field = {
|
||||
"label": _(field.label),
|
||||
"name": field.fieldname,
|
||||
"type": field.fieldtype,
|
||||
"options": field.options,
|
||||
"options": getOptions(field),
|
||||
"mandatory": field.reqd,
|
||||
"placeholder": field.get("placeholder"),
|
||||
"filters": field.get("link_filters"),
|
||||
@ -86,17 +82,17 @@ def save_fields_layout(doctype: str, type: str, layout: str):
|
||||
def get_default_layout(doctype: str):
|
||||
fields = frappe.get_meta(doctype).fields
|
||||
fields = [
|
||||
{
|
||||
"label": _(field.label),
|
||||
"name": field.fieldname,
|
||||
"type": field.fieldtype,
|
||||
"options": field.options,
|
||||
"mandatory": field.reqd,
|
||||
"placeholder": field.get("placeholder"),
|
||||
"filters": field.get("link_filters"),
|
||||
}
|
||||
field.fieldname
|
||||
for field in fields
|
||||
if field.fieldtype not in ["Section Break", "Column Break"]
|
||||
if field.fieldtype not in ["Tab Break", "Section Break", "Column Break"]
|
||||
]
|
||||
|
||||
return [{"no_tabs": True, "sections": [{"hideLabel": True, "fields": fields}]}]
|
||||
|
||||
|
||||
def getOptions(field):
|
||||
if field.fieldtype == "Select" and field.options:
|
||||
field.options = field.options.split("\n")
|
||||
field.options = [{"label": _(option), "value": option} for option in field.options]
|
||||
field.options.insert(0, {"label": "", "value": ""})
|
||||
return field.options
|
||||
|
||||
@ -33,7 +33,6 @@
|
||||
<script setup>
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import FieldLayout from '@/components/FieldLayout.vue'
|
||||
import { getMeta } from '@/stores/meta'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import { createResource } from 'frappe-ui'
|
||||
import { nextTick } from 'vue'
|
||||
@ -44,7 +43,6 @@ const props = defineProps({
|
||||
doctype: String,
|
||||
})
|
||||
|
||||
const { getFields } = getMeta(props.doctype)
|
||||
const { isManager } = usersStore()
|
||||
|
||||
const show = defineModel()
|
||||
@ -52,28 +50,9 @@ const showGridRowFieldsModal = defineModel('showGridRowFieldsModal')
|
||||
|
||||
const tabs = createResource({
|
||||
url: 'crm.fcrm.doctype.crm_fields_layout.crm_fields_layout.get_fields_layout',
|
||||
cache: ['GridRow', props.doctype],
|
||||
cache: ['Grid Row', props.doctype],
|
||||
params: { doctype: props.doctype, type: 'Grid Row' },
|
||||
auto: true,
|
||||
transform: (data) => {
|
||||
if (data.length) return data
|
||||
let fields = getFields()
|
||||
if (!fields) return []
|
||||
return [
|
||||
{
|
||||
no_tabs: true,
|
||||
sections: [
|
||||
{
|
||||
hideLabel: true,
|
||||
opened: true,
|
||||
fields: fields.map((f) => {
|
||||
return { ...f, name: f.fieldname, type: f.fieldtype }
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
function openGridRowFieldsModal() {
|
||||
|
||||
@ -79,7 +79,6 @@
|
||||
<Grid
|
||||
v-else-if="field.type === 'Table'"
|
||||
v-model="data[field.name]"
|
||||
:fields="field.fields"
|
||||
:doctype="field.options"
|
||||
:parentDoctype="doctype"
|
||||
/>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user