1
0
Fork 0
mirror of synced 2024-09-08 13:41:09 +12:00

Merge pull request #10672 from Budibase/fix/grid-schema-updates

Fix issue with schema mutation in grids
This commit is contained in:
Andrew Kingston 2023-05-24 08:44:03 +01:00 committed by GitHub
commit 0c2ffd0030
3 changed files with 23 additions and 9 deletions

View file

@ -16,11 +16,11 @@
import GridEditColumnModal from "components/backend/DataTable/modals/grid/GridEditColumnModal.svelte"
const userSchemaOverrides = {
firstName: { name: "First name", disabled: true },
lastName: { name: "Last name", disabled: true },
email: { name: "Email", disabled: true },
roleId: { name: "Role", disabled: true },
status: { name: "Status", disabled: true },
firstName: { displayName: "First name", disabled: true },
lastName: { displayName: "Last name", disabled: true },
email: { displayName: "Email", disabled: true },
roleId: { displayName: "Role", disabled: true },
status: { displayName: "Status", disabled: true },
}
$: id = $tables.selected?._id

View file

@ -52,7 +52,7 @@
{:else}
<div class="text-cell" class:number={type === "number"}>
<div class="value">
{value || ""}
{value ?? ""}
</div>
</div>
{/if}

View file

@ -116,10 +116,24 @@ export const initialise = context => {
const schema = derived(
[table, schemaOverrides],
([$table, $schemaOverrides]) => {
let newSchema = $table?.schema
if (!newSchema) {
if (!$table?.schema) {
return null
}
let newSchema = { ...$table?.schema }
// Edge case to temporarily allow deletion of duplicated user
// fields that were saved with the "disabled" flag set.
// By overriding the saved schema we ensure only overrides can
// set the disabled flag.
// TODO: remove in future
Object.keys(newSchema).forEach(field => {
newSchema[field] = {
...newSchema[field],
disabled: false,
}
})
// Apply schema overrides
Object.keys($schemaOverrides || {}).forEach(field => {
if (newSchema[field]) {
newSchema[field] = {
@ -160,7 +174,7 @@ export const initialise = context => {
fields
.map(field => ({
name: field,
label: $schema[field].name || field,
label: $schema[field].displayName || field,
schema: $schema[field],
width: $schema[field].width || DefaultColumnWidth,
visible: $schema[field].visible ?? true,