1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

Update duplicate rows action to support views V2

This commit is contained in:
Andrew Kingston 2023-08-24 16:14:37 +01:00
parent fd71ad57da
commit 5763a9843c
2 changed files with 15 additions and 7 deletions

View file

@ -1,7 +1,7 @@
<script>
import { Select, Label, Body, Checkbox, Input } from "@budibase/bbui"
import { store, currentAsset } from "builderStore"
import { tables } from "stores/backend"
import { tables, viewsV2 } from "stores/backend"
import {
getContextProviderComponents,
getSchemaForDatasourcePlus,
@ -23,7 +23,15 @@
)
$: providerOptions = getProviderOptions(formComponents, schemaComponents)
$: schemaFields = getSchemaFields($currentAsset, parameters?.tableId)
$: tableOptions = $tables.list || []
$: tableOptions = $tables.list.map(table => ({
label: table.name,
resourceId: table._id,
}))
$: viewOptions = $viewsV2.list.map(view => ({
label: view.name,
resourceId: view.id,
}))
$: options = [...(tableOptions || []), ...(viewOptions || [])]
// Gets a context definition of a certain type from a component definition
const extractComponentContext = (component, contextType) => {
@ -89,9 +97,9 @@
<Label small>Duplicate to Table</Label>
<Select
bind:value={parameters.tableId}
options={tableOptions}
getOptionLabel={option => option.name}
getOptionValue={option => option._id}
{options}
getOptionLabel={option => option.label}
getOptionValue={option => option.resourceId}
/>
<Label small />

View file

@ -42,7 +42,7 @@ const saveRowHandler = async (action, context) => {
}
// Refresh related datasources
await dataSourceStore.actions.invalidateDataSource(row.tableId, {
await dataSourceStore.actions.invalidateDataSource(tableId, {
invalidateRelationships: true,
})
@ -75,7 +75,7 @@ const duplicateRowHandler = async (action, context) => {
}
// Refresh related datasources
await dataSourceStore.actions.invalidateDataSource(row.tableId, {
await dataSourceStore.actions.invalidateDataSource(tableId, {
invalidateRelationships: true,
})