diff --git a/src/app/pages/agenda/edit-event/edit-event.page.html b/src/app/pages/agenda/edit-event/edit-event.page.html index 9d211078a..51526d5c1 100644 --- a/src/app/pages/agenda/edit-event/edit-event.page.html +++ b/src/app/pages/agenda/edit-event/edit-event.page.html @@ -389,11 +389,11 @@
- +

- {{document.SourceName}} + {{document.subject || document.SourceName || document.sourceName}} @@ -435,7 +435,7 @@ - diff --git a/src/app/pages/agenda/edit-event/edit-event.page.ts b/src/app/pages/agenda/edit-event/edit-event.page.ts index 080736aec..095fa092b 100644 --- a/src/app/pages/agenda/edit-event/edit-event.page.ts +++ b/src/app/pages/agenda/edit-event/edit-event.page.ts @@ -19,6 +19,7 @@ import { HttpErrorHandle } from 'src/app/services/http-error-handle.service' import { environment } from 'src/environments/environment'; import { ContactsService } from 'src/app/services/contacts.service'; import { DomSanitizerService } from 'src/app/services/DomSanitizer.service'; +import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service'; const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { parse: { @@ -89,6 +90,8 @@ export class EditEventPage implements OnInit { sesseionStora = SessionStore environment = environment allDayCheck: boolean = false; + deletedAttachmentsList = []; + addedAttachmentsList = []; constructor( private modalController: ModalController, @@ -101,7 +104,8 @@ export class EditEventPage implements OnInit { public ThemeService: ThemeService, private httpErrorHandle: HttpErrorHandle, private contactsService: ContactsService, - private domSanitazerService: DomSanitizerService + private domSanitazerService: DomSanitizerService, + private agendaDataRepository: AgendaDataRepositoryService ) { /* this.postEvent = new Event(); */ @@ -123,6 +127,8 @@ export class EditEventPage implements OnInit { this.postEvent.Attendees[index].UserType = userData.UserType } + console.log('jhv',this.postEvent.Category) + } @@ -155,15 +161,15 @@ export class EditEventPage implements OnInit { this.isRecurring = "Repete"; } - this.getAttachments(this.postEvent.EventId); - + this.loadedEventAttachments = this.postEvent?.Attachments this.CalendarNameOwnerName = this.eventsService.detectCalendarNameByCalendarId(this.postEvent.CalendarId) this.changeAgenda() } ngOnInit() { - + console.log(this.postEvent?.Attachments) + console.log(this.loadedEventAttachments) window.onresize = (event) => { // if not mobile remove all component if (window.innerWidth >= 1024) { @@ -202,7 +208,7 @@ export class EditEventPage implements OnInit { } cancel() { - this.modalController.dismiss({action:'cancel'}); + this.modalController.dismiss({ action: 'cancel' }); } goBack() { @@ -358,6 +364,59 @@ export class EditEventPage implements OnInit { } } + async save_v2() { + this.injectValidation() + this.runValidation() + + if (this.Form.invalid) { + return false + } + this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc); + try { + + this.agendaDataRepository.updateEvent(this.postEvent.EventId, this.postEvent).subscribe((value) => { + console.log(value) + }, ((error) => { + console.log('edit event error: ', error) + })); + + this.agendaDataRepository.addEventAttendee(this.postEvent.EventId, this.postEvent.Attendees).subscribe((value) => { + console.log(value) + }, ((error) => { + console.log('add Attendee error: ', error) + })); + + + await this.saveDocument() + + if (this.addedAttachmentsList.length > 0) { + this.agendaDataRepository.addEventAttachment(this.postEvent.EventId, this.loadedEventAttachments).subscribe((value) => { + console.log(value) + }, ((error) => { + console.log('add attachment error: ', error) + })); + } + + if (this.deletedAttachmentsList.length > 0) { + this.agendaDataRepository.removeEventAttachment(this.postEvent.EventId, { attachments: this.deletedAttachmentsList }).subscribe((value) => { + console.log(value) + }, ((error) => { + console.log('remove attachment error: ', error) + })); + } + + + this.isEventEdited = true; + this.goBack(); + this.httpErrorHandle.httpsSucessMessagge('Editar evento') + + } catch (error) { + this.httpErrorHandle.httpStatusHandle(error) + console.log('edit: ', error) + } + + } + async save() { @@ -403,7 +462,7 @@ export class EditEventPage implements OnInit { this.httpErrorHandle.httpStatusHandle(error) }); } else { - console.log('edid calendar id',this.postEvent.CalendarId); + console.log('edid calendar id', this.postEvent.CalendarId); this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).subscribe(async () => { if (window['reloadCalendar']) { @@ -568,12 +627,13 @@ export class EditEventPage implements OnInit { deleteAttachment(attachmentID: string, index) { const id: any = this.loadedEventAttachments[index].Id + this.deletedAttachmentsList.push(id) - if (id == 'add') { + /* if (id == 'add') { this.loadedEventAttachments = this.loadedEventAttachments.filter((e, i) => i != index) } else { this.loadedEventAttachments[index]['remove'] = true - } + } */ } @@ -585,6 +645,7 @@ export class EditEventPage implements OnInit { componentProps: { type: 'AccoesPresidenciais & ArquivoDespachoElect', showSearchInput: true, + eventAgenda: true, select: true, } }); @@ -593,7 +654,7 @@ export class EditEventPage implements OnInit { if (res) { const data = res.data; - const ApplicationIdDocumentToSave: any = { + /* const ApplicationIdDocumentToSave: any = { SourceName: data.selected.Assunto, ParentId: this.postEvent.EventId, SourceId: data.selected.Id, @@ -606,11 +667,11 @@ export class EditEventPage implements OnInit { Source: '1', Link: '', SerialNumber: '', - } + } */ - this.loadedEventAttachments.push(ApplicationIdDocumentToSave) - this.postEvent.Attachments = this.loadedEventAttachments; + this.loadedEventAttachments.push(data.selected) + this.addedAttachmentsList.push(data.selected) } }) @@ -642,52 +703,52 @@ export class EditEventPage implements OnInit { } - onCheckboxChange(event: any) { - console.log(this.postEvent.CalendarId) - if (this.allDayCheck) { - this.postEvent.IsAllDayEvent = this.allDayCheck; - this.postEvent.StartDate = this.setAlldayTime(this.postEvent.StartDate) - this.postEvent.EndDate = this.setAlldayTimeEndDate(this.postEvent.EndDate) + onCheckboxChange(event: any) { + console.log(this.postEvent.CalendarId) + if (this.allDayCheck) { + this.postEvent.IsAllDayEvent = this.allDayCheck; + this.postEvent.StartDate = this.setAlldayTime(this.postEvent.StartDate) + this.postEvent.EndDate = this.setAlldayTimeEndDate(this.postEvent.EndDate) - console.log('Recurso ativado!!'); - } else { - this.postEvent.IsAllDayEvent = this.allDayCheck; - this.postEvent.EndDate = this.setAlldayTimeEndDateNotAlday(this.postEvent.EndDate) - console.log('Recurso desativado'); + console.log('Recurso ativado!!'); + } else { + this.postEvent.IsAllDayEvent = this.allDayCheck; + this.postEvent.EndDate = this.setAlldayTimeEndDateNotAlday(this.postEvent.EndDate) + console.log('Recurso desativado'); - } } + } - setAlldayTime(timeToReturn) { - let date: any = new Date(timeToReturn) || new Date(); - let newdate = new Date(); - date.setHours(0) - date.setMinutes(0) - date.setSeconds(0); + setAlldayTime(timeToReturn) { + let date: any = new Date(timeToReturn) || new Date(); + let newdate = new Date(); + date.setHours(0) + date.setMinutes(0) + date.setSeconds(0); - return date - } + return date + } - setAlldayTimeEndDate(timeToReturn) { - let date: any = new Date(timeToReturn) || new Date(); - let newdate = new Date(); - date.setHours(23) - date.setMinutes(59) - date.setSeconds(0); + setAlldayTimeEndDate(timeToReturn) { + let date: any = new Date(timeToReturn) || new Date(); + let newdate = new Date(); + date.setHours(23) + date.setMinutes(59) + date.setSeconds(0); - return date - } + return date + } - setAlldayTimeEndDateNotAlday(timeToReturn) { - let date: any = new Date(timeToReturn) || new Date(); - let newdate = new Date(); - date.setHours(23) - date.setMinutes(0) - date.setSeconds(0); + setAlldayTimeEndDateNotAlday(timeToReturn) { + let date: any = new Date(timeToReturn) || new Date(); + let newdate = new Date(); + date.setHours(23) + date.setMinutes(0) + date.setSeconds(0); - return date - } + return date + } } diff --git a/src/app/pages/agenda/event-actions-popover/event-actions-popover.page.ts b/src/app/pages/agenda/event-actions-popover/event-actions-popover.page.ts index c18a9cef6..80c1fe394 100644 --- a/src/app/pages/agenda/event-actions-popover/event-actions-popover.page.ts +++ b/src/app/pages/agenda/event-actions-popover/event-actions-popover.page.ts @@ -8,6 +8,7 @@ import { ThemeService } from 'src/app/services/theme.service' import { RouteService } from 'src/app/services/route.service'; import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'; import { TaskService } from 'src/app/services/task.service' +import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service'; @Component({ @@ -16,28 +17,29 @@ import { TaskService } from 'src/app/services/task.service' styleUrls: ['./event-actions-popover.page.scss'], }) export class EventActionsPopoverPage implements OnInit { - serialNumber:string; + serialNumber: string; instanceId: string; activityInstanceName: string constructor( private navParams: NavParams, - private processes:ProcessesService, + private processes: ProcessesService, private modalController: ModalController, private popoverController: PopoverController, private toastService: ToastService, private RouteService: RouteService, private httpErrorHandle: HttpErrorHandle, public ThemeService: ThemeService, - public TaskService: TaskService) { - this.serialNumber = this.navParams.get('serialNumber'); - this.instanceId = this.navParams.get('InstanceId'); - this.activityInstanceName = this.navParams.get('InstanceId'); + public TaskService: TaskService, + private agendaDataRepository: AgendaDataRepositoryService) { + this.serialNumber = this.navParams.get('serialNumber'); + this.instanceId = this.navParams.get('InstanceId'); + this.activityInstanceName = this.navParams.get('InstanceId'); } ngOnInit() { window.onresize = (event) => { - if( window.innerWidth >= 800){ + if (window.innerWidth >= 800) { this.popoverController.dismiss(); } }; @@ -55,14 +57,21 @@ export class EventActionsPopoverPage implements OnInit { async approveTask() { let body = { "serialNumber": this.serialNumber, "action": "Aprovar" } - - + const loader = this.toastService.loading() + try { - await this.processes.PostTaskAction(body).toPromise() - this.TaskService.loadEventosParaAprovacao() - this.httpErrorHandle.httpsSucessMessagge('Evento aprovação') - this.goBack(); + /* await this.processes.PostTaskAction(body).toPromise() */ + this.agendaDataRepository.eventToaprovalStatus(this.serialNumber, 'Approved').subscribe((value) => { + console.log(value) + this.TaskService.loadEventosParaAprovacao() + this.httpErrorHandle.httpsSucessMessagge('Evento aprovação') + this.goBack(); + }, ((error) => { + console.log('aprove event error: ', error) + this.httpErrorHandle.httpStatusHandle(error) + })) + } catch (error) { this.httpErrorHandle.httpStatusHandle(error) } @@ -74,8 +83,8 @@ export class EventActionsPopoverPage implements OnInit { async ReenviarTask() { let body = { "serialNumber": this.serialNumber, "action": "Reenviar" } - - + + const loader = this.toastService.loading() try { await this.processes.PostTaskAction(body).toPromise() @@ -93,10 +102,10 @@ export class EventActionsPopoverPage implements OnInit { async emendarTask() { this.closePopover(); - + const modal = await this.modalController.create({ component: EmendMessageModalPage, - componentProps:{ + componentProps: { }, cssClass: 'emend-message-modal', backdropDismiss: false @@ -104,36 +113,42 @@ export class EventActionsPopoverPage implements OnInit { modal.onDidDismiss() - .then( async (res) => { - - - if(res.data.option == 'save') { - let body = { "serialNumber": this.serialNumber, - "action": "Emendar", - "dataFields": { + .then(async (res) => { + + + if (res.data.option == 'save') { + let body = { + "serialNumber": this.serialNumber, + "action": "Emendar", + "dataFields": { "ReviewUserComment": res.data, } } - - + + const loader = this.toastService.loading() - - try { - await this.processes.PostTaskAction(body).toPromise(); - this.httpErrorHandle.httpsSucessMessagge('Rever') - this.TaskService.loadEventosParaAprovacao() - this.goBack(); + + try { + /* await this.processes.PostTaskAction(body).toPromise(); */ + this.agendaDataRepository.eventToaprovalStatus(this.serialNumber, 'Revision').subscribe((value) => { + this.httpErrorHandle.httpsSucessMessagge('Rever') + this.TaskService.loadEventosParaAprovacao() + this.goBack(); + }, ((error) => { + console.log('send event to revision error: ', error) + this.httpErrorHandle.httpStatusHandle(error) + })); } catch (error) { this.httpErrorHandle.httpStatusHandle(error) } finally { loader.remove() } - } else { - - } + } else { - }); + } + + }); await modal.present(); @@ -143,11 +158,16 @@ export class EventActionsPopoverPage implements OnInit { let body = { "serialNumber": this.serialNumber, "action": "Descartar" } const loader = this.toastService.loading(); - try { - await this.processes.PostTaskAction(body).toPromise(); - this.TaskService.loadEventosParaAprovacao() - this.httpErrorHandle.httpsSucessMessagge('Rejeitar') - this.goBack(); + try { + /* await this.processes.PostTaskAction(body).toPromise(); */ + this.agendaDataRepository.eventToaprovalStatus(this.serialNumber, 'Declined').subscribe((value) => { + this.TaskService.loadEventosParaAprovacao() + this.httpErrorHandle.httpsSucessMessagge('Rejeitar') + this.goBack(); + }, ((error) => { + console.log('reject event error: ', error) + this.httpErrorHandle.httpStatusHandle(error) + })) } catch (error) { this.httpErrorHandle.httpStatusHandle(error) } @@ -171,10 +191,10 @@ export class EventActionsPopoverPage implements OnInit { }); - modal.onDidDismiss().then(res => {}); + modal.onDidDismiss().then(res => { }); await modal.present(); } - + } diff --git a/src/app/pages/agenda/view-event/view-event.page.html b/src/app/pages/agenda/view-event/view-event.page.html index 6f3fc63e3..ed41be91e 100644 --- a/src/app/pages/agenda/view-event/view-event.page.html +++ b/src/app/pages/agenda/view-event/view-event.page.html @@ -95,7 +95,7 @@

