Fix delete row action

This commit is contained in:
Andrew Kingston 2021-02-04 19:18:32 +00:00
parent f453ed6c43
commit 580837f949
2 changed files with 7 additions and 17 deletions

View File

@ -15,8 +15,9 @@
) )
$: { $: {
// Automatically set rev and table ID based on row ID // Automatically set rev and table ID based on row ID
if (parameters.rowId) { if (parameters.providerId) {
parameters.revId = parameters.rowId.replace("_id", "_rev") parameters.rowId = `{{ ${parameters.providerId}._id }}`
parameters.revId = `{{ ${parameters.providerId}._rev }}`
const providerComponent = dataProviderComponents.find( const providerComponent = dataProviderComponents.find(
provider => provider._id === parameters.providerId provider => provider._id === parameters.providerId
) )
@ -37,12 +38,10 @@
</div> </div>
{:else} {:else}
<Label size="m" color="dark">Datasource</Label> <Label size="m" color="dark">Datasource</Label>
<Select secondary bind:value={parameters.rowId}> <Select secondary bind:value={parameters.providerId}>
<option value="" /> <option value="" />
{#each dataProviderComponents as provider} {#each dataProviderComponents as provider}
<option value={`{{ ${provider._id}._id }}`}> <option value={provider._id}>{provider._instanceName}</option>
{provider._instanceName}
</option>
{/each} {/each}
</Select> </Select>
{/if} {/if}

View File

@ -17,19 +17,10 @@ const saveRowHandler = async (action, context) => {
} }
} }
const deleteRowHandler = async (action, context) => { const deleteRowHandler = async action => {
const { tableId, revId, rowId } = action.parameters const { tableId, revId, rowId } = action.parameters
if (tableId && revId && rowId) { if (tableId && revId && rowId) {
const [enrichTable, enrichRow, enrichRev] = await Promise.all([ await deleteRow({ tableId, rowId, revId })
enrichDataBinding(tableId, context),
enrichDataBinding(rowId, context),
enrichDataBinding(revId, context),
])
await deleteRow({
tableId: enrichTable,
rowId: enrichRow,
revId: enrichRev,
})
} }
} }