Files
doneit-web/src/app/modals/document-detail/document-detail.page.ts
T

261 lines
7.7 KiB
TypeScript
Raw Normal View History

2021-04-08 01:56:11 +01:00
import { Component, OnInit } from '@angular/core';
2021-08-10 13:22:33 +01:00
import { MenuController, ModalController, NavParams, PopoverController } from '@ionic/angular';
2021-04-09 04:34:21 +01:00
import { AlertService } from 'src/app/services/alert.service';
import { ProcessesService } from 'src/app/services/processes.service';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
2021-07-23 15:57:01 +01:00
import { ExpedientTaskModalPage } from 'src/app/pages/gabinete-digital/expediente/expedient-task-modal/expedient-task-modal.page';
2021-07-29 10:13:39 +01:00
import { DocumentSetUpMeetingPage } from '../document-set-up-meeting/document-set-up-meeting.page';
2021-08-20 12:02:27 +01:00
import { SearchDocumentDetails, SearchFolderDetails } from 'src/app/models/search-document';
2021-07-30 22:03:48 +01:00
import { ExpedientTaskModalPageNavParamsTask } from 'src/app/models/ExpedientTaskModalPage';
2022-03-28 15:46:07 +01:00
import { PermissionService } from 'src/app/services/permission.service';
2021-08-10 13:22:33 +01:00
import { SearchedDocumentOptionsPage } from 'src/app/shared/popover/searched-document-options/searched-document-options.page';
2021-09-15 13:38:14 +01:00
import { Location } from '@angular/common';
2021-10-09 11:31:58 +01:00
import { ViewDocumentPage } from '../view-document/view-document.page';
2022-05-23 14:54:40 +01:00
import { ThemeService } from 'src/app/services/theme.service';
2021-10-25 10:53:01 +01:00
2021-04-08 01:56:11 +01:00
@Component({
selector: 'app-document-detail',
templateUrl: './document-detail.page.html',
styleUrls: ['./document-detail.page.scss'],
})
export class DocumentDetailPage implements OnInit {
2021-04-09 05:46:01 +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"];
customDate:any;
2021-04-09 04:34:21 +01:00
docId: string;
applicationId:string;
2021-04-09 05:46:01 +01:00
LoadedDocument:any = null;
2021-04-09 04:34:21 +01:00
2021-08-20 12:02:27 +01:00
folder: SearchFolderDetails
document: SearchDocumentDetails
2021-07-30 22:03:48 +01:00
2021-08-20 12:02:27 +01:00
task: ExpedientTaskModalPageNavParamsTask;
2021-10-09 11:31:58 +01:00
DocumentTask: ExpedientTaskModalPageNavParamsTask;
dicIndex = 0;
2021-08-10 13:22:33 +01:00
2021-04-09 04:34:21 +01:00
constructor(
private navParams: NavParams,
private modalController: ModalController,
private alertService: AlertService,
private processes: ProcessesService,
private menu: MenuController,
private iab: InAppBrowser,
2021-08-05 11:47:09 +01:00
public p: PermissionService,
2021-09-15 13:38:14 +01:00
private popoverController: PopoverController,
private location: Location,
2021-10-25 10:53:01 +01:00
public ThemeService: ThemeService
2021-08-09 15:47:36 +01:00
) {
2021-04-09 04:34:21 +01:00
this.docId = this.navParams.get('docId');
this.applicationId = this.navParams.get('applicationId');
}
2021-04-08 01:56:11 +01:00
ngOnInit() {
2021-04-09 04:34:21 +01:00
this.LoadDocumentDetails();
}
2021-04-30 14:12:45 +01:00
async LoadDocumentDetails() {
this.processes.GetDocumentDetails(this.docId, this.applicationId).subscribe(res=>{
2021-09-15 13:38:14 +01:00
2021-04-30 14:12:45 +01:00
this.LoadedDocument = res;
this.LoadedDocument.Subject = this.LoadedDocument.Assunto
2021-04-09 05:46:01 +01:00
2021-08-09 13:56:17 +01:00
let thedate = new Date(this.LoadedDocument.DateDispatch || this.LoadedDocument.DocDate);
2021-04-09 05:46:01 +01:00
this.customDate = this.days[thedate.getDay()]+ ", " + thedate.getDate() +" de " + ( this.months[thedate.getMonth()]);
2021-07-30 22:03:48 +01:00
2021-08-10 14:27:12 +01:00
let task: ExpedientTaskModalPageNavParamsTask
2021-08-20 12:02:27 +01:00
let document: SearchDocumentDetails = this.LoadedDocument
let folder: SearchFolderDetails = this.LoadedDocument
2021-09-15 13:38:14 +01:00
2021-08-11 17:05:37 +01:00
if(this.LoadedDocument.ApplicationID == 361 || this.LoadedDocument.ApplicationId == 361) {
2021-10-18 16:20:51 +01:00
2021-08-10 14:27:12 +01:00
} else if (document.ApplicationID == 8 || document.ApplicationId == 8) {
2021-10-18 16:20:51 +01:00
2021-08-10 14:27:12 +01:00
} else {
2023-05-26 14:23:37 +01:00
2021-07-23 15:57:01 +01:00
}
2021-09-15 13:38:14 +01:00
2021-10-09 11:31:58 +01:00
task = {
serialNumber: '',
taskStartDate: '',
isEvent: true,
workflowInstanceDataFields: {
FolderID: '',
Subject: this.LoadedDocument.SourceName || this.LoadedDocument.Assunto,
SourceSecFsID: this.LoadedDocument.ApplicationId || this.LoadedDocument.ApplicationID,
SourceType: 'DOC',
SourceID: this.LoadedDocument.DocId || this.LoadedDocument.SourceId || this.LoadedDocument['folderId'],
DispatchNumber: ''
}
}
this.DocumentTask = Object.assign(task, res)
2021-07-23 15:57:01 +01:00
2021-08-10 14:27:12 +01:00
});
2021-08-10 13:22:33 +01:00
}
2021-10-09 11:31:58 +01:00
async viewDocument() {
const modal = await this.modalController.create({
component: ViewDocumentPage,
componentProps: {
trustedUrl: '',
file: {
title: this.LoadedDocument.Assunto,
url: '',
title_link: '',
},
Document: this.LoadedDocument.Documents,
applicationId: this.DocumentTask.workflowInstanceDataFields.SourceSecFsID,
docId: this.DocumentTask.workflowInstanceDataFields.SourceID,
task: this.DocumentTask
},
cssClass: 'modal modal-desktop'
});
await modal.present();
}
docIndex(index: number) {
this.dicIndex = index;
}
async viewDocumentModal() {
2022-03-28 15:46:07 +01:00
2021-10-09 11:31:58 +01:00
const selectedDoc = this.LoadedDocument.Documents[ this.dicIndex]
2021-10-18 16:20:51 +01:00
let task = {
2021-10-09 11:31:58 +01:00
serialNumber: '',
taskStartDate: '',
isEvent: true,
workflowInstanceDataFields: {
FolderID: '',
Subject: selectedDoc.SourceName || selectedDoc.Assunto,
SourceSecFsID: selectedDoc.ApplicationId || selectedDoc.ApplicationID,
SourceType: 'DOC',
SourceID: selectedDoc.DocId || selectedDoc.SourceId,
DispatchNumber: ''
}
}
const modal = await this.modalController.create({
component: ViewDocumentPage,
componentProps: {
trustedUrl: '',
file: {
2021-10-18 16:20:51 +01:00
title: task.workflowInstanceDataFields.Subject,
2021-10-09 11:31:58 +01:00
url: '',
title_link: '',
},
Document: this.LoadedDocument.Documents[ this.dicIndex],
2021-10-18 16:20:51 +01:00
applicationId: task.workflowInstanceDataFields.SourceSecFsID,
docId: task.workflowInstanceDataFields.SourceID ,
2021-10-09 11:31:58 +01:00
folderId: '',
2021-10-18 16:20:51 +01:00
task: task
2021-10-09 11:31:58 +01:00
},
cssClass: 'modal modal-desktop'
2021-08-10 13:22:33 +01:00
});
2021-10-09 11:31:58 +01:00
await modal.present();
2021-08-10 13:22:33 +01:00
}
openMenu() {
this.menu.open();
this.modalController.dismiss();
}
close() {
this.modalController.dismiss();
}
2021-09-15 13:38:14 +01:00
2021-08-10 13:22:33 +01:00
notImplemented() {
this.alertService.presentAlert('Funcionalidade em desenvolvimento');
}
2021-09-15 13:38:14 +01:00
// efetuar despacho
2021-08-10 13:22:33 +01:00
async openExpedientActionsModal( taskAction: any) {
2021-07-23 15:57:01 +01:00
let classs;
2021-09-15 13:38:14 +01:00
if( window.innerWidth < 701) {
2021-07-23 15:57:01 +01:00
classs = 'modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
component: ExpedientTaskModalPage,
componentProps: {
taskAction: taskAction,
2021-10-18 16:20:51 +01:00
task: this.DocumentTask,
2021-08-11 17:05:37 +01:00
aplicationId: this.LoadedDocument.ApplicationId || this.LoadedDocument.ApplicationID
2021-07-23 15:57:01 +01:00
},
cssClass: classs,
});
2023-07-15 11:01:09 +01:00
2023-07-14 10:19:33 +01:00
modal.onDidDismiss().then( async(res)=>{}, (error) => {
console.log(error)
});
2021-07-23 15:57:01 +01:00
2023-07-15 11:01:09 +01:00
await modal.present();
2021-07-23 15:57:01 +01:00
}
async openBookMeetingModal() {
let classs;
2021-09-15 13:38:14 +01:00
if( window.innerWidth < 701) {
2021-07-23 15:57:01 +01:00
classs = 'book-meeting-modal modal modal-desktop'
} else {
classs = 'modal modal-desktop showAsideOptions'
}
const modal = await this.modalController.create({
2021-07-29 10:13:39 +01:00
component: DocumentSetUpMeetingPage,
2021-07-23 15:57:01 +01:00
componentProps: {
2021-10-18 16:20:51 +01:00
subject: this.LoadedDocument.Assunto,
2021-08-11 17:05:37 +01:00
document: this.LoadedDocument,
2021-07-23 15:57:01 +01:00
},
cssClass: classs,
backdropDismiss: false
});
2023-07-15 11:01:09 +01:00
modal.onDidDismiss().then(res => {
2022-01-06 14:47:22 +01:00
//this.RouteService.goBack();
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-09-15 14:19:16 +01:00
});
2023-07-15 11:01:09 +01:00
await modal.present();
2021-07-23 15:57:01 +01:00
}
2021-08-10 13:22:33 +01:00
async openOptions() {
const popover = await this.popoverController.create({
component: SearchedDocumentOptionsPage,
cssClass: 'exp-options',
componentProps: {
2021-08-10 14:27:12 +01:00
task: this.task,
LoadedDocument: this.LoadedDocument
2021-08-10 13:22:33 +01:00
},
translucent: true
});
2023-07-15 11:01:09 +01:00
2021-08-13 09:45:44 +01:00
popover.onDidDismiss().then((res:any) => {
if(res.data.component == 'openBookMeetingModal') {
this.openBookMeetingModal()
} else if(res.data.component == 'openExpedientActionsModal') {
this.openExpedientActionsModal(res.data.taskAction)
}
2023-07-14 10:19:33 +01:00
}, (error) => {
console.log(error)
2021-08-13 09:45:44 +01:00
});
2023-07-15 11:01:09 +01:00
await popover.present()
2021-08-10 13:22:33 +01:00
}
2021-09-15 13:38:14 +01:00
}