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()
}
}