Remove cache dependency

This commit is contained in:
Adria Navarro 2024-09-09 16:24:20 +02:00
parent 77be1cd869
commit 26db79d421
1 changed files with 13 additions and 23 deletions

View File

@ -12,7 +12,7 @@
export let columns
export let fromRelationshipField
const { datasource, dispatch, cache, config } = getContext("grid")
const { datasource, dispatch, config } = getContext("grid")
$: canSetRelationshipSchemas = $config.canSetRelationshipSchemas
@ -114,29 +114,19 @@
return { ...c, options }
})
let relationshipPanelColumns = []
async function fetchRelationshipPanelColumns(relationshipField) {
relationshipPanelColumns = []
if (!relationshipField) {
return
}
const table = await cache.actions.getTable(relationshipField.tableId)
relationshipPanelColumns = Object.entries(
$: relationshipPanelColumns = Object.entries(
relationshipField?.columns || {}
).map(([name, column]) => {
return {
name: name,
label: name,
schema: {
type: table.schema[name].type,
type: column.type,
visible: column.visible,
readonly: column.readonly,
},
}
})
}
$: fetchRelationshipPanelColumns(relationshipField)
async function toggleColumn(column, permission) {
const visible = permission !== FieldPermissions.HIDDEN