1
0
Fork 0
mirror of synced 2024-07-30 02:26:11 +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 disableSorting = false
export let customPlaceholder = false
export let allowEditing = true
const dispatch = createEventDispatcher()
@ -109,6 +110,7 @@
{rowCount}
{disableSorting}
{customPlaceholder}
allowEditRows={allowEditing}
showAutoColumns={!hideAutocolumns}
on:clickrelationship={e => selectRelationship(e.detail)}
on:sort

View file

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

View file

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