This commit is contained in:
2023-12-24 23:00:20 +01:00
parent c5effd8f7f
commit a2687083e0
16 changed files with 91 additions and 38 deletions

View File

@@ -40,7 +40,7 @@
<td>{t("elo.name")}</td>
<td>{t("elo.elo")}</td>
</tr>
{#each data as player, i}
{#each data as player, i (player.id)}
<tr>
<td>{`${i + 1}.`}</td>
<td>{player.name}</td>

View File

@@ -49,14 +49,14 @@
<div>
<table>
<tr class="font-bold border-b">
{#each Array(rows) as _}
{#each Array(rows) as i (i)}
<td>{t("announcements.table.team")}</td>
<td>{t("announcements.table.points")}</td>
{/each}
</tr>
{#each window(teamPoints, rows) as teams}
<tr>
{#each teams as team}
{#each teams as team (team.team.id)}
<td>{team.team.name}</td>
<td>{team.points}</td>
{/each}

View File

@@ -40,7 +40,7 @@
<div class="overflow-y-auto p-3 text-sm w-60" slot="header">
<Search bind:value={searchValue} on:focus={() => open = true} on:keydown={() => open = true}/>
</div>
{#each filteredItems as item}
{#each filteredItems as item (item)}
<button on:click={() => selectItem(item)} class="rounded p-2 hover:bg-gray-100 dark:hover:bg-gray-600 w-full cursor-pointer border-b border-b-gray-600">
{item.name}
</button>

View File

@@ -102,7 +102,7 @@
</div>
{#if filteredPlayers.length < 100}
<ul class="flex-1 overflow-scroll">
{#each filteredPlayers as player}
{#each filteredPlayers as player (player.id)}
<li class="p-4 transition-colors hover:bg-gray-700 cursor-pointer" class:text-orange-500={player.id === selectedPlayer} on:click|preventDefault={() => selectedPlayer = player.id}>
{player.name}
</li>

View File

@@ -216,7 +216,7 @@
<Checkbox class="ml-2 text-center" checked={group.fights.every(gf => selectedFights.has(gf))} on:click={() => cycleGroup(group.fights)}/>
<h1 class="ml-4 text-2xl">{group.group ?? "Ungrouped"}</h1>
</div>
{#each group.fights.sort((a, b) => a.start - b.start) as fight, i}
{#each group.fights.sort((a, b) => a.start - b.start) as fight, i (fight.id)}
<FightCard {fight} {i} {data} selected={selectedFights.has(fight)}
on:select={() => {
if (selectedFights.has(fight)) {

View File

@@ -24,7 +24,7 @@
export let data: ExtendedEvent;
</script>
<div class="m-4">
{#each data.teams as team}
{#each data.teams as team (team.id)}
<div class="flex flex-row my-2">
<Avatar size="lg">{team.kuerzel}</Avatar>
<div class="m-2">

View File

@@ -58,7 +58,7 @@
redTeam: parseInt(redTeam),
start: dayjs(start),
map,
kampfleiter: parseInt(kampfleiter),
kampfleiter: parseInt(kampfleiter!),
group,
});
reset()

View File

@@ -37,12 +37,12 @@
function dragToNewGroup(event: CustomEvent<DragEvent>) {
event.detail.preventDefault();
let teamId = parseInt(event.detail.dataTransfer.getData("team"));
let teamId = parseInt(event.detail.dataTransfer!.getData("team"));
groups = [...groups.map(value => value.filter(value1 => value1 != teamId)), [teamId]].filter(value => value.length > 0);
}
function teamDragStart(ev: DragEvent, team: Team) {
ev.dataTransfer.setData("team", team.id.toString())
ev.dataTransfer!.setData("team", team.id.toString())
}
let resetDragOver = false;
@@ -54,14 +54,14 @@
function dropReset(ev: DragEvent) {
ev.preventDefault();
let teamId = parseInt(ev.dataTransfer.getData("team"));
let teamId = parseInt(ev.dataTransfer!.getData("team"));
groups = groups.map(group => group.filter(team => team !== teamId)).filter(group => group.length > 0);
resetDragOver = false;
}
function dropGroup(ev: CustomEvent<DragEvent>, groupIndex: number) {
ev.preventDefault();
let teamId = parseInt(ev.detail.dataTransfer.getData("team"));
let teamId = parseInt(ev.detail.dataTransfer!.getData("team"));
groups = groups.map((group, i) => i === groupIndex ? [...group.filter(value => value != teamId), teamId] : group.filter(value => value != teamId)).filter(group => group.length > 0);
}
@@ -104,8 +104,8 @@
groups = groups.filter(group => group.length > 0);
}
function generateGroups(groups): number[][][][] {
let groupFights = [];
function generateGroups(groups: number[][]): number[][][][] {
const groupFights: number[][][][] = [];
groups.forEach((group) => {
let round = group.length + (group.length % 2) - 1;
let groupFight = [];
@@ -138,8 +138,8 @@
groupsFights.forEach((group, i) => {
group.forEach((round, j) => {
round.forEach(async (fight, k) => {
let blueTeam = teams.get(fight[0])
let redTeam = teams.get(fight[1])
const blueTeam = teams.get(fight[0])!
const redTeam = teams.get(fight[1])!
await $fightRepo.createFight(data.event.id, {
blueTeam: blueTeam.id,
@@ -160,7 +160,7 @@
<div class="flex justify-between">
<div id="reseter" class:border-white={resetDragOver} class="flex m-2 bg-gray-800 w-fit p-2 border border-gray-700 rounded ml-4 h-20 pt-6 relative" on:dragover={resetDragOverEvent} on:dragleave={() => resetDragOver = false} on:drop={dropReset} role="group">
{#each teamsNotInGroup as team}
{#each teamsNotInGroup as team (team.id)}
<TeamChip {team} on:dragstart={ev => teamDragStart(ev, team)}/>
{/each}
</div>
@@ -171,10 +171,10 @@
</div>
<div class="flex m-4 gap-4 border-b border-gray-700 pb-4">
{#each groups as group, i}
{#each groups as group, i (i)}
<DragAcceptor on:drop={ev => dropGroup(ev, i)}>
<h1>Group {i + 1} ({group.length})</h1>
{#each group as teamId}
{#each group as teamId (teamId)}
<TeamChip team={teams.get(teamId)} on:dragstart={ev => teamDragStart(ev, teams.get(teamId))}/>
{/each}
</DragAcceptor>

View File

@@ -81,7 +81,7 @@
</svelte:fragment>
<span on:click={() => dispatch("reset")} class="hover:underline hover:cursor-pointer text-2xl">{t("dashboard.schematic.home")}</span>
</BreadcrumbItem>
{#each schematics.breadcrumbs as bread}
{#each schematics.breadcrumbs as bread (bread.id)}
<BreadcrumbItem>
<svelte:fragment slot="icon">
<ChevronDoubleRightOutline class="w-4 h-4 mx-2 dark:text-white" />
@@ -141,7 +141,7 @@
<th></th>
</tr>
{/if}
{#each pagedSchematics as schem}
{#each pagedSchematics as schem (schem.id)}
<SchematicListTile schem={schem} players={schematics.players} on:click={schemListClick(schem.type == null, schem.id)} />
{/each}
</tbody>

View File

@@ -18,7 +18,7 @@
*/
export function window<T>(arr: T[], len: number): T[][] {
let result: T[][] = [];
const result: T[][] = [];
for (let i = 0; i < arr.length; i += len) {
result.push(arr.slice(i, i + len));
}