Merge pull request #10672 from Budibase/fix/grid-schema-updates
Fix issue with schema mutation in grids
This commit is contained in:
commit
0c2ffd0030
|
@ -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
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
{:else}
|
||||
<div class="text-cell" class:number={type === "number"}>
|
||||
<div class="value">
|
||||
{value || ""}
|
||||
{value ?? ""}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue