This commit is contained in:
Peter Maquiran
2023-06-13 12:27:27 +01:00
parent 5db8d1f1e5
commit fced941d55
4 changed files with 70 additions and 55 deletions
@@ -313,7 +313,7 @@ export class EditEventPage implements OnInit {
}
save() {
async save() {
this.injectValidation()
this.runValidation()
@@ -340,7 +340,6 @@ export class EditEventPage implements OnInit {
await this.eventsService.changeAgenda(body).toPromise();
} catch (error) {}
finally {
this.goBack();
}
}
@@ -363,7 +362,6 @@ export class EditEventPage implements OnInit {
await this.eventsService.changeAgenda(body).toPromise();
} catch (error) {}
finally {
this.goBack();
}
}
@@ -379,42 +377,50 @@ export class EditEventPage implements OnInit {
this.isEventEdited = true;
this.modalController.dismiss(this.isEventEdited);
await this.saveDocument()
this.saveDocument()
this.goBack();
}
saveDocument() {
async saveDocument() {
this.loadedEventAttachments.forEach((e) => {
try {
for( let e of this.loadedEventAttachments) {
const id: any = e.Id
const remove = e['remove']
const id: any = e.Id
const remove = e['remove']
if ( id == 'add') {
//data.selected
const DocumentToSave = {
SourceTitle: e.SourceName,
ParentId: this.postEvent.EventId,
Source: '1',
SourceId: e.SourceId,
ApplicationId: e.ApplicationId.toString(),
Id: '0',
Link: '',
SerialNumber: '',
};
if ( id == 'add') {
//data.selected
const DocumentToSave = {
SourceTitle: e.SourceName,
ParentId: this.postEvent.EventId,
Source: '1',
SourceId: e.SourceId,
ApplicationId: e.ApplicationId.toString(),
Id: '0',
Link: '',
SerialNumber: '',
};
await this.attachmentsService.setEventAttachmentById(DocumentToSave).toPromise();
this.attachmentsService.setEventAttachmentById(DocumentToSave).subscribe(()=>{
this.getAttachments(this.postEvent.EventId);
});
} else if(remove) {
this.attachmentsService.deleteEventAttachmentById(e.Id).subscribe( res=> {})
} else if(remove) {
await this.attachmentsService.deleteEventAttachmentById(e.Id).toPromise()
}
}
} catch (error) {
})
} finally {
}
this.modalController.dismiss({
isEventEdited: this.isEventEdited,
postEvent: this.postEvent
});
}