diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/DeleteRow.svelte b/packages/builder/src/components/userInterface/EventsEditor/actions/DeleteRow.svelte new file mode 100644 index 0000000000..6e6f6b6b21 --- /dev/null +++ b/packages/builder/src/components/userInterface/EventsEditor/actions/DeleteRow.svelte @@ -0,0 +1,91 @@ + + +
+ {#if idFields.length === 0} +
+ Delete row can only be used within a component that provides data, such as + a List +
+ {:else} + + + {/if} +
+ + diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/index.js b/packages/builder/src/components/userInterface/EventsEditor/actions/index.js index 109a3104f8..1c07356ee9 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/actions/index.js +++ b/packages/builder/src/components/userInterface/EventsEditor/actions/index.js @@ -1,5 +1,6 @@ import NavigateTo from "./NavigateTo.svelte" import SaveRow from "./SaveRow.svelte" +import DeleteRow from "./DeleteRow.svelte" // defines what actions are available, when adding a new one // the component is the setup panel for the action @@ -11,6 +12,10 @@ export default [ name: "Save Row", component: SaveRow, }, + { + name: "Delete Row", + component: DeleteRow, + }, { name: "Navigate To", component: NavigateTo, diff --git a/packages/client/src/api/index.js b/packages/client/src/api/index.js index 6082accb51..f5f129d9c8 100644 --- a/packages/client/src/api/index.js +++ b/packages/client/src/api/index.js @@ -67,6 +67,11 @@ const updateRow = async (params, state) => { }) } +const deleteRow = async params => + await del({ + url: `/api/${params.tableId}/rows/${params.rowId}/${params.revId}`, + }) + const makeRowRequestBody = (parameters, state) => { // start with the row thats currently in context const body = { ...(state.data || {}) } @@ -103,4 +108,5 @@ export default { authenticate: authenticate(apiOpts), saveRow, updateRow, + deleteRow, } diff --git a/packages/client/src/state/eventHandlers.js b/packages/client/src/state/eventHandlers.js index 629631d001..7461913929 100644 --- a/packages/client/src/state/eventHandlers.js +++ b/packages/client/src/state/eventHandlers.js @@ -8,6 +8,7 @@ export const eventHandlers = routeTo => { "Navigate To": param => routeTo(param && param.url), "Update Row": api.updateRow, "Save Row": api.saveRow, + "Delete Row": api.deleteRow, "Trigger Workflow": api.triggerWorkflow, }