2021-01-29 09:45:27 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2021-07-02 11:19:52 +01:00
|
|
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
2021-06-29 10:50:05 +01:00
|
|
|
import { Router } from '@angular/router';
|
2022-04-26 16:14:55 +01:00
|
|
|
import { AlertController, ModalController, NavParams } from '@ionic/angular';
|
2021-04-23 10:35:53 +01:00
|
|
|
import { Attachment } from 'src/app/models/attachment.model';
|
2021-01-31 01:40:19 +01:00
|
|
|
import { EventBody } from 'src/app/models/eventbody.model';
|
|
|
|
|
import { EventPerson } from 'src/app/models/eventperson.model';
|
2021-04-23 10:35:53 +01:00
|
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
2021-01-31 01:40:19 +01:00
|
|
|
import { EventsService } from 'src/app/services/events.service';
|
2021-06-15 15:09:20 +01:00
|
|
|
import { ToastService } from 'src/app/services/toast.service';
|
2021-01-31 01:40:19 +01:00
|
|
|
import { Event } from '../../../models/event.model';
|
2021-06-15 15:28:03 +01:00
|
|
|
import { AttendeesPageModal } from '../../events/attendees/attendees.page';
|
2021-04-23 10:35:53 +01:00
|
|
|
import { SearchPage } from '../../search/search.page';
|
2022-01-21 15:54:53 +01:00
|
|
|
import { ThemeService } from 'src/app/services/theme.service';
|
|
|
|
|
import { NgxMatDateFormats } from '@angular-material-components/datetime-picker';
|
|
|
|
|
import { NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
|
2022-04-02 14:51:57 +01:00
|
|
|
import { SessionStore } from 'src/app/store/session.service';
|
2023-02-27 09:34:36 +01:00
|
|
|
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service'
|
2023-07-20 16:54:58 +01:00
|
|
|
import { environment } from 'src/environments/environment';
|
2023-07-25 15:56:42 +01:00
|
|
|
import { ContactsService } from 'src/app/services/contacts.service';
|
2023-11-14 12:04:31 +01:00
|
|
|
import { DomSanitizerService } from 'src/app/services/DomSanitizer.service';
|
2022-01-21 15:54:53 +01:00
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-01-29 09:45:27 +01:00
|
|
|
@Component({
|
|
|
|
|
selector: 'app-edit-event',
|
|
|
|
|
templateUrl: './edit-event.page.html',
|
|
|
|
|
styleUrls: ['./edit-event.page.scss'],
|
2022-01-21 15:54:53 +01:00
|
|
|
providers: [
|
|
|
|
|
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_DATE_FORMATS },
|
|
|
|
|
]
|
2021-01-29 09:45:27 +01:00
|
|
|
})
|
|
|
|
|
export class EditEventPage implements OnInit {
|
|
|
|
|
|
2021-07-02 11:19:52 +01:00
|
|
|
Form: FormGroup;
|
|
|
|
|
validateFrom = false
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2021-01-31 01:40:19 +01:00
|
|
|
postEvent: Event;
|
2024-02-29 09:58:08 +01:00
|
|
|
isRecurring: string;
|
2021-01-31 01:40:19 +01:00
|
|
|
isEventEdited: boolean;
|
|
|
|
|
loadedEvent: Event;
|
|
|
|
|
eventBody: EventBody;
|
2024-02-29 09:58:08 +01:00
|
|
|
segment: string = "true";
|
|
|
|
|
profile: string;
|
2021-01-31 01:40:19 +01:00
|
|
|
eventAttendees: EventPerson[];
|
|
|
|
|
selectedSegment: string;
|
|
|
|
|
selectedDate: Date;
|
2021-06-29 10:50:05 +01:00
|
|
|
initCalendarName: string;
|
2024-02-29 09:58:08 +01:00
|
|
|
caller: string;
|
2021-07-08 21:31:14 +01:00
|
|
|
recurringTypes: any;
|
|
|
|
|
selectedRecurringType: any;
|
2021-01-31 01:40:19 +01:00
|
|
|
|
2023-07-20 16:54:58 +01:00
|
|
|
CalendarNameOwnerName = ''
|
|
|
|
|
CalendarNamesOptions = []
|
|
|
|
|
|
2022-01-21 15:54:53 +01:00
|
|
|
public date: any;
|
|
|
|
|
public disabled = false;
|
|
|
|
|
public showSpinners = true;
|
|
|
|
|
public showSeconds = false;
|
|
|
|
|
public touchUi = false;
|
|
|
|
|
public enableMeridian = false;
|
2024-02-29 09:58:08 +01:00
|
|
|
public endMinDate = new Date(new Date().getTime() + 15 * 60000).toISOString().slice(0, 10)
|
2022-01-21 15:54:53 +01:00
|
|
|
public maxDate: any;
|
|
|
|
|
public stepHour = 1;
|
2022-12-17 17:01:36 +01:00
|
|
|
public stepMinute = 15;
|
|
|
|
|
public stepSecond = 15;
|
2022-01-21 15:54:53 +01:00
|
|
|
|
2021-07-09 12:35:11 +01:00
|
|
|
loadedEventAttachments: Attachment[] = [];
|
2021-04-06 11:28:46 +01:00
|
|
|
taskParticipants: any = [];
|
|
|
|
|
taskParticipantsCc: any = [];
|
|
|
|
|
adding: "intervenient" | "CC" = "intervenient";
|
|
|
|
|
|
2021-04-09 13:57:31 +01:00
|
|
|
showAttendees = false;
|
|
|
|
|
|
2022-01-21 15:54:53 +01:00
|
|
|
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];
|
|
|
|
|
|
2022-04-02 14:51:57 +01:00
|
|
|
sesseionStora = SessionStore
|
2023-07-20 16:54:58 +01:00
|
|
|
environment = environment
|
2024-03-02 12:38:30 +01:00
|
|
|
allDayCheck: boolean = false;
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2021-01-29 09:45:27 +01:00
|
|
|
constructor(
|
|
|
|
|
private modalController: ModalController,
|
2021-01-31 01:40:19 +01:00
|
|
|
private navParams: NavParams,
|
2023-07-20 16:54:58 +01:00
|
|
|
public eventsService: EventsService,
|
2021-01-31 01:40:19 +01:00
|
|
|
public alertController: AlertController,
|
2021-04-23 10:35:53 +01:00
|
|
|
private attachmentsService: AttachmentsService,
|
2021-06-15 15:09:20 +01:00
|
|
|
private toastService: ToastService,
|
2021-06-29 10:50:05 +01:00
|
|
|
private router: Router,
|
2023-02-27 09:34:36 +01:00
|
|
|
public ThemeService: ThemeService,
|
2023-07-25 15:56:42 +01:00
|
|
|
private httpErrorHandle: HttpErrorHandle,
|
2023-11-14 12:04:31 +01:00
|
|
|
private contactsService: ContactsService,
|
|
|
|
|
private domSanitazerService: DomSanitizerService
|
2021-04-07 10:04:58 +01:00
|
|
|
) {
|
2021-07-01 11:26:45 +01:00
|
|
|
|
2022-01-21 15:54:53 +01:00
|
|
|
/* this.postEvent = new Event(); */
|
2021-01-31 01:40:19 +01:00
|
|
|
this.isEventEdited = false;
|
2022-01-21 15:54:53 +01:00
|
|
|
/* this.postEvent.EventRecurrence = { Type:'-1', LastOccurrence:''}; */
|
2021-07-09 14:39:45 +01:00
|
|
|
this.postEvent = this.navParams.get('event');
|
2022-01-21 15:54:53 +01:00
|
|
|
|
2021-06-29 10:50:05 +01:00
|
|
|
this.caller = this.navParams.get('caller');
|
|
|
|
|
this.initCalendarName = this.postEvent.CalendarName;
|
2024-03-02 12:38:30 +01:00
|
|
|
this.allDayCheck = this.postEvent.IsAllDayEvent;
|
2021-04-23 10:35:53 +01:00
|
|
|
|
2023-07-25 15:56:42 +01:00
|
|
|
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
for (const index in this.postEvent.Attendees) {
|
2023-07-25 15:56:42 +01:00
|
|
|
const user = this.postEvent.Attendees[index]
|
|
|
|
|
|
|
|
|
|
const userData = this.contactsService.constacts.find(e => user.EmailAddress == e.EmailAddress)
|
2024-02-29 09:58:08 +01:00
|
|
|
if (userData) {
|
2023-07-25 15:56:42 +01:00
|
|
|
this.postEvent.Attendees[index].UserType = userData.UserType
|
|
|
|
|
}
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2023-07-25 15:56:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (this.postEvent) {
|
|
|
|
|
if (this.postEvent.Body) {
|
|
|
|
|
if (typeof (this.postEvent.Body.Text) == 'string') {
|
2021-04-23 10:35:53 +01:00
|
|
|
this.postEvent.Body.Text = this.postEvent.Body.Text.replace(/<[^>]+>/g, '');
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-08 09:14:28 +01:00
|
|
|
}
|
2021-04-06 11:28:46 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (this.postEvent.Attendees == null) {
|
2021-04-06 11:28:46 +01:00
|
|
|
this.taskParticipants = []
|
|
|
|
|
} else {
|
2021-04-08 13:39:48 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
this.postEvent.Attendees.forEach(e => {
|
|
|
|
|
if (e.IsRequired) {
|
2021-04-08 13:39:48 +01:00
|
|
|
this.taskParticipants.push(e);
|
|
|
|
|
} else {
|
|
|
|
|
this.taskParticipantsCc.push(e);
|
|
|
|
|
}
|
|
|
|
|
})
|
2021-04-06 11:28:46 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (this.postEvent.IsRecurring == false) {
|
2021-01-31 01:40:19 +01:00
|
|
|
this.isRecurring = "Não se repete";
|
|
|
|
|
}
|
2021-04-12 10:01:43 +01:00
|
|
|
else {
|
2021-01-31 01:40:19 +01:00
|
|
|
this.isRecurring = "Repete";
|
|
|
|
|
}
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2021-04-23 10:35:53 +01:00
|
|
|
this.getAttachments(this.postEvent.EventId);
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2023-07-20 16:54:58 +01:00
|
|
|
|
|
|
|
|
this.CalendarNameOwnerName = this.eventsService.detectCalendarNameByCalendarId(this.postEvent.CalendarId)
|
|
|
|
|
this.changeAgenda()
|
2021-01-31 01:40:19 +01:00
|
|
|
}
|
2021-01-29 09:45:27 +01:00
|
|
|
|
|
|
|
|
ngOnInit() {
|
2022-01-21 15:54:53 +01:00
|
|
|
|
2021-02-24 20:23:15 +01:00
|
|
|
window.onresize = (event) => {
|
|
|
|
|
// if not mobile remove all component
|
2024-02-29 09:58:08 +01:00
|
|
|
if (window.innerWidth >= 1024) {
|
2021-02-24 20:23:15 +01:00
|
|
|
this.modalController.dismiss();
|
|
|
|
|
}
|
2021-05-06 13:32:54 +01:00
|
|
|
}
|
2024-02-29 09:58:08 +01:00
|
|
|
if (window.innerWidth > 800) {
|
|
|
|
|
this.showAttendees = true;
|
2021-06-10 15:38:08 +01:00
|
|
|
}
|
2021-07-08 13:20:54 +01:00
|
|
|
|
|
|
|
|
this.getRecurrenceTypes();
|
2021-07-12 11:20:08 +01:00
|
|
|
setTimeout(() => {
|
|
|
|
|
this.selectedRecurringType = this.postEvent.EventRecurrence.Type.toString();
|
|
|
|
|
}, 500);
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2021-01-29 09:45:27 +01:00
|
|
|
}
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2023-08-22 08:35:44 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
|
clearInterval(this.myInterval)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
myInterval = setInterval(() => {
|
2024-02-29 09:58:08 +01:00
|
|
|
document.querySelectorAll('.ngx-mat-timepicker input').forEach((e: any) => {
|
|
|
|
|
if (e) {
|
2023-08-22 08:35:44 +01:00
|
|
|
e.disabled = true;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
2023-09-06 21:23:21 +01:00
|
|
|
ngOnChanges(changes: any): void {
|
|
|
|
|
this.loadedEventAttachments = this.postEvent?.Attachments
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-12 10:01:43 +01:00
|
|
|
close() {
|
2021-01-31 01:40:19 +01:00
|
|
|
this.modalController.dismiss();
|
2021-01-29 09:45:27 +01:00
|
|
|
}
|
2021-04-07 11:52:28 +01:00
|
|
|
|
2024-03-02 12:21:00 +01:00
|
|
|
cancel() {
|
|
|
|
|
this.modalController.dismiss({action:'cancel'});
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-29 10:50:05 +01:00
|
|
|
goBack() {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
this.router.navigate(['/home', this.caller]);
|
2021-06-29 10:50:05 +01:00
|
|
|
}
|
2021-04-08 13:39:48 +01:00
|
|
|
|
2021-07-08 13:20:54 +01:00
|
|
|
getRecurrenceTypes() {
|
2024-02-29 09:58:08 +01:00
|
|
|
this.eventsService.getRecurrenceTypes().subscribe(res => {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2021-07-08 21:31:14 +01:00
|
|
|
this.recurringTypes = res;
|
2021-07-08 13:20:54 +01:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-06 17:54:06 +01:00
|
|
|
roundTimeQuarterHour(timeToReturn = new Date()) {
|
2023-02-06 16:30:11 +01:00
|
|
|
let date = timeToReturn || new Date();
|
|
|
|
|
const minutes = date.getMinutes();
|
|
|
|
|
date.setSeconds(0);
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (minutes % 15 != 0) {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2023-02-06 16:30:11 +01:00
|
|
|
if (minutes > 45) {
|
|
|
|
|
date.setMinutes(60)
|
|
|
|
|
} else if (minutes > 30) {
|
|
|
|
|
date.setMinutes(45)
|
|
|
|
|
} else if (minutes > 15) {
|
|
|
|
|
date.setMinutes(30)
|
2023-02-06 19:04:26 +01:00
|
|
|
} else if (minutes > 0) {
|
2023-02-06 16:30:11 +01:00
|
|
|
date.setMinutes(15)
|
2022-12-17 17:01:36 +01:00
|
|
|
}
|
2023-02-06 16:30:11 +01:00
|
|
|
|
2023-09-20 20:25:48 +01:00
|
|
|
}
|
2023-02-06 16:30:11 +01:00
|
|
|
|
|
|
|
|
return date
|
2022-12-17 17:01:36 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
roundTimeQuarterHourPlus15(date: Date) {
|
2023-02-13 18:50:31 +01:00
|
|
|
const _date = new Date(date);
|
2024-02-29 09:58:08 +01:00
|
|
|
const minutes = _date.getMinutes();
|
|
|
|
|
_date.setMinutes(minutes + 15)
|
2023-09-20 20:25:48 +01:00
|
|
|
return _date
|
2023-02-13 18:50:31 +01:00
|
|
|
}
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
onSelectedRecurringChanged(ev?: any) {
|
2022-06-22 16:35:47 +01:00
|
|
|
|
|
|
|
|
this.calculetedLastOccurrence(ev);
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (ev.length > 1) {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2021-07-08 21:31:14 +01:00
|
|
|
this.selectedRecurringType = ev.filter(data => data != '-1');
|
|
|
|
|
}
|
2024-02-29 09:58:08 +01:00
|
|
|
if (ev.length == 0) {
|
2021-07-08 21:31:14 +01:00
|
|
|
this.selectedRecurringType = "-1";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
calculetedLastOccurrence(type: number) {
|
2022-06-29 15:51:28 +01:00
|
|
|
// console.log(type);
|
2023-09-20 20:25:48 +01:00
|
|
|
var valor;
|
2022-06-22 16:35:47 +01:00
|
|
|
var opcao: boolean;
|
|
|
|
|
if (type == 0) {
|
|
|
|
|
valor = 7;
|
|
|
|
|
opcao = true;
|
2024-02-29 09:58:08 +01:00
|
|
|
} else if (type == 1) {
|
2022-06-22 16:35:47 +01:00
|
|
|
valor = 30;
|
|
|
|
|
opcao = true;
|
2024-02-29 09:58:08 +01:00
|
|
|
} else if (type == 2) {
|
2022-06-22 16:35:47 +01:00
|
|
|
valor = 1;
|
|
|
|
|
opcao = false;
|
2024-02-29 09:58:08 +01:00
|
|
|
} else if (type == 3) {
|
2022-06-22 16:35:47 +01:00
|
|
|
valor = 5;
|
|
|
|
|
opcao = false;
|
|
|
|
|
}
|
|
|
|
|
this.defineLastOccurrence(valor, opcao);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
defineLastOccurrence(valor: number, opcao: boolean) {
|
2022-06-22 16:35:47 +01:00
|
|
|
var time = new Date(this.postEvent.EndDate);
|
|
|
|
|
if (opcao == true) {
|
|
|
|
|
time.setDate(time.getDate() + valor);
|
|
|
|
|
this.postEvent.EventRecurrence.LastOccurrence = time;
|
|
|
|
|
} else {
|
|
|
|
|
time = new Date(
|
2023-09-20 20:25:48 +01:00
|
|
|
time.getFullYear() + valor,
|
|
|
|
|
time.getMonth(),
|
|
|
|
|
time.getDate(),
|
|
|
|
|
time.getHours(),
|
2022-06-22 16:35:47 +01:00
|
|
|
time.getMinutes()
|
|
|
|
|
);
|
|
|
|
|
this.postEvent.EventRecurrence.LastOccurrence = time;
|
|
|
|
|
}
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2022-06-22 16:35:47 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-02 11:19:52 +01:00
|
|
|
|
|
|
|
|
runValidation() {
|
2024-02-29 09:58:08 +01:00
|
|
|
this.validateFrom = true
|
2021-07-02 11:19:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
injectValidation() {
|
|
|
|
|
|
|
|
|
|
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, [
|
|
|
|
|
Validators.required
|
|
|
|
|
]),
|
2021-07-15 08:53:54 +01:00
|
|
|
Categories: new FormControl(this.postEvent.Category, [
|
2021-07-02 11:19:52 +01:00
|
|
|
Validators.required
|
|
|
|
|
]),
|
|
|
|
|
IsRecurring: new FormControl(this.postEvent.IsRecurring, [
|
|
|
|
|
Validators.required
|
|
|
|
|
]),
|
2024-02-29 09:58:08 +01:00
|
|
|
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, [
|
2022-07-06 09:12:57 +01:00
|
|
|
Validators.required
|
|
|
|
|
]),
|
2024-02-29 09:58:08 +01:00
|
|
|
Date: new FormControl(new Date(this.postEvent.StartDate).getTime() <= new Date(this.postEvent.EndDate).getTime() ? 'ok' : null, [
|
2021-07-13 16:02:14 +01:00
|
|
|
Validators.required
|
|
|
|
|
]),
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2021-07-13 16:02:14 +01:00
|
|
|
participantes: new FormControl(this.taskParticipants, [
|
2024-02-29 09:58:08 +01:00
|
|
|
Validators.required
|
2021-07-13 16:02:14 +01:00
|
|
|
]),
|
2021-07-02 11:19:52 +01:00
|
|
|
|
|
|
|
|
})
|
|
|
|
|
}
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2022-01-21 15:54:53 +01:00
|
|
|
openInicio() {
|
|
|
|
|
let input: any = document.querySelector('#new-inicio')
|
2024-02-29 09:58:08 +01:00
|
|
|
if (input) {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2022-01-21 15:54:53 +01:00
|
|
|
input.click()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openFim() {
|
|
|
|
|
let input: any = document.querySelector('#new-fim')
|
2024-02-29 09:58:08 +01:00
|
|
|
if (input) {
|
2022-01-21 15:54:53 +01:00
|
|
|
input.click()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openLastOccurrence() {
|
|
|
|
|
let input: any = document.querySelector('#last-occurrence')
|
2024-02-29 09:58:08 +01:00
|
|
|
if (input) {
|
2022-01-21 15:54:53 +01:00
|
|
|
input.click()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-02 11:19:52 +01:00
|
|
|
|
2023-06-13 12:27:27 +01:00
|
|
|
async save() {
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2021-07-02 11:19:52 +01:00
|
|
|
this.injectValidation()
|
|
|
|
|
this.runValidation()
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (this.Form.invalid) return false;
|
|
|
|
|
if (this.selectedRecurringType != '-1') {
|
2021-07-09 14:39:45 +01:00
|
|
|
this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
|
|
|
|
|
}
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2021-04-08 13:39:48 +01:00
|
|
|
this.postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc)
|
2023-11-29 16:06:56 +01:00
|
|
|
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/* ) */;
|
2021-09-15 15:39:55 +01:00
|
|
|
|
2021-07-16 23:16:55 +01:00
|
|
|
this.postEvent.EventRecurrence.Type = this.selectedRecurringType;
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
|
2022-04-02 14:51:57 +01:00
|
|
|
this.eventsService.editEvent(this.postEvent, 2, 3).subscribe(async () => {
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (window['reloadCalendar']) {
|
2023-08-15 12:03:37 +01:00
|
|
|
window['reloadCalendar']()
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (this.initCalendarName != this.postEvent.CalendarName) {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2022-04-02 14:51:57 +01:00
|
|
|
let body = {
|
|
|
|
|
"EventId": this.postEvent.EventId,
|
|
|
|
|
"CalendarDestinationName": this.postEvent.CalendarName,
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
await this.eventsService.changeAgenda(body).toPromise();
|
2024-02-29 09:58:08 +01:00
|
|
|
} catch (error) { }
|
2022-04-02 14:51:57 +01:00
|
|
|
finally {
|
|
|
|
|
}
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2021-12-06 15:09:59 +01:00
|
|
|
}
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2023-02-27 09:34:36 +01:00
|
|
|
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2022-04-02 14:51:57 +01:00
|
|
|
}, error => {
|
2023-02-27 09:34:36 +01:00
|
|
|
this.httpErrorHandle.httpStatusHandle(error)
|
2022-04-02 14:51:57 +01:00
|
|
|
});
|
|
|
|
|
} else {
|
2024-03-03 05:36:03 +01:00
|
|
|
console.log('edid calendar id',this.postEvent.CalendarId);
|
2022-04-02 14:51:57 +01:00
|
|
|
this.eventsService.editEvent(this.postEvent, 2, 3, this.postEvent.CalendarId).subscribe(async () => {
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (window['reloadCalendar']) {
|
2023-08-15 12:03:37 +01:00
|
|
|
window['reloadCalendar']()
|
|
|
|
|
}
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (this.initCalendarName != this.postEvent.CalendarName) {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2022-04-02 14:51:57 +01:00
|
|
|
let body = {
|
|
|
|
|
"EventId": this.postEvent.EventId,
|
|
|
|
|
"CalendarDestinationName": this.postEvent.CalendarName,
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
await this.eventsService.changeAgenda(body).toPromise();
|
2024-02-29 09:58:08 +01:00
|
|
|
} catch (error) { }
|
2022-04-02 14:51:57 +01:00
|
|
|
finally {
|
|
|
|
|
}
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2021-12-06 15:09:59 +01:00
|
|
|
}
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2023-02-27 09:34:36 +01:00
|
|
|
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2022-04-02 14:51:57 +01:00
|
|
|
}, error => {
|
2023-02-27 09:34:36 +01:00
|
|
|
this.httpErrorHandle.httpStatusHandle(error)
|
2022-04-02 14:51:57 +01:00
|
|
|
});
|
|
|
|
|
}
|
2022-01-21 15:54:53 +01:00
|
|
|
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2021-05-24 16:49:25 +01:00
|
|
|
|
2021-07-16 23:16:55 +01:00
|
|
|
this.isEventEdited = true;
|
2021-09-15 15:39:55 +01:00
|
|
|
|
2021-05-24 16:49:25 +01:00
|
|
|
|
2023-09-20 20:25:48 +01:00
|
|
|
await this.saveDocument()
|
2021-05-24 16:49:25 +01:00
|
|
|
|
2023-06-13 12:27:27 +01:00
|
|
|
this.goBack();
|
2021-07-09 12:35:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-06-13 12:27:27 +01:00
|
|
|
async saveDocument() {
|
2021-07-09 12:35:11 +01:00
|
|
|
|
2023-06-13 12:27:27 +01:00
|
|
|
try {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
for (let e of this.loadedEventAttachments) {
|
2023-06-13 12:27:27 +01:00
|
|
|
const id: any = e.Id
|
|
|
|
|
const remove = e['remove']
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (id == 'add') {
|
2023-06-13 12:27:27 +01:00
|
|
|
//data.selected
|
|
|
|
|
const DocumentToSave = {
|
|
|
|
|
SourceTitle: e.SourceName,
|
|
|
|
|
ParentId: this.postEvent.EventId,
|
|
|
|
|
Source: '1',
|
|
|
|
|
SourceId: e.SourceId,
|
|
|
|
|
ApplicationId: e.ApplicationId.toString(),
|
|
|
|
|
Id: '0',
|
|
|
|
|
Link: '',
|
|
|
|
|
SerialNumber: '',
|
|
|
|
|
};
|
|
|
|
|
|
2023-09-20 20:25:48 +01:00
|
|
|
// await this.attachmentsService.setEventAttachmentById(DocumentToSave).toPromise();
|
2023-06-13 12:27:27 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
} else if (remove) {
|
2023-06-13 12:27:27 +01:00
|
|
|
await this.attachmentsService.deleteEventAttachmentById(e.Id).toPromise()
|
|
|
|
|
}
|
2021-07-09 12:35:11 +01:00
|
|
|
}
|
2023-06-13 12:27:27 +01:00
|
|
|
} catch (error) {
|
2021-07-09 12:35:11 +01:00
|
|
|
|
2023-06-13 12:27:27 +01:00
|
|
|
} finally {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2023-06-13 12:27:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.modalController.dismiss({
|
|
|
|
|
isEventEdited: this.isEventEdited,
|
|
|
|
|
postEvent: this.postEvent
|
|
|
|
|
});
|
2021-07-09 12:35:11 +01:00
|
|
|
|
2021-01-29 09:45:27 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-07 10:04:58 +01:00
|
|
|
async openAttendees() {
|
2024-02-29 09:58:08 +01:00
|
|
|
if (window.innerWidth > 801) {
|
|
|
|
|
this.showAttendees = true;
|
2021-06-10 15:38:08 +01:00
|
|
|
}
|
2022-04-20 14:41:02 +01:00
|
|
|
else {
|
2021-06-10 15:38:08 +01:00
|
|
|
const modal = await this.modalController.create({
|
2021-06-15 15:28:03 +01:00
|
|
|
component: AttendeesPageModal,
|
2024-02-29 09:58:08 +01:00
|
|
|
componentProps: {
|
2021-06-10 15:38:08 +01:00
|
|
|
adding: this.adding,
|
|
|
|
|
taskParticipants: this.taskParticipants,
|
|
|
|
|
taskParticipantsCc: this.taskParticipantsCc
|
|
|
|
|
},
|
2021-08-30 14:32:15 +01:00
|
|
|
cssClass: 'modal attendee modal-desktop',
|
2021-06-10 15:38:08 +01:00
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
2021-01-31 01:40:19 +01:00
|
|
|
|
2021-06-10 15:38:08 +01:00
|
|
|
await modal.present();
|
2021-04-07 11:52:28 +01:00
|
|
|
|
2021-06-10 15:38:08 +01:00
|
|
|
modal.onDidDismiss().then((data) => {
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (data) {
|
2021-06-10 15:38:08 +01:00
|
|
|
data = data['data'];
|
2021-05-04 15:44:48 +01:00
|
|
|
|
2021-06-10 15:38:08 +01:00
|
|
|
const newAttendees: EventPerson[] = data['taskParticipants'];
|
|
|
|
|
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
|
2021-05-04 15:44:48 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (newAttendees.length) {
|
2021-08-30 14:32:15 +01:00
|
|
|
this.setIntervenient(newAttendees);
|
2022-04-20 14:41:02 +01:00
|
|
|
} else {
|
|
|
|
|
this.setIntervenient([]);
|
2021-08-30 14:32:15 +01:00
|
|
|
}
|
2024-02-29 09:58:08 +01:00
|
|
|
if (newAttendeesCC) {
|
2021-08-30 14:32:15 +01:00
|
|
|
this.setIntervenientCC(newAttendeesCC);
|
2022-04-20 14:41:02 +01:00
|
|
|
} else {
|
|
|
|
|
this.setIntervenientCC([]);
|
2021-08-30 14:32:15 +01:00
|
|
|
}
|
2021-09-15 15:39:55 +01:00
|
|
|
|
2021-06-10 15:38:08 +01:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-05-04 15:44:48 +01:00
|
|
|
|
2021-04-07 11:52:28 +01:00
|
|
|
|
2021-04-06 11:28:46 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-21 16:45:17 +01:00
|
|
|
setIntervenient(data) {
|
2021-04-06 11:28:46 +01:00
|
|
|
this.taskParticipants = data;
|
|
|
|
|
this.postEvent.Attendees = data;
|
|
|
|
|
}
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2022-04-21 16:45:17 +01:00
|
|
|
setIntervenientCC(data) {
|
2021-04-06 11:28:46 +01:00
|
|
|
this.taskParticipantsCc = data;
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-21 16:45:17 +01:00
|
|
|
addParticipants() {
|
2021-04-06 11:28:46 +01:00
|
|
|
this.adding = 'intervenient'
|
2021-04-07 10:04:58 +01:00
|
|
|
this.openAttendees();
|
2021-04-06 11:28:46 +01:00
|
|
|
}
|
|
|
|
|
|
2022-04-21 16:45:17 +01:00
|
|
|
addParticipantsCC() {
|
2021-06-29 10:50:05 +01:00
|
|
|
this.adding = 'CC';
|
2021-04-07 10:04:58 +01:00
|
|
|
this.openAttendees();
|
2021-04-06 11:28:46 +01:00
|
|
|
}
|
2021-01-31 01:40:19 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
dynamicSetIntervenient({ taskParticipants, taskParticipantsCc }) {
|
2021-04-08 13:39:48 +01:00
|
|
|
this.taskParticipants = taskParticipants;
|
|
|
|
|
this.taskParticipantsCc = taskParticipantsCc;
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2023-06-09 15:29:03 +01:00
|
|
|
getAttachments(eventId: string) {
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (this.postEvent.HasAttachments) {
|
|
|
|
|
this.attachmentsService.getAttachmentsById(eventId).subscribe(res => {
|
2023-06-09 15:29:03 +01:00
|
|
|
this.loadedEventAttachments = res;
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
}, ((erro) => {
|
2023-06-09 15:29:03 +01:00
|
|
|
console.error('editgetAttchament', erro)
|
2023-09-20 20:25:48 +01:00
|
|
|
}));
|
2023-06-09 15:29:03 +01:00
|
|
|
}
|
|
|
|
|
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2021-04-23 10:35:53 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-09 12:35:11 +01:00
|
|
|
deleteAttachment(attachmentID: string, index) {
|
2021-04-23 10:35:53 +01:00
|
|
|
|
2021-07-09 12:35:11 +01:00
|
|
|
const id: any = this.loadedEventAttachments[index].Id
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (id == 'add') {
|
|
|
|
|
this.loadedEventAttachments = this.loadedEventAttachments.filter((e, i) => i != index)
|
2021-07-09 12:35:11 +01:00
|
|
|
} else {
|
|
|
|
|
this.loadedEventAttachments[index]['remove'] = true
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-13 12:05:17 +01:00
|
|
|
|
2021-04-23 10:35:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async getDoc() {
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: SearchPage,
|
|
|
|
|
cssClass: 'modal-width-100-width-background modal',
|
|
|
|
|
componentProps: {
|
2021-04-30 14:12:45 +01:00
|
|
|
type: 'AccoesPresidenciais & ArquivoDespachoElect',
|
2021-05-03 17:24:48 +01:00
|
|
|
showSearchInput: true,
|
|
|
|
|
select: true,
|
2021-04-23 10:35:53 +01:00
|
|
|
}
|
|
|
|
|
});
|
2023-07-15 11:01:09 +01:00
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
modal.onDidDismiss().then(async (res) => {
|
|
|
|
|
if (res) {
|
2021-04-23 10:35:53 +01:00
|
|
|
const data = res.data;
|
2021-07-09 12:35:11 +01:00
|
|
|
|
|
|
|
|
const ApplicationIdDocumentToSave: any = {
|
|
|
|
|
SourceName: data.selected.Assunto,
|
2021-04-23 10:35:53 +01:00
|
|
|
ParentId: this.postEvent.EventId,
|
|
|
|
|
SourceId: data.selected.Id,
|
2021-07-09 12:35:11 +01:00
|
|
|
Stakeholders: false,
|
2021-04-23 10:35:53 +01:00
|
|
|
ApplicationId: data.selected.ApplicationType.toString(),
|
2021-07-09 12:35:11 +01:00
|
|
|
CreateDate: false,
|
|
|
|
|
// needed to attach this document
|
|
|
|
|
Id: 'add',
|
|
|
|
|
SourceTitle: data.selected.Assunto,
|
|
|
|
|
Source: '1',
|
2021-04-23 10:35:53 +01:00
|
|
|
Link: '',
|
|
|
|
|
SerialNumber: '',
|
2021-07-09 12:35:11 +01:00
|
|
|
}
|
2021-04-23 10:35:53 +01:00
|
|
|
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2021-07-09 12:35:11 +01:00
|
|
|
this.loadedEventAttachments.push(ApplicationIdDocumentToSave)
|
2023-09-06 21:23:21 +01:00
|
|
|
this.postEvent.Attachments = this.loadedEventAttachments;
|
2021-04-23 10:35:53 +01:00
|
|
|
|
|
|
|
|
}
|
2021-07-09 12:35:11 +01:00
|
|
|
})
|
2023-07-15 11:01:09 +01:00
|
|
|
|
|
|
|
|
await modal.present();
|
2021-04-23 10:35:53 +01:00
|
|
|
}
|
|
|
|
|
|
2023-07-20 16:54:58 +01:00
|
|
|
|
|
|
|
|
changeAgenda() {
|
|
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
2024-02-29 09:58:08 +01:00
|
|
|
if (this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Oficial'] && this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Pessoal']) {
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2023-07-20 16:54:58 +01:00
|
|
|
this.CalendarNamesOptions = ['Oficial', 'Pessoal']
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2023-07-20 16:54:58 +01:00
|
|
|
} else if (this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Oficial']) {
|
|
|
|
|
this.CalendarNamesOptions = ['Oficial']
|
|
|
|
|
this.postEvent.CalendarName = 'Oficial'
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2023-07-20 16:54:58 +01:00
|
|
|
} else if (this.eventsService.calendarNamesType[this.CalendarNameOwnerName]?.['Pessoal']) {
|
|
|
|
|
this.CalendarNamesOptions = ['Pessoal']
|
|
|
|
|
this.postEvent.CalendarName = 'Pessoal'
|
2023-09-20 20:25:48 +01:00
|
|
|
|
2023-07-20 16:54:58 +01:00
|
|
|
} else {
|
|
|
|
|
this.CalendarNamesOptions = ['Oficial', 'Pessoal']
|
|
|
|
|
}
|
|
|
|
|
}, 50)
|
|
|
|
|
|
|
|
|
|
}
|
2024-02-29 09:58:08 +01:00
|
|
|
|
2024-03-02 12:38:30 +01:00
|
|
|
onCheckboxChange(event: any) {
|
2024-03-03 05:36:03 +01:00
|
|
|
console.log(this.postEvent.CalendarId)
|
2024-03-02 12:38:30 +01:00
|
|
|
if (this.allDayCheck) {
|
|
|
|
|
this.postEvent.IsAllDayEvent = this.allDayCheck;
|
|
|
|
|
this.postEvent.StartDate = this.setAlldayTime(this.postEvent.StartDate)
|
2024-03-03 05:36:03 +01:00
|
|
|
this.postEvent.EndDate = this.setAlldayTimeEndDate(this.postEvent.EndDate)
|
2024-03-02 12:38:30 +01:00
|
|
|
|
|
|
|
|
console.log('Recurso ativado!!');
|
|
|
|
|
} else {
|
|
|
|
|
this.postEvent.IsAllDayEvent = this.allDayCheck;
|
2024-03-03 05:36:03 +01:00
|
|
|
this.postEvent.EndDate = this.setAlldayTimeEndDateNotAlday(this.postEvent.EndDate)
|
2024-03-02 12:38:30 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
2024-03-03 05:36:03 +01:00
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
2024-03-02 12:38:30 +01:00
|
|
|
return date
|
|
|
|
|
}
|
2021-07-13 12:05:17 +01:00
|
|
|
}
|