add ability to copy _rev and _id from data tab
This commit is contained in:
parent
0f153c3666
commit
e2ae8b8437
|
@ -5,11 +5,13 @@
|
||||||
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
|
||||||
export let value
|
export let value
|
||||||
export let customRenderers = []
|
export let customRenderers = []
|
||||||
|
|
||||||
|
let renderer
|
||||||
const typeMap = {
|
const typeMap = {
|
||||||
boolean: BooleanRenderer,
|
boolean: BooleanRenderer,
|
||||||
datetime: DateTimeRenderer,
|
datetime: DateTimeRenderer,
|
||||||
|
@ -20,10 +22,20 @@
|
||||||
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)
|
||||||
$: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer
|
$: {
|
||||||
|
// this has to be done purely in the front-end due to migration issues
|
||||||
|
// the schema gets overriden on every tables fetch so we can't just set
|
||||||
|
// these to be a new type unfortunately
|
||||||
|
if (schema.name === "_id" || schema.name === "_rev") {
|
||||||
|
renderer = customRenderer?.component ?? typeMap.internal ?? StringRenderer
|
||||||
|
} else {
|
||||||
|
renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if renderer && (customRenderer || (value != null && value !== ""))}
|
{#if renderer && (customRenderer || (value != null && value !== ""))}
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<script>
|
||||||
|
import Icon from "../Icon/Icon.svelte"
|
||||||
|
import { notifications } from "../Stores/notifications"
|
||||||
|
export let value
|
||||||
|
|
||||||
|
const onClick = e => {
|
||||||
|
e.stopPropagation()
|
||||||
|
copyToClipboard(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyToClipboard(value) {
|
||||||
|
navigator.clipboard.writeText(value).then(() => {
|
||||||
|
notifications.success("Copied")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div on:click|stopPropagation={onClick}>
|
||||||
|
<Icon size="S" name="Copy" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -43,8 +43,6 @@
|
||||||
function schemaHasOptions(schema) {
|
function schemaHasOptions(schema) {
|
||||||
return !!schema.constraints?.inclusion?.length
|
return !!schema.constraints?.inclusion?.length
|
||||||
}
|
}
|
||||||
|
|
||||||
$: console.log($tables.list)
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
|
|
|
@ -97,6 +97,8 @@ export const AUTO_COLUMN_SUB_TYPES = {
|
||||||
CREATED_AT: "createdAt",
|
CREATED_AT: "createdAt",
|
||||||
UPDATED_BY: "updatedBy",
|
UPDATED_BY: "updatedBy",
|
||||||
UPDATED_AT: "updatedAt",
|
UPDATED_AT: "updatedAt",
|
||||||
|
_id: "_id",
|
||||||
|
_rev: "_rev"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AUTO_COLUMN_DISPLAY_NAMES = {
|
export const AUTO_COLUMN_DISPLAY_NAMES = {
|
||||||
|
@ -105,6 +107,8 @@ export const AUTO_COLUMN_DISPLAY_NAMES = {
|
||||||
CREATED_AT: "Created At",
|
CREATED_AT: "Created At",
|
||||||
UPDATED_BY: "Updated By",
|
UPDATED_BY: "Updated By",
|
||||||
UPDATED_AT: "Updated At",
|
UPDATED_AT: "Updated At",
|
||||||
|
_id: "_id",
|
||||||
|
_rev: "_rev"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const FILE_TYPES = {
|
export const FILE_TYPES = {
|
||||||
|
|
Loading…
Reference in New Issue