Refactor EventFight handling to include team relation names and update type definitions
SteamWarCI Build successful
SteamWarCI Build successful
This commit is contained in:
@@ -258,10 +258,10 @@
|
||||
{group?.name ?? "Keine Gruppe"}
|
||||
</TableCell>
|
||||
<TableCell class="text-right">
|
||||
<Button variant="ghost" size="icon" onclick={() => openGroupEditDialog(group)}>
|
||||
<Button variant="ghost" size="icon" onclick={() => openGroupEditDialog(group!)}>
|
||||
<EditIcon />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon" onclick={() => openGroupResultsDialog(group)}>
|
||||
<Button variant="ghost" size="icon" onclick={() => openGroupResultsDialog(group!)}>
|
||||
<GroupIcon />
|
||||
</Button>
|
||||
<DropdownMenu>
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
import { Checkbox } from "@components/ui/checkbox";
|
||||
import { renderComponent } from "@components/ui/data-table";
|
||||
import type { ColumnDef } from "@tanstack/table-core";
|
||||
import type { EventFight } from "@type/event.ts";
|
||||
import type { EventFightModel } from "./eventmodel.svelte";
|
||||
|
||||
export const columns: ColumnDef<EventFight> = [
|
||||
export const columns: ColumnDef<EventFightModel>[] = [
|
||||
{
|
||||
id: "auswahl",
|
||||
header: ({ table }) => {
|
||||
@@ -32,7 +32,7 @@ export const columns: ColumnDef<EventFight> = [
|
||||
onCheckedChange: () => {
|
||||
if (!table.getIsSomeRowsSelected() && !table.getIsAllRowsSelected()) {
|
||||
const now = new Date();
|
||||
const rows = table.getRowModel().rows.filter((row) => new Date(row.original.date) > now);
|
||||
const rows = table.getRowModel().rows.filter((row) => new Date(row.original.start) > now);
|
||||
|
||||
if (rows.length > 0) {
|
||||
rows.forEach((row) => {
|
||||
@@ -57,7 +57,7 @@ export const columns: ColumnDef<EventFight> = [
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorFn: (r) => r.blueTeam.name + " vs " + r.redTeam.name,
|
||||
accessorFn: (r) => r.blueTeam.nameWithRelation + " vs " + r.redTeam.nameWithRelation,
|
||||
id: "begegnung",
|
||||
header: "Begegnung",
|
||||
},
|
||||
|
||||
@@ -25,28 +25,44 @@ export class EventModel {
|
||||
private remapFights(v: Array<EventFight>, rels: Array<ResponseRelation>) {
|
||||
return v.map((fight) => {
|
||||
let f = JSON.parse(JSON.stringify(fight)) as EventFight;
|
||||
|
||||
let blueTeamRelation = f.blueTeam.name;
|
||||
let redTeamRelation = f.redTeam.name;
|
||||
|
||||
let relations = rels.filter((relation) => relation.fight === f.id);
|
||||
|
||||
relations.forEach((relation) => {
|
||||
let str = "";
|
||||
if (relation.type === "FIGHT") {
|
||||
str += `${relation.fromPlace === 0 ? "Gewinner" : "Verlierer"} von ${relation.fromFight?.blueTeam.name} vs ${relation.fromFight?.redTeam.name} (${new Date(
|
||||
str = `${relation.fromPlace === 0 ? "Gewinner" : "Verlierer"} von ${relation.fromFight?.blueTeam.name} vs ${relation.fromFight?.redTeam.name} (${new Date(
|
||||
relation.fromFight?.start ?? 0
|
||||
).toLocaleTimeString("de-DE", {
|
||||
timeStyle: "short",
|
||||
})})`;
|
||||
} else {
|
||||
str += `${relation.fromPlace + 1}. Platz von ${relation.fromGroup?.name}`;
|
||||
str = `${relation.fromPlace + 1}. Platz von ${relation.fromGroup?.name}`;
|
||||
}
|
||||
|
||||
if (relation.team === "BLUE") {
|
||||
f.blueTeam.name += ` (${str})`;
|
||||
blueTeamRelation = str;
|
||||
} else {
|
||||
f.redTeam.name += ` (${str})`;
|
||||
redTeamRelation = str;
|
||||
}
|
||||
});
|
||||
|
||||
return f;
|
||||
return {
|
||||
...f,
|
||||
blueTeam: {
|
||||
...f.blueTeam,
|
||||
nameWithRelation: `${f.blueTeam.name} (${blueTeamRelation})`,
|
||||
},
|
||||
redTeam: {
|
||||
...f.redTeam,
|
||||
nameWithRelation: `${f.redTeam.name} (${redTeamRelation})`,
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export type EventFightModel = (typeof EventModel.prototype.fights)[number];
|
||||
|
||||
Reference in New Issue
Block a user