2021-04-30 12:57:54 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
|
import { Router } from '@angular/router';
|
|
|
|
|
import { ModalController, NavParams } from '@ionic/angular';
|
|
|
|
|
import { Event } from 'src/app/models/event.model'
|
|
|
|
|
import { EventBody } from 'src/app/models/eventbody.model';
|
|
|
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
|
|
|
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 { AddParticipantsModalPage } from 'src/app/pages/gabinete-digital/expediente/add-participants-modal/add-participants-modal.page';
|
|
|
|
|
import { AddParticipantsCcModalPage } from 'src/app/pages/gabinete-digital/expediente/add-participants-cc-modal/add-participants-cc-modal.page';
|
|
|
|
|
import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discart-expedient-modal/discart-expedient-modal.page';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-delegar',
|
|
|
|
|
templateUrl: './delegar.page.html',
|
|
|
|
|
styleUrls: ['./delegar.page.scss'],
|
|
|
|
|
})
|
|
|
|
|
export class DelegarPage implements OnInit {
|
|
|
|
|
task: any;
|
|
|
|
|
|
|
|
|
|
taskParticipants: EventPerson[] = [];
|
|
|
|
|
taskParticipantsCc: EventPerson[] = [];
|
|
|
|
|
|
|
|
|
|
taskDocId:string;
|
|
|
|
|
loadedAttachments:any;
|
|
|
|
|
|
|
|
|
|
adding: "intervenient" | "CC" = "intervenient";
|
|
|
|
|
|
|
|
|
|
postData: Event;
|
|
|
|
|
eventBody: EventBody;
|
|
|
|
|
eventAttendees: EventPerson[];
|
|
|
|
|
|
|
|
|
|
formLocationSatus: boolean = false;
|
|
|
|
|
showAttendees= false;
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
private modalController: ModalController,
|
|
|
|
|
private router:Router,
|
|
|
|
|
private navParams: NavParams,
|
|
|
|
|
private processes:ProcessesService,
|
|
|
|
|
private attachmentsService: AttachmentsService,
|
|
|
|
|
private calendarService: EventsService,
|
|
|
|
|
) {
|
|
|
|
|
this.task = this.navParams.get('task');
|
|
|
|
|
this.postData = new Event();
|
|
|
|
|
this.eventBody = { BodyType : "1", Text : ""};
|
|
|
|
|
this.postData.Body = this.eventBody;
|
|
|
|
|
|
|
|
|
|
/* Initialize 'Subject' with the title of the expedient */
|
|
|
|
|
this.postData.Subject = this.task.Folio;
|
|
|
|
|
this.postData.CalendarName = "Oficial";
|
|
|
|
|
/* this.postData.StartDate = new Date(); */
|
|
|
|
|
/* Set + 30minutes to seleted datetime */
|
|
|
|
|
let selectedEndDate = new Date();
|
|
|
|
|
/* this.postData.EndDate = new Date(selectedEndDate.setMinutes(new Date().getMinutes() + 30)); */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
|
this.adding = "intervenient";
|
|
|
|
|
console.log(this.task);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close(){
|
|
|
|
|
this.router.navigate(['/home/gabinete-digital/expediente']);
|
|
|
|
|
this.modalController.dismiss(null);
|
|
|
|
|
}
|
|
|
|
|
cancelTask(){
|
|
|
|
|
this.modalController.dismiss(null);
|
|
|
|
|
}
|
2021-04-30 14:05:55 +01:00
|
|
|
|
2021-04-30 12:57:54 +01:00
|
|
|
saveTask(){
|
|
|
|
|
|
|
|
|
|
// issue12323423
|
|
|
|
|
let Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
|
|
|
|
|
|
|
|
|
|
this.eventBody={
|
|
|
|
|
BodyType: '1',
|
|
|
|
|
Text: this.postData.Body.Text,
|
|
|
|
|
}
|
|
|
|
|
this.postData = {
|
|
|
|
|
EventId: '',
|
|
|
|
|
Subject: this.postData.Subject,
|
|
|
|
|
Body: this.eventBody,
|
|
|
|
|
Location: this.postData.Location,
|
|
|
|
|
CalendarId: '',
|
|
|
|
|
CalendarName: this.postData.CalendarName,
|
|
|
|
|
StartDate: this.postData.StartDate,
|
|
|
|
|
EndDate: this.postData.EndDate,
|
|
|
|
|
EventType: 'Reunião',
|
|
|
|
|
Attendees: Attendees,
|
|
|
|
|
IsMeeting: false,
|
|
|
|
|
IsRecurring: false,
|
|
|
|
|
AppointmentState: 0,
|
|
|
|
|
TimeZone: 'UTC',
|
|
|
|
|
Organizer: null,
|
|
|
|
|
Categories: null,
|
|
|
|
|
HasAttachments: true,
|
|
|
|
|
}
|
|
|
|
|
console.log(this.postData);
|
|
|
|
|
|
|
|
|
|
if(this.task.FsId == '8'){
|
|
|
|
|
this.calendarService.postExpedientEvent(this.task.DocId, this.postData, "md",this.task.SerialNumber, this.task.FsId);
|
|
|
|
|
this.distartExpedientModal();
|
|
|
|
|
}
|
|
|
|
|
else if(this.task.FsId == '361'){
|
|
|
|
|
this.calendarService.createTaskEvent(this.task.FolderId, this.postData, "md",this.task.SerialNumber, this.task.FsId);
|
|
|
|
|
}
|
|
|
|
|
this.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async addParticipants(){
|
|
|
|
|
this.adding = "intervenient";
|
|
|
|
|
if(window.innerWidth <= 800){
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: AddParticipantsModalPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
eventPersons: this.eventAttendees
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'book-meeting-modal',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await modal.present();
|
|
|
|
|
|
|
|
|
|
modal.onDidDismiss().then((res) => {
|
|
|
|
|
this.taskParticipants = res.data;
|
|
|
|
|
let newattendees: EventPerson[] = res['data'];
|
|
|
|
|
if(newattendees != null){
|
|
|
|
|
newattendees.forEach(newattendee => {
|
|
|
|
|
let att = {
|
|
|
|
|
"EmailAddress": newattendee.EmailAddress,
|
|
|
|
|
"Name": newattendee.Name,
|
|
|
|
|
"IsRequired": true
|
|
|
|
|
};
|
|
|
|
|
if(this.eventAttendees == null){
|
|
|
|
|
this.eventAttendees = new Array();
|
|
|
|
|
}
|
|
|
|
|
this.eventAttendees.push(att);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.postData.Attendees = this.eventAttendees;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.showAttendees = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async distartExpedientModal(){
|
|
|
|
|
const modal = await this.modalController.create({
|
|
|
|
|
component: DiscartExpedientModalPage,
|
|
|
|
|
componentProps: {
|
|
|
|
|
serialNumber: this.task.SerialNumber,
|
|
|
|
|
},
|
|
|
|
|
cssClass: 'discart-expedient-modal',
|
|
|
|
|
backdropDismiss: false
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await modal.present();
|
|
|
|
|
|
|
|
|
|
modal.onDidDismiss();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
validateFormInputs(){
|
|
|
|
|
let formLocation = this.postData.Location.trim();
|
|
|
|
|
if(!this.postData.Location && formLocation.length <= 0){
|
|
|
|
|
this.formLocationSatus=true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dynamicSetIntervenient({taskParticipants, taskParticipantsCc}){
|
|
|
|
|
|
|
|
|
|
this.taskParticipants = taskParticipants;
|
|
|
|
|
this.taskParticipantsCc = taskParticipantsCc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|