refactor to remove object reference

This commit is contained in:
Peter Clement 2021-10-18 16:03:13 +01:00
parent 1d0f5c4d90
commit a20af34a03
1 changed files with 12 additions and 12 deletions

View File

@ -16,34 +16,34 @@
import { Pagination } from "@budibase/bbui"
let hideAutocolumns = true
let copiedSchema
let schema
$: isUsersTable = $tables.selected?._id === TableNames.USERS
$: type = $tables.selected?.type
$: isInternal = type !== "external"
$: {
schema = $tables.selected?.schema
copiedSchema = schema
$: schema = $tables.selected?.schema
$: enrichedSchema = enrichSchema($tables.selected?.schema)
$: id = $tables.selected?._id
$: search = searchTable(id)
$: columnOptions = Object.keys($search.schema || {})
copiedSchema._id = {
const enrichSchema = schema => {
let tempSchema = { ...schema }
tempSchema._id = {
type: "internal",
editable: false,
displayName: "ID",
autocolumn: true,
}
if (isInternal) {
copiedSchema._rev = {
tempSchema._rev = {
type: "internal",
editable: false,
displayName: "Revision",
autocolumn: true,
}
}
}
$: id = $tables.selected?._id
$: search = searchTable(id)
$: columnOptions = Object.keys($search.schema || {})
return tempSchema
}
// Fetches new data whenever the table changes
const searchTable = tableId => {
return fetchTableData({
@ -86,7 +86,7 @@
<div>
<Table
title={$tables.selected?.name}
schema={copiedSchema}
schema={enrichedSchema}
{type}
tableId={id}
data={$search.rows}