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