add delegate functionality

This commit is contained in:
tiago.kayaya
2021-05-03 12:57:26 +01:00
parent 7bfb09dfaf
commit 620bd61801
7 changed files with 81 additions and 71 deletions
+32 -46
View File
@@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ModalController, NavParams } from '@ionic/angular';
import { AlertController, 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';
@@ -10,6 +10,7 @@ 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';
import { AlertService } from 'src/app/services/alert.service';
@Component({
selector: 'app-delegar',
@@ -18,6 +19,7 @@ import { DiscartExpedientModalPage } from 'src/app/pages/gabinete-digital/discar
})
export class DelegarPage implements OnInit {
task: any;
note:string;
taskParticipants: EventPerson[] = [];
taskParticipantsCc: EventPerson[] = [];
@@ -29,7 +31,7 @@ export class DelegarPage implements OnInit {
postData: Event;
eventBody: EventBody;
eventAttendees: EventPerson[];
eventAttendees: EventPerson;
formLocationSatus: boolean = false;
showAttendees= false;
@@ -41,6 +43,8 @@ export class DelegarPage implements OnInit {
private processes:ProcessesService,
private attachmentsService: AttachmentsService,
private calendarService: EventsService,
public alertController: AlertController,
private alertService: AlertService,
) {
this.task = this.navParams.get('task');
this.postData = new Event();
@@ -73,47 +77,30 @@ export class DelegarPage implements OnInit {
this.modalController.dismiss(null);
}
saveTask(){
// issue12323423
let Attendees = this.taskParticipants.concat(this.taskParticipantsCc);
this.eventBody={
BodyType: '1',
Text: this.postData.Body.Text,
async saveTask(){
if(this.taskParticipants.length > 1){
this.alertService.presentErrorMessage("Selecione apenas um destinatário");
}
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,
else{
let body = {
"SerialNumber": this.task.SerialNumber,
"DispatchDocId": this.task.DocId,
"FolderID": this.task.FolderId,
"Subject": this.task.Folio,
"Comment": this.note,
"DelegatedUserEmail": this.taskParticipants[0].EmailAddress,
}
console.log(body);
this.processes.DelegateTask(body).subscribe(res=>{
console.log(res);
});
this.close();
}
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(){
console.log('HERE');
this.adding = "intervenient";
if(window.innerWidth <= 800){
const modal = await this.modalController.create({
@@ -128,7 +115,7 @@ export class DelegarPage implements OnInit {
await modal.present();
modal.onDidDismiss().then((res) => {
this.taskParticipants = res.data;
/* this.taskParticipants = res.data;
let newattendees: EventPerson[] = res['data'];
if(newattendees != null){
newattendees.forEach(newattendee => {
@@ -138,12 +125,13 @@ export class DelegarPage implements OnInit {
"IsRequired": true
};
if(this.eventAttendees == null){
this.eventAttendees = new Array();
this.eventAttendees = null;
}
this.eventAttendees.push(att);
this.eventAttendees = att;
console.log(att);
});
}
this.postData.Attendees = this.eventAttendees;
} */
});
} else {
this.showAttendees = true;
@@ -172,10 +160,8 @@ export class DelegarPage implements OnInit {
}
}
dynamicSetIntervenient({taskParticipants, taskParticipantsCc}){
dynamicSetIntervenient({taskParticipants}){
this.taskParticipants = taskParticipants;
this.taskParticipantsCc = taskParticipantsCc;
}
}