1
0
Fork 0
mirror of synced 2024-09-15 08:47:37 +12:00
This commit is contained in:
Adria Navarro 2024-07-15 14:06:13 +02:00
parent 18ef23258f
commit 66b7c6aa08
3 changed files with 65 additions and 1 deletions

View file

@ -20,7 +20,7 @@
}
</script>
<Modal bind:this={modal} on:hide={onCancel}>
<Modal bind:this={modal} on:hide={onCancel} zIndex={9999}>
<ModalContent
onConfirm={onOk}
{title}

View file

@ -1,14 +1,19 @@
<script>
import { Body, Button, Drawer, DrawerContent, Table } from "@budibase/bbui"
import { rowActions as rowActionsStore } from "stores/builder"
import UpsertRowActionDrawer from "./UpsertRowActionDrawer.svelte"
import ConfirmDialog from "../ConfirmDialog.svelte"
export let tableId
export let rowActions
export let drawer
let upsertDrawer
let modal
let rowAction
let selectedRowActions
function addNewAction() {
upsertDrawer.show()
}
@ -32,6 +37,13 @@
function onRowActionDrawerHide() {
rowAction = undefined
}
async function deleteRowActions() {
await rowActionsStore.delete(
tableId,
selectedRowActions?.map(a => a.id)
)
}
</script>
<Drawer
@ -54,10 +66,39 @@
{#if !rowActions.length}
<Body size="S">No row actions are created for this table.</Body>
{:else}
<div class="delete-button">
<div>
<Button
icon="Delete"
warning
quiet
on:click={modal.show}
disabled={!selectedRowActions?.length}
>
Delete
{selectedRowActions?.length}
row actions
</Button>
</div>
</div>
<ConfirmDialog
bind:this={modal}
okText="Delete"
onOk={deleteRowActions}
title="Confirm Deletion"
>
Are you sure you want to delete
{selectedRowActions?.length}
row actions?
</ConfirmDialog>
<Table
data={rowActions}
schema={actionSchema}
allowEditColumns={false}
allowEditRows={false}
allowSelectRows
rowIdProp="id"
bind:selectedRows={selectedRowActions}
on:editrow={e => editRowAction(e.detail)}
on:click={e => editRowAction(e.detail)}
/>
@ -71,3 +112,12 @@
{rowAction}
on:drawerHide={onRowActionDrawerHide}
/>
<style>
.delete-button {
display: flex;
}
.delete-button > * {
margin-left: auto;
}
</style>

View file

@ -44,6 +44,20 @@ export function createRowActionStore() {
return sort([...store.filter(f => f.id !== rowActionId), response])
})
},
delete: async (tableId, rowIds) => {
if (rowIds && !Array.isArray(rowIds)) {
rowIds = [rowIds]
}
for (const id of rowIds) {
await API.delete({
url: `/api/tables/${tableId}/actions/${id}`,
})
store.update(store => {
return sort(store.filter(f => f.id !== id))
})
}
},
}
}