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:
parent
e171873b10
commit
f8073c3f5a
|
@ -617,6 +617,7 @@ const getDeviceBindings = () => {
|
||||||
/**
|
/**
|
||||||
* Gets all selected rows bindings for tables in the current asset.
|
* 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
|
* TODO: remove in future because we don't need a separate store for this
|
||||||
|
* DEPRECATED
|
||||||
*/
|
*/
|
||||||
const getSelectedRowsBindings = asset => {
|
const getSelectedRowsBindings = asset => {
|
||||||
let bindings = []
|
let bindings = []
|
||||||
|
@ -632,8 +633,8 @@ const getSelectedRowsBindings = asset => {
|
||||||
runtimeBinding: `${safeState}.${makePropSafe(table._id)}.${makePropSafe(
|
runtimeBinding: `${safeState}.${makePropSafe(table._id)}.${makePropSafe(
|
||||||
"selectedRows"
|
"selectedRows"
|
||||||
)}`,
|
)}`,
|
||||||
readableBinding: `${table._instanceName}.Selected rows`,
|
readableBinding: `${table._instanceName}.Selected Row IDs (deprecated)`,
|
||||||
category: "Selected rows",
|
category: "Selected Row IDs (deprecated)",
|
||||||
icon: "ViewRow",
|
icon: "ViewRow",
|
||||||
display: { name: table._instanceName },
|
display: { name: table._instanceName },
|
||||||
}))
|
}))
|
||||||
|
@ -649,8 +650,8 @@ const getSelectedRowsBindings = asset => {
|
||||||
runtimeBinding: `${safeState}.${makePropSafe(
|
runtimeBinding: `${safeState}.${makePropSafe(
|
||||||
block._id + "-table"
|
block._id + "-table"
|
||||||
)}.${makePropSafe("selectedRows")}`,
|
)}.${makePropSafe("selectedRows")}`,
|
||||||
readableBinding: `${block._instanceName}.Selected rows`,
|
readableBinding: `${block._instanceName}.Selected Row IDs (deprecated)`,
|
||||||
category: "Selected rows",
|
category: "Selected Row IDs (deprecated)",
|
||||||
icon: "ViewRow",
|
icon: "ViewRow",
|
||||||
display: { name: block._instanceName },
|
display: { name: block._instanceName },
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -4719,10 +4719,22 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"context": {
|
"context": [
|
||||||
"type": "schema",
|
{
|
||||||
"scope": "local"
|
"type": "schema",
|
||||||
}
|
"scope": "local"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "static",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"label": "Selected Rows",
|
||||||
|
"key": "selectedRows",
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"daterangepicker": {
|
"daterangepicker": {
|
||||||
"name": "Date Range",
|
"name": "Date Range",
|
||||||
|
@ -5610,37 +5622,50 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"context": {
|
"context": [
|
||||||
"type": "static",
|
{
|
||||||
"suffix": "provider",
|
"type": "static",
|
||||||
"values": [
|
"suffix": "provider",
|
||||||
{
|
"values": [
|
||||||
"label": "Rows",
|
{
|
||||||
"key": "rows",
|
"label": "Rows",
|
||||||
"type": "array"
|
"key": "rows",
|
||||||
},
|
"type": "array"
|
||||||
{
|
},
|
||||||
"label": "Extra Info",
|
{
|
||||||
"key": "info",
|
"label": "Extra Info",
|
||||||
"type": "string"
|
"key": "info",
|
||||||
},
|
"type": "string"
|
||||||
{
|
},
|
||||||
"label": "Rows Length",
|
{
|
||||||
"key": "rowsLength",
|
"label": "Rows Length",
|
||||||
"type": "number"
|
"key": "rowsLength",
|
||||||
},
|
"type": "number"
|
||||||
{
|
},
|
||||||
"label": "Schema",
|
{
|
||||||
"key": "schema",
|
"label": "Schema",
|
||||||
"type": "object"
|
"key": "schema",
|
||||||
},
|
"type": "object"
|
||||||
{
|
},
|
||||||
"label": "Page Number",
|
{
|
||||||
"key": "pageNumber",
|
"label": "Page Number",
|
||||||
"type": "number"
|
"key": "pageNumber",
|
||||||
}
|
"type": "number"
|
||||||
]
|
}
|
||||||
}
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "static",
|
||||||
|
"suffix": "table",
|
||||||
|
"values": [
|
||||||
|
{
|
||||||
|
"label": "Selected Rows",
|
||||||
|
"key": "selectedRows",
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"cardsblock": {
|
"cardsblock": {
|
||||||
"block": true,
|
"block": true,
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import { Table } from "@budibase/bbui"
|
import { Table } from "@budibase/bbui"
|
||||||
import SlotRenderer from "./SlotRenderer.svelte"
|
import SlotRenderer from "./SlotRenderer.svelte"
|
||||||
import { canBeSortColumn } from "@budibase/shared-core"
|
import { canBeSortColumn } from "@budibase/shared-core"
|
||||||
|
import Provider from "../../context/Provider.svelte"
|
||||||
|
|
||||||
export let dataProvider
|
export let dataProvider
|
||||||
export let columns
|
export let columns
|
||||||
|
@ -55,6 +56,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build our data context
|
||||||
|
$: dataContext = {
|
||||||
|
selectedRows,
|
||||||
|
}
|
||||||
|
|
||||||
const getFields = (
|
const getFields = (
|
||||||
schema,
|
schema,
|
||||||
customColumns,
|
customColumns,
|
||||||
|
@ -156,27 +162,29 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div use:styleable={$component.styles} class={size}>
|
<div use:styleable={$component.styles} class={size}>
|
||||||
<Table
|
<Provider data={dataContext}>
|
||||||
{data}
|
<Table
|
||||||
{schema}
|
{data}
|
||||||
{loading}
|
{schema}
|
||||||
{rowCount}
|
{loading}
|
||||||
{quiet}
|
{rowCount}
|
||||||
{compact}
|
{quiet}
|
||||||
{customRenderers}
|
{compact}
|
||||||
allowSelectRows={allowSelectRows && table}
|
{customRenderers}
|
||||||
bind:selectedRows
|
allowSelectRows={allowSelectRows && table}
|
||||||
allowEditRows={false}
|
bind:selectedRows
|
||||||
allowEditColumns={false}
|
allowEditRows={false}
|
||||||
showAutoColumns={true}
|
allowEditColumns={false}
|
||||||
disableSorting
|
showAutoColumns={true}
|
||||||
autoSortColumns={!columns?.length}
|
disableSorting
|
||||||
on:sort={onSort}
|
autoSortColumns={!columns?.length}
|
||||||
on:click={handleClick}
|
on:sort={onSort}
|
||||||
placeholderText={noRowsMessage || "No rows found"}
|
on:click={handleClick}
|
||||||
>
|
placeholderText={noRowsMessage || "No rows found"}
|
||||||
<slot />
|
>
|
||||||
</Table>
|
<slot />
|
||||||
|
</Table>
|
||||||
|
</Provider>
|
||||||
{#if allowSelectRows && selectedRows.length}
|
{#if allowSelectRows && selectedRows.length}
|
||||||
<div class="row-count">
|
<div class="row-count">
|
||||||
{selectedRows.length} row{selectedRows.length === 1 ? "" : "s"} selected
|
{selectedRows.length} row{selectedRows.length === 1 ? "" : "s"} selected
|
||||||
|
|
|
@ -5,7 +5,7 @@ const createRowSelectionStore = () => {
|
||||||
|
|
||||||
function updateSelection(componentId, tableId, selectedRows) {
|
function updateSelection(componentId, tableId, selectedRows) {
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
state[componentId] = { tableId: tableId, selectedRows: selectedRows }
|
state[componentId] = { tableId, selectedRows }
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue