Loading portal/static/js/components/pieces/Agenda.mjs +29 −14 Changes for portal/static/js/components/pieces/Agenda.mjs: 29 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import { agenda } from "../../model/Agenda.mjs" import { StatusPill } from "./StatusPill.mjs" let isAgendaEditable = false let isSaving = false export const Agenda = { view(vnode) { Loading @@ -20,7 +21,10 @@ export const Agenda = { "div", item.name, item.taiga && m(StatusPill, { item }), m(StatusPill, { item, disabled: isSaving, }), ) : item.name, ), Loading @@ -28,29 +32,40 @@ export const Agenda = { ) : m("span.message", vnode.attrs.message), ]), isAgendaEditable ? [ m( getAction(), ) }, } function getAction() { if (isSaving) { return m( ".action.disabled", m("i.fa-solid.fa-circle-notch.fa-spin"), "Wird gespeichert...", ) } else if (isAgendaEditable) { return m( "a.action", { onclick: async () => { // TODO Disable and maybe even show a spinner or something? isSaving = true await agenda.save() isSaving = false isAgendaEditable = false }, }, m("i.fa-solid.fa-floppy-disk"), agenda.changes.length > 0 ? "Speichern" : "Ohne Änderungen speichern", ), ] : m( agenda.changes.length > 0 ? "Speichern" : "Ohne Änderungen speichern", ) } else { return m( "a.action", { onclick: () => (isAgendaEditable = true), }, { onclick: () => (isAgendaEditable = true) }, m("i.fa-solid.fa-pen-to-square"), "Bearbeiten", ), ) }, } } portal/static/js/components/pieces/Pill.mjs +7 −5 Changes for portal/static/js/components/pieces/Pill.mjs: 7 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ */ export const Pill = { view(vnode) { const model = vnode.attrs.model const { model, disabled } = vnode.attrs return m( "ul.pill", Loading @@ -25,12 +25,14 @@ export const Pill = { "li", { onclick: () => { if (disabled) return model.active = it.id }, class: (model.active === it.id ? "active" : "") + " " + (it.class || ""), class: [ model.active === it.id ? "active" : "", it.class || "", disabled ? "disabled" : "", ].join(" "), title: it.title, }, it.label, Loading portal/static/js/components/pieces/StatusPill.mjs +2 −0 Changes for portal/static/js/components/pieces/StatusPill.mjs: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import { Pill } from "./Pill.mjs" export const StatusPill = { view(vnode) { const agendaItem = vnode.attrs.item const disabled = vnode.attrs.disabled return m(Pill, { items: [ Loading Loading @@ -45,6 +46,7 @@ export const StatusPill = { agendaItem.taiga.status = id }, }, disabled, }) }, } Loading
portal/static/js/components/pieces/Agenda.mjs +29 −14 Changes for portal/static/js/components/pieces/Agenda.mjs: 29 added lines, 14 removed lines. Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import { agenda } from "../../model/Agenda.mjs" import { StatusPill } from "./StatusPill.mjs" let isAgendaEditable = false let isSaving = false export const Agenda = { view(vnode) { Loading @@ -20,7 +21,10 @@ export const Agenda = { "div", item.name, item.taiga && m(StatusPill, { item }), m(StatusPill, { item, disabled: isSaving, }), ) : item.name, ), Loading @@ -28,29 +32,40 @@ export const Agenda = { ) : m("span.message", vnode.attrs.message), ]), isAgendaEditable ? [ m( getAction(), ) }, } function getAction() { if (isSaving) { return m( ".action.disabled", m("i.fa-solid.fa-circle-notch.fa-spin"), "Wird gespeichert...", ) } else if (isAgendaEditable) { return m( "a.action", { onclick: async () => { // TODO Disable and maybe even show a spinner or something? isSaving = true await agenda.save() isSaving = false isAgendaEditable = false }, }, m("i.fa-solid.fa-floppy-disk"), agenda.changes.length > 0 ? "Speichern" : "Ohne Änderungen speichern", ), ] : m( agenda.changes.length > 0 ? "Speichern" : "Ohne Änderungen speichern", ) } else { return m( "a.action", { onclick: () => (isAgendaEditable = true), }, { onclick: () => (isAgendaEditable = true) }, m("i.fa-solid.fa-pen-to-square"), "Bearbeiten", ), ) }, } }
portal/static/js/components/pieces/Pill.mjs +7 −5 Changes for portal/static/js/components/pieces/Pill.mjs: 7 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ */ export const Pill = { view(vnode) { const model = vnode.attrs.model const { model, disabled } = vnode.attrs return m( "ul.pill", Loading @@ -25,12 +25,14 @@ export const Pill = { "li", { onclick: () => { if (disabled) return model.active = it.id }, class: (model.active === it.id ? "active" : "") + " " + (it.class || ""), class: [ model.active === it.id ? "active" : "", it.class || "", disabled ? "disabled" : "", ].join(" "), title: it.title, }, it.label, Loading
portal/static/js/components/pieces/StatusPill.mjs +2 −0 Changes for portal/static/js/components/pieces/StatusPill.mjs: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import { Pill } from "./Pill.mjs" export const StatusPill = { view(vnode) { const agendaItem = vnode.attrs.item const disabled = vnode.attrs.disabled return m(Pill, { items: [ Loading Loading @@ -45,6 +46,7 @@ export const StatusPill = { agendaItem.taiga.status = id }, }, disabled, }) }, }