Tidy
This commit is contained in:
parent
a63d193a3c
commit
6301b9de4c
|
@ -115,35 +115,31 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
let relationshipPanelColumns = []
|
let relationshipPanelColumns = []
|
||||||
$: {
|
async function fetchRelationshipPanelColumns(relationshipField) {
|
||||||
relationshipPanelColumns = []
|
relationshipPanelColumns = []
|
||||||
if (relationshipField) {
|
if (!relationshipField) {
|
||||||
cache.actions.getTable(relationshipField.tableId).then(table => {
|
return
|
||||||
relationshipPanelColumns = Object.entries(
|
|
||||||
relationshipField?.schema || {}
|
|
||||||
)
|
|
||||||
.map(([name, column]) => {
|
|
||||||
return {
|
|
||||||
name: name,
|
|
||||||
label: name,
|
|
||||||
primaryDisplay: name === table.primaryDisplay,
|
|
||||||
schema: {
|
|
||||||
type: table.schema[name].type,
|
|
||||||
visible: column.visible,
|
|
||||||
readonly: column.readonly,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.sort((a, b) =>
|
|
||||||
a.primaryDisplay === b.primaryDisplay
|
|
||||||
? 0
|
|
||||||
: a.primaryDisplay
|
|
||||||
? -1
|
|
||||||
: 1
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const table = await cache.actions.getTable(relationshipField.tableId)
|
||||||
|
relationshipPanelColumns = Object.entries(relationshipField?.schema || {})
|
||||||
|
.map(([name, column]) => {
|
||||||
|
return {
|
||||||
|
name: name,
|
||||||
|
label: name,
|
||||||
|
primaryDisplay: name === table.primaryDisplay,
|
||||||
|
schema: {
|
||||||
|
type: table.schema[name].type,
|
||||||
|
visible: column.visible,
|
||||||
|
readonly: column.readonly,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.sort((a, b) =>
|
||||||
|
a.primaryDisplay === b.primaryDisplay ? 0 : a.primaryDisplay ? -1 : 1
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
$: fetchRelationshipPanelColumns(relationshipField)
|
||||||
|
|
||||||
async function toggleColumn(column, permission) {
|
async function toggleColumn(column, permission) {
|
||||||
const visible = permission !== FieldPermissions.HIDDEN
|
const visible = permission !== FieldPermissions.HIDDEN
|
||||||
|
@ -217,7 +213,7 @@
|
||||||
{#if allowRelationshipSchemas}
|
{#if allowRelationshipSchemas}
|
||||||
<Popover
|
<Popover
|
||||||
on:close={() => (relationshipFieldName = null)}
|
on:close={() => (relationshipFieldName = null)}
|
||||||
open={!!relationshipPanelColumns}
|
open={!!relationshipField}
|
||||||
anchor={relationshipPanelAnchor}
|
anchor={relationshipPanelAnchor}
|
||||||
align="right-outside"
|
align="right-outside"
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in New Issue