Merge branch 'master' into BUDI-8084/single-attachment-binding
This commit is contained in:
commit
7a779faf6b
|
@ -28,7 +28,6 @@
|
||||||
let deleteTableName
|
let deleteTableName
|
||||||
|
|
||||||
$: externalTable = table?.sourceType === DB_TYPE_EXTERNAL
|
$: externalTable = table?.sourceType === DB_TYPE_EXTERNAL
|
||||||
$: allowDeletion = !externalTable || table?.created
|
|
||||||
|
|
||||||
function showDeleteModal() {
|
function showDeleteModal() {
|
||||||
templateScreens = $screenStore.screens.filter(
|
templateScreens = $screenStore.screens.filter(
|
||||||
|
@ -56,7 +55,7 @@
|
||||||
$goto(`./datasource/${table.datasourceId}`)
|
$goto(`./datasource/${table.datasourceId}`)
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
notifications.error("Error deleting table")
|
notifications.error(`Error deleting table - ${error.message}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,17 +85,15 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if allowDeletion}
|
<ActionMenu>
|
||||||
<ActionMenu>
|
<div slot="control" class="icon">
|
||||||
<div slot="control" class="icon">
|
<Icon s hoverable name="MoreSmallList" />
|
||||||
<Icon s hoverable name="MoreSmallList" />
|
</div>
|
||||||
</div>
|
{#if !externalTable}
|
||||||
{#if !externalTable}
|
<MenuItem icon="Edit" on:click={editorModal.show}>Edit</MenuItem>
|
||||||
<MenuItem icon="Edit" on:click={editorModal.show}>Edit</MenuItem>
|
{/if}
|
||||||
{/if}
|
<MenuItem icon="Delete" on:click={showDeleteModal}>Delete</MenuItem>
|
||||||
<MenuItem icon="Delete" on:click={showDeleteModal}>Delete</MenuItem>
|
</ActionMenu>
|
||||||
</ActionMenu>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<Modal bind:this={editorModal} on:show={initForm}>
|
<Modal bind:this={editorModal} on:show={initForm}>
|
||||||
<ModalContent
|
<ModalContent
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
|
import { get } from "svelte/store"
|
||||||
import { generate } from "shortid"
|
import { generate } from "shortid"
|
||||||
import Block from "components/Block.svelte"
|
import Block from "components/Block.svelte"
|
||||||
import BlockComponent from "components/BlockComponent.svelte"
|
import BlockComponent from "components/BlockComponent.svelte"
|
||||||
|
@ -33,8 +34,9 @@
|
||||||
export let sidePanelDeleteLabel
|
export let sidePanelDeleteLabel
|
||||||
export let notificationOverride
|
export let notificationOverride
|
||||||
|
|
||||||
const { fetchDatasourceSchema, API } = getContext("sdk")
|
const { fetchDatasourceSchema, API, generateGoldenSample } = getContext("sdk")
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
const context = getContext("context")
|
||||||
const stateKey = `ID_${generate()}`
|
const stateKey = `ID_${generate()}`
|
||||||
|
|
||||||
let formId
|
let formId
|
||||||
|
@ -48,20 +50,6 @@
|
||||||
let schemaLoaded = false
|
let schemaLoaded = false
|
||||||
|
|
||||||
$: deleteLabel = setDeleteLabel(sidePanelDeleteLabel, sidePanelShowDelete)
|
$: deleteLabel = setDeleteLabel(sidePanelDeleteLabel, sidePanelShowDelete)
|
||||||
|
|
||||||
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 +93,30 @@
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// Provide additional data context for live binding eval
|
||||||
|
export const getAdditionalDataContext = () => {
|
||||||
|
const rows = get(context)[dataProviderId]?.rows
|
||||||
|
const goldenRow = generateGoldenSample(rows)
|
||||||
|
return {
|
||||||
|
eventContext: {
|
||||||
|
row: goldenRow,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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") {
|
||||||
|
|
|
@ -40,16 +40,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle certain key presses regardless of selection state
|
||||||
|
if (e.key === "Enter" && (e.ctrlKey || e.metaKey) && $config.canAddRows) {
|
||||||
|
e.preventDefault()
|
||||||
|
dispatch("add-row-inline")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// If nothing selected avoid processing further key presses
|
// If nothing selected avoid processing further key presses
|
||||||
if (!$focusedCellId) {
|
if (!$focusedCellId) {
|
||||||
if (e.key === "Tab" || e.key?.startsWith("Arrow")) {
|
if (e.key === "Tab" || e.key?.startsWith("Arrow")) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
focusFirstCell()
|
focusFirstCell()
|
||||||
} else if (e.key === "Enter" && (e.ctrlKey || e.metaKey)) {
|
|
||||||
if ($config.canAddRows) {
|
|
||||||
e.preventDefault()
|
|
||||||
dispatch("add-row-inline")
|
|
||||||
}
|
|
||||||
} else if (e.key === "Delete" || e.key === "Backspace") {
|
} else if (e.key === "Delete" || e.key === "Backspace") {
|
||||||
if (Object.keys($selectedRows).length && $config.canDeleteRows) {
|
if (Object.keys($selectedRows).length && $config.canDeleteRows) {
|
||||||
dispatch("request-bulk-delete")
|
dispatch("request-bulk-delete")
|
||||||
|
|
|
@ -61,9 +61,6 @@ export async function destroy(ctx: UserCtx) {
|
||||||
const tableToDelete: TableRequest = await sdk.tables.getTable(
|
const tableToDelete: TableRequest = await sdk.tables.getTable(
|
||||||
ctx.params.tableId
|
ctx.params.tableId
|
||||||
)
|
)
|
||||||
if (!tableToDelete || !tableToDelete.created) {
|
|
||||||
ctx.throw(400, "Cannot delete tables which weren't created in Budibase.")
|
|
||||||
}
|
|
||||||
const datasourceId = getDatasourceId(tableToDelete)
|
const datasourceId = getDatasourceId(tableToDelete)
|
||||||
try {
|
try {
|
||||||
const { datasource, table } = await sdk.tables.external.destroy(
|
const { datasource, table } = await sdk.tables.external.destroy(
|
||||||
|
|
Loading…
Reference in New Issue