-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: pdamianik <[email protected]>
- Loading branch information
Showing
7 changed files
with
94 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,47 @@ | ||
<script lang="ts"> | ||
import type { ExistingDocument, ProductList } from '$lib/db'; | ||
import { Card, Heading } from 'flowbite-svelte'; | ||
import { Button, Card, Heading, Modal } from 'flowbite-svelte'; | ||
import TrashBinSolid from '~icons/flowbite/trash-bin-solid'; | ||
import ExclamationCircleSolid from '~icons/flowbite/exclamation-circle-solid'; | ||
export let productlist: ExistingDocument<ProductList>; | ||
import { db as DB } from '$lib/db'; | ||
import { get } from 'svelte/store'; | ||
async function deleteList(id: string) { | ||
async function deleteList() { | ||
const db = get(DB); | ||
const list = await db.get(id); | ||
const list = await db.get(deleteModalId); | ||
await db.remove(list); | ||
} | ||
</script> | ||
<head> | ||
<link | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" | ||
rel="stylesheet" | ||
/> | ||
</head> | ||
let deleteModal = false; | ||
let deleteModalId = ''; | ||
</script> | ||
|
||
<Card href={`/items/${productlist._id}`} {...$$restProps}> | ||
<div class="flex items-center justify-between"> | ||
<Heading tag="h4">{productlist.name}</Heading> | ||
<button | ||
class="inline-flex items-center justify-center rounded bg-red-500 px-4 py-2 font-bold text-white hover:bg-red-700" | ||
on:click|stopPropagation|preventDefault={() => { | ||
if (confirm('Möchten Sie diese Liste wirklich löschen?')) { | ||
deleteList(productlist._id); | ||
} | ||
<Button | ||
color="red" | ||
on:click={(e) => { | ||
e.preventDefault(); | ||
deleteModal = true; | ||
deleteModalId = productlist._id; | ||
}} | ||
> | ||
<i class="fas fa-trash-alt"></i> | ||
</button> | ||
<TrashBinSolid aria-label="Löschen" /> | ||
</Button> | ||
</div> | ||
</Card> | ||
|
||
<Modal bind:open={deleteModal} size="xs" autoclose outsideclose> | ||
<div class="text-center"> | ||
<ExclamationCircleSolid class="mx-auto mb-4 h-12 w-12 text-gray-400 dark:text-gray-200" /> | ||
<h3 class="mb-5 text-lg font-normal text-gray-500 dark:text-gray-400"> | ||
Sicher, dass sie dieses Produkt löschen möchten? | ||
</h3> | ||
<Button color="red" class="me-2" on:click={deleteList}>Ja, ich bin sicher</Button> | ||
<Button color="alternative">Nein, abbrechen</Button> | ||
</div> | ||
</Modal> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
// place files you want to import through the `$lib` alias in this folder. | ||
export { default as getSlug } from 'speakingurl'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.