implement session deletion button in session list
This commit is contained in:
parent
7f393276a8
commit
9561d7a05f
@ -25,6 +25,7 @@ export default class BaseView {
|
|||||||
return m(SessionList, {
|
return m(SessionList, {
|
||||||
models: this.#model.sessions,
|
models: this.#model.sessions,
|
||||||
onSelect: (session) => this.#model.current = session,
|
onSelect: (session) => this.#model.current = session,
|
||||||
|
onDelete: (id, index) => this.#model.deleteSession(id, index),
|
||||||
});
|
});
|
||||||
|
|
||||||
return m("p", "Wart kurz, i lad grad die Spiele…");
|
return m("p", "Wart kurz, i lad grad die Spiele…");
|
||||||
@ -159,4 +160,10 @@ class BaseViewModel {
|
|||||||
this.loadAllSessions();
|
this.loadAllSessions();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
deleteSession(id, index) {
|
||||||
|
SessionRepo.delete(id);
|
||||||
|
if (this.#sessions[index] === undefined || this.#sessions[index].id !== id)
|
||||||
|
return;
|
||||||
|
this.#sessions.splice(index, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,15 +4,20 @@ import Session from "/models/session.js";
|
|||||||
|
|
||||||
export default class SessionList {
|
export default class SessionList {
|
||||||
/** @param {{ attrs: { models: Session[] } }} param The sessions to show. */
|
/** @param {{ attrs: { models: Session[] } }} param The sessions to show. */
|
||||||
view({attrs: { models, onSelect } }) {
|
view({attrs: { models, onSelect, onDelete } }) {
|
||||||
return m("section.wb-session-list", [
|
return m("section.wb-session-list", [
|
||||||
m("ol", [
|
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.theirname", s.theirTeam !== "" ? s.theirTeam : "Se"),
|
||||||
m("span.ourname", s.ourTeam !== "" ? s.ourTeam : "Mia"),
|
m("span.ourname", s.ourTeam !== "" ? s.ourTeam : "Mia"),
|
||||||
m("span.theirpoints", "•".repeat(s.result.theirPoints)),
|
m("span.theirpoints", "•".repeat(s.result.theirPoints)),
|
||||||
m("span.ourpoints", "•".repeat(s.result.ourPoints)),
|
m("span.ourpoints", "•".repeat(s.result.ourPoints)),
|
||||||
m("div.actions",
|
m("div.actions",
|
||||||
|
m(
|
||||||
|
"button.wb-button.-slim._positioned",
|
||||||
|
{ onclick: () => onDelete(s.id, i) },
|
||||||
|
"löschn"
|
||||||
|
),
|
||||||
m(
|
m(
|
||||||
m.route.Link,
|
m.route.Link,
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user