Refactor of the delete label logic into a block
This commit is contained in:
parent
a04dd3a66d
commit
d6ae511eda
|
@ -45,8 +45,21 @@
|
||||||
let enrichedSearchColumns
|
let enrichedSearchColumns
|
||||||
let schemaLoaded = false
|
let schemaLoaded = false
|
||||||
|
|
||||||
// Accommodate old config to ensure delete button does not reappear
|
$: deleteLabel = setDeleteLabel(sidePanelDeleteLabel, sidePanelShowDelete)
|
||||||
$: deleteLabel = sidePanelShowDelete === false ? "" : sidePanelDeleteLabel
|
|
||||||
|
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(
|
||||||
|
@ -249,7 +262,7 @@
|
||||||
props={{
|
props={{
|
||||||
dataSource,
|
dataSource,
|
||||||
saveButtonLabel: sidePanelSaveLabel || "Save", //always show
|
saveButtonLabel: sidePanelSaveLabel || "Save", //always show
|
||||||
deleteButtonLabel: deleteLabel == "" ? "" : "Delete",
|
deleteButtonLabel: deleteLabel,
|
||||||
actionType: "Update",
|
actionType: "Update",
|
||||||
rowId: `{{ ${safe("state")}.${safe(stateKey)} }}`,
|
rowId: `{{ ${safe("state")}.${safe(stateKey)} }}`,
|
||||||
fields: sidePanelFields || normalFields,
|
fields: sidePanelFields || normalFields,
|
||||||
|
|
Loading…
Reference in New Issue