mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
147 lines
4.0 KiB
TypeScript
147 lines
4.0 KiB
TypeScript
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
|
|
import { NavigationStart, Router } from '@angular/router';
|
|
import { ProcessesService } from 'src/app/services/processes.service';
|
|
import { LoginUserRespose } from 'src/app/models/user.model';
|
|
import { CustomTaskPipe } from 'src/app/pipes/custom-task.pipe';
|
|
import { ExpedienteGdStore } from 'src/app/store/expedientegd-store.service';
|
|
import { ExpedienteTaskPipe } from 'src/app/pipes/expediente-task.pipe';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
import { SortService } from 'src/app/services/functions/sort.service';
|
|
import { SessionStore } from 'src/app/store/session.service';
|
|
import { TaskService } from 'src/app/services/task.service'
|
|
|
|
|
|
@Component({
|
|
selector: 'app-expedientes-pr',
|
|
templateUrl: './expedientes-pr.page.html',
|
|
styleUrls: ['./expedientes-pr.page.scss'],
|
|
})
|
|
export class ExpedientesPrPage implements OnInit {
|
|
|
|
taskslist = [];
|
|
serialNumber:string;
|
|
skeletonLoader = true;
|
|
expedienteGdStore = ExpedienteGdStore;
|
|
customTaskPipe = new CustomTaskPipe()
|
|
expedienteTaskPipe = new ExpedienteTaskPipe()
|
|
|
|
loggeduser: LoginUserRespose;
|
|
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
|
|
|
|
showSearch = false
|
|
searchSubject = ''
|
|
list = []
|
|
hideSearchBtn: boolean = false;
|
|
|
|
@Output() openExpedientDetail:EventEmitter<any> = new EventEmitter<any>();
|
|
|
|
constructor(
|
|
private processes:ProcessesService,
|
|
private router: Router,
|
|
public ThemeService: ThemeService,
|
|
private sortService: SortService,
|
|
public TaskService: TaskService
|
|
) {
|
|
this.loggeduser = SessionStore.user;
|
|
}
|
|
|
|
ngOnInit() {
|
|
|
|
this.LoadList()
|
|
|
|
this.router.events.forEach((event) => {
|
|
if (event instanceof NavigationStart &&
|
|
event.url.startsWith('/home/gabinete-digital?expedientespr=true') ||
|
|
event instanceof NavigationStart &&
|
|
event.url.startsWith('/home/gabinete-digital?expedientes-pr=true')) {
|
|
|
|
if(window.location.pathname.split('/').length >= 4 && window.location.pathname.startsWith('/home/gabinete-digital')) {
|
|
this.refreshing()
|
|
} else {
|
|
this.LoadList()
|
|
}
|
|
}
|
|
});
|
|
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
|
|
async dynamicSearch() {
|
|
|
|
if(this.showSearch && this.searchSubject) {
|
|
|
|
this.list = this.expedienteGdStore.list.filter((task) => {
|
|
let subject = task.Folio || task.Subject || task.workflowInstanceDataFields.Subject
|
|
subject = subject.toLowerCase();
|
|
return subject.includes(this.searchSubject.toLowerCase())
|
|
})
|
|
} else {
|
|
this.list = this.expedienteGdStore.list
|
|
}
|
|
|
|
}
|
|
|
|
|
|
openSearch() {
|
|
this.dynamicSearch()
|
|
}
|
|
async closeSearch() {
|
|
this.searchSubject = ''
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
async basicSearch() {
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
|
|
|
|
openExpedientDetailPage(data){
|
|
|
|
this.openExpedientDetail.emit(data);
|
|
}
|
|
|
|
LoadList() {
|
|
this.skeletonLoader = true;
|
|
this.processes.GetTaskListExpediente(false).subscribe(result => {
|
|
|
|
this.taskslist = [];
|
|
let res = result.reverse().filter(data => data.workflowInstanceDataFields.Status == "" || data.workflowInstanceDataFields.Status == "Active");
|
|
this.taskslist = res.map((element) => this.expedienteTaskPipe.transform(element));
|
|
|
|
this.taskslist = this.sortService.sortDate(this.taskslist, 'CreateDate')
|
|
|
|
this.expedienteGdStore.reset(this.taskslist);
|
|
this.skeletonLoader = false;
|
|
this.dynamicSearch()
|
|
|
|
}, (error) => {
|
|
this.skeletonLoader = false
|
|
// this.getEventsFromLocalDb();
|
|
});
|
|
}
|
|
|
|
refreshing() {
|
|
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1000);
|
|
}
|
|
|
|
doRefresh(event) {
|
|
this.LoadList();
|
|
setTimeout(() => {
|
|
try {
|
|
event?.target?.complete();
|
|
} catch(error) {}
|
|
}, 2000);
|
|
}
|
|
|
|
goToExpediente(serialNumber:any){
|
|
/* this.router.navigate(['/home/gabinete-digital/expedientes-pr',serialNumber,'gabinete-digital']); */
|
|
this.router.navigate(['/home/gabinete-digital/expediente', serialNumber, 'gabinete-digital']);
|
|
}
|
|
|
|
}
|