1
0
Fork 0
mirror of synced 2024-09-29 08:41:16 +13:00

Improve performance of table block

This commit is contained in:
Andrew Kingston 2024-03-20 15:46:15 +00:00
parent fdde7f8895
commit 65b4b6c35d

View file

@ -48,20 +48,7 @@
let schemaLoaded = false let schemaLoaded = false
$: deleteLabel = setDeleteLabel(sidePanelDeleteLabel, sidePanelShowDelete) $: deleteLabel = setDeleteLabel(sidePanelDeleteLabel, sidePanelShowDelete)
$: id = $component.id
const setDeleteLabel = sidePanelDeleteLabel => {
// Accommodate old config to ensure delete button does not reappear
let labelText = sidePanelShowDelete === false ? "" : sidePanelDeleteLabel
// Empty text is considered hidden.
if (labelText?.trim() === "") {
return ""
}
// Default to "Delete" if the value is unset
return labelText || "Delete"
}
$: isDSPlus = dataSource?.type === "table" || dataSource?.type === "viewV2" $: isDSPlus = dataSource?.type === "table" || dataSource?.type === "viewV2"
$: fetchSchema(dataSource) $: fetchSchema(dataSource)
$: enrichSearchColumns(searchColumns, schema).then( $: enrichSearchColumns(searchColumns, schema).then(
@ -105,6 +92,19 @@
}, },
] ]
const setDeleteLabel = sidePanelDeleteLabel => {
// Accommodate old config to ensure delete button does not reappear
let labelText = sidePanelShowDelete === false ? "" : sidePanelDeleteLabel
// Empty text is considered hidden.
if (labelText?.trim() === "") {
return ""
}
// Default to "Delete" if the value is unset
return labelText || "Delete"
}
// Load the datasource schema so we can determine column types // Load the datasource schema so we can determine column types
const fetchSchema = async dataSource => { const fetchSchema = async dataSource => {
if (dataSource?.type === "table") { if (dataSource?.type === "table") {
@ -267,7 +267,7 @@
dataSource, dataSource,
buttonPosition: "top", buttonPosition: "top",
buttons: Utils.buildFormBlockButtonConfig({ buttons: Utils.buildFormBlockButtonConfig({
_id: $component.id + "-form-edit", _id: id + "-form-edit",
showDeleteButton: deleteLabel !== "", showDeleteButton: deleteLabel !== "",
showSaveButton: true, showSaveButton: true,
saveButtonLabel: sidePanelSaveLabel || "Save", saveButtonLabel: sidePanelSaveLabel || "Save",
@ -301,7 +301,7 @@
dataSource, dataSource,
buttonPosition: "top", buttonPosition: "top",
buttons: Utils.buildFormBlockButtonConfig({ buttons: Utils.buildFormBlockButtonConfig({
_id: $component.id + "-form-new", _id: id + "-form-new",
showDeleteButton: false, showDeleteButton: false,
showSaveButton: true, showSaveButton: true,
saveButtonLabel: "Save", saveButtonLabel: "Save",