49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
|
import { Pipe, PipeTransform} from '@angular/core'
|
||
|
|
||
|
|
||
|
@Pipe({
|
||
|
name: 'claimsDatatable'
|
||
|
})
|
||
|
export class ClaimsDatatablePipe implements PipeTransform {
|
||
|
|
||
|
transform(array: any[], args: any[]): any {
|
||
|
let query: string = args[0];
|
||
|
let counter:any = args[1];
|
||
|
let active: any = args[2];
|
||
|
|
||
|
active.page = 1;
|
||
|
|
||
|
if (query) {
|
||
|
var result = array.filter(row=>this.filterAll(row, query));
|
||
|
counter.count = result.length;
|
||
|
return result;
|
||
|
}
|
||
|
return array;
|
||
|
}
|
||
|
|
||
|
filterAll(row: any, query: string) {
|
||
|
if(row.userMail.indexOf(query) > -1) {
|
||
|
return true;
|
||
|
}
|
||
|
if(row.targetType != 'project' && row.target.title.indexOf(query) > -1) {
|
||
|
return true;
|
||
|
}
|
||
|
if(row.sourceType != 'project' && row.source.title.indexOf(query) > -1) {
|
||
|
return true;
|
||
|
}
|
||
|
if(row.date.indexOf(query) > -1) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if(row.curatedBy != null && row.curatedBy.indexOf(query) > -1) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
if(row.curationDate != null && row.curationDate.indexOf(query) > -1) {
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
return false;
|
||
|
}
|
||
|
}
|