Verified Commit 4f27fef8 authored by Jakob Moser's avatar Jakob Moser
Browse files

Change editability impl, run save on save pressed

parent f1ca2ca0
Loading
Loading
Loading
Loading
+22 −4
Changes for portal/static/js/components/pieces/Agenda.mjs: 22 added lines, 4 removed lines.
Original line number Diff line number Diff line
import { agenda } from "../../model/Agenda.mjs"
import { StatusPill } from "./StatusPill.mjs"

let isAgendaEditable = false

export const Agenda = {
    view(vnode) {
        return m(
@@ -12,7 +15,7 @@ export const Agenda = {
                          vnode.attrs.items.map(item =>
                              m(
                                  "li",
                                  this.editable
                                  isAgendaEditable
                                      ? m(
                                            "div",
                                            item.name,
@@ -25,13 +28,28 @@ export const Agenda = {
                      )
                    : m("span.message", vnode.attrs.message),
            ]),
            isAgendaEditable
                ? [
                      m(
                          "a.action",
                          {
                    href: "https://fachschaft.cl.uni-heidelberg.de/todo",
                    target: "_blank",
                              onclick: async () => {
                                  // TODO Disable and maybe even show a spinner or something?
                                  await agenda.save()
                                  isAgendaEditable = false
                              },
                          },
                          m("i.fa-solid.fa-floppy-disk"),
                          "Speichern",
                      ),
                  ]
                : m(
                      "a.action",
                      {
                          onclick: () => (isAgendaEditable = true),
                      },
                [m("i.fa-solid.fa-list-check"), "Bearbeiten im Todo-Tool"],
                      m("i.fa-solid.fa-pen-to-square"),
                      "Bearbeiten",
                  ),
        )
    },