mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
Improve attaching new files
This commit is contained in:
@@ -38,7 +38,7 @@ export class EditEventPage implements OnInit {
|
||||
caller:string;
|
||||
|
||||
|
||||
loadedEventAttachments: Attachment[];
|
||||
loadedEventAttachments: Attachment[] = [];
|
||||
taskParticipants: any = [];
|
||||
taskParticipantsCc: any = [];
|
||||
adding: "intervenient" | "CC" = "intervenient";
|
||||
@@ -185,6 +185,40 @@ export class EditEventPage implements OnInit {
|
||||
this.toastService.badRequest()
|
||||
}
|
||||
|
||||
this.saveDocument()
|
||||
}
|
||||
|
||||
|
||||
saveDocument() {
|
||||
|
||||
this.loadedEventAttachments.forEach((e)=>{
|
||||
|
||||
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: '',
|
||||
};
|
||||
|
||||
this.attachmentsService.setEventAttachmentById(DocumentToSave).subscribe(()=>{
|
||||
this.getAttachments(this.postEvent.EventId);
|
||||
});
|
||||
|
||||
} else if(remove) {
|
||||
this.attachmentsService.deleteEventAttachmentById(e.Id).subscribe( res=> {})
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async openAttendees() {
|
||||
@@ -254,12 +288,17 @@ export class EditEventPage implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
deleteAttachment(attachmentID: string) {
|
||||
deleteAttachment(attachmentID: string, index) {
|
||||
|
||||
this.attachmentsService.deleteEventAttachmentById(attachmentID).subscribe(
|
||||
res=>{
|
||||
this.loadedEventAttachments = this.loadedEventAttachments.filter(e=> e.Id.toString() != attachmentID);
|
||||
})
|
||||
const id: any = this.loadedEventAttachments[index].Id
|
||||
|
||||
if(id == 'add') {
|
||||
this.loadedEventAttachments = this.loadedEventAttachments.filter((e,i)=> i!=index)
|
||||
} else {
|
||||
this.loadedEventAttachments[index]['remove'] = true
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async getDoc() {
|
||||
@@ -273,27 +312,30 @@ export class EditEventPage implements OnInit {
|
||||
}
|
||||
});
|
||||
await modal.present();
|
||||
modal.onDidDismiss().then( async (res)=>{
|
||||
if(res){
|
||||
modal.onDidDismiss().then( async (res)=> {
|
||||
if(res) {
|
||||
const data = res.data;
|
||||
//data.selected
|
||||
const DocumentToSave = {
|
||||
SourceTitle: data.selected.Assunto,
|
||||
|
||||
const ApplicationIdDocumentToSave: any = {
|
||||
SourceName: data.selected.Assunto,
|
||||
ParentId: this.postEvent.EventId,
|
||||
Source: '1',
|
||||
SourceId: data.selected.Id,
|
||||
Stakeholders: false,
|
||||
ApplicationId: data.selected.ApplicationType.toString(),
|
||||
Id: '0',
|
||||
CreateDate: false,
|
||||
// needed to attach this document
|
||||
Id: 'add',
|
||||
SourceTitle: data.selected.Assunto,
|
||||
Source: '1',
|
||||
Link: '',
|
||||
SerialNumber: '',
|
||||
};
|
||||
}
|
||||
|
||||
await this.attachmentsService.setEventAttachmentById(DocumentToSave).subscribe(()=>{
|
||||
this.getAttachments(this.postEvent.EventId);
|
||||
});
|
||||
console.log( this.loadedEventAttachments)
|
||||
this.loadedEventAttachments.push(ApplicationIdDocumentToSave)
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user