Fix for inclusion parsing for arrays and options. View table fix to hide edit button
This commit is contained in:
parent
2cbae832c4
commit
98963c1505
|
@ -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
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
{loading}
|
||||
{type}
|
||||
rowCount={10}
|
||||
allowEditing={false}
|
||||
bind:hideAutocolumns
|
||||
>
|
||||
<ViewFilterButton {view} />
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue