1
0
Fork 0
mirror of synced 2024-09-08 21:51:58 +12:00

Fix for inclusion parsing for arrays and options. View table fix to hide edit button

This commit is contained in:
Dean 2023-05-04 11:21:24 +01:00
parent 2cbae832c4
commit 98963c1505
3 changed files with 13 additions and 6 deletions

View file

@ -22,6 +22,7 @@
export let rowCount export let rowCount
export let disableSorting = false export let disableSorting = false
export let customPlaceholder = false export let customPlaceholder = false
export let allowEditing = true
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
@ -109,6 +110,7 @@
{rowCount} {rowCount}
{disableSorting} {disableSorting}
{customPlaceholder} {customPlaceholder}
allowEditRows={allowEditing}
showAutoColumns={!hideAutocolumns} showAutoColumns={!hideAutocolumns}
on:clickrelationship={e => selectRelationship(e.detail)} on:clickrelationship={e => selectRelationship(e.detail)}
on:sort on:sort

View file

@ -58,6 +58,7 @@
{loading} {loading}
{type} {type}
rowCount={10} rowCount={10}
allowEditing={false}
bind:hideAutocolumns bind:hideAutocolumns
> >
<ViewFilterButton {view} /> <ViewFilterButton {view} />

View file

@ -129,17 +129,21 @@ export function importToRows(
// the real schema of the table passed in, not the clone used for // the real schema of the table passed in, not the clone used for
// incrementing auto IDs // incrementing auto IDs
for (const [fieldName, schema] of Object.entries(originalTable.schema)) { for (const [fieldName, schema] of Object.entries(originalTable.schema)) {
const rowVal = Array.isArray(row[fieldName]) ? row[fieldName] : [row[fieldName]]
if ( if (
(schema.type === FieldTypes.OPTIONS || (schema.type === FieldTypes.OPTIONS ||
schema.type === FieldTypes.ARRAY) && schema.type === FieldTypes.ARRAY) &&
row[fieldName] && row[fieldName]
(!schema.constraints!.inclusion ||
schema.constraints!.inclusion.indexOf(row[fieldName]) === -1)
) { ) {
schema.constraints!.inclusion = [
let merged = [
...schema.constraints!.inclusion!, ...schema.constraints!.inclusion!,
row[fieldName], ...rowVal
] ]
let superSet = new Set(merged);
schema.constraints!.inclusion = Array.from(superSet);
schema.constraints!.inclusion.sort() schema.constraints!.inclusion.sort()
} }
} }