mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
144 lines
3.9 KiB
TypeScript
144 lines
3.9 KiB
TypeScript
import { Component, Input, OnInit } from '@angular/core';
|
|
import { NavigationEnd, Router } from '@angular/router';
|
|
import { customTask, DailyWorkTask } from '../../../models/dailyworktask.model';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
|
|
import { SortService } from 'src/app/services/functions/sort.service';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { DeplomasStore } from 'src/app/store/deplomas.service';
|
|
import { TaskService } from 'src/app/services/task.service'
|
|
import { RouteService } from 'src/app/services/route.service';
|
|
@Component({
|
|
selector: 'app-diplomas-gerars',
|
|
templateUrl: './diplomas-gerar.page.html',
|
|
styleUrls: ['./diplomas-gerar.page.scss'],
|
|
})
|
|
export class DiplomasGerarPage implements OnInit {
|
|
//profile:string;
|
|
diplomasList:DailyWorkTask[] = [];
|
|
showLoader: boolean;
|
|
totalDocs:any;
|
|
serialNumber:string;
|
|
|
|
@Input() profile:string;
|
|
@Input() segment:string;
|
|
|
|
customTaskPipe = new CustomTaskPipe()
|
|
skeletonLoader = true
|
|
deplomasStore = DeplomasStore
|
|
|
|
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
|
|
showSearch = false
|
|
searchSubject = ''
|
|
list = []
|
|
ordinance: string = 'old'
|
|
|
|
constructor(
|
|
private processes:ProcessesService,
|
|
private router: Router,
|
|
private sortService: SortService,
|
|
public ThemeService: ThemeService,
|
|
public TaskService: TaskService,
|
|
private RouteService: RouteService,) {
|
|
}
|
|
|
|
ngOnInit() {
|
|
const location = window.location
|
|
const pathname = location.pathname + location.search
|
|
|
|
this.LoadList()
|
|
|
|
this.router.events.forEach((event) => {
|
|
if (event instanceof NavigationEnd && event.url.startsWith(pathname)) {
|
|
if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
|
this.refreshing()
|
|
} else {
|
|
this.LoadList()
|
|
}
|
|
}
|
|
});
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
reorderList(orderBy: string) {
|
|
|
|
this.ordinance = orderBy;
|
|
|
|
this.dynamicSearch();
|
|
}
|
|
|
|
|
|
async dynamicSearch() {
|
|
|
|
if(this.showSearch && this.searchSubject) {
|
|
|
|
const list = this.deplomasStore.DiplomaGerarList.filter((task) => {
|
|
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
|
|
subject = subject.toLowerCase();
|
|
return subject.includes(this.searchSubject.toLowerCase())
|
|
})
|
|
|
|
this.list = this.TaskService.reorderList(this.ordinance, list)
|
|
} else {
|
|
const list = this.deplomasStore.DiplomaGerarList
|
|
this.list = this.TaskService.reorderList(this.ordinance, list)
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
goToDiploma(serialNumber:any) {
|
|
this.router.navigate(['/home/gabinete-digital/diplomas-gerar',serialNumber,'gabinete-digital']);
|
|
}
|
|
|
|
async refreshing() {
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1000);
|
|
}
|
|
|
|
doRefresh(event) {
|
|
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1000);
|
|
}
|
|
|
|
async LoadList() {
|
|
|
|
this.skeletonLoader = true
|
|
|
|
try {
|
|
|
|
await this.TaskService.loadDiplomas();
|
|
let diplomas = await this.processes.GetTasksList("Despacho do Presidente da República", false).toPromise();
|
|
this.diplomasList = [];
|
|
|
|
let gerarDiploma = diplomas.reverse().filter(data => data.activityInstanceName == "Gerar Diploma" || data.activityInstanceName == "Retificar Diploma");
|
|
|
|
gerarDiploma.forEach(element => {
|
|
let task: customTask = this.customTaskPipe.transform(element)
|
|
this.diplomasList.push(task);
|
|
});
|
|
|
|
this.diplomasList = this.sortService.sortDate(this.diplomasList, 'CreateDate');
|
|
this.deplomasStore.resetDiplomaGerar(this.diplomasList);
|
|
|
|
this.dynamicSearch()
|
|
} catch(error) {
|
|
|
|
}
|
|
|
|
|
|
this.skeletonLoader = false
|
|
this.showLoader = false;
|
|
|
|
}
|
|
|
|
goBack() {
|
|
this.RouteService.goBack();
|
|
// window.history.back()
|
|
}
|
|
}
|