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 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
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
{loading}
|
{loading}
|
||||||
{type}
|
{type}
|
||||||
rowCount={10}
|
rowCount={10}
|
||||||
|
allowEditing={false}
|
||||||
bind:hideAutocolumns
|
bind:hideAutocolumns
|
||||||
>
|
>
|
||||||
<ViewFilterButton {view} />
|
<ViewFilterButton {view} />
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue