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

377 lines
11 KiB
TypeScript
Raw Normal View History

2021-02-24 09:14:58 +01:00
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2021-08-19 15:40:21 +01:00
import { AlertController, ModalController, PopoverController } from '@ionic/angular';
2021-02-24 09:14:58 +01:00
import { Attachment } from 'src/app/models/attachment.model';
import { EventBody } from 'src/app/models/eventbody.model';
import { EventsService } from 'src/app/services/events.service';
import { Event } from 'src/app/models/event.model';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
2021-04-05 15:02:57 +01:00
import { ProcessesService } from 'src/app/services/processes.service';
2021-06-25 11:00:25 +01:00
import { ToastService } from 'src/app/services/toast.service';
2021-07-20 19:22:11 +01:00
import { EliminateEventPage } from 'src/app/modals/eliminate-event/eliminate-event.page';
2021-10-07 09:43:16 +01:00
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
import { DocumentSetUpMeetingPage } from 'src/app/modals/document-set-up-meeting/document-set-up-meeting.page';
import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
2021-10-08 19:29:21 +01:00
import { ViewDocumentPage } from 'src/app/modals/view-document/view-document.page';
2022-10-12 17:01:09 +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-06-22 12:53:35 +01:00
import { NavigationExtras, Router } from '@angular/router';
import { EventController } from 'src/app/controller/event'
2021-02-24 09:14:58 +01:00
@Component({
selector: 'app-view-event',
templateUrl: './view-event.page.html',
styleUrls: ['./view-event.page.scss'],
})
export class ViewEventPage implements OnInit {
2022-04-02 14:51:57 +01:00
loadedEvent: Event;
2021-02-24 09:14:58 +01:00
isEventEdited: boolean;
eventBody: EventBody;
loadedAttachments:any;
pageId: string;
showLoader: boolean;
2021-10-07 09:43:16 +01:00
task: ExpedientTaskModalPageNavParamsTask;
2021-02-24 09:14:58 +01:00
minDate: Date;
2021-10-07 09:43:16 +01:00
LoadedDocument:any = null;
2021-02-24 09:14:58 +01:00
customDate:any;
today:any;
2021-07-13 09:31:42 +01:00
2021-02-24 09:14:58 +01:00
months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
2021-07-13 09:31:42 +01:00
2021-04-19 18:03:41 +01:00
documents: Attachment[] = [];
2021-04-27 09:56:14 +01:00
dicIndex = 0;
2021-04-19 18:03:41 +01:00
2021-02-24 09:14:58 +01:00
@Input() profile:string;
@Input() eventId: string;
2022-05-27 13:36:37 +01:00
@Input() CalendarId: string;
2021-02-24 09:14:58 +01:00
@Output() viewEventDetailDismiss = new EventEmitter<any>();
2022-04-02 14:13:37 +01:00
sesseionStora = SessionStore
2021-02-24 09:14:58 +01:00
2023-09-26 10:42:42 +01:00
TimeZoneString = ''
2021-02-24 09:14:58 +01:00
constructor(
2022-04-21 16:45:17 +01:00
public eventsService: EventsService,
2021-02-24 09:14:58 +01:00
public alertController: AlertController,
private iab: InAppBrowser,
2021-04-05 15:02:57 +01:00
private processes: ProcessesService,
2021-04-23 10:35:53 +01:00
private modalController: ModalController,
2021-06-25 11:00:25 +01:00
public popoverController: PopoverController,
2021-10-22 15:43:57 +01:00
private toastService: ToastService,
2022-04-02 14:13:37 +01:00
public ThemeService: ThemeService,
2023-06-22 12:53:35 +01:00
private httpErrorHandle: HttpErrorHandle,
private router: Router,
2021-10-07 09:43:16 +01:00
) {
2021-02-24 09:14:58 +01:00
this.isEventEdited = false;
this.loadedEvent = new Event();
this.eventBody = { BodyType : "1", Text : ""};
this.loadedEvent.Body = this.eventBody;
2022-07-04 19:13:28 +01:00
2023-09-26 10:42:42 +01:00
2021-02-24 09:14:58 +01:00
}
ngOnInit() {
2022-07-04 19:13:28 +01:00
2021-02-24 09:14:58 +01:00
this.loadEvent();
}
2021-07-13 09:31:42 +01:00
2021-10-07 09:43:16 +01:00
doRefresh(ev) {
2021-09-15 16:20:59 +01:00
this.loadEvent();
ev.target.complete();
}
2021-03-18 20:02:44 +01:00
ngOnChanges(changes: any): void {
2021-10-07 09:43:16 +01:00
this.loadedEvent.Attachments = null;
2021-03-18 20:02:44 +01:00
this.loadEvent();
}
2021-07-17 22:42:02 +01:00
toDateString(e) {
return new Date(e).toDateString()
}
2021-07-15 15:24:30 +01:00
openOptions() {
2021-05-12 16:15:30 +01:00
}
2021-04-27 09:56:14 +01:00
docIndex(index: number) {
this.dicIndex = index;
}
2023-06-22 12:53:35 +01:00
async openNewGroupPage() {
let roomName = this.loadedEvent.Subject
let attendees = this.loadedEvent.Attendees
const room = await EventController.createOrFindGroupFromEvent(roomName, attendees)
let navigationExtras: NavigationExtras = { queryParams: { "roomId": room.id } };
this.router.navigate(['/home/chat'], navigationExtras);
}
2021-10-08 19:29:21 +01:00
close() {
2021-07-13 09:31:42 +01:00
2021-02-24 09:14:58 +01:00
this.viewEventDetailDismiss.emit({
type: 'close'
})
}
setTimeZone() {
this.TimeZoneString = this.loadedEvent.TimeZone.split(')')[1]
}
2021-07-15 17:30:02 +01:00
loadEvent() {
2021-11-07 20:56:34 +01:00
2022-04-02 14:13:37 +01:00
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
this.eventsService.getEvent(this.eventId).subscribe(res => {
2023-09-26 10:42:42 +01:00
2022-04-02 14:13:37 +01:00
this.loadedEvent = res;
this.setTimeZone()
2022-12-16 18:55:13 +01:00
2022-04-02 14:13:37 +01:00
this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
}, (error)=> {
2023-09-26 10:42:42 +01:00
2022-04-02 14:13:37 +01:00
this.viewEventDetailDismiss.emit({
type: 'close'
})
2023-09-26 10:42:42 +01:00
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpStatusHandle(error)
2023-09-26 10:42:42 +01:00
2022-04-02 14:13:37 +01:00
});
} else {
2021-07-15 17:30:02 +01:00
2022-05-27 13:36:37 +01:00
if(this.CalendarId) {
2023-09-26 10:42:42 +01:00
2022-05-27 13:36:37 +01:00
this.eventsService.genericGetEvent(this.eventId, this.CalendarId).subscribe(res => {
2022-12-16 18:47:27 +01:00
const div = document.createElement("div")
div.innerHTML = res.Body.Text
res.Body.Text = div.innerText
2022-04-06 14:51:35 +01:00
this.loadedEvent = res;
this.setTimeZone()
2022-12-16 18:47:27 +01:00
2022-04-06 14:51:35 +01:00
this.today = new Date(res.StartDate);
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
}, (error)=> {
2023-09-26 10:42:42 +01:00
2022-04-06 14:51:35 +01:00
this.viewEventDetailDismiss.emit({
type: 'close'
})
2023-09-26 10:42:42 +01:00
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpStatusHandle(error)
2022-04-06 14:51:35 +01:00
});
}
2022-04-02 14:13:37 +01:00
}
2023-09-26 10:42:42 +01:00
2021-02-24 09:14:58 +01:00
}
2021-04-26 13:29:19 +01:00
deleteYesOrNo() {
this.alertController.create({
header: 'Eliminar evento?',
message: '',
buttons: [
{
text: 'Não',
handler: () => {
}
},
{
text: 'Sim',
handler: () => {
this.deleteEvent();
}
}
]
}).then(res => {
res.present();
});
}
2021-08-06 14:34:39 +01:00
async deleteEvent() {
2021-07-29 16:21:48 +01:00
2021-07-20 19:22:11 +01:00
if (this.loadedEvent.IsRecurring) {
2021-10-06 10:59:42 +01:00
const loader = this.toastService.loading()
2021-07-20 19:22:11 +01:00
2023-09-26 10:42:42 +01:00
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
2022-04-02 14:13:37 +01:00
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpsSucessMessagge('delete event')
2022-04-02 14:13:37 +01:00
this.close();
2023-02-27 09:34:36 +01:00
},(error)=>{
this.httpErrorHandle.httpStatusHandle(error)
},
2022-04-02 14:13:37 +01:00
()=>{
loader.remove();
});
} else {
2022-05-27 13:36:37 +01:00
if(this.CalendarId) {
this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, this.CalendarId).subscribe(async () => {
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpsSucessMessagge('delete event');
2022-04-02 14:13:37 +01:00
this.close();
2023-02-27 09:34:36 +01:00
},(error)=>{
this.httpErrorHandle.httpStatusHandle(error)
},
2022-04-02 14:13:37 +01:00
()=>{
loader.remove();
});
2023-09-26 10:42:42 +01:00
}
2022-04-02 14:13:37 +01:00
}
2023-09-26 10:42:42 +01:00
2021-07-20 19:22:11 +01:00
} else {
2021-10-06 10:59:42 +01:00
const loader = this.toastService.loading()
2023-09-26 10:42:42 +01:00
if(this.sesseionStora.user.Profile == 'MDGPR' || this.sesseionStora.user.Profile == 'PR') {
2022-04-02 14:13:37 +01:00
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName).subscribe(async () => {
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpsSucessMessagge('delete event');
2022-04-02 14:13:37 +01:00
this.close();
2023-02-27 09:34:36 +01:00
},(error)=>{
this.httpErrorHandle.httpStatusHandle(error)
},
2022-04-02 14:13:37 +01:00
()=>{
loader.remove();
});
} else {
2022-05-27 13:36:37 +01:00
this.eventsService.genericDeleteEvent(this.loadedEvent.EventId, 0, this.loadedEvent.CalendarName, this.CalendarId).subscribe(async () => {
2023-02-27 09:34:36 +01:00
this.httpErrorHandle.httpsSucessMessagge('delete event');
2022-04-02 14:51:57 +01:00
this.close();
2023-02-27 09:34:36 +01:00
},(error)=>{
this.httpErrorHandle.httpStatusHandle(error)
},
2022-04-02 14:51:57 +01:00
()=>{
loader.remove();
});
2022-04-02 14:13:37 +01:00
}
2021-10-06 10:59:42 +01:00
2021-07-20 19:22:11 +01:00
}
}
async deleteRecurringEvent() {
2021-07-29 16:21:48 +01:00
2021-07-20 19:22:11 +01:00
const modal = await this.modalController.create({
component: EliminateEventPage,
componentProps: {},
cssClass: 'discart-expedient-modal',
});
2023-07-15 11:01:09 +01:00
2021-07-20 19:22:11 +01:00
modal.onDidDismiss().then((res) => {
});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-02-24 09:14:58 +01:00
}
async editEvent() {
this.viewEventDetailDismiss.emit({
type: 'edit',
event: this.loadedEvent
})
}
2021-07-13 09:31:42 +01:00
2021-08-25 15:23:30 +01:00
viewDocument(sourceId) {
2021-04-05 15:02:57 +01:00
this.processes.GetDocumentUrl(sourceId, '8').subscribe(res=>{
const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
const browser = this.iab.create(url,"_blank");
browser.show();
});
2021-02-24 09:14:58 +01:00
}
2021-10-07 09:43:16 +01:00
async LoadDocumentDetails() {
2023-09-26 10:42:42 +01:00
2021-10-07 16:57:21 +01:00
const docId = this.loadedEvent.Attachments[ this.dicIndex].SourceId
2021-10-08 19:29:21 +01:00
const applicationId: any = this.loadedEvent.Attachments[ this.dicIndex].ApplicationId
const selectedDoc = this.loadedEvent.Attachments[ this.dicIndex]
2023-09-26 10:42:42 +01:00
2021-10-08 19:29:21 +01:00
this.task = {
serialNumber: '',
taskStartDate: '',
isEvent: true,
workflowInstanceDataFields: {
FolderID: '',
Subject: selectedDoc.SourceName,
2022-04-02 14:51:57 +01:00
SourceSecFsID: selectedDoc.ApplicationId || selectedDoc['ApplicationID'],
2021-10-08 19:29:21 +01:00
SourceType: 'DOC',
SourceID: selectedDoc.SourceId,
DispatchNumber: ''
2021-10-07 09:43:16 +01:00
}
2021-10-08 19:29:21 +01:00
}
2021-10-07 09:43:16 +01:00
2021-10-08 19:29:21 +01:00
const modal = await this.modalController.create({
2021-10-09 11:31:58 +01:00
component: ViewDocumentPage,
componentProps: {
trustedUrl: '',
file: {
title: this.task.workflowInstanceDataFields.Subject,
url: '',
title_link: '',
2021-10-07 09:43:16 +01:00
},
2021-10-09 11:31:58 +01:00
Document: this.loadedEvent.Attachments[ this.dicIndex],
applicationId: this.task.workflowInstanceDataFields.SourceSecFsID,
docId: selectedDoc.SourceId,
folderId: '',
task: this.task
},
cssClass: 'modal modal-desktop'
});
await modal.present();
2021-10-07 09:43:16 +01:00
}
async openBookMeetingModal() {
let classs;
if( window.innerWidth < 701) {
classs = 'book-meeting-modal modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: DocumentSetUpMeetingPage,
componentProps: {
subject: this.task.workflowInstanceDataFields.Subject,
2021-10-08 19:29:21 +01:00
document: this.loadedEvent.Attachments[ this.dicIndex],
2021-10-07 09:43:16 +01:00
},
cssClass: classs,
backdropDismiss: false
});
2023-07-15 11:01:09 +01:00
2021-10-07 09:43:16 +01:00
modal.onDidDismiss().then(res=>{
2022-01-06 14:47:22 +01:00
//this.RouteService.goBack();
2021-10-07 09:43:16 +01:00
});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-10-07 09:43:16 +01:00
}
// efetuar despacho
async openExpedientActionsModal( taskAction: any) {
let classs;
if( window.innerWidth < 701) {
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: ExpedientTaskModalPage,
componentProps: {
taskAction: taskAction,
task: this.task,
2021-10-08 19:29:21 +01:00
seachDocuments: this.loadedEvent.Attachments[ this.dicIndex],
2022-04-02 14:51:57 +01:00
aplicationId: this.loadedEvent.Attachments[ this.dicIndex].ApplicationId || this.loadedEvent.Attachments[ this.dicIndex]['ApplicationID']
2021-10-07 09:43:16 +01:00
},
cssClass: classs,
});
2023-07-15 11:01:09 +01:00
2021-10-07 09:43:16 +01:00
modal.onDidDismiss().then( async(res)=>{});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-10-07 09:43:16 +01:00
2021-05-12 15:52:10 +01:00
}
2021-07-13 09:31:42 +01:00
}