88 lines
2.0 KiB
Svelte
88 lines
2.0 KiB
Svelte
<script>
|
|
import { goto } from '$app/navigation';
|
|
import { page } from '$app/stores';
|
|
|
|
import {
|
|
Button,
|
|
Icon,
|
|
} from 'sveltestrap';
|
|
|
|
let gongs = [
|
|
{
|
|
id: 1,
|
|
title: "Coq",
|
|
},
|
|
{
|
|
id: 2,
|
|
title: "Marseillaise",
|
|
enabled: true,
|
|
},
|
|
{
|
|
id: 3,
|
|
title: "Trompette de l'armée française",
|
|
},
|
|
];
|
|
|
|
function chooseGong(gong) {
|
|
gongs = gongs.map((g) => {
|
|
g.enabled = g.id == gong.id
|
|
return g;
|
|
})
|
|
}
|
|
|
|
export let flush = false;
|
|
export let edit = false;
|
|
|
|
export { className as class };
|
|
let className = '';
|
|
</script>
|
|
|
|
<div class="d-flex justify-content-between align-items-center" class:px-2={flush}>
|
|
<h2>
|
|
Gongs
|
|
</h2>
|
|
<div>
|
|
{#if !edit}
|
|
<Button
|
|
href="musiks/gongs"
|
|
color="outline-info"
|
|
size="sm"
|
|
>
|
|
<Icon name="pencil" />
|
|
</Button>
|
|
{/if}
|
|
<Button
|
|
href="musiks/gongs/new"
|
|
color="outline-primary"
|
|
size="sm"
|
|
>
|
|
<Icon name="plus-lg" />
|
|
</Button>
|
|
<Button
|
|
color="outline-dark"
|
|
size="sm"
|
|
>
|
|
<Icon name="arrow-clockwise" />
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
<div class="list-group {className}" class:list-group-flush={flush}>
|
|
{#each gongs as gong (gong.id)}
|
|
<button
|
|
type="button"
|
|
class="list-group-item list-group-item-action"
|
|
class:active={(edit && $page.url.pathname.indexOf('/gongs/') !== -1 && $page.params.gid == gong.id) || (!edit && gong.enabled)}
|
|
aria-current="true"
|
|
on:click={() => {
|
|
if (edit) {
|
|
goto('musiks/gongs/' + gong.id);
|
|
} else {
|
|
chooseGong(gong);
|
|
}
|
|
}}
|
|
>
|
|
{gong.title}
|
|
</button>
|
|
{/each}
|
|
</div>
|