1
0

implement session deletion button in session list

This commit is contained in:
Adrian Wannenmacher 2026-03-09 20:49:04 +01:00
parent 7f393276a8
commit 9561d7a05f
Signed by: tfld
GPG Key ID: 19D986ECB1E492D5
2 changed files with 14 additions and 2 deletions

View File

@ -25,6 +25,7 @@ export default class BaseView {
return m(SessionList, {
models: this.#model.sessions,
onSelect: (session) => this.#model.current = session,
onDelete: (id, index) => this.#model.deleteSession(id, index),
});
return m("p", "Wart kurz, i lad grad die Spiele…");
@ -159,4 +160,10 @@ class BaseViewModel {
this.loadAllSessions();
};
deleteSession(id, index) {
SessionRepo.delete(id);
if (this.#sessions[index] === undefined || this.#sessions[index].id !== id)
return;
this.#sessions.splice(index, 1);
}
}

View File

@ -4,15 +4,20 @@ import Session from "/models/session.js";
export default class SessionList {
/** @param {{ attrs: { models: Session[] } }} param The sessions to show. */
view({attrs: { models, onSelect } }) {
view({attrs: { models, onSelect, onDelete } }) {
return m("section.wb-session-list", [
m("ol", [
models.map((s) => m("li.item._alternate._apply", [
models.map((s, i) => m("li.item._alternate._apply", [
m("span.theirname", s.theirTeam !== "" ? s.theirTeam : "Se"),
m("span.ourname", s.ourTeam !== "" ? s.ourTeam : "Mia"),
m("span.theirpoints", "•".repeat(s.result.theirPoints)),
m("span.ourpoints", "•".repeat(s.result.ourPoints)),
m("div.actions",
m(
"button.wb-button.-slim._positioned",
{ onclick: () => onDelete(s.id, i) },
"löschn"
),
m(
m.route.Link,
{