1
0
forked from test/crm

fix: allow adding table field & dont show already added field in field layout editor

This commit is contained in:
Shariq Ansari 2024-12-23 19:50:20 +05:30
parent e32f187be0
commit 11fec38acd

View File

@ -209,7 +209,6 @@ const props = defineProps({
const tabIndex = ref(0) const tabIndex = ref(0)
const restrictedFieldTypes = [ const restrictedFieldTypes = [
'Table',
'Geolocation', 'Geolocation',
'Attach', 'Attach',
'Attach Image', 'Attach Image',
@ -230,6 +229,34 @@ const fields = createResource({
params: params.value, params: params.value,
cache: ['fieldsMeta', props.doctype], cache: ['fieldsMeta', props.doctype],
auto: true, auto: true,
transform: (data) => {
let restrictedFields = [
'name',
'owner',
'creation',
'modified',
'modified_by',
'docstatus',
'_comments',
'_user_tags',
'_assign',
'_liked_by',
]
let existingFields = []
for (let tab of props.tabs) {
for (let section of tab.sections) {
existingFields = existingFields.concat(section.fields)
}
}
return data.filter((field) => {
return (
!existingFields.find((f) => f.name === field.fieldname) &&
!restrictedFields.includes(field.fieldname)
)
})
},
}) })
function addTab() { function addTab() {
@ -243,7 +270,12 @@ function addTab() {
function addField(section, field) { function addField(section, field) {
if (!field) return if (!field) return
section.fields.push(field) let newFieldObj = {
...field,
name: field.fieldname,
type: field.fieldtype,
}
section.fields.push(newFieldObj)
} }
function getTabOptions(tab) { function getTabOptions(tab) {