Project

General

Profile

1
import {Dates} from '../../utils/string-utils.class';
2
export class Filter{
3
    public title: string; // eg Type
4
    public filterId: string; // type (name in url parameter)
5
    public originalFilterId: string; // (in index)
6
    public countSelectedValues: number = 0;
7
    public values: Value[] = [];
8
    public filterOperator: string ='or';
9
    public valueIsExact: boolean = true;  // for search table view, if value is contained or is equal with column entry
10
    public filterType: string = "checkbox";
11
//    public uniqueValueIdSelected: string;
12
}
13

    
14
export class Value{
15
    public name: string; //eg Article, Journal
16
    public id: string; //0001
17
    public selected: boolean = false;
18
    public number: number = 0;
19

    
20
}
21
export class AdvancedField{
22
    public id: string; //
23
    public param:string;
24
    public name: string; //
25
    public type: string = "keyword"; //keyword, static or dynamic
26
    public value: string = '';
27
    public operatorId: string;
28
    public operatorName: string ="";
29
    public valid: boolean = true;
30
    public dateValue:DateValue = new DateValue("any");
31

    
32
    constructor(id:string,param:string,name:string, type:string, value:string,operator:string){
33
      this.id = id;
34
      this.param = param;
35
      this.name = name;
36
      this.type = type;
37
      this.value = value;
38
      this.operatorId =  operator;
39
      // this.operatorName =  "AND";
40

    
41
    }
42
}
43
export class DateValue{
44
    public types = ["1mon","2mon","3mon","6mon","12mon","2year","5year","10year","range"];
45
    public typesTitle = ["Last month","Last 2 months","Last 3 months","Last 6 months","Last year","Last 2 years","Last 5 years","Last 10 years", "Specify date range..."];
46
    public type: string ;
47
    public from:Date = new Date();
48
    public to:Date = new Date();
49
    constructor(type:string = "any"){
50
      this.setDatesByType(type);
51
    }
52
    public setDatesByType(type:string){
53
      if(this.types.indexOf(type) == -1){
54
        type=this.types[0];
55
      }
56
      this.type = type;
57
      this.to = Dates.getDateToday();
58
      if(this.type == "range" || this.type == "any"){ // for type "any" just to  initiate with values
59
        this.from = Dates.getDateXMonthsAgo(1);
60
      }else if(this.type == "1mon"){
61
        this.from = Dates.getDateXMonthsAgo(1);
62
      }else if(this.type == "2mon"){
63
        this.from = Dates.getDateXMonthsAgo(2);
64
      }else if(this.type == "3mon"){
65
        this.from = Dates.getDateXMonthsAgo(3);
66
      }else if(this.type == "6mon"){
67
        this.from = Dates.getDateXMonthsAgo(6);
68
      }else if(this.type == "12mon"){
69
        this.from = Dates.getDateXMonthsAgo(12);
70
      }else if(this.type == "2year"){
71
        this.from = Dates.getDateXYearsAgo(2);
72
      }else if(this.type == "5year"){
73
        this.from = Dates.getDateXYearsAgo(5);
74
      }else if(this.type == "10year"){
75
        this.from = Dates.getDateXYearsAgo(10);
76
      }
77
    }
78

    
79
}
80
export class OPERATOR{
81
    public static AND: string ="and";
82
    public static OR: string ="or";
83
    public static NOT: string ="not";
84

    
85
}
86

    
87
export class AutoCompleteValue{
88
  public id: string;
89
  public label: string;
90
}
(36-36/55)