- {{attach.SourceName || 'Sem título'}} + {{attach.SourceName || attach.subject || attach.sourceName || 'Sem título'}} {{attach.Stakeholders}}

diff --git a/src/app/pages/agenda/view-event/view-event.page.ts b/src/app/pages/agenda/view-event/view-event.page.ts index 12877e975..83fb3601b 100644 --- a/src/app/pages/agenda/view-event/view-event.page.ts +++ b/src/app/pages/agenda/view-event/view-event.page.ts @@ -16,7 +16,7 @@ import { StorageService } from 'src/app/services/storage.service'; import { ThemeService } from 'src/app/services/theme.service' import { RouteService } from 'src/app/services/route.service'; import { SessionStore } from 'src/app/store/session.service'; -import { HttpErrorHandle} from 'src/app/services/http-error-handle.service' +import { HttpErrorHandle } from 'src/app/services/http-error-handle.service' import { AttachmentsService } from 'src/app/services/attachments.service'; import { DateService } from 'src/app/services/date.service'; import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service'; @@ -155,7 +155,7 @@ export class ViewEventPage implements OnInit { // }); // } - openOptions() {} + openOptions() { } close() { this.modalController.dismiss(this.isEventEdited); @@ -194,10 +194,10 @@ export class ViewEventPage implements OnInit { let res = await this.agendaDataRepository.getEventById(this.eventId) - if(res.isOk()) { + if (res.isOk()) { console.log('Loaded Event', res.value) loader.remove() - let changeDate = this.dateService.fixDate(res.value as any) as any + let changeDate = this.dateService.fixDate(res.value as any) as any this.loadedEvent = changeDate as any; this.setTimeZone() } else { @@ -210,36 +210,36 @@ export class ViewEventPage implements OnInit { } - loadEvent1() { - - - if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { - this.eventsService.getEvent(this.eventId).subscribe(res => { - - res = this.dateService.fixDate(res as any) - this.loadedEvent = res; - this.setTimeZone() - // this.addEventToDb(res); - }, (error) => { - }); - } else { - - - if(this.CalendarId) { - this.eventsService.genericGetEvent(this.eventId, this.CalendarId).subscribe(res => { - - res = this.dateService.fixDate(res as any) - this.loadedEvent = res; + /* loadEvent1() { + + + if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + this.eventsService.getEvent(this.eventId).subscribe(res => { + + res = this.dateService.fixDate(res as any) + this.loadedEvent = res; this.setTimeZone() - - }, (error) => { - - }); - } - - } - - } + // this.addEventToDb(res); + }, (error) => { + }); + } else { + + + if(this.CalendarId) { + this.eventsService.genericGetEvent(this.eventId, this.CalendarId).subscribe(res => { + + res = this.dateService.fixDate(res as any) + this.loadedEvent = res; + this.setTimeZone() + + }, (error) => { + + }); + } + + } + + } */ deleteYesOrNo() { this.alertController.create({ @@ -268,7 +268,31 @@ export class ViewEventPage implements OnInit { const loader = this.toastService.loading() - if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { + + console.log(this.loadedEvent.EventId) + this.agendaDataRepository.deleteEvent(this.loadedEvent.EventId).subscribe(async () => { + const alert = await this.alertController.create({ + cssClass: 'my-custom-class', + header: 'Evento removido', + buttons: ['OK'] + }); + + setTimeout(() => { + alert.dismiss(); + }, 1500); + this.goBack(); + this.httpErrorHandle.httpsSucessMessagge('delete event') + }, (error) => { + console.log('delete event error: ', error) + this.httpErrorHandle.httpStatusHandle(error) + }, () => { + loader.remove(); + }); + + + + + /* if (this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') { this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => { const alert = await this.alertController.create({ cssClass: 'my-custom-class', @@ -281,7 +305,7 @@ export class ViewEventPage implements OnInit { }, 1500); this.goBack(); this.httpErrorHandle.httpsSucessMessagge('delete event') - }, () => { }, + }, () => { }, () => { loader.remove(); }); @@ -300,15 +324,15 @@ export class ViewEventPage implements OnInit { }, 1500); this.goBack(); this.httpErrorHandle.httpsSucessMessagge('delete event') - }, (error) => { - this.httpErrorHandle.httpStatusHandle(error) - }, + }, (error) => { + this.httpErrorHandle.httpStatusHandle(error) + }, () => { loader.remove(); - }); + }); - } + } */ } @@ -360,8 +384,8 @@ export class ViewEventPage implements OnInit { if (res) { setTimeout(() => { - /* this.loadEvent(); */ - this.loadEvent1() + this.loadEvent(); + /* this.loadEvent1() */ }, 250); this.isEventEdited = true; console.log('res', res, res.data?.action, 'cancel') @@ -394,13 +418,13 @@ export class ViewEventPage implements OnInit { if (res.data?.action == 'cancel') { setTimeout(() => { - /* this.loadEvent(); */ - this.loadEvent1() + this.loadEvent(); + /* this.loadEvent1() */ }, 250); this.isEventEdited = true; - if(res.data.Attendees?.length >= 1) { + if (res.data.Attendees?.length >= 1) { this.loadedEvent.HasAttachments = true this.getAttachments() } @@ -413,7 +437,7 @@ export class ViewEventPage implements OnInit { }, 250); this.isEventEdited = true; - if(res.data.Attendees?.length >= 1) { + if (res.data.Attendees?.length >= 1) { this.loadedEvent.HasAttachments = true this.getAttachments() } @@ -432,11 +456,11 @@ export class ViewEventPage implements OnInit { getAttachments() { - if(this.loadedEvent.HasAttachments) { - this.attachmentsService.getAttachmentsById(this.loadedEvent.EventId).subscribe(res=>{ + if (this.loadedEvent.HasAttachments) { + this.attachmentsService.getAttachmentsById(this.loadedEvent.EventId).subscribe(res => { this.loadedEvent.Attachments = res; - },((erro) => { + }, ((erro) => { console.error('editgetAttchament', erro) })); } diff --git a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.html b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.html index c7429e29e..7845f5c95 100644 --- a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.html +++ b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.html @@ -95,7 +95,7 @@ *ngFor="let attachment of loadedAttachments" (click)="viewDocument(attachment.DocId, attachment)"> -

{{attachment.Description || 'Sem título'}}

+

{{attachment.sourceName || attachment.Description || 'Sem título'}}

{{attachment.Stakeholders}}{{ attachment.CreateDate | date: 'dd-MM-yyyy HH:mm' }}

diff --git a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts index aa07e5e3b..dae7bef2f 100644 --- a/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts +++ b/src/app/pages/gabinete-digital/event-list/approve-event/approve-event.page.ts @@ -95,15 +95,16 @@ export class ApproveEventPage implements OnInit { } - async getTask () { + async getTask() { const res = await this.AgendaDataRepositoryService.getEventToApproveById(this.serialNumber) - - if(res.isOk()) { + console.log(res) + if (res.isOk()) { this.loadedEvent = res.value; this.today = new Date(res.value.workflowInstanceDataFields.StartDate); // - this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]); + this.customDate = this.days[this.today.getDay()] + ", " + this.today.getDate() + " de " + (this.months[this.today.getMonth()]); + this.loadedAttachments = res.value.Attachments } else { console.log(res.error.status) this.httpErrorHandle.httpStatusHandle(res.error) @@ -117,10 +118,18 @@ export class ApproveEventPage implements OnInit { const loader = this.toastService.loading() try { - await this.processes.PostTaskAction(body).toPromise() - this.goBack(); - this.httpErrorHandle.httpsSucessMessagge('Evento aprovação') - this.TaskService.loadEventosParaAprovacao(); + + this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Approved').subscribe(async (value) => { + + await this.processes.PostTaskAction(body).toPromise() + this.goBack(); + this.httpErrorHandle.httpsSucessMessagge('Evento aprovação') + this.TaskService.loadEventosParaAprovacao(); + + }, ((error) => { + console.log('aprove event error: ', error) + this.httpErrorHandle.httpStatusHandle(error) + })) } catch (error) { this.httpErrorHandle.httpStatusHandle(error) @@ -147,7 +156,7 @@ export class ApproveEventPage implements OnInit { modal.onDidDismiss() .then(async (res) => { - if(res.data.option == 'save') { + if (res.data.option == 'save') { let body = { "serialNumber": serialNumber, @@ -161,14 +170,17 @@ export class ApproveEventPage implements OnInit { const loader = this.toastService.loading() try { - await this.processes.PostTaskAction(body).toPromise() - .catch(() => { + this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Revision').subscribe((value) => { + this.httpErrorHandle.httpsSucessMessagge('Rever') + this.TaskService.loadEventosParaAprovacao(); + this.goBack(); + }, ((error) => { + console.log('send event to revision error: ', error) + this.httpErrorHandle.httpStatusHandle(error) this.offlineManager.storeRequestData('event-listRever', body); - }); - this.httpErrorHandle.httpsSucessMessagge('Rever') - this.TaskService.loadEventosParaAprovacao(); - this.goBack(); + })); + } catch (error) { this.httpErrorHandle.httpStatusHandle(error) } finally { @@ -181,7 +193,7 @@ export class ApproveEventPage implements OnInit { console.log(error) }); - await modal.present(); + await modal.present(); } @@ -190,10 +202,15 @@ export class ApproveEventPage implements OnInit { const loader = this.toastService.loading() try { - await this.processes.PostTaskAction(body).toPromise(); - this.httpErrorHandle.httpsSucessMessagge('Rejeitar') - this.TaskService.loadEventosParaAprovacao(); - this.goBack(); + /* await this.processes.PostTaskAction(body).toPromise(); */ + this.AgendaDataRepositoryService.eventToaprovalStatus(serialNumber, 'Declined').subscribe((value) => { + this.httpErrorHandle.httpsSucessMessagge('Rejeitar') + this.TaskService.loadEventosParaAprovacao(); + this.goBack(); + }, ((error) => { + console.log('reject event error: ', error) + this.httpErrorHandle.httpStatusHandle(error) + })) } catch (error) { this.httpErrorHandle.httpStatusHandle(error) } @@ -262,7 +279,7 @@ export class ApproveEventPage implements OnInit { modal.onDidDismiss().then(async (res) => { - if(res.data.option == 'save') { + if (res.data.option == 'save') { let body = { "serialNumber": serialNumber, @@ -337,7 +354,7 @@ export class ApproveEventPage implements OnInit { this.loadedAttachments = await this.attachmentsService.getAttachmentsById(this.loadedEvent.workflowInstanceDataFields.InstanceId).toPromise(); console.log(this.loadedAttachments) } catch (error) { - console.error('getAttchaments',error) + console.error('getAttchaments', error) } diff --git a/src/app/pages/gabinete-digital/event-list/event-list.page.ts b/src/app/pages/gabinete-digital/event-list/event-list.page.ts index 6d025183a..12191b829 100644 --- a/src/app/pages/gabinete-digital/event-list/event-list.page.ts +++ b/src/app/pages/gabinete-digital/event-list/event-list.page.ts @@ -173,6 +173,7 @@ export class EventListPage implements OnInit { } async LoadToApproveEvents() { + console.log('aprove event') this.showLoader = true; this.skeletonLoader = true diff --git a/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts b/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts index 0d639af8c..07ca9a6cd 100644 --- a/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts +++ b/src/app/services/Repositorys/Agenda/agenda-data-repository.service.ts @@ -25,6 +25,8 @@ export class AgendaDataRepositoryService { try { const result = await this.agendaDataService.getEvent(id).pipe( map((response) => { + console.log('Response',response.data) + console.log('Output',EventMapper.toDomain(response.data)) return EventMapper.toDomain(response.data) }) ).toPromise() @@ -91,7 +93,7 @@ export class AgendaDataRepositoryService { type: this.utils.calendarTypeSeleted(eventData.Category), category: this.utils.calendarCategorySeleted(eventData.CalendarName), attendees: this.utils.attendeesAdded(eventData.Attendees), - attachments: documents, + attachments: this.utils.documentAdded(documents), recurrence: { frequency: 0, occurrences: 0, @@ -130,7 +132,7 @@ export class AgendaDataRepositoryService { } addEventAttachment(id,attachmentData) { - return this.agendaDataService.addEventAttachment(id,attachmentData); + return this.agendaDataService.addEventAttachment(id,{ attachments: this.utils.documentAdded(attachmentData) }); } deleteEvent(eventId) { diff --git a/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts b/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts index 42e439fd6..79a50e27f 100644 --- a/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts +++ b/src/app/services/Repositorys/Agenda/mapper/EventDetailsMapper.ts @@ -25,10 +25,10 @@ export class EventMapper { wxUserId: e.wxUserId, EmailAddress: e.emailAddress, Name: e.name, - IsRequired: e.attendeeType == '0' ? true : false, + IsRequired: e.attendeeType == 'Required', UserType: "GD", // "IsPR": false, - Acknowledgment: e.attendeeType == '0' ? true : false, + attendeeType: e.attendeeType // "RoleDescription": null, // "RoleId": 0 })), diff --git a/src/app/services/Repositorys/Agenda/mapper/EventToApproveDetailsMapper.ts b/src/app/services/Repositorys/Agenda/mapper/EventToApproveDetailsMapper.ts index 40c943dc9..ff2c4f256 100644 --- a/src/app/services/Repositorys/Agenda/mapper/EventToApproveDetailsMapper.ts +++ b/src/app/services/Repositorys/Agenda/mapper/EventToApproveDetailsMapper.ts @@ -72,9 +72,10 @@ export class EventToApproveDetailsMapper { ...dto.attendees.map( e => ({ Name: e.name, EmailAddress: e.emailAddress, - IsRequired: e.attendeeType == '0' ? true : false, + IsRequired: e.attendeeType == 'Required', UserType: "GD", - wxUserId: e.wxUserId + wxUserId: e.wxUserId, + attendeeType: e.attendeeType })) ], //"EventOrganizer": "{\"$type\":\"GabineteDigital.k2RESTidentifier_EventPerson, GabineteDigital, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null\",\"EmailAddress\":\"agenda.mdgpr@gabinetedigital.local\",\"Name\":\"Agenda do Ministro e Director do Gabinete do PR\",\"IsRequired\":true}", @@ -104,6 +105,7 @@ export class EventToApproveDetailsMapper { "Documents": null, "PrivateMessage": null, Attachments: dto.attachments.map( e => ({ + id: e.id, DocId: e.docId, Description: e.sourceName, Stakeholders: '', diff --git a/src/app/services/Repositorys/Agenda/model/eventDTOOutput.ts b/src/app/services/Repositorys/Agenda/model/eventDTOOutput.ts index 4a0827760..a06e68d20 100644 --- a/src/app/services/Repositorys/Agenda/model/eventDTOOutput.ts +++ b/src/app/services/Repositorys/Agenda/model/eventDTOOutput.ts @@ -7,7 +7,7 @@ export const AttachmentInputDTOSchema = z.object({ description: z.string().nullable(), applicationId: z.number().int(), }).strict(); -const EAttendeeTypeDTO = z.enum(["0", "1", "2"]); +const EAttendeeTypeDTO = z.enum(["Required", "Acknowledgment", "Optional"]); const CommentSchema = z.object({ diff --git a/src/app/services/Repositorys/Agenda/utils.ts b/src/app/services/Repositorys/Agenda/utils.ts index 70b03e4c5..70aa303b5 100644 --- a/src/app/services/Repositorys/Agenda/utils.ts +++ b/src/app/services/Repositorys/Agenda/utils.ts @@ -64,10 +64,10 @@ export class Utils { console.log('added doc create event',documents) return documents.map((e) => { return { - docId: parseInt(e.Id), - sourceName: e.Assunto, + docId: e.docId, + sourceName: e.subject || e.sourceNames, description: "", - applicationId: parseInt(JSON.stringify(e.ApplicationType)) + applicationId: e.applicationId }; }); diff --git a/src/app/services/date.service.ts b/src/app/services/date.service.ts index 173602ef0..588180b36 100644 --- a/src/app/services/date.service.ts +++ b/src/app/services/date.service.ts @@ -55,7 +55,7 @@ export class DateService { const month = String(date.getMonth() + 1).padStart(2,'0'); const fullYear = date.getFullYear(); const formattedDate = `${fullYear}-${month}-${_date} 23:59`; - res.EndDate = formattedDate + res.EndDate = new Date(formattedDate).toISOString(); } diff --git a/src/app/shared/agenda/approve-event/approve-event.page.ts b/src/app/shared/agenda/approve-event/approve-event.page.ts index 4798e9164..73d185134 100644 --- a/src/app/shared/agenda/approve-event/approve-event.page.ts +++ b/src/app/shared/agenda/approve-event/approve-event.page.ts @@ -129,9 +129,14 @@ export class ApproveEventPage implements OnInit { const loader = this.toastService.loading() try { - await this.processes.PostTaskAction(body).toPromise() + /* await this.processes.PostTaskAction(body).toPromise() */ + this.agendaDataRepository.eventToaprovalStatus(serialNumber, 'Declined').subscribe((value) => { this.httpErroHandle.httpsSucessMessagge('Rejeitar'); this.TaskService.loadEventosParaAprovacao(); + }, ((error) => { + console.log('reject event error: ', error) + this.httpErroHandle.httpStatusHandle(error) + })) } catch (error) { this.httpErroHandle.httpStatusHandle(error) diff --git a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts index 2b20fb006..364d7c572 100644 --- a/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts +++ b/src/app/shared/agenda/edit-event-to-approve/edit-event-to-approve.page.ts @@ -143,7 +143,7 @@ export class EditEventToApprovePage implements OnInit { } ngOnInit() { - + console.log('here!!!') if (this.restoreTemporaryData()) { this.setOtherData() } else { @@ -384,7 +384,7 @@ export class EditEventToApprovePage implements OnInit { })); if (this.addedAttachmentsList.length > 0) { - this.agendaDataRepository.addEventAttachment(this.eventProcess.serialNumber, { attachments: this.loadedAttachments }).subscribe((value) => { + this.agendaDataRepository.addEventAttachment(this.eventProcess.serialNumber, this.loadedAttachments).subscribe((value) => { console.log(value) }, ((error) => { this.showLoader = false @@ -393,13 +393,13 @@ export class EditEventToApprovePage implements OnInit { } if (this.deletedAttachmentsList.length > 0) { - this.agendaDataRepository.removeEventAttachment(this.eventProcess.serialNumber, { attachments: [] }).subscribe((value) => { - console.log(value) - }, ((error) => { - this.showLoader = false - console.log('remove attachment error: ', error) - })); - } + this.agendaDataRepository.removeEventAttachment(this.eventProcess.serialNumber, { attachments: this.deletedAttachmentsList }).subscribe((value) => { + console.log(value) + }, ((error) => { + this.showLoader = false + console.log('remove attachment error: ', error) + })); + } this.close() @@ -578,10 +578,12 @@ export class EditEventToApprovePage implements OnInit { } deleteAttachment(attachment: Attachment, index) { - const id: any = this.loadedEventAttachments[index].Id - console.log(attachment) - this.loadedAttachments[index]['action'] = 'delete' - this.deletedAttachmentsList.push(id) + if (this.loadedEventAttachments[index].Id) { + const id: any = this.loadedEventAttachments[index].Id + console.log(attachment) + this.loadedAttachments[index]['action'] = 'delete' + this.deletedAttachmentsList.push(id) + } } async getDoc() { 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 1489a7bd3..d9166acb4 100644 --- a/src/app/shared/agenda/edit-event/edit-event.page.ts +++ b/src/app/shared/agenda/edit-event/edit-event.page.ts @@ -374,7 +374,7 @@ export class EditEventPage implements OnInit { await this.saveDocument() if (this.addedAttachmentsList.length > 0) { - this.agendaDataRepository.addEventAttachment(this._postEvent.EventId, { "attachments": this._postEvent.Attachments }).subscribe((value) => { + this.agendaDataRepository.addEventAttachment(this._postEvent.EventId, this._postEvent.Attachments).subscribe((value) => { console.log(value) }, ((error) => { this.showLoader = false diff --git a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html index b7faae8f4..38af057b0 100644 --- a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html +++ b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.html @@ -288,9 +288,9 @@
- +

- {{document.SourceName}} + {{document.subject || document.Description || 'Sem título'}} Correspondencia AccoesPresidenciais ArquivoDespachoElect @@ -298,7 +298,7 @@

-

{{document.Stakeholders}} {{document.CreateDate }}

+

{{document.Stakeholders}} {{document.dateEntry }}

diff --git a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts index cafbd4728..6f884b3e3 100644 --- a/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts +++ b/src/app/shared/gabinete-digital/edit-event-to-approve/edit-event.page.ts @@ -14,6 +14,7 @@ import { NgxMatDateFormats, NGX_MAT_DATE_FORMATS } from '@angular-material-compo import { NavigationExtras, Router } from '@angular/router'; import { ThemeService } from 'src/app/services/theme.service' import { HttpErrorHandle } from 'src/app/services/http-error-handle.service' +import { AgendaDataRepositoryService } from 'src/app/services/Repositorys/Agenda/agenda-data-repository.service'; const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { parse: { @@ -44,7 +45,7 @@ export class EditEventToApproveComponent implements OnInit { public showSeconds = false; public touchUi = false; public enableMeridian = false; - public minDate = new Date().toISOString().slice(0,10) + public minDate = new Date().toISOString().slice(0, 10) public endMinDate = new Date(new Date().getTime() + 15 * 60000); public maxDate: any; public stepHour = 1; @@ -62,12 +63,14 @@ export class EditEventToApproveComponent implements OnInit { @ViewChild('picker1') picker1: any; serialNumber: string - loadedAttachments: Attachment[]= [] + loadedAttachments: any[] = [] + addedAttachmentsList: any[] = [] + deletedAttachmentsList: any[] = [] eventProcess = { serialNumber: "", taskStartDate: "", - workflowInstanceDataFields:{ + workflowInstanceDataFields: { Body: "", OccurrenceType: '', Category: '', @@ -91,10 +94,10 @@ export class EditEventToApproveComponent implements OnInit { show = false postEvent: Event; - isRecurring:string; + isRecurring: string; isEventEdited: boolean; - segment:string = "true"; - profile:string; + segment: string = "true"; + profile: string; eventAttendees: EventPerson[]; startDate: Date; endDate: Date; @@ -115,11 +118,12 @@ export class EditEventToApproveComponent implements OnInit { private eventsService: EventsService, public alertController: AlertController, private attachmentsService: AttachmentsService, - private processes:ProcessesService, + private processes: ProcessesService, private toastService: ToastService, - private router:Router, + private router: Router, public ThemeService: ThemeService, - private httpErroHalde: HttpErrorHandle + private httpErroHalde: HttpErrorHandle, + private agendaDataRepository: AgendaDataRepositoryService ) { // Edit event to approve this.serialNumber = this.navParams.get('serialNumber'); @@ -129,6 +133,7 @@ export class EditEventToApproveComponent implements OnInit { ngOnInit() { + console.log('Here you ares') this.getTask() this.getRecurrenceTypes(); } @@ -138,8 +143,8 @@ export class EditEventToApproveComponent implements OnInit { } myInterval = setInterval(() => { - document.querySelectorAll('.ngx-mat-timepicker input').forEach((e :any) => { - if(e) { + document.querySelectorAll('.ngx-mat-timepicker input').forEach((e: any) => { + if (e) { e.disabled = true; } }) @@ -147,80 +152,86 @@ export class EditEventToApproveComponent implements OnInit { async getTask() { - const result = await this.processes.GetTask(this.serialNumber).toPromise(); + /* const result = await this.processes.GetTask(this.serialNumber).toPromise(); */ + const res = await this.agendaDataRepository.getEventToApproveById(this.serialNumber) + if (res.isOk()) { + console.log('Loaded Event', res.value) - this.eventProcess = result - this.eventProcess.workflowInstanceDataFields.Category = result.workflowInstanceDataFields.EventType - this.eventProcess.workflowInstanceDataFields.LastOccurrence = new Date(this.eventProcess.workflowInstanceDataFields.LastOccurrence) + this.eventProcess = res.value as any + this.eventProcess.workflowInstanceDataFields.Category = res.value.workflowInstanceDataFields.EventType + this.eventProcess.workflowInstanceDataFields.LastOccurrence = new Date(this.eventProcess.workflowInstanceDataFields.LastOccurrence) - this.startDate = new Date(this.eventProcess.workflowInstanceDataFields.StartDate); - this.endDate = new Date(this.eventProcess.workflowInstanceDataFields.EndDate); + this.startDate = new Date(this.eventProcess.workflowInstanceDataFields.StartDate); + this.endDate = new Date(this.eventProcess.workflowInstanceDataFields.EndDate); - // description - let body : any =this.eventProcess.workflowInstanceDataFields.Body.replace(/<[^>]+>/g, '') - this.eventProcess.workflowInstanceDataFields.Body = body - this.Location = this.eventProcess.workflowInstanceDataFields.Location + // description + let body: any = this.eventProcess.workflowInstanceDataFields.Body.replace(/<[^>]+>/g, '') + this.eventProcess.workflowInstanceDataFields.Body = body + this.Location = this.eventProcess.workflowInstanceDataFields.Location - this.InstanceId = this.eventProcess.workflowInstanceDataFields.InstanceId - try { - this.getAttachments() + this.InstanceId = this.eventProcess.workflowInstanceDataFields.InstanceId - } catch (error) { - this.httpErroHalde.httpStatusHandle(error) - } - - - if(this.eventProcess.workflowInstanceDataFields.IsRecurring == false) { - this.isRecurring = "Não se repete"; - } - else { - this.isRecurring = "Repete"; - } - - this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e => { - if(e.IsRequired) { - this.taskParticipants.push(e); - } else { - this.taskParticipantsCc.push(e); + this.loadedAttachments = res.value.Attachments + /* this.getAttachments() + */ + if (this.eventProcess.workflowInstanceDataFields.IsRecurring == false) { + this.isRecurring = "Não se repete"; } - }) + else { + this.isRecurring = "Repete"; + } + + this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e => { + if (e.IsRequired) { + this.taskParticipants.push(e); + } else { + this.taskParticipantsCc.push(e); + } + }) + + } else { + this.httpErroHalde.httpStatusHandle(res.error) + } + + + /* }) */ } getRecurrenceTypes() { - this.eventsService.getRecurrenceTypes().subscribe(res=>{ + this.eventsService.getRecurrenceTypes().subscribe(res => { this.recurringTypes = res; }); } - onSelectedRecurringChanged(ev:any){ + onSelectedRecurringChanged(ev: any) { this.calculetedLastOccurrence(ev); - if(ev.length > 1){ + if (ev.length > 1) { this.postEvent.EventRecurrence.Type = ev.filter(data => data != '-1'); } - if(ev.length == 0){ + if (ev.length == 0) { this.postEvent.EventRecurrence.Type = "-1"; } } - calculetedLastOccurrence(type:number){ + calculetedLastOccurrence(type: number) { var valor; var opcao: boolean; if (type == 0) { valor = 7; opcao = true; - } else if(type == 1){ + } else if (type == 1) { valor = 30; opcao = true; - } else if(type == 2){ + } else if (type == 2) { valor = 1; opcao = false; - }else if(type == 3){ + } else if (type == 3) { valor = 5; opcao = false; } @@ -228,7 +239,7 @@ export class EditEventToApproveComponent implements OnInit { } - defineLastOccurrence(valor:number, opcao:boolean){ + defineLastOccurrence(valor: number, opcao: boolean) { var time = new Date(this.endDate); if (opcao == true) { time.setDate(time.getDate() + valor); @@ -248,7 +259,7 @@ export class EditEventToApproveComponent implements OnInit { openLastOccurrence() { let input: any = document.querySelector('#last-occurrence') - if(input) { + if (input) { input.click() } } @@ -262,15 +273,15 @@ export class EditEventToApproveComponent implements OnInit { save() { // set dates to eventProcess object - this.taskParticipantsCc.forEach(e=>{ + this.taskParticipantsCc.forEach(e => { e.IsRequired = false }) this.eventProcess.workflowInstanceDataFields.ParticipantsList = this.taskParticipants.concat(this.taskParticipantsCc) - this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e=>{ + this.eventProcess.workflowInstanceDataFields.ParticipantsList.forEach(e => { - if(e.hasOwnProperty('$type')) { + if (e.hasOwnProperty('$type')) { delete e.$type } }) @@ -306,15 +317,47 @@ export class EditEventToApproveComponent implements OnInit { } - this.eventsService.postEventToApproveEdit(event).subscribe(()=>{ + /* this.eventsService.postEventToApproveEdit(event).subscribe(()=>{ this.httpErroHalde.httpsSucessMessagge('Editar evento') window['approve-event-getTask']() }, error =>{ this.httpErroHalde.httpStatusHandle(error) - }) + }) */ + + this.agendaDataRepository.updateEvent(this.eventProcess.serialNumber, event).subscribe((value) => { + console.log(value) + }, ((error) => { + console.log('edit event error: ', error) + })); + + this.agendaDataRepository.addEventAttendee(this.eventProcess.serialNumber, this.eventProcess.workflowInstanceDataFields.ParticipantsList).subscribe((value) => { + console.log(value) + }, ((error) => { + console.log('add Attendee error: ', error) + })); - this.loadedAttachments.forEach((document:any)=>{ + if (this.addedAttachmentsList.length > 0) { + this.agendaDataRepository.addEventAttachment(this.eventProcess.serialNumber, this.loadedAttachments).subscribe((value) => { + console.log(value) + }, ((error) => { + this.showLoader = false + console.log('add attachment error: ', error) + })); + } + + if (this.deletedAttachmentsList.length > 0) { + this.agendaDataRepository.removeEventAttachment(this.eventProcess.serialNumber, { attachments: this.deletedAttachmentsList }).subscribe((value) => { + console.log(value) + }, ((error) => { + this.showLoader = false + console.log('remove attachment error: ', error) + })); + } + + + + /* this.loadedAttachments.forEach((document:any)=>{ if(document['action'] == 'add') { delete document.action this.attachmentsService.setEventAttachmentById(document).subscribe(()=>{ @@ -343,17 +386,17 @@ export class EditEventToApproveComponent implements OnInit { }) } - }) + }) */ this.close(); } async openAttendees() { - if(window.innerWidth <= 1024) { + if (window.innerWidth <= 1024) { const modal = await this.modalController.create({ component: AttendeesPageModal, - componentProps: { + componentProps: { adding: this.adding, taskParticipants: this.taskParticipants, taskParticipantsCc: this.taskParticipantsCc @@ -366,7 +409,7 @@ export class EditEventToApproveComponent implements OnInit { modal.onDidDismiss().then((data) => { - if(data) { + if (data) { data = data['data']; const newAttendees: EventPerson[] = data['taskParticipants']; @@ -402,7 +445,7 @@ export class EditEventToApproveComponent implements OnInit { this.openAttendees(); } - dynamicSetIntervenient({taskParticipants, taskParticipantsCc}) { + dynamicSetIntervenient({ taskParticipants, taskParticipantsCc }) { this.taskParticipants = taskParticipants; this.taskParticipantsCc = taskParticipantsCc; } @@ -416,7 +459,7 @@ export class EditEventToApproveComponent implements OnInit { console.error('getAttachments', error) } - result.forEach((e)=>{ + result.forEach((e) => { e.action = false }) @@ -426,8 +469,16 @@ export class EditEventToApproveComponent implements OnInit { } deleteAttachment(attachment: Attachment, index) { + console.log( this.loadedAttachments) + const id: any = this.loadedAttachments[index].id + let update = this.removeItemById(this.loadedAttachments, id) + this.loadedAttachments = update + console.log( update) + this.deletedAttachmentsList.push(id) + } - this.loadedAttachments[index]['action'] = 'delete' + removeItemById(array, id) { + return array.filter(item => item.id !== id); } async getDoc() { @@ -437,34 +488,36 @@ export class EditEventToApproveComponent implements OnInit { componentProps: { type: 'AccoesPresidenciais & ArquivoDespachoElect', showSearchInput: true, + eventAgenda: true, select: true, } }); - modal.onDidDismiss().then( async (res)=>{ - if(res){ + modal.onDidDismiss().then(async (res) => { + if (res) { const data: SearchList = res.data.selected; - - const DocumentToSave: any = { - SourceTitle: data.Assunto, - ParentId: this.InstanceId, - Source: '1', - SourceId: data.Id, - ApplicationId: data.ApplicationType.toString(), - Id: '', - Link: '', - SerialNumber: '', - action: 'add', - CreateDate: data.Data, - Data: data.Data, - Description: data.DocTypeDesc, - SourceName: data.Assunto, - Stakeholders: data.EntidadeOrganicaNome, - }; + console.log(data) + /* const DocumentToSave: any = { + SourceTitle: data.Assunto, + ParentId: this.InstanceId, + Source: '1', + SourceId: data.Id, + ApplicationId: data.ApplicationType.toString(), + Id: '', + Link: '', + SerialNumber: '', + action: 'add', + CreateDate: data.Data, + Data: data.Data, + Description: data.DocTypeDesc, + SourceName: data.Assunto, + Stakeholders: data.EntidadeOrganicaNome, + }; */ - this.loadedAttachments.push(DocumentToSave) + this.loadedAttachments.push(data) + this.addedAttachmentsList.push(data) // await this.attachmentsService.setEventAttachmentById(DocumentToSave).subscribe(()=>{