Skip to content

Commit

Permalink
Add preventDelete prop
Browse files Browse the repository at this point in the history
  • Loading branch information
nas-tabchiche committed Feb 12, 2024
1 parent 47e9644 commit b18a2de
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions frontend/src/lib/components/ModelTable/ModelTable.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
{row}
hasBody={$$slots.actionsBody}
{identifierField}
preventDelete={row.meta.preventDelete ?? false}
>
<svelte:fragment slot="head">
{#if $$slots.actionsHead}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
export let deleteForm: SuperValidated<AnyZodObject> | undefined;
export let URLModel: urlModel | string | undefined;
export let identifierField: string = 'id';
export let preventDelete = false;
export let hasBody = false;
Expand Down Expand Up @@ -46,7 +47,8 @@
}
const user = $page.data.user;
const canDeleteObject: boolean = Object.hasOwn(user.permissions, `delete_${model?.name}`);
const canDeleteObject: boolean =
Object.hasOwn(user.permissions, `delete_${model?.name}`) && !preventDelete;
const canEditObject: boolean = Object.hasOwn(user.permissions, `change_${model?.name}`);
$: displayDetail = detailURL;
Expand Down

0 comments on commit b18a2de

Please sign in to comment.