feat: enable updating gottesdienste

This commit is contained in:
2025-03-21 21:18:25 +01:00
parent 4d92b911b7
commit 3caf5a0c13
5 changed files with 73 additions and 27 deletions
+16 -9
View File
@@ -88,21 +88,27 @@ const sortedGottesdienste = computed(() => {
})
})
async function createGottesdienst(){
async function createGottesdienst(gottesdienstId?: number){
let gottesdienstRef = plan.gottesdienste.find(gottesdienst => gottesdienst.id == gottesdienstId)
let gottesdienst = gottesdienstRef ? Object.assign({}, toRaw(gottesdienstRef)) : null;
Dialogs.createDialog(CreateGottesdienstDialog, {
onPositive() {},
onNegative() {},
onDismiss() {}
}, {
planId: parseInt(planId.value as string),
gottesdienst,
planId: parseInt(planId.value as unknown),
async onCreate(godi: Gottesdienst) {
const newGodi = await API.addGottesdienst(
godi.name,
godi.date,
godi.attendance,
godi.planId
)
plan.gottesdienste.push(newGodi)
if(godi.id == -1) {
const newGodi = await API.addGottesdienstNew(godi)
godi.id = newGodi.id
plan.gottesdienste.push(godi)
} else {
await API.updateGottesdienst(godi)
const index = plan.gottesdienste.findIndex(g => g.id == godi.id)
plan.gottesdienste.splice(index, 1)
plan.gottesdienste.push(godi)
}
}
})
}
@@ -293,6 +299,7 @@ async function createMinistrant(ministrantId?: number) {
:small-mode="editPlanAdmin"
@added="addGodi"
@delete="deleteGottedienst"
@edit="createGottesdienst"
@toggle-mark="toggleMark"
@end-edit="editPlanAdmin = false"
@reset-password="resetPassword"