Files
doneit-web/src/app/shared/agenda/edit-event/edit-event.page.ts
T

638 lines
17 KiB
TypeScript
Raw Normal View History

2021-06-23 15:39:45 +01:00
import { Component, OnInit, Input, Output, EventEmitter, ViewChild } from '@angular/core';
2021-02-24 09:14:58 +01:00
import { ModalController } from '@ionic/angular';
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 { Event } from 'src/app/models/event.model';
import { AlertController } from '@ionic/angular';
2021-04-08 20:11:25 +01:00
import { removeDuplicate } from 'src/plugin/removeDuplicate.js'
2021-04-19 11:35:48 +01:00
import { SearchPage } from 'src/app/pages/search/search.page';
2021-04-19 18:03:41 +01:00
import { AttachmentsService } from 'src/app/services/attachments.service';
import { Attachment } from 'src/app/models/attachment.model';
2021-07-01 16:23:47 +01:00
import { FormControl, FormGroup, Validators } from '@angular/forms';
2021-09-03 12:19:21 +01:00
import { ParticipantsPipe } from 'src/app/pipes/participants.pipe';
2021-10-22 15:43:57 +01:00
import { ThemeService } from 'src/app/services/theme.service'
2022-04-02 14:13:37 +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-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';
2021-10-22 15:43:57 +01:00
2021-02-24 09:14:58 +01:00
@Component({
selector: 'app-edit-event',
2021-06-03 14:10:16 +01:00
templateUrl: './edit-event.page.html',
styleUrls: ['./edit-event.page.scss'],
2021-02-24 09:14:58 +01:00
})
2021-07-06 16:18:00 +01:00
2021-06-03 14:10:16 +01:00
export class EditEventPage implements OnInit {
2021-07-13 11:15:19 +01:00
2021-02-24 09:14:58 +01:00
stEvent: Event;
isRecurring:string;
isEventEdited: boolean;
loadedEvent: Event;
2021-06-29 10:50:05 +01:00
initCalendarName: string;
2021-02-24 09:14:58 +01:00
eventBody: EventBody;
segment:string = "true";
eventAttendees: EventPerson[];
2021-06-23 15:39:45 +01:00
// minDate: string;
2021-07-09 12:50:03 +01:00
loadedEventAttachments: Attachment[]=[];
2021-08-31 15:05:42 +01:00
recurringTypes = [];
selectedRecurringType: any;
2021-06-23 15:39:45 +01:00
public date: any;
public disabled = false;
public showSpinners = true;
public showSeconds = false;
public touchUi = false;
public enableMeridian = false;
2021-07-08 14:45:38 +01:00
public minDate = new Date().toISOString().slice(0,10)
2021-07-12 16:30:03 +01:00
public endMinDate = new Date(new Date().getTime() + 15 * 60000).toISOString().slice(0,10)
2021-06-23 15:39:45 +01:00
public maxDate: any;
public stepHour = 1;
public stepMinute = 15;
public stepSecond = 15;
2021-06-23 15:39:45 +01:00
2021-07-01 16:23:47 +01:00
Form: FormGroup;
validateFrom = false
2021-04-08 13:39:48 +01:00
@Input() taskParticipants: EventPerson[];
@Input() taskParticipantsCc: EventPerson[];
2021-02-24 09:14:58 +01:00
@Input() profile:string;
@Input() selectedSegment: string;
@Input() postEvent: Event;
@Output() clearContact = new EventEmitter<any>();
2021-02-24 09:14:58 +01:00
2021-03-25 15:18:12 +01:00
@Output() openAttendeesComponent = new EventEmitter<any>();
@Output() closeComponent = new EventEmitter<any>();
2021-07-12 16:39:55 +01:00
2021-04-07 15:13:31 +01:00
@Output() setIntervenient = new EventEmitter<any>();
@Output() setIntervenientCC = new EventEmitter<any>();
2021-04-08 13:39:48 +01:00
@Output() clearPostEvent = new EventEmitter<any>();
2021-02-24 09:14:58 +01:00
2021-06-23 15:39:45 +01:00
showLoader = false
@ViewChild('picker') picker: any;
@ViewChild('fim') fim: any;
@ViewChild('inicio') inicio: any;
@ViewChild('picker1') picker1: any;
2023-07-25 15:56:42 +01:00
@Input() _postEvent: Event;
2021-06-23 15:39:45 +01:00
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];
2021-09-03 12:19:21 +01:00
private participantsPipe = new ParticipantsPipe()
2022-04-02 14:13:37 +01:00
sesseionStora = SessionStore
2021-09-03 12:19:21 +01:00
2023-07-20 16:54:58 +01:00
CalendarNameOwnerName = ''
CalendarNamesOptions = []
2024-03-03 05:36:03 +01:00
allDayCheck: boolean = false;
2023-07-20 16:54:58 +01:00
2021-02-24 09:14:58 +01:00
constructor(
private modalController: ModalController,
private eventsService: EventsService,
public alertController: AlertController,
2021-04-19 18:03:41 +01:00
private attachmentsService: AttachmentsService,
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 domSanitizeService: DomSanitizerService
2021-09-27 16:23:41 +01:00
) {}
2021-02-24 09:14:58 +01:00
ngOnInit() {
2023-07-25 15:56:42 +01:00
this._postEvent = this.postEvent
2024-03-03 05:36:03 +01:00
this.allDayCheck = this.postEvent.IsAllDayEvent;
2021-06-30 14:44:48 +01:00
if(!this.restoreTemporaryData()) {
2021-04-21 14:27:55 +01:00
// clear
2021-07-12 16:39:55 +01:00
2023-07-25 15:56:42 +01:00
if(this._postEvent) {
if( this._postEvent.Body){
if(typeof(this._postEvent.Body.Text) == 'string'){
this._postEvent.Body.Text = this._postEvent.Body.Text.replace(/<[^>]+>/g, '');
2021-04-19 18:03:41 +01:00
}
}
}
2021-07-12 16:39:55 +01:00
2023-07-25 15:56:42 +01:00
2023-09-20 20:25:48 +01:00
2023-07-25 15:56:42 +01:00
for(const index in this._postEvent.Attendees) {
const user = this._postEvent.Attendees[index]
const userData = this.contactsService.constacts.find(e => user.EmailAddress == e.EmailAddress)
if(userData) {
this._postEvent.Attendees[index].UserType = userData.UserType
} else {
console.log('user not set')
}
2023-09-20 20:25:48 +01:00
2023-07-25 15:56:42 +01:00
}
if (this._postEvent.Attendees != null) {
const result = this.participantsPipe.transform(this._postEvent.Attendees)
2022-07-06 14:52:53 +01:00
this.taskParticipants = result.taskParticipants
this.taskParticipantsCc = result.taskParticipantsCc
2021-07-12 16:39:55 +01:00
2022-07-06 14:52:53 +01:00
this.taskParticipants = removeDuplicate(this.taskParticipants);
this.taskParticipantsCc = removeDuplicate(this.taskParticipantsCc);
2021-07-12 16:39:55 +01:00
2022-07-06 14:52:53 +01:00
this.setIntervenient.emit(this.taskParticipants);
this.setIntervenientCC.emit(this.taskParticipantsCc);
}
2021-02-24 09:14:58 +01:00
}
2021-04-19 18:03:41 +01:00
2023-07-25 15:56:42 +01:00
this.initCalendarName = this._postEvent.CalendarName;
2023-02-14 16:28:27 +01:00
2021-07-12 16:39:55 +01:00
this.getRecurrenceTypes();
2021-07-13 15:20:16 +01:00
2021-07-12 16:39:55 +01:00
setTimeout(() => {
2023-07-25 15:56:42 +01:00
this._postEvent.EventRecurrence.Type = this._postEvent.EventRecurrence.Type.toString();
2023-09-20 20:25:48 +01:00
2022-07-06 14:52:53 +01:00
}, 500);
2021-07-13 09:31:42 +01:00
2023-07-25 15:56:42 +01:00
this.CalendarNameOwnerName = this.eventsService.detectCalendarNameByCalendarId(this._postEvent.CalendarId)
2023-07-20 16:54:58 +01:00
this.changeAgenda()
2023-07-25 15:56:42 +01:00
2021-02-24 09:14:58 +01:00
}
2021-07-12 16:39:55 +01:00
2023-08-22 08:35:44 +01:00
ngOnDestroy() {
clearInterval(this.myInterval)
}
myInterval = setInterval(() => {
document.querySelectorAll('.ngx-mat-timepicker input').forEach((e :any) => {
if(e) {
e.disabled = true;
}
})
}, 1000);
2021-11-07 20:56:34 +01:00
ngOnChanges(changes: any): void {
2023-08-10 16:46:55 +01:00
this.loadedEventAttachments = this._postEvent?.Attachments
2021-11-07 20:56:34 +01:00
}
2021-06-23 15:39:45 +01:00
close() {
this.closeComponent.emit();
2021-04-08 13:39:48 +01:00
this.setIntervenient.emit([]);
this.setIntervenientCC.emit([]);
this.clearContact.emit();
this.deleteTemporaryData();
2021-02-24 09:14:58 +01:00
}
2021-04-08 13:39:48 +01:00
2021-07-12 16:39:55 +01:00
getRecurrenceTypes() {
this.eventsService.getRecurrenceTypes().subscribe(res=>{
2023-09-20 20:25:48 +01:00
2021-07-12 16:39:55 +01:00
this.recurringTypes = res;
});
}
2021-07-01 16:23:47 +01:00
runValidation() {
this.validateFrom = true
}
injectValidation() {
2023-07-25 15:56:42 +01:00
if (typeof(this._postEvent.EventRecurrence.Type) == 'number') {
const str: any = this._postEvent.EventRecurrence.Type.toString()
this._postEvent.EventRecurrence.Type = str
2021-07-20 19:22:11 +01:00
}
2021-09-15 15:39:55 +01:00
2021-07-01 16:23:47 +01:00
this.Form = new FormGroup({
2023-07-25 15:56:42 +01:00
Subject: new FormControl(this._postEvent.Subject, [
2021-07-01 16:23:47 +01:00
Validators.required,
// Validators.minLength(4)
]),
2023-07-25 15:56:42 +01:00
Location: new FormControl(this._postEvent.Location, [
2021-07-01 16:23:47 +01:00
Validators.required,
]),
2023-07-25 15:56:42 +01:00
CalendarName: new FormControl(this._postEvent.CalendarName),
Categories: new FormControl(this._postEvent.Category, [
2021-07-01 16:23:47 +01:00
Validators.required
]),
2023-07-25 15:56:42 +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, [
2021-07-01 16:23:47 +01:00
Validators.required
2021-07-13 11:15:19 +01:00
]),
2021-07-08 13:41:27 +01:00
participantes: new FormControl(this.taskParticipants, [
2021-07-20 12:30:52 +01:00
// Validators.required
2021-07-01 16:23:47 +01:00
]),
2023-08-30 18:43:48 +01:00
Date: new FormControl( true,[
2021-07-12 16:05:05 +01:00
Validators.required
]),
2021-07-01 16:23:47 +01:00
})
2021-11-16 17:03:34 +01:00
2021-07-01 16:23:47 +01:00
}
2021-07-13 11:15:19 +01:00
openInicio() {
let input: any = document.querySelector('#new-inicio')
if(input) {
2023-09-20 20:25:48 +01:00
2021-07-13 11:15:19 +01:00
input.click()
}
}
openFim() {
let input: any = document.querySelector('#new-fim')
if(input) {
input.click()
}
}
openLastOccurrence() {
let input: any = document.querySelector('#last-occurrence')
if(input) {
input.click()
}
}
roundTimeQuarterHour() {
2023-02-06 16:30:11 +01:00
let date = new Date();
const minutes = date.getMinutes();
date.setSeconds(0);
2023-02-06 16:30:11 +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)
}
2023-09-20 20:25:48 +01:00
}
2023-02-06 16:30:11 +01:00
return date
}
2023-02-13 18:50:31 +01:00
roundTimeQuarterHourPlus15(date:Date) {
const _date = new Date(date);
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
}
2021-07-15 16:09:30 +01:00
onSelectedRecurringChanged(ev:any){
this.calculetedLastOccurrence(ev);
2023-09-20 20:25:48 +01:00
2021-07-15 16:09:30 +01:00
if(ev.length > 1){
2023-09-20 20:25:48 +01:00
2023-07-25 15:56:42 +01:00
this._postEvent.EventRecurrence.Type = ev.filter(data => data != '-1');
2021-07-15 16:09:30 +01:00
}
if(ev.length == 0){
2023-07-25 15:56:42 +01:00
this._postEvent.EventRecurrence.Type = "-1";
2021-07-15 16:09:30 +01:00
}
}
calculetedLastOccurrence(type:number){
2023-09-20 20:25:48 +01:00
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){
2023-07-25 15:56:42 +01:00
var time = new Date(this._postEvent.EndDate);
if (opcao == true) {
time.setDate(time.getDate() + valor);
2023-07-25 15:56:42 +01:00
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(),
time.getMinutes()
);
2023-07-25 15:56:42 +01:00
this._postEvent.EventRecurrence.LastOccurrence = time;
}
2023-09-20 20:25:48 +01:00
}
2021-07-01 16:23:47 +01:00
2021-06-23 15:39:45 +01:00
async save() {
2021-04-19 11:35:48 +01:00
2021-07-01 16:23:47 +01:00
this.injectValidation()
this.runValidation()
2021-07-06 16:18:00 +01:00
if(this.Form.invalid) {
return false
}
2021-07-01 16:23:47 +01:00
2023-07-25 15:56:42 +01:00
this._postEvent.Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
2023-11-29 16:06:56 +01:00
this._postEvent.Subject = /* this.domSanitizeService.sanitizeInput( */this._postEvent.Subject/* ) */;
this._postEvent.Location = /* this.domSanitizeService.sanitizeInput( */this._postEvent.Location/* ) */;
this._postEvent.Body.Text = /* this.domSanitizeService.sanitizeInput( */this._postEvent.Body.Text/* ) */;
2021-04-08 13:39:48 +01:00
2023-07-25 15:56:42 +01:00
if(!this._postEvent.EventRecurrence.hasOwnProperty('Type')) {
this._postEvent.EventRecurrence.Type = '-1'
2021-09-03 12:19:21 +01:00
} else {
2021-07-20 12:30:52 +01:00
}
2023-07-25 15:56:42 +01:00
if(this._postEvent.EventRecurrence.Type == undefined) {
this._postEvent.EventRecurrence.Type = '-1'
2021-07-20 12:30:52 +01:00
}
2021-07-15 14:26:26 +01:00
this.showLoader = true;
2021-11-16 17:03:34 +01:00
try {
2023-09-20 20:25:48 +01:00
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
2024-05-24 11:29:53 +01:00
await this.eventsService.editEvent(this._postEvent, 2, 3, this._postEvent.CalendarId).toPromise()
2023-07-25 15:56:42 +01:00
if(this.initCalendarName != this._postEvent.CalendarName) {
2022-04-02 14:13:37 +01:00
let body = {
2023-07-25 15:56:42 +01:00
"EventId": this._postEvent.EventId,
"CalendarDestinationName": this._postEvent.CalendarName,
2022-04-02 14:13:37 +01:00
}
2023-09-20 20:25:48 +01:00
2022-04-02 14:13:37 +01:00
try {
await this.eventsService.changeAgenda(body).toPromise();
} catch (e) {}
2021-06-29 10:50:05 +01:00
}
2022-04-02 14:13:37 +01:00
this.showLoader = false;
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
2022-04-02 14:13:37 +01:00
} else {
2024-05-24 11:29:53 +01:00
console.log(this._postEvent, 2, 3, this._postEvent.CalendarId)
2023-07-25 15:56:42 +01:00
await this.eventsService.editEvent(this._postEvent, 2, 3, this._postEvent.CalendarId).toPromise()
if(this.initCalendarName != this._postEvent.CalendarName) {
2022-04-02 14:13:37 +01:00
let body = {
2023-07-25 15:56:42 +01:00
"EventId": this._postEvent.EventId,
"CalendarDestinationName": this._postEvent.CalendarName,
2022-04-02 14:13:37 +01:00
}
2023-09-20 20:25:48 +01:00
2022-04-02 14:13:37 +01:00
try {
await this.eventsService.changeAgenda(body).toPromise();
} catch (e) {}
}
this.showLoader = false;
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpsSucessMessagge('Editar evento')
2021-06-29 10:50:05 +01:00
}
2022-04-02 14:13:37 +01:00
2021-11-16 17:03:34 +01:00
} catch(error) {
2021-06-23 15:39:45 +01:00
this.showLoader = false
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpStatusHandle(error)
2021-11-16 17:03:34 +01:00
}
2021-04-08 13:39:48 +01:00
this.clearPostEvent.emit();
this.deleteTemporaryData();
2021-07-12 16:39:55 +01:00
2023-09-20 20:25:48 +01:00
await this.saveDocument()
2021-10-06 09:28:58 +01:00
this.close();
2021-07-09 12:50:03 +01:00
}
2021-10-06 09:28:58 +01:00
async saveDocument() {
2021-07-09 12:50:03 +01:00
2021-10-06 09:28:58 +01:00
2023-06-13 12:27:27 +01:00
try {
2023-09-20 20:25:48 +01:00
2023-06-13 12:27:27 +01:00
for( let e of this.loadedEventAttachments) {
const id: any = e.Id
const remove = e['remove']
if ( id == 'add') {
//data.selected
const DocumentToSave = {
SourceTitle: e.SourceName,
2023-07-25 15:56:42 +01:00
ParentId: this._postEvent.EventId,
2023-06-13 12:27:27 +01:00
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
} else if(remove) {
await this.attachmentsService.deleteEventAttachmentById(e.Id).toPromise()
}
2021-07-09 12:50:03 +01:00
}
2023-06-13 12:27:27 +01:00
} catch (error) {
2021-07-09 12:50:03 +01:00
2023-06-13 12:27:27 +01:00
}
2021-07-09 12:50:03 +01:00
2021-04-08 13:39:48 +01:00
}
2021-04-07 15:13:31 +01:00
2021-04-08 13:39:48 +01:00
async addParticipants() {
this.saveTemporaryData();
2021-04-08 13:39:48 +01:00
this.openAttendeesComponent.emit({
type: "intervenient"
});
this.clearContact.emit();
2021-02-24 09:14:58 +01:00
}
2021-04-08 13:39:48 +01:00
async addParticipantsCc() {
this.saveTemporaryData();
2021-04-08 13:39:48 +01:00
this.openAttendeesComponent.emit({
type: "CC"
});
2021-02-24 09:14:58 +01:00
2021-03-25 15:18:12 +01:00
this.clearContact.emit();
2021-04-07 15:13:31 +01:00
}
2021-02-24 09:14:58 +01:00
2021-06-23 15:39:45 +01:00
saveTemporaryData() {
2021-07-12 16:39:55 +01:00
window['temp.path:/home/agenda/edit-event.component.ts'] = {
2023-07-25 15:56:42 +01:00
postEvent: this._postEvent,
eventBody: this.eventBody,
2023-07-28 16:28:59 +01:00
segment: this.segment,
loadedEventAttachments: this.loadedEventAttachments
}
}
2021-06-23 15:39:45 +01:00
restoreTemporaryData(): boolean {
2021-07-12 16:39:55 +01:00
const restoredData = window['temp.path:/home/agenda/edit-event.component.ts']
if(JSON.stringify(restoredData) != "{}" && undefined != restoredData){
2023-07-25 15:56:42 +01:00
this._postEvent = restoredData.postEvent
this.eventBody = restoredData.eventBody
this.segment = restoredData.segment
2023-07-28 16:28:59 +01:00
this.loadedEventAttachments = restoredData.loadedEventAttachments
2021-07-12 16:39:55 +01:00
return true;
} else {
return false;
}
2021-07-12 16:39:55 +01:00
}
deleteTemporaryData(){
window['temp.path:/home/agenda/edit-event.component.ts'] = {}
}
2021-11-07 20:56:34 +01:00
async getAttachments(eventId: string){
2023-07-25 15:56:42 +01:00
if(this._postEvent.HasAttachments) {
2023-06-09 15:29:03 +01:00
let rest: any;
try {
rest = this.attachmentsService.getAttachmentsById(eventId).toPromise()
} catch (error) {
console.error('getAttchment', error)
}
this.loadedEventAttachments = rest;
2022-12-21 16:25:09 +01:00
}
2021-04-19 18:03:41 +01:00
}
2021-07-09 12:50:03 +01:00
deleteAttachment(attachmentID: string, index) {
2021-04-20 15:05:40 +01:00
2021-07-09 12:50:03 +01:00
const id: any = this.loadedEventAttachments[index].Id
2021-07-12 16:39:55 +01:00
2021-07-09 12:50:03 +01:00
if(id == 'add') {
this.loadedEventAttachments = this.loadedEventAttachments.filter((e,i)=> i!=index)
} else {
this.loadedEventAttachments[index]['remove'] = true
}
2021-04-20 16:06:31 +01:00
}
2023-02-14 16:28:27 +01:00
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,
}
});
2023-07-15 11:01:09 +01:00
2023-09-20 20:25:48 +01:00
modal.onDidDismiss().then( async (res) => {
2023-02-14 16:35:11 +01:00
if(res) {
2023-02-14 16:28:27 +01:00
const data = res.data;
const ApplicationIdDocumentToSave: any = {
SourceName: data.selected.Assunto,
2023-07-25 15:56:42 +01:00
ParentId: this._postEvent.EventId,
2023-02-14 16:28:27 +01:00
SourceId: data.selected.Id,
2024-05-24 11:29:53 +01:00
Stakeholders: data.selected.EntidadeOrganicaNome | data.selected.Stakeholders,
2023-02-14 16:28:27 +01:00
ApplicationId: data.selected.ApplicationType.toString(),
CreateDate: data.selected.Data,
Id: 'add',
SourceTitle: data.selected.Assunto,
Source: '1',
Link: '',
SerialNumber: '',
}
2021-07-09 12:50:03 +01:00
2023-02-14 16:28:27 +01:00
this.loadedEventAttachments.push(ApplicationIdDocumentToSave)
2021-04-20 16:06:31 +01:00
2023-02-14 16:28:27 +01:00
}
});
2023-07-15 11:01:09 +01:00
await modal.present();
2023-02-14 16:28:27 +01:00
}
2021-04-20 15:05:40 +01:00
2021-04-20 16:06:31 +01:00
2023-07-20 16:54:58 +01:00
changeAgenda() {
setTimeout(() => {
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']
2023-07-25 15:56:42 +01:00
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']
2023-07-25 15:56:42 +01:00
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-03-03 05:36:03 +01:00
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)
2024-05-24 11:29:53 +01:00
2024-03-03 05:36:03 +01:00
console.log('Recurso ativado!!');
} else {
this.postEvent.IsAllDayEvent = this.allDayCheck;
this.postEvent.EndDate = this.setAlldayTimeEndDateNotAlday(this.postEvent.EndDate)
console.log('Recurso desativado');
2024-05-24 11:29:53 +01:00
2024-03-03 05:36:03 +01:00
}
}
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
}
2024-02-29 22:47:42 +01:00
2024-03-03 05:36:03 +01:00
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
2024-02-29 10:23:17 +01:00
}
2024-03-03 05:36:03 +01:00
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
2024-02-29 10:23:17 +01:00
}
2021-02-24 09:14:58 +01:00
}