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

View File

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