import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; import { EventBody } from 'src/app/models/eventbody.model'; import { EventPerson } from 'src/app/models/eventperson.model'; import { EventsService } from 'src/app/services/events.service'; import { AttachmentsService } from 'src/app/services/attachments.service'; import { Event } from 'src/app/models/event.model'; import { ModalController } from '@ionic/angular'; import { removeDuplicate } from 'src/plugin/removeDuplicate.js' import { SearchPage } from 'src/app/pages/search/search.page'; import { SearchList } from "src/app/models/search-document"; import { EventAttachment } from 'src/app/models/attachment.model'; import { ToastService } from 'src/app/services/toast.service'; import { LoginUserRespose } from 'src/app/models/user.model'; import { DateAdapter } from '@angular/material/core'; import * as _moment from 'moment'; import * as _rollupMoment from 'moment'; import { FormControl } from '@angular/forms'; import { NgxMatDateFormats } from '@angular-material-components/datetime-picker'; import { ThemePalette } from '@angular/material/core'; import { ViewChild } from '@angular/core'; import { FormGroup, Validators } from '@angular/forms'; import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker'; import { ThemeService } from 'src/app/services/theme.service' import { ChatMethodsService } from 'src/app/services/chat/chat-methods.service'; import { ServerConnectionService } from 'src/app/services/server-connection.service'; import { SessionStore } from 'src/app/store/session.service'; import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'; import { environment } from 'src/environments/environment'; import { EventToAprove } from 'src/app/models/eventToAprove.model'; import { ProcessesService } from 'src/app/services/processes.service'; import { Subject } from 'rxjs'; import { TaskService } from 'src/app/services/task.service' import { ContactsService } from 'src/app/services/contacts.service'; import { DomSanitizerService } from 'src/app/services/DomSanitizer.service'; import { ChangeProfileService } from 'src/app/services/change-profile.service'; const CUSTOM_DATE_FORMATS: NgxMatDateFormats = { parse: { dateInput: "YYYY-MMMM-DD HH:mm" }, display: { dateInput: "DD MMM YYYY H:mm", monthYearLabel: "MMM YYYY", dateA11yLabel: "LL", monthYearA11yLabel: "MMMM YYYY" } } @Component({ selector: 'app-new-event', templateUrl: './new-event.page.html', styleUrls: ['./new-event.page.scss'], providers: [ { provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS }, ] }) export class NewEventPage implements OnInit { eventBody: EventBody; segment: string = "true"; public date: any; public disabled = false; public showSpinners = true; public showSeconds = false; public touchUi = false; public enableMeridian = false; public stepHour = 1; public stepMinute = 15; public stepSecond = 15; currentDate = this.roundTimeQuarterHour(); public color: ThemePalette = 'primary'; recurringTypes = [] selectedRecurringType: any; loggedAttendDad: boolean = true; mostrarModal = false; @Input() attendees: [] @Input() profile: string; @Input() roomId: string; @Input() selectedSegment: string; @Input() selectedDate: Date; @Input() CalendarDate: Date; @Input() taskParticipants: EventPerson[] = []; @Input() taskParticipantsCc: any = []; @Output() setIntervenient = new EventEmitter(); @Output() setIntervenientCC = new EventEmitter(); postEvent: Event; postEventToAprove: EventToAprove; @Output() onAddEvent = new EventEmitter(); @Output() openAttendeesComponent = new EventEmitter(); @Output() clearContact = new EventEmitter(); @Output() GoBackEditOrAdd = new EventEmitter(); @Output() cloneAllmobileComponent = new EventEmitter(); @Output() backToChat = new EventEmitter(); documents: SearchList[] = []; loggeduser: LoginUserRespose; @ViewChild('picker') picker: any; @ViewChild('fim') fim: any; @ViewChild('inicio') inicio: any; @ViewChild('occurrence') occurrence: any; @ViewChild('picker1') picker1: any; Form: FormGroup; validateFrom = false; autoStartTime; autoEndTime; public options = [ { value: true, label: 'True' }, { value: false, label: 'False' } ]; public listColors = ['primary', 'accent', 'warn']; public stepHours = [1, 2, 3, 4, 5]; public stepMinutes = [1, 5, 10, 15, 20, 25]; public stepSeconds = [1, 5, 10, 15, 20, 25]; showLoader = false CalendarName; CalendarNameShow = true CalendarNamesOptions = ['Oficial', 'Pessoal'] environment = environment eventPersons: EventPerson[]; contacts: EventPerson[] = []; allDayCheck: boolean = false; constructor( private modalController: ModalController, public eventService: EventsService, private attachmentsService: AttachmentsService, private toastService: ToastService, private dateAdapter: DateAdapter, public ThemeService: ThemeService, private chatMethodService: ChatMethodsService, private hhtpErrorHandle: HttpErrorHandle, private processeService: ProcessesService, public TaskService: TaskService, private contactsService: ContactsService, private domSanitazerService: DomSanitizerService, private changeProfileService: ChangeProfileService, ) { this.dateAdapter.setLocale('pt'); this.loggeduser = SessionStore.user; this.postEvent = new Event(); } ngOnInit() { console.log(' INTERVENIENTES',this.taskParticipants) this.changeProfileService.registerCallback(() => { this.initializeData() }) if (!this.CalendarName) { if (this.eventService.calendarNamesAry.includes('Meu calendario')) { this.CalendarName = 'Meu calendario'; } else { this.CalendarName = this.eventService.calendarNamesAry[0] } } this.getRecurrenceTypes(); if (!this.restoreTemporaryData()) { // clear this.eventBody = { BodyType: "1", Text: "" }; this.postEvent.Body = this.eventBody; this.initializeData() if (this.postEvent.Attendees != null) { this.postEvent.Attendees.forEach(e => { if (e.IsRequired) { this.taskParticipants.push(e); } else { this.taskParticipantsCc.push(e); } }) } console.log('Attendes',this.taskParticipants) this.taskParticipants = removeDuplicate(this.taskParticipants); this.taskParticipantsCc = removeDuplicate(this.taskParticipantsCc); this.setIntervenient.emit(this.taskParticipants); this.setIntervenientCC.emit(this.taskParticipantsCc); this.setDefaultTime(); } this.date = new Date(2021, 9, 4, 5, 6, 7); this.injectValidation(); this.changeAgenda() this.fetchContacts("") } initializeData() { if (this.selectedSegment != "Combinada") { this.postEvent = { EventId: '', Subject: '', Body: this.eventBody, Location: '', CalendarId: '', CalendarName: 'Oficial', StartDate: this.autoStartTime, EndDate: this.autoEndTime, EventType: 'Reunião', Attendees: this.attendees || null, IsMeeting: false, IsRecurring: false, AppointmentState: 0, TimeZone: '', Organizer: '', Category: 'Reunião', HasAttachments: false, EventRecurrence: { Type: '-1', LastOccurrence: this.autoEndTime }, }; } else { this.postEvent = { EventId: '', Subject: '', Body: this.eventBody, Location: '', CalendarId: '', CalendarName: 'Oficial', StartDate: this.autoStartTime, EndDate: this.autoEndTime, EventType: 'Reunião', Attendees: this.attendees || null, IsMeeting: false, IsRecurring: false, AppointmentState: 0, TimeZone: '', Organizer: '', Category: 'Reunião', HasAttachments: false, EventRecurrence: { Type: '-1', LastOccurrence: this.autoEndTime }, } } } setDefaultTime() { this.postEvent.StartDate = this.roundTimeQuarterHour(this.CalendarDate); this.postEvent.EndDate = this.roundTimeQuarterHourPlus15(this.postEvent.StartDate); } roundTimeQuarterHour(timeToReturn = new Date()): Date { let date = new Date(timeToReturn) || new Date(); let newdate = new Date(); const minutes = newdate.getMinutes(); date.setHours(newdate.getHours()) date.setSeconds(0); if (minutes % 15 != 0) { if (minutes > 45) { date.setMinutes(60) } else if (minutes > 30) { date.setMinutes(45) } else if (minutes > 15) { date.setMinutes(30) } else if (minutes > 0) { date.setMinutes(15) } } return date } roundTimeQuarterHourPlus15(date: Date) { const _date = new Date(date); const minutes = _date.getMinutes(); _date.setMinutes(minutes + 15) return _date } roundTimeQuarterHour1(timeToReturn) { let date: any = new Date(timeToReturn) || new Date(); const minutes = date.getMinutes(); date.setSeconds(0); if ((minutes % 15) != 0) { let a = (Math.floor(minutes / 15) + 1) * 15 date.setMinutes(a) } return date } setStartDate() { // this.postEvent.StartDate = this.roundTimeQuarterHour(); } setEndDate() { // this.postEvent.EndDate = this.postEvent.StartDate; } runValidation() { this.validateFrom = true; if (new Date(this.postEvent.StartDate).getTime() > new Date(this.postEvent.EndDate).getTime()) { this.toastService._badRequest("A data de fim não pode ser inferior a data de início do evento") } } injectValidation() { if (typeof (this.postEvent.EventRecurrence.Type) == 'number') { const str: any = this.postEvent.EventRecurrence.Type.toString() this.postEvent.EventRecurrence.Type = str } this.Form = new FormGroup({ Subject: new FormControl(this.postEvent.Subject, [ Validators.required, // Validators.minLength(4) ]), Location: new FormControl(this.postEvent.Location, [ Validators.required, ]), CalendarName: new FormControl(this.postEvent.CalendarName), Categories: new FormControl(this.postEvent.Category, [ Validators.required ]), dateStart: new FormControl(this.postEvent.StartDate, [ Validators.required ]), dateEnd: new FormControl(this.postEvent.EndDate, [ Validators.required ]), dateOccurrence: new FormControl(this.postEvent.EventRecurrence.Type.toString() == '-1' ? ['ok'] : this.postEvent.EventRecurrence.LastOccurrence && new Date(this.postEvent.EventRecurrence.LastOccurrence).getTime() > new Date(this.postEvent.EndDate).getTime() ? 'ok' : null, [ Validators.required ]), participantes: new FormControl(this.taskParticipants, [ // Validators.required ]), Date: new FormControl(new Date(this.postEvent.StartDate).getTime() < new Date(this.postEvent.EndDate).getTime() ? 'ok' : null, [ Validators.required ]), }) } openInicio() { let input: any = document.querySelector('#new-inicio') if (input) { input.click() } } openFim() { let input: any = document.querySelector('#new-fim') if (input) { input.click() } } changeAgenda() { this.CalendarNameShow = false setTimeout(() => { this.CalendarNameShow = true if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) { this.CalendarNamesOptions = ['Oficial', 'Pessoal'] console.log(this.postEvent.CalendarName) } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial']) { this.CalendarNamesOptions = ['Oficial'] this.postEvent.CalendarName = 'Oficial' console.log(this.postEvent.CalendarName) } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal']) { this.CalendarNamesOptions = ['Pessoal'] this.postEvent.CalendarName = 'Pessoal' console.log(this.postEvent.CalendarName) } else { this.CalendarNamesOptions = ['Oficial', 'Pessoal'] console.log(this.postEvent.CalendarName) } }, 50) } openLastOccurrence() { let input: any = document.querySelector('#last-occurrence') if (input) { input.click() } } async getDoc() { const modal = await this.modalController.create({ component: SearchPage, cssClass: 'modal-width-100-width-background modal', componentProps: { type: 'AccoesPresidenciais & ArquivoDespachoElect', showSearchInput: true, select: true } }); modal.onDidDismiss().then((res) => { if (res) { const data = res.data; this.documents.push(data.selected); } }); await modal.present(); } close() { this.deleteTemporaryData(); this.clearContact.emit(); this.setIntervenient.emit([]); this.setIntervenientCC.emit([]); // chat exit this.backToChat.emit({ roomId: this.roomId }) // agenda exit this.cloneAllmobileComponent.emit({}) } getRecurrenceTypes() { this.eventService.getRecurrenceTypes().subscribe(res => { this.recurringTypes = res; }); } onSelectedRecurringChanged(ev: any) { this.calculetedLastOccurrence(ev); if (ev.length > 1) { this.postEvent.EventRecurrence.Type = ev.filter(data => data != '-1'); } if (ev.length == 0) { this.postEvent.EventRecurrence.Type = "-1"; } } calculetedLastOccurrence(type: number) { var valor; var opcao: boolean; if (type == 0) { valor = 7; opcao = true; } else if (type == 1) { valor = 30; opcao = true; } else if (type == 2) { valor = 1; opcao = false; } else if (type == 3) { valor = 5; opcao = false; } this.defineLastOccurrence(valor, opcao); } defineLastOccurrence(valor: number, opcao: boolean) { var time = new Date(this.postEvent.EndDate); if (opcao == true) { time.setDate(time.getDate() + valor); this.postEvent.EventRecurrence.LastOccurrence = time; } else { time = new Date( time.getFullYear() + valor, time.getMonth(), time.getDate(), time.getHours(), time.getMinutes() ); this.postEvent.EventRecurrence.LastOccurrence = time; } } async save() { this.injectValidation() this.runValidation() if (this.Form.invalid) { if(new Date(this.postEvent.StartDate).getTime() < new Date(this.postEvent.EndDate).getTime()) { this.toastService._badRequest("Data de inicio menor que a data de fim") } return false } this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc); this.postEvent.Subject = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Subject/* ); */ this.postEvent.Location = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Location/* ); */ this.postEvent.Body.Text = /* this.domSanitazerService.sanitizeInput( */this.postEvent.Body.Text/* ); */ if (this.documents.length > 0) { this.postEvent.HasAttachments = true; } if (this.postEvent.EventRecurrence.Type == undefined) { this.postEvent.EventRecurrence.Type = '-1' } if (this.loggeduser.Profile == 'MDGPR') { const CalendarId = this.selectedCalendarId() this.showLoader = true; this.postEvent.CalendarId = CalendarId let loader = this.toastService.loading(); this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe( async (id) => { loader.remove() this.showLoader = false const eventId: any = id; const DocumentToSave: EventAttachment[] = this.documents.map((e) => { return { SourceTitle: e.Assunto, ParentId: eventId, Source: '1', SourceId: e.Id, ApplicationId: e.ApplicationType.toString(), Id: '', Link: '', SerialNumber: '' }; }); await DocumentToSave.forEach((attachments, i) => { this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => { if (DocumentToSave.length == (i + 1)) { this.afterSave(); } }); }); if (DocumentToSave.length == 0) { this.afterSave(); } this.hhtpErrorHandle.httpsSucessMessagge('new event') let data = { "subject": this.postEvent.Subject, "start": this.postEvent.StartDate, "end": this.postEvent.EndDate, "venue": this.postEvent.Location, "id": id, "calendarId": CalendarId } if (this.roomId) { this.chatMethodService.sendMessage(this.roomId, data); } }, error => { loader.remove() this.showLoader = false this.hhtpErrorHandle.httpStatusHandle(error) }); } else if (this.loggeduser.Profile == 'PR') { const CalendarId = this.selectedCalendarId() let loader = this.toastService.loading(); this.postEvent.CalendarId = CalendarId this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe( (id) => { loader.remove() const eventId: any = id; const DocumentToSave: EventAttachment[] = this.documents.map((e) => { return { SourceTitle: e.Assunto, ParentId: eventId, Source: '1', SourceId: e.Id, ApplicationId: e.ApplicationType.toString(), Id: '', Link: '', SerialNumber: '' }; }); DocumentToSave.forEach((attachments, i) => { this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => { if (DocumentToSave.length == (i + 1)) { this.afterSave(); } }); }); if (DocumentToSave.length == 0) { this.afterSave(); } this.hhtpErrorHandle.httpsSucessMessagge('new event') let data = { "subject": this.postEvent.Subject, "start": this.postEvent.StartDate, "end": this.postEvent.EndDate, "venue": this.postEvent.Location, "id": id, "calendarId": CalendarId } if (this.roomId) { this.chatMethodService.sendMessage(this.roomId, data); } }, (error) => { //const connectionToServer = this.ServerConnectionService.BaseAPI() this.hhtpErrorHandle.httpStatusHandle(error) loader.remove() this.showLoader = false }); } else if (this.loggeduser.Profile == 'SGGPR') { console.log(this.postEventToAprove) console.log(this.postEvent) console.log(this.postEvent.CalendarName) console.log(this.CalendarName) console.log(this.eventService.calendarNamesAry) const CalendarId = this.selectedCalendarId() let selectedCalendar try { selectedCalendar = this.eventService.calendarNamesAry.find(calendar => calendar.Fullname === this.CalendarName) } catch (error) { } console.log('selectedCalendar', selectedCalendar) if (selectedCalendar) { if (selectedCalendar.Role = 'Presidente da República') { let loader = this.toastService.loading(); const DocumentToSave: EventAttachment[] = this.documents.map((e) => { return { SourceTitle: e.Assunto, ParentId: "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate(), Source: '1', SourceId: e.Id, ApplicationId: e.ApplicationType.toString(), Id: '', Link: '', SerialNumber: '' }; }); let body = this.eventToaproveBody(this.postEvent, CalendarId, this.loggeduser.RoleID, this.loggeduser.UserId, DocumentToSave); await this.processeService.createEventToAprove(this.postEvent.CalendarName, 'pr', body).subscribe((id) => { loader.remove() this.afterSave(); this.hhtpErrorHandle.httpsSucessMessagge('new event to aprove') /* DocumentToSave.forEach((attachments, i) => { this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => { if (DocumentToSave.length == (i + 1)) { this.afterSave(); } }); }); if (DocumentToSave.length == 0) { this.afterSave(); } */ }, (error) => { loader.remove() this.showLoader = false this.hhtpErrorHandle.httpStatusHandle(error) }); } else if (selectedCalendar.Role = 'Ministro e Director do Gabinete do PR') { let loader = this.toastService.loading(); const DocumentToSave: EventAttachment[] = this.documents.map((e) => { return { SourceTitle: e.Assunto, ParentId: "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate(), Source: '1', SourceId: e.Id, ApplicationId: e.ApplicationType.toString(), Id: '', Link: '', SerialNumber: '' }; }); let body = this.eventToaproveBody(this.postEvent, CalendarId, this.loggeduser.RoleID, this.loggeduser.UserId, DocumentToSave); await this.processeService.createEventToAprove(this.postEvent.CalendarName, 'md', body).subscribe((id) => { loader.remove() this.afterSave(); this.hhtpErrorHandle.httpsSucessMessagge('new event to aprove') /* DocumentToSave.forEach((attachments, i) => { this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => { if (DocumentToSave.length == (i + 1)) { this.afterSave(); } }); }); if (DocumentToSave.length == 0) { this.afterSave(); } */ }, (error) => { loader.remove() this.showLoader = false this.hhtpErrorHandle.httpStatusHandle(error) }); } } if (!selectedCalendar && this.CalendarName == "Meu calendario") { console.log('SG generic') this.postEvent.CalendarName const CalendarId = this.selectedCalendarId() let loader = this.toastService.loading(); this.postEvent.CalendarId = CalendarId this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe( (id) => { loader.remove(); const eventId: any = id; const DocumentToSave: EventAttachment[] = this.documents.map((e) => { return { SourceTitle: e.Assunto, ParentId: eventId, Source: '1', SourceId: e.Id, ApplicationId: e.ApplicationType.toString(), Id: '', Link: '', SerialNumber: '' }; }); DocumentToSave.forEach((attachments, i) => { this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => { if (DocumentToSave.length == (i + 1)) { this.afterSave(); } }); }); if (DocumentToSave.length == 0) { this.afterSave(); } this.hhtpErrorHandle.httpsSucessMessagge('new event') let data = { "subject": this.postEvent.Subject, "start": this.postEvent.StartDate, "end": this.postEvent.EndDate, "venue": this.postEvent.Location, "id": id, "calendarId": CalendarId } if (this.roomId) { this.chatMethodService.sendMessage(this.roomId, data); } }, (error) => { loader.remove() this.showLoader = false this.hhtpErrorHandle.httpStatusHandle(error) }); } } else { this.postEvent.CalendarName const CalendarId = this.selectedCalendarId() let loader = this.toastService.loading(); this.postEvent.CalendarId = CalendarId this.eventService.postEventGeneric(this.postEvent, this.postEvent.CalendarName, CalendarId).subscribe( (id) => { loader.remove(); const eventId: any = id; const DocumentToSave: EventAttachment[] = this.documents.map((e) => { return { SourceTitle: e.Assunto, ParentId: eventId, Source: '1', SourceId: e.Id, ApplicationId: e.ApplicationType.toString(), Id: '', Link: '', SerialNumber: '' }; }); DocumentToSave.forEach((attachments, i) => { this.attachmentsService.setEventAttachmentById(attachments).subscribe((res) => { if (DocumentToSave.length == (i + 1)) { this.afterSave(); } }); }); if (DocumentToSave.length == 0) { this.afterSave(); } this.hhtpErrorHandle.httpsSucessMessagge('new event') let data = { "subject": this.postEvent.Subject, "start": this.postEvent.StartDate, "end": this.postEvent.EndDate, "venue": this.postEvent.Location, "id": id, "calendarId": CalendarId } if (this.roomId) { this.chatMethodService.sendMessage(this.roomId, data); } }, (error) => { loader.remove() this.showLoader = false this.hhtpErrorHandle.httpStatusHandle(error) }); } } selectedCalendarId() { if (this.eventService.calendarNamesType[this.CalendarName]?.['Oficial'] && this.postEvent.CalendarName == 'Oficial') { return this.eventService.calendarNamesType[this.CalendarName]['OficialId'] } else if (this.eventService.calendarNamesType[this.CalendarName]?.['Pessoal'] && this.postEvent.CalendarName == 'Pessoal') { return this.eventService.calendarNamesType[this.CalendarName]['PessoalId'] } else { return '11:11' } } afterSave() { this.deleteTemporaryData(); this.onAddEvent.emit(Object.assign(this.postEvent, { roomId: this.roomId })); this.GoBackEditOrAdd.emit(); this.setIntervenient.emit([]); this.setIntervenientCC.emit([]); } removeAttachment(index: number) { this.documents = this.documents.filter((e, i) => index != i); } async addParticipants() { this.saveTemporaryData(); this.openAttendeesComponent.emit({ type: "intervenient" }); this.clearContact.emit(); this.mostrarModal = true; } async addParticipantsCc() { this.saveTemporaryData(); this.openAttendeesComponent.emit({ type: "CC" }); this.clearContact.emit(); } saveTemporaryData() { window['temp.path:/home/agenda/new-event.component.ts'] = { postEvent: this.postEvent, eventBody: this.eventBody, segment: this.segment, CalendarName: this.CalendarName, documents: this.documents } } /** * * @description o pipeline já esta a funcionar tuda vez que nos fazer push na branch master e test o pipeline executa os teste, mas agora os teste temos que melhora para testar a app em tudos os pontos * o pipeline já está a funcionar toda vez que nos fazer um push na branch master ou teste o pipeline executa os testes, mas agora os testes temos que melhorar para testar a app em todos os pontos */ restoreTemporaryData(): boolean { const restoredData = window['temp.path:/home/agenda/new-event.component.ts'] if (JSON.stringify(restoredData) != "{}" && undefined != restoredData) { this.postEvent = restoredData.postEvent this.eventBody = restoredData.eventBody this.segment = restoredData.segment this.CalendarName = restoredData.CalendarName this.documents = restoredData.documents // restore dater for date and hours picker return true; } else { } } deleteTemporaryData() { window['temp.path:/home/agenda/new-event.component.ts'] = {} } eventToaproveBody(event, calendarId, role, userId, attachments) { let toAproveObject = { "EventProcess": { "Body": event.Body, "Location": event.Location, "Subject": event.Subject, "StartDate": event.StartDate, "EndDate": event.EndDate, "Status": "Active", "IsAllDayEvent": event.IsRecurring, "EventType": event.EventType, "ParticipantsList": event.Attendees, "EventRecurrence": event.EventRecurrence, "HasAttachments": event.HasAttachments, "CalendarId": calendarId, "Role": role, "wxUserID": userId, "TimeZone": "W. Central Africa Standard Time" }, "Attachments": attachments, "InstanceID": "AGD_" + this.loggeduser.UserName + "_" + this.processeService.generateInstaceFormatDate() } return toAproveObject; } async fetchContacts(filter: string) { console.log(this.loggeduser.Profile) if (this.loggeduser.Profile == 'PR') { this.contactsService.getContacts(filter).subscribe(result => { if (this.eventPersons != null) { this.eventPersons.forEach(attendee => { const index: number = result.findIndex((cont) => { return cont.EmailAddress.toLocaleLowerCase() == attendee.EmailAddress.toLocaleLowerCase() }); result.splice(index, 1); }); } this.contacts = result; console.log('Attendes Email', this.loggeduser.Email) let filterLoggedUserEmail = this.contacts.filter(item => item.RoleDescription == "Ministro e Director do Gabinete do PR") console.log('Attendes Email', filterLoggedUserEmail) this.contacts = filterLoggedUserEmail; this.taskParticipants.push(this.contacts[0]); this.setIntervenient.emit(this.taskParticipants); console.log('Attendes Email', this.taskParticipants) } ); } } onCheckboxChange(event: any) { 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'); } } 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 } 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 } 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 } }