Project

General

Profile

1 50169 argiro.kok
import { Pipe, PipeTransform} from '@angular/core'
2
3
4
@Pipe({
5
  name: 'claimsDatatable'
6
})
7
export class ClaimsDatatablePipe implements PipeTransform  {
8
9
  transform(array: any[], args: any[]): any {
10
    let query: string = args[0];
11
    let counter:any = args[1];
12
    let active: any = args[2];
13
14
    active.page = 1;
15
16
    if (query) {
17
      var result = array.filter(row=>this.filterAll(row, query));
18
      counter.count = result.length;
19
      return result;
20
    }
21
    return array;
22
  }
23
24
  filterAll(row: any, query: string) {
25
    if(row.userMail.indexOf(query) > -1) {
26
      return true;
27
    }
28
    if(row.targetType != 'project' && row.target.title.indexOf(query) > -1) {
29
      return true;
30
    }
31
    if(row.sourceType != 'project' && row.source.title.indexOf(query) > -1) {
32
      return true;
33
    }
34
    if(row.date.indexOf(query) > -1) {
35
      return true;
36
    }
37
38
    if(row.curatedBy != null && row.curatedBy.indexOf(query) > -1) {
39
      return true;
40
    }
41
42
    if(row.curationDate != null && row.curationDate.indexOf(query) > -1) {
43
      return true;
44
    }
45
46
    return false;
47
  }
48
}