Fix grid config store so that schema overrides work
This commit is contained in:
parent
c7d1010ce3
commit
c936304410
|
@ -57,8 +57,8 @@
|
||||||
<Grid
|
<Grid
|
||||||
{API}
|
{API}
|
||||||
datasource={gridDatasource}
|
datasource={gridDatasource}
|
||||||
allowAddRows={!isUsersTable}
|
canAddRows={!isUsersTable}
|
||||||
allowDeleteRows={!isUsersTable}
|
canDeleteRows={!isUsersTable}
|
||||||
schemaOverrides={isUsersTable ? userSchemaOverrides : null}
|
schemaOverrides={isUsersTable ? userSchemaOverrides : null}
|
||||||
showAvatars={false}
|
showAvatars={false}
|
||||||
on:updatedatasource={handleGridTableUpdate}
|
on:updatedatasource={handleGridTableUpdate}
|
||||||
|
|
|
@ -196,7 +196,6 @@
|
||||||
icon="Label"
|
icon="Label"
|
||||||
on:click={makeDisplayColumn}
|
on:click={makeDisplayColumn}
|
||||||
disabled={idx === "sticky" ||
|
disabled={idx === "sticky" ||
|
||||||
!$config.canEditPrimaryDisplay ||
|
|
||||||
bannedDisplayColumnTypes.includes(column.schema.type)}
|
bannedDisplayColumnTypes.includes(column.schema.type)}
|
||||||
>
|
>
|
||||||
Use as display column
|
Use as display column
|
||||||
|
|
|
@ -80,9 +80,6 @@ export const createActions = context => {
|
||||||
|
|
||||||
// Updates the datasources primary display column
|
// Updates the datasources primary display column
|
||||||
const changePrimaryDisplay = async column => {
|
const changePrimaryDisplay = async column => {
|
||||||
if (!get(config).canEditPrimaryDisplay) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return await datasource.actions.saveDefinition({
|
return await datasource.actions.saveDefinition({
|
||||||
...get(definition),
|
...get(definition),
|
||||||
primaryDisplay: column,
|
primaryDisplay: column,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { derivedMemo } from "../../../utils"
|
import { derivedMemo } from "../../../utils"
|
||||||
import { derived } from "svelte/store"
|
import { derived } from "svelte/store"
|
||||||
|
|
||||||
export const deriveStores = context => {
|
export const createStores = context => {
|
||||||
const { props, hasNonAutoColumn } = context
|
const { props } = context
|
||||||
const getProp = prop => derivedMemo(props, $props => $props[prop])
|
const getProp = prop => derivedMemo(props, $props => $props[prop])
|
||||||
|
|
||||||
// Derive and memoize some props so that we can react to them in isolation
|
// Derive and memoize some props so that we can react to them in isolation
|
||||||
|
@ -16,16 +16,27 @@ export const deriveStores = context => {
|
||||||
const notifySuccess = getProp("notifySuccess")
|
const notifySuccess = getProp("notifySuccess")
|
||||||
const notifyError = getProp("notifyError")
|
const notifyError = getProp("notifyError")
|
||||||
|
|
||||||
|
return {
|
||||||
|
datasource,
|
||||||
|
initialSortColumn,
|
||||||
|
initialSortOrder,
|
||||||
|
initialFilter,
|
||||||
|
fixedRowHeight,
|
||||||
|
schemaOverrides,
|
||||||
|
columnWhitelist,
|
||||||
|
notifySuccess,
|
||||||
|
notifyError,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const deriveStores = context => {
|
||||||
|
const { props, hasNonAutoColumn } = context
|
||||||
|
|
||||||
// Derive features
|
// Derive features
|
||||||
const config = derived(
|
const config = derived(
|
||||||
[props, hasNonAutoColumn],
|
[props, hasNonAutoColumn],
|
||||||
([$props, $hasNonAutoColumn]) => {
|
([$props, $hasNonAutoColumn]) => {
|
||||||
let config = {
|
let config = { ...$props }
|
||||||
...$props,
|
|
||||||
|
|
||||||
// Additional granular features which we don't expose as props
|
|
||||||
canEditPrimaryDisplay: $props.canEditColumns,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disable some features if we're editing a view
|
// Disable some features if we're editing a view
|
||||||
if ($props.datasource?.type === "viewV2") {
|
if ($props.datasource?.type === "viewV2") {
|
||||||
|
@ -43,14 +54,5 @@ export const deriveStores = context => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
config,
|
config,
|
||||||
datasource,
|
|
||||||
initialSortColumn,
|
|
||||||
initialSortOrder,
|
|
||||||
initialFilter,
|
|
||||||
fixedRowHeight,
|
|
||||||
schemaOverrides,
|
|
||||||
columnWhitelist,
|
|
||||||
notifySuccess,
|
|
||||||
notifyError,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue