Update grid flags to allow readonly modifications of schema

This commit is contained in:
Andrew Kingston 2023-06-08 08:35:36 +01:00
parent f9a8be507d
commit 5820996e4d
6 changed files with 12 additions and 14 deletions

View File

@ -21,9 +21,8 @@
{allowEditRows}
{allowDeleteRows}
showControls={false}
allowAddColumns={false}
allowEditColumns={false}
allowExpandRows={false}
allowSchemaChanges={false}
/>
</div>

View File

@ -163,7 +163,7 @@
<MenuItem
icon="Edit"
on:click={editColumn}
disabled={!$config.allowEditColumns || column.schema.disabled}
disabled={!$config.allowSchemaChanges || column.schema.disabled}
>
Edit column
</MenuItem>
@ -171,7 +171,7 @@
icon="Label"
on:click={makeDisplayColumn}
disabled={idx === "sticky" ||
!$config.allowEditColumns ||
!$config.allowSchemaChanges ||
bannedDisplayColumnTypes.includes(column.schema.type)}
>
Use as display column

View File

@ -10,7 +10,7 @@
quiet
size="M"
on:click={() => dispatch("add-column")}
disabled={!$config.allowAddColumns}
disabled={!$config.allowSchemaChanges}
>
Add column
</ActionButton>

View File

@ -35,11 +35,10 @@
export let tableId = null
export let schemaOverrides = null
export let allowAddRows = true
export let allowAddColumns = true
export let allowEditColumns = true
export let allowExpandRows = true
export let allowEditRows = true
export let allowDeleteRows = true
export let allowSchemaChanges = true
export let stripeRows = false
export let collaboration = true
export let showAvatars = true
@ -53,8 +52,7 @@
const schemaOverridesStore = writable(schemaOverrides)
const config = writable({
allowAddRows,
allowAddColumns,
allowEditColumns,
allowSchemaChanges,
allowExpandRows,
allowEditRows,
allowDeleteRows,
@ -88,8 +86,7 @@
$: schemaOverridesStore.set(schemaOverrides)
$: config.set({
allowAddRows,
allowAddColumns,
allowEditColumns,
allowSchemaChanges,
allowExpandRows,
allowEditRows,
allowDeleteRows,

View File

@ -29,7 +29,7 @@
{/each}
</div>
</GridScrollWrapper>
{#if $config.allowAddColumns}
{#if $config.allowSchemaChanges}
<div
class="add"
style="left:{left}px"

View File

@ -46,7 +46,7 @@ export const createStores = () => {
}
export const deriveStores = context => {
const { table, columns, stickyColumn, API, dispatch } = context
const { table, columns, stickyColumn, API, dispatch, config } = context
// Updates the tables primary display column
const changePrimaryDisplay = async column => {
@ -95,7 +95,9 @@ export const deriveStores = context => {
dispatch("updatetable", newTable)
// Update server
await API.saveTable(newTable)
if (get(config).allowSchemaChanges) {
await API.saveTable(newTable)
}
}
return {