mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
143 lines
3.1 KiB
TypeScript
143 lines
3.1 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { customTask } from '../../../models/dailyworktask.model';
|
|
import { NavigationStart, Router } from '@angular/router';
|
|
import { DespachoService } from 'src/app/Rules/despacho.service';
|
|
import { TaskService } from 'src/app/services/task.service';
|
|
import { ThemeService } from 'src/app/services/theme.service'
|
|
|
|
@Component({
|
|
selector: 'app-despachos',
|
|
templateUrl: './despachos.page.html',
|
|
styleUrls: ['./despachos.page.scss'],
|
|
})
|
|
export class DespachosPage implements OnInit {
|
|
|
|
skeletonLoader = false;
|
|
filterName: 'Para hoje' | 'Novos'| 'Lidos'| 'Não lidos'| 'OverdueTasks' | 'Todos' = 'Todos'
|
|
showSearch = false
|
|
searchSubject = ''
|
|
list = []
|
|
hideSearchBtn: boolean = false;
|
|
ordinance: string = 'old'
|
|
|
|
listSubscription : {
|
|
delete(): void;
|
|
}
|
|
|
|
routerSubscription;
|
|
|
|
constructor (
|
|
private router: Router,
|
|
private despachoRule: DespachoService,
|
|
public TaskService: TaskService,
|
|
public ThemeService: ThemeService,
|
|
) {}
|
|
|
|
ngOnInit() {
|
|
|
|
this.LoadList()
|
|
|
|
this.listSubscription = this.TaskService.despachoStore.registerCallback({
|
|
id: import.meta.url,
|
|
funx:() => {
|
|
|
|
this.dynamicSearch()
|
|
}
|
|
})
|
|
this.dynamicSearch();
|
|
|
|
|
|
this.routerSubscription = this.router.events.subscribe((event) => {
|
|
if (event instanceof NavigationStart && event.url.startsWith('/home/gabinete-digital?despachos=true')) {
|
|
this.LoadList()
|
|
}
|
|
});
|
|
|
|
window['gabinete-aside-refresh'] = () => {
|
|
this.LoadList()
|
|
}
|
|
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
console.log('destroy')
|
|
this.listSubscription.delete()
|
|
this.routerSubscription?.unsubscribe();
|
|
}
|
|
|
|
reorderList(orderBy: string) {
|
|
|
|
this.ordinance = orderBy;
|
|
|
|
this.dynamicSearch();
|
|
}
|
|
|
|
async dynamicSearch() {
|
|
|
|
if(this.showSearch && this.searchSubject) {
|
|
|
|
const list = this.TaskService.despachoStore.list.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.TaskService.despachoStore.list
|
|
this.list = this.TaskService.reorderList(this.ordinance, list)
|
|
}
|
|
|
|
}
|
|
|
|
|
|
openSearch() {
|
|
this.dynamicSearch()
|
|
}
|
|
async closeSearch() {
|
|
this.searchSubject = ''
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
async basicSearch() {
|
|
this.dynamicSearch()
|
|
}
|
|
|
|
|
|
|
|
goToDespacho({ SerialNumber } : customTask) {
|
|
this.router.navigate(['/home/gabinete-digital/despachos',SerialNumber,'gabinete-digital']);
|
|
}
|
|
|
|
async LoadList() {
|
|
|
|
this.skeletonLoader = true;
|
|
|
|
await this.despachoRule.getList({updateStore: true})
|
|
this.dynamicSearch()
|
|
this.skeletonLoader = false;
|
|
}
|
|
|
|
doRefresh(event) {
|
|
if (event) {
|
|
setTimeout(() => {
|
|
try {
|
|
event?.target?.complete();
|
|
} catch(error) {}
|
|
}, 2000);
|
|
}
|
|
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1000);
|
|
}
|
|
|
|
refreshing() {
|
|
setTimeout(() => {
|
|
this.LoadList();
|
|
}, 1000);
|
|
}
|
|
|
|
}
|