copy table schema and dont mutate directly

This commit is contained in:
Peter Clement 2021-10-18 14:53:57 +01:00
parent 2eccb159c0
commit b41287630a
1 changed files with 5 additions and 4 deletions

View File

@ -16,22 +16,23 @@
import { Pagination } from "@budibase/bbui" import { Pagination } from "@budibase/bbui"
let hideAutocolumns = true let hideAutocolumns = true
let copiedSchema
let schema let schema
$: isUsersTable = $tables.selected?._id === TableNames.USERS $: isUsersTable = $tables.selected?._id === TableNames.USERS
$: type = $tables.selected?.type $: type = $tables.selected?.type
$: isInternal = type !== "external" $: isInternal = type !== "external"
$: { $: {
schema = $tables.selected?.schema schema = $tables.selected?.schema
copiedSchema = schema
// Manually add these as we don't want them to be 'real' auto-columns copiedSchema._id = {
schema._id = {
type: "internal", type: "internal",
editable: false, editable: false,
displayName: "ID", displayName: "ID",
autocolumn: true, autocolumn: true,
} }
if (isInternal) { if (isInternal) {
schema._rev = { copiedSchema._rev = {
type: "internal", type: "internal",
editable: false, editable: false,
displayName: "Revision", displayName: "Revision",
@ -85,7 +86,7 @@
<div> <div>
<Table <Table
title={$tables.selected?.name} title={$tables.selected?.name}
{schema} schema={copiedSchema}
{type} {type}
tableId={id} tableId={id}
data={$search.rows} data={$search.rows}