Ensure grid metadata is saved when creating views, even if not yet associated with the table
This commit is contained in:
parent
37158ea387
commit
c2b6a7d016
|
@ -11,6 +11,18 @@
|
||||||
$: views = Object.keys($definition?.views || {})
|
$: views = Object.keys($definition?.views || {})
|
||||||
$: nameExists = views.includes(name?.trim())
|
$: nameExists = views.includes(name?.trim())
|
||||||
|
|
||||||
|
const enrichSchema = schema => {
|
||||||
|
// We need to sure that "visible" is set to true for any fields which have
|
||||||
|
// not yet been saved with grid metadata attached
|
||||||
|
const cloned = { ...schema }
|
||||||
|
Object.entries(cloned).forEach(([field, fieldSchema]) => {
|
||||||
|
if (fieldSchema.visible == null) {
|
||||||
|
cloned[field] = { ...cloned[field], visible: true }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return cloned
|
||||||
|
}
|
||||||
|
|
||||||
const saveView = async () => {
|
const saveView = async () => {
|
||||||
name = name?.trim()
|
name = name?.trim()
|
||||||
try {
|
try {
|
||||||
|
@ -22,13 +34,12 @@
|
||||||
field: $sort.column,
|
field: $sort.column,
|
||||||
order: $sort.order,
|
order: $sort.order,
|
||||||
},
|
},
|
||||||
schema: $definition.schema,
|
schema: enrichSchema($definition.schema),
|
||||||
primaryDisplay: $definition.primaryDisplay,
|
primaryDisplay: $definition.primaryDisplay,
|
||||||
})
|
})
|
||||||
notifications.success(`View ${name} created`)
|
notifications.success(`View ${name} created`)
|
||||||
$goto(`../../view/v2/${newView.id}`)
|
$goto(`../../view/v2/${newView.id}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
|
||||||
notifications.error("Error creating view")
|
notifications.error("Error creating view")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue