diff --git a/src/app/shared/agenda/edit-event/edit-event.page.html b/src/app/shared/agenda/edit-event/edit-event.page.html index 797c03bea..f60650c94 100644 --- a/src/app/shared/agenda/edit-event/edit-event.page.html +++ b/src/app/shared/agenda/edit-event/edit-event.page.html @@ -261,8 +261,8 @@ -
- +
+

@@ -270,7 +270,7 @@ Correspondencia AccoesPresidenciais ArquivoDespachoElect - + diff --git a/src/app/shared/agenda/edit-event/edit-event.page.ts b/src/app/shared/agenda/edit-event/edit-event.page.ts index cd98e1da2..961134570 100644 --- a/src/app/shared/agenda/edit-event/edit-event.page.ts +++ b/src/app/shared/agenda/edit-event/edit-event.page.ts @@ -30,7 +30,7 @@ export class EditEventPage implements OnInit { segment:string = "true"; eventAttendees: EventPerson[]; // minDate: string; - loadedEventAttachments: Attachment[]; + loadedEventAttachments: Attachment[]=[]; public date: any; public disabled = false; @@ -221,6 +221,41 @@ export class EditEventPage implements OnInit { this.clearPostEvent.emit(); this.deleteTemporaryData(); this.close(); + + 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 addParticipants() { @@ -300,12 +335,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 + } + + } @@ -323,21 +363,25 @@ export class EditEventPage implements OnInit { 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: '', - }; + } + + console.log( this.loadedEventAttachments) + this.loadedEventAttachments.push(ApplicationIdDocumentToSave) - await this.attachmentsService.setEventAttachmentById(DocumentToSave).subscribe(()=>{ - this.getAttachments(this.postEvent.EventId); - }); } }); diff --git a/src/app/shared/agenda/event-list/event-list.page.ts b/src/app/shared/agenda/event-list/event-list.page.ts index 15ec45d77..91fe48d1c 100644 --- a/src/app/shared/agenda/event-list/event-list.page.ts +++ b/src/app/shared/agenda/event-list/event-list.page.ts @@ -27,7 +27,6 @@ export class EventListPage implements OnInit { @Output() approveEventDismiss = new EventEmitter(); - constructor( private processes:ProcessesService, private modalController: ModalController,