mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
317 lines
8.9 KiB
TypeScript
317 lines
8.9 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { AnimationController, ModalController, NavParams } from '@ionic/angular';
|
|
import { AddParticipantsCcModalPage } from '../add-participants-cc-modal/add-participants-cc-modal.page';
|
|
import { AddParticipantsModalPage } from '../add-participants-modal/add-participants-modal.page';
|
|
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 { DiscartExpedientModalPage } from '../../discart-expedient-modal/discart-expedient-modal.page';
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
import { SearchPage } from 'src/app/pages/search/search.page';
|
|
import { SearchDocument } from 'src/app/models/search-document';
|
|
import { BadRequestPage } from 'src/app/shared/popover/bad-request/bad-request.page';
|
|
import { SuccessMessagePage } from 'src/app/shared/popover/success-message/success-message.page';
|
|
import { User } from 'src/app/models/user.model';
|
|
import { AuthService } from 'src/app/services/auth.service';
|
|
import { AttendeesPageModal } from 'src/app/pages/events/attendees/attendees.page';
|
|
import { ToastService } from 'src/app/services/toast.service';
|
|
|
|
@Component({
|
|
selector: 'app-book-meeting-modal',
|
|
templateUrl: './book-meeting-modal.page.html',
|
|
styleUrls: ['./book-meeting-modal.page.scss'],
|
|
})
|
|
|
|
export class BookMeetingModalPage implements OnInit {
|
|
|
|
task: any;
|
|
|
|
taskParticipants: EventPerson[];
|
|
taskParticipantsCc: EventPerson[] = [];
|
|
|
|
taskDocId:string;
|
|
loadedAttachments:any;
|
|
documents:SearchDocument[] = [];
|
|
|
|
adding: "intervenient" | "CC" = "intervenient";
|
|
|
|
postData: Event;
|
|
eventBody: EventBody;
|
|
eventAttendees: EventPerson[];
|
|
|
|
formLocationSatus: boolean = false;
|
|
showAttendees= false;
|
|
loggeduser: User;
|
|
emptyTextDescription = "Sem intervenientes selecionados";
|
|
|
|
constructor(
|
|
private modalController: ModalController,
|
|
private router:Router,
|
|
private navParams: NavParams,
|
|
private processes:ProcessesService,
|
|
private attachmentsService: AttachmentsService,
|
|
private calendarService: EventsService,
|
|
authService: AuthService,
|
|
private animationController: AnimationController,
|
|
private toastService: ToastService,
|
|
) {
|
|
this.taskParticipants = [];
|
|
this.loggeduser = authService.ValidatedUser;
|
|
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);
|
|
|
|
|
|
this.getAttachments();
|
|
}
|
|
|
|
getAttachments(){
|
|
this.attachmentsService.getAttachmentsBySerial(this.task.SerialNumber).subscribe(res=>{
|
|
this.loadedAttachments = res;
|
|
});
|
|
}
|
|
|
|
close(){
|
|
this.router.navigate(['/home/gabinete-digital/expediente']);
|
|
this.modalController.dismiss(null);
|
|
}
|
|
cancelTask(){
|
|
this.modalController.dismiss(null);
|
|
}
|
|
async 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') {
|
|
|
|
try {
|
|
switch (this.loggeduser.Profile) {
|
|
case 'MDGPR':
|
|
await this.calendarService.postExpedientEvent(this.task.DocId, this.postData, "md",this.task.SerialNumber, this.task.FsId).toPromise();
|
|
break;
|
|
|
|
case 'PR':
|
|
await this.calendarService.postExpedientEvent(this.task.DocId, this.postData, "pr",this.task.SerialNumber, this.task.FsId).toPromise()
|
|
break;
|
|
}
|
|
|
|
this.distartExpedientModal();
|
|
this.toastService.successMessage('Reunião criada')
|
|
} catch (error) {
|
|
this.toastService.badRequest('Reunião não criada')
|
|
}
|
|
|
|
|
|
}
|
|
else if(this.task.FsId == '361') {
|
|
try {
|
|
switch (this.loggeduser.Profile) {
|
|
case 'MDGPR':
|
|
await this.calendarService.createTaskEvent(this.task.FolderId, this.postData, "md",this.task.SerialNumber, this.task.FsId).toPromise();
|
|
break;
|
|
|
|
case 'PR':
|
|
await this.calendarService.createTaskEvent(this.task.FolderId, this.postData, "pr",this.task.SerialNumber, this.task.FsId).toPromise();
|
|
break;
|
|
}
|
|
|
|
this.toastService.successMessage('Reunião criada', ()=>{
|
|
this.close();
|
|
})
|
|
|
|
} catch (error) {
|
|
this.toastService.badRequest()
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
async addParticipants(){
|
|
|
|
this.adding = "intervenient";
|
|
|
|
if(window.innerWidth <= 800){
|
|
const modal = await this.modalController.create({
|
|
component: AttendeesPageModal,
|
|
componentProps: {
|
|
adding: this.adding,
|
|
taskParticipants: this.taskParticipants,
|
|
taskParticipantsCc: this.taskParticipantsCc
|
|
},
|
|
cssClass: 'modal modal-desktop',
|
|
backdropDismiss: false
|
|
});
|
|
|
|
await modal.present();
|
|
|
|
modal.onDidDismiss().then((data) => {
|
|
|
|
if(data) {
|
|
data = data['data'];
|
|
|
|
const newAttendees: EventPerson[] = data['taskParticipants'];
|
|
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
|
|
|
|
this.setIntervenient(newAttendees);
|
|
this.setIntervenientCC(newAttendeesCC);
|
|
}
|
|
});
|
|
|
|
} else {
|
|
this.showAttendees = true;
|
|
}
|
|
}
|
|
|
|
async addParticipantsCc() {
|
|
|
|
this.adding = "CC";
|
|
|
|
if(window.innerWidth <= 800) {
|
|
const modal = await this.modalController.create({
|
|
component: AttendeesPageModal,
|
|
componentProps: {
|
|
adding: this.adding,
|
|
taskParticipants: this.taskParticipants,
|
|
taskParticipantsCc: this.taskParticipantsCc
|
|
},
|
|
cssClass: 'modal modal-desktop',
|
|
backdropDismiss: false
|
|
});
|
|
|
|
await modal.present();
|
|
|
|
modal.onDidDismiss().then((data) => {
|
|
|
|
if(data){
|
|
data = data['data'];
|
|
|
|
const newAttendees: EventPerson[] = data['taskParticipants'];
|
|
const newAttendeesCC: EventPerson[] = data['taskParticipantsCc'];
|
|
|
|
this.setIntervenient(newAttendees);
|
|
this.setIntervenientCC(newAttendeesCC);
|
|
}
|
|
});
|
|
} 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();
|
|
}
|
|
|
|
|
|
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
|
|
}
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then((res)=> {
|
|
if(res){
|
|
const data = res.data;
|
|
this.documents.push(data.selected);
|
|
}
|
|
});
|
|
}
|
|
|
|
removeAttachment(index: number){
|
|
|
|
this.documents = this.documents.filter( (e, i) => index != i);
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
goToGabinete() {
|
|
this.router.navigate(['/home/gabinete-digital']);
|
|
}
|
|
|
|
|
|
setIntervenient(data){
|
|
this.taskParticipants = data;
|
|
}
|
|
|
|
setIntervenientCC(data){
|
|
this.taskParticipantsCc = data;
|
|
}
|
|
|
|
|
|
} |