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