FIX: Error when deleting selected rows that have attachment (#13006)

* Deprecate selectedRowIds

* Delete selected rows table

* Add selectedRows to table block context

* update account-portal

* update account-portal

* Lowercase deprecated
This commit is contained in:
melohagan 2024-02-13 16:44:21 +00:00 committed by GitHub
parent e171873b10
commit f8073c3f5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 95 additions and 61 deletions

View File

@ -617,6 +617,7 @@ const getDeviceBindings = () => {
/**
* Gets all selected rows bindings for tables in the current asset.
* TODO: remove in future because we don't need a separate store for this
* DEPRECATED
*/
const getSelectedRowsBindings = asset => {
let bindings = []
@ -632,8 +633,8 @@ const getSelectedRowsBindings = asset => {
runtimeBinding: `${safeState}.${makePropSafe(table._id)}.${makePropSafe(
"selectedRows"
)}`,
readableBinding: `${table._instanceName}.Selected rows`,
category: "Selected rows",
readableBinding: `${table._instanceName}.Selected Row IDs (deprecated)`,
category: "Selected Row IDs (deprecated)",
icon: "ViewRow",
display: { name: table._instanceName },
}))
@ -649,8 +650,8 @@ const getSelectedRowsBindings = asset => {
runtimeBinding: `${safeState}.${makePropSafe(
block._id + "-table"
)}.${makePropSafe("selectedRows")}`,
readableBinding: `${block._instanceName}.Selected rows`,
category: "Selected rows",
readableBinding: `${block._instanceName}.Selected Row IDs (deprecated)`,
category: "Selected Row IDs (deprecated)",
icon: "ViewRow",
display: { name: block._instanceName },
}))

View File

@ -4719,10 +4719,22 @@
]
}
],
"context": {
"type": "schema",
"scope": "local"
}
"context": [
{
"type": "schema",
"scope": "local"
},
{
"type": "static",
"values": [
{
"label": "Selected Rows",
"key": "selectedRows",
"type": "array"
}
]
}
]
},
"daterangepicker": {
"name": "Date Range",
@ -5610,37 +5622,50 @@
]
}
],
"context": {
"type": "static",
"suffix": "provider",
"values": [
{
"label": "Rows",
"key": "rows",
"type": "array"
},
{
"label": "Extra Info",
"key": "info",
"type": "string"
},
{
"label": "Rows Length",
"key": "rowsLength",
"type": "number"
},
{
"label": "Schema",
"key": "schema",
"type": "object"
},
{
"label": "Page Number",
"key": "pageNumber",
"type": "number"
}
]
}
"context": [
{
"type": "static",
"suffix": "provider",
"values": [
{
"label": "Rows",
"key": "rows",
"type": "array"
},
{
"label": "Extra Info",
"key": "info",
"type": "string"
},
{
"label": "Rows Length",
"key": "rowsLength",
"type": "number"
},
{
"label": "Schema",
"key": "schema",
"type": "object"
},
{
"label": "Page Number",
"key": "pageNumber",
"type": "number"
}
]
},
{
"type": "static",
"suffix": "table",
"values": [
{
"label": "Selected Rows",
"key": "selectedRows",
"type": "array"
}
]
}
]
},
"cardsblock": {
"block": true,

View File

@ -3,6 +3,7 @@
import { Table } from "@budibase/bbui"
import SlotRenderer from "./SlotRenderer.svelte"
import { canBeSortColumn } from "@budibase/shared-core"
import Provider from "../../context/Provider.svelte"
export let dataProvider
export let columns
@ -55,6 +56,11 @@
}
}
// Build our data context
$: dataContext = {
selectedRows,
}
const getFields = (
schema,
customColumns,
@ -156,27 +162,29 @@
</script>
<div use:styleable={$component.styles} class={size}>
<Table
{data}
{schema}
{loading}
{rowCount}
{quiet}
{compact}
{customRenderers}
allowSelectRows={allowSelectRows && table}
bind:selectedRows
allowEditRows={false}
allowEditColumns={false}
showAutoColumns={true}
disableSorting
autoSortColumns={!columns?.length}
on:sort={onSort}
on:click={handleClick}
placeholderText={noRowsMessage || "No rows found"}
>
<slot />
</Table>
<Provider data={dataContext}>
<Table
{data}
{schema}
{loading}
{rowCount}
{quiet}
{compact}
{customRenderers}
allowSelectRows={allowSelectRows && table}
bind:selectedRows
allowEditRows={false}
allowEditColumns={false}
showAutoColumns={true}
disableSorting
autoSortColumns={!columns?.length}
on:sort={onSort}
on:click={handleClick}
placeholderText={noRowsMessage || "No rows found"}
>
<slot />
</Table>
</Provider>
{#if allowSelectRows && selectedRows.length}
<div class="row-count">
{selectedRows.length} row{selectedRows.length === 1 ? "" : "s"} selected

View File

@ -5,7 +5,7 @@ const createRowSelectionStore = () => {
function updateSelection(componentId, tableId, selectedRows) {
store.update(state => {
state[componentId] = { tableId: tableId, selectedRows: selectedRows }
state[componentId] = { tableId, selectedRows }
return state
})
}