feat: enable updating gottesdienste
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user