Merge pull request #3046 from Budibase/fix/copy-id-and-rev

Add back the ability to copy the ID and Revision (safely)
This commit is contained in:
Peter Clement 2021-10-19 13:01:18 +01:00 committed by GitHub
commit 4a4246af6e
3 changed files with 29 additions and 1 deletions

View File

@ -5,6 +5,7 @@
import RelationshipRenderer from "./RelationshipRenderer.svelte" import RelationshipRenderer from "./RelationshipRenderer.svelte"
import AttachmentRenderer from "./AttachmentRenderer.svelte" import AttachmentRenderer from "./AttachmentRenderer.svelte"
import ArrayRenderer from "./ArrayRenderer.svelte" import ArrayRenderer from "./ArrayRenderer.svelte"
import InternalRenderer from "./InternalRenderer.svelte"
export let row export let row
export let schema export let schema
@ -22,6 +23,7 @@
number: StringRenderer, number: StringRenderer,
longform: StringRenderer, longform: StringRenderer,
array: ArrayRenderer, array: ArrayRenderer,
internal: InternalRenderer,
} }
$: type = schema?.type ?? "string" $: type = schema?.type ?? "string"
$: customRenderer = customRenderers?.find(x => x.column === schema?.name) $: customRenderer = customRenderers?.find(x => x.column === schema?.name)

View File

@ -20,10 +20,30 @@
$: 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)
$: id = $tables.selected?._id $: id = $tables.selected?._id
$: search = searchTable(id) $: search = searchTable(id)
$: columnOptions = Object.keys($search.schema || {}) $: columnOptions = Object.keys($search.schema || {})
const enrichSchema = schema => {
let tempSchema = { ...schema }
tempSchema._id = {
type: "internal",
editable: false,
displayName: "ID",
autocolumn: true,
}
if (isInternal) {
tempSchema._rev = {
type: "internal",
editable: false,
displayName: "Revision",
autocolumn: true,
}
}
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({
@ -66,7 +86,7 @@
<div> <div>
<Table <Table
title={$tables.selected?.name} title={$tables.selected?.name}
{schema} schema={enrichedSchema}
{type} {type}
tableId={id} tableId={id}
data={$search.rows} data={$search.rows}

View File

@ -4,10 +4,15 @@ import { get as svelteGet } from "svelte/store"
// currently supported level of relationship depth (server side) // currently supported level of relationship depth (server side)
const MAX_DEPTH = 1 const MAX_DEPTH = 1
//https://github.com/Budibase/budibase/issues/3030
const internalType = "internal"
const TYPES_TO_SKIP = [ const TYPES_TO_SKIP = [
FIELDS.FORMULA.type, FIELDS.FORMULA.type,
FIELDS.LONGFORM.type, FIELDS.LONGFORM.type,
FIELDS.ATTACHMENT.type, FIELDS.ATTACHMENT.type,
internalType,
] ]
export function getBindings({ export function getBindings({
@ -53,6 +58,7 @@ export function getBindings({
const field = Object.values(FIELDS).find( const field = Object.values(FIELDS).find(
field => field.type === schema.type field => field.type === schema.type
) )
const label = path == null ? column : `${path}.0.${column}` const label = path == null ? column : `${path}.0.${column}`
// only supply a description for relationship paths // only supply a description for relationship paths
const description = const description =