fix: allow adding table field & dont show already added field in field layout editor
This commit is contained in:
parent
e32f187be0
commit
11fec38acd
@ -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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user