mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-20 13:26:08 +00:00
221 lines
5.9 KiB
TypeScript
221 lines
5.9 KiB
TypeScript
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
|
import { AlertController, ModalController, NavParams, PopoverController } from '@ionic/angular';
|
|
import { Attachment } from 'src/app/models/attachment.model';
|
|
import { EventBody } from 'src/app/models/eventbody.model';
|
|
import { AttachmentsService } from 'src/app/services/attachments.service';
|
|
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';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
|
|
import { momentG } from 'src/plugin/momentG';
|
|
import { BookMeetingModalPage } from 'src/app/pages/gabinete-digital/expediente/book-meeting-modal/book-meeting-modal.page';
|
|
import { ChatPopoverPage } from '../../popover/chat-popover/chat-popover.page';
|
|
|
|
@Component({
|
|
selector: 'app-view-event',
|
|
templateUrl: './view-event.page.html',
|
|
styleUrls: ['./view-event.page.scss'],
|
|
})
|
|
export class ViewEventPage implements OnInit {
|
|
|
|
loadedEvent: Event;
|
|
isEventEdited: boolean;
|
|
eventBody: EventBody;
|
|
loadedAttachments:any;
|
|
loadedEventAttachments: Attachment[];
|
|
pageId: string;
|
|
showLoader: boolean;
|
|
|
|
minDate: Date;
|
|
|
|
customDate:any;
|
|
today:any;
|
|
|
|
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"];
|
|
|
|
documents: Attachment[] = [];
|
|
dicIndex = 0;
|
|
|
|
@Input() profile:string;
|
|
@Input() eventId: string;
|
|
|
|
@Output() viewEventDetailDismiss = new EventEmitter<any>();
|
|
|
|
constructor(
|
|
private eventsService: EventsService,
|
|
private attachmentsService: AttachmentsService,
|
|
public alertController: AlertController,
|
|
private iab: InAppBrowser,
|
|
private processes: ProcessesService,
|
|
private modalController: ModalController,
|
|
public popoverController: PopoverController
|
|
)
|
|
{
|
|
this.isEventEdited = false;
|
|
this.loadedEvent = new Event();
|
|
this.eventBody = { BodyType : "1", Text : ""};
|
|
this.loadedEvent.Body = this.eventBody;
|
|
}
|
|
|
|
ngOnInit() {
|
|
|
|
/* console.log(this.eventId); */
|
|
this.loadEvent();
|
|
//this.getAttachments();
|
|
}
|
|
|
|
ngOnChanges(changes: any): void {
|
|
this.loadedAttachments = null;
|
|
this.loadEvent();
|
|
}
|
|
|
|
openOptions(){
|
|
|
|
}
|
|
|
|
docIndex(index: number) {
|
|
this.dicIndex = index;
|
|
}
|
|
|
|
close(){
|
|
console.log(this.isEventEdited);
|
|
|
|
this.viewEventDetailDismiss.emit({
|
|
type: 'close'
|
|
})
|
|
}
|
|
|
|
loadEvent(){
|
|
this.eventsService.getEvent(this.eventId).subscribe(res => {
|
|
this.loadedEvent = res;
|
|
// console.log(res);
|
|
this.today = new Date(res.StartDate);
|
|
// console.log(new Date(this.today));
|
|
this.customDate = this.days[this.today.getDay()]+ ", " + this.today.getDate() +" de " + ( this.months[this.today.getMonth()]);
|
|
this.getAttachments(this.loadedEvent.EventId);
|
|
});
|
|
}
|
|
|
|
deleteEvent(){
|
|
this.eventsService.deleteEvent(this.loadedEvent.EventId, 0).subscribe(async () =>
|
|
{
|
|
const alert = await this.alertController.create({
|
|
cssClass: 'my-custom-class',
|
|
header: 'Evento removido',
|
|
buttons: ['OK']
|
|
});
|
|
|
|
setTimeout(()=>{
|
|
alert.dismiss();
|
|
}, 1500);
|
|
this.close();
|
|
});
|
|
}
|
|
|
|
getAttachments(eventId){
|
|
this.attachmentsService.getAttachmentsById(eventId).subscribe(res=>{
|
|
this.loadedAttachments = res;
|
|
console.log(res);
|
|
});
|
|
}
|
|
|
|
async editEvent() {
|
|
|
|
this.viewEventDetailDismiss.emit({
|
|
type: 'edit',
|
|
event: this.loadedEvent
|
|
})
|
|
}
|
|
|
|
viewDocument(sourceId){
|
|
this.processes.GetDocumentUrl(sourceId, '8').subscribe(res=>{
|
|
console.log(res);
|
|
const url: string = res.replace("webTRIX.Viewer","webTRIX.Viewer.Branch1");
|
|
const browser = this.iab.create(url,"_blank");
|
|
browser.show();
|
|
|
|
});
|
|
}
|
|
|
|
async openExpedientActionsModal(taskAction: any, task: any) {
|
|
//this.modalController.dismiss();
|
|
let classs;
|
|
if( window.innerWidth <= 800){
|
|
classs = 'modal modal-desktop'
|
|
} else {
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
}
|
|
|
|
const doc = this.loadedAttachments[ this.dicIndex];
|
|
|
|
task = {
|
|
serialNumber: doc.SourceId,
|
|
taskStartDate: doc.CreateDate,
|
|
isEvent: true,
|
|
workflowInstanceDataFields: {
|
|
FsId: doc.ApplicationId,
|
|
FolderID: null,
|
|
DocId: doc.SourceId,
|
|
Subject: doc.SourceName
|
|
},
|
|
}
|
|
|
|
const modal = await this.modalController.create({
|
|
component: ExpedientTaskModalPage,
|
|
componentProps: {
|
|
taskAction: taskAction,
|
|
task: task,
|
|
profile: this.profile,
|
|
},
|
|
cssClass: classs,
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss().then(res=>{
|
|
console.log(res['data']);
|
|
if(res['data']=='openDiscart'){
|
|
console.log('open discart');
|
|
|
|
// this.distartExpedientModal();
|
|
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
async openBookMeetingModal(task: any) {
|
|
|
|
const doc = this.loadedAttachments[ this.dicIndex];
|
|
|
|
task = {
|
|
serialNumber: doc.SourceId,
|
|
taskStartDate: doc.CreateDate,
|
|
isEvent: true,
|
|
workflowInstanceDataFields: {
|
|
FsId: doc.ApplicationId,
|
|
FolderID: null,
|
|
DocId: doc.SourceId,
|
|
Subject: doc.SourceName
|
|
},
|
|
}
|
|
|
|
let classs;
|
|
if( window.innerWidth <= 800){
|
|
classs = 'book-meeting-modal modal modal-desktop'
|
|
} else {
|
|
classs = 'modal modal-desktop showAsideOptions'
|
|
}
|
|
const modal = await this.modalController.create({
|
|
component: BookMeetingModalPage,
|
|
componentProps: {
|
|
task: task,
|
|
},
|
|
cssClass: classs,
|
|
backdropDismiss: false
|
|
});
|
|
await modal.present();
|
|
modal.onDidDismiss();
|
|
}
|
|
|
|
} |