Add button to delete tracks and gongs

This commit is contained in:
nemunaire 2022-10-15 11:13:45 +02:00
parent e9a906fbfb
commit 46e8d1a1d2
2 changed files with 42 additions and 0 deletions

View File

@ -1,15 +1,25 @@
<script> <script>
import { goto } from '$app/navigation';
import { page } from '$app/stores'; import { page } from '$app/stores';
import { import {
Container, Container,
Input, Input,
Icon,
ListGroup, ListGroup,
ListGroupItem, ListGroupItem,
Spinner, Spinner,
} from 'sveltestrap'; } from 'sveltestrap';
import { getGong } from '$lib/gong'; import { getGong } from '$lib/gong';
import { gongs } from '$lib/stores/gongs';
function deleteThis(gong) {
gong.delete().then(() => {
gongs.refresh();
goto('musiks/gongs/');
})
}
</script> </script>
{#await getGong($page.params.gid)} {#await getGong($page.params.gid)}
@ -35,5 +45,17 @@
<span class="text-muted">{gong.id}</span> <span class="text-muted">{gong.id}</span>
</ListGroupItem> </ListGroupItem>
</ListGroup> </ListGroup>
<ListGroup class="my-2 text-center">
<ListGroupItem
action
tag="button"
class="text-danger fw-bold"
on:click={() => deleteThis(gong)}
>
<Icon name="trash" />
Supprimer ce gong
</ListGroupItem>
</ListGroup>
</Container> </Container>
{/await} {/await}

View File

@ -12,6 +12,14 @@
} from 'sveltestrap'; } from 'sveltestrap';
import { getTrack } from '$lib/track'; import { getTrack } from '$lib/track';
import { tracks } from '$lib/stores/tracks';
function deleteThis(track) {
track.delete().then(() => {
tracks.refresh();
goto('musiks/tracks/');
})
}
</script> </script>
{#await getTrack($page.params.tid)} {#await getTrack($page.params.tid)}
@ -37,5 +45,17 @@
<span class="text-muted">{track.id}</span> <span class="text-muted">{track.id}</span>
</ListGroupItem> </ListGroupItem>
</ListGroup> </ListGroup>
<ListGroup class="my-2 text-center">
<ListGroupItem
action
tag="button"
class="text-danger fw-bold"
on:click={() => deleteThis(track)}
>
<Icon name="trash" />
Supprimer cette piste
</ListGroupItem>
</ListGroup>
</Container> </Container>
{/await} {/await}