export functitionality

This commit is contained in:
2025-02-19 14:59:12 +01:00
parent fccdcc176e
commit 85248e8c91
5 changed files with 59 additions and 30 deletions

View File

@ -13,7 +13,7 @@
Modal,
} from "flowbite-svelte";
import TourCreator from "./TourCreator.svelte";
import { Link } from "svelte-routing";
import { Link, navigate } from "svelte-routing";
let thingsList: model.Tournament[] = $state([]);
let newThing: boolean = $state(false);
@ -46,9 +46,7 @@
<TableBodyCell>{t.WinnerParticipant.Name}</TableBodyCell>
<TableBodyCell>
<Link class="text-primary-500 underline" to={`/tournament/${t.ID}`}
>Edit</Link
>
<Button onclick={() => navigate(`/tournament/${t.ID}`)}>View</Button>
</TableBodyCell>
</TableBodyRow>
{/each}

View File

@ -28,7 +28,7 @@
function saveMatch(m: model.Match): Promise<void> {
if (matches[matches.length - 1].length == 1) {
tournament.WinnerParticipantID = m.WinnerParticipantID;
tournament.WinnerParticipant = m.WinnerParticipant;
SaveTournament(tournament).then(update);
}
return SaveMatch(m);
@ -71,32 +71,33 @@
</TableHead>
<TableBody>
{#each ms as m}
<TableBodyRow>
<TableBodyRow class="h-20">
<TableBodyCell>
{m.Participant1.Name}
</TableBodyCell>
<TableBodyCell>
{m.Participant2.Name}
</TableBodyCell>
<TableBodyCell>
<TableBodyCell class="w-96">
{#if m.WinnerParticipant.Name == ""}
<Button
class="m-1"
onclick={() => {
m.WinnerParticipant = m.Participant1;
saveMatch(m).then(update);
}}
>
{m.Participant1.Name}
</Button>
<Button
onclick={() => {
m.WinnerParticipantID = m.Participant2ID;
saveMatch(m).then(update);
}}
>
{m.Participant2.Name}
</Button>
<div class="grid grid-cols-2 gap-5">
<Button
onclick={() => {
m.WinnerParticipant = m.Participant1;
saveMatch(m).then(update);
}}
>
{m.Participant1.Name}
</Button>
<Button
onclick={() => {
m.WinnerParticipant = m.Participant2;
saveMatch(m).then(update);
}}
>
{m.Participant2.Name}
</Button>
</div>
{:else}
{m.WinnerParticipant.Name}
{/if}

View File

@ -67,7 +67,6 @@
<TableHeadCell>Name</TableHeadCell>
<TableHeadCell />
<TableHeadCell />
<TableHeadCell />
</TableHead>
<TableBody>
{#each participants as p}
@ -75,7 +74,7 @@
<TableBodyCell>
{p.Name}
</TableBodyCell>
<TableBodyCell>
<TableBodyCell class="w-6">
{#if tournament.Participants.find((pa) => pa.ID == p.ID)}
<Button
onclick={() => {
@ -92,7 +91,7 @@
>
{/if}
</TableBodyCell>
<TableBodyCell>
<TableBodyCell class="w-6">
<Button onclick={() => DeleteParticipat(p).then(update)}
>Delete</Button
>