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
|
|
10
|
|
11
|
}
|
12
|
|
13
|
export class Value{
|
14
|
public name: string; //eg Article, Journal
|
15
|
public id: string; //0001
|
16
|
public selected: boolean = false;
|
17
|
public number: number = 0;
|
18
|
|
19
|
}
|
20
|
export class AdvancedField{
|
21
|
public id: string; //
|
22
|
public param:string;
|
23
|
public name: string; //
|
24
|
public type: string = "keyword"; //keyword, static or dynamic
|
25
|
public value: string = '';
|
26
|
public operatorId: string;
|
27
|
public operatorName: string ="";
|
28
|
public valid: boolean = true;
|
29
|
public dateValue:DateValue = new DateValue("any");
|
30
|
|
31
|
constructor(id:string,param:string,name:string, type:string, value:string,operator:string){
|
32
|
this.id = id;
|
33
|
this.param = param;
|
34
|
this.name = name;
|
35
|
this.type = type;
|
36
|
this.value = value;
|
37
|
this.operatorId = operator;
|
38
|
// this.operatorName = "AND";
|
39
|
|
40
|
}
|
41
|
}
|
42
|
export class DateValue{
|
43
|
public types = ["any","range","1mon","2mon","3mon","6mon","12mon","2year","5year","10year"];
|
44
|
public typesTitle = ["any","in the specified date range","in the last month","in the last 2 months","in the last 3 months","in the last 6 months","in the last year","in the last 2 years","in the last 5 years","in the last 10 years"];
|
45
|
public type: string ;
|
46
|
public from:Date = new Date();
|
47
|
public to:Date = new Date();
|
48
|
constructor(type:string = "any"){
|
49
|
this.setDatesByType(type);
|
50
|
}
|
51
|
public setDatesByType(type:string){
|
52
|
if(this.types.indexOf(type) == -1){
|
53
|
type=this.types[0];
|
54
|
}
|
55
|
this.type = type;
|
56
|
this.to = Dates.getDateToday();
|
57
|
if(this.type == "range" || this.type == "any"){ // for type "any" just to initiate with values
|
58
|
this.from = Dates.getDateXMonthsAgo(1);
|
59
|
}else if(this.type == "1mon"){
|
60
|
this.from = Dates.getDateXMonthsAgo(1);
|
61
|
}else if(this.type == "2mon"){
|
62
|
this.from = Dates.getDateXMonthsAgo(2);
|
63
|
}else if(this.type == "3mon"){
|
64
|
this.from = Dates.getDateXMonthsAgo(3);
|
65
|
}else if(this.type == "6mon"){
|
66
|
this.from = Dates.getDateXMonthsAgo(6);
|
67
|
}else if(this.type == "12mon"){
|
68
|
this.from = Dates.getDateXMonthsAgo(12);
|
69
|
}else if(this.type == "2year"){
|
70
|
this.from = Dates.getDateXYearsAgo(2);
|
71
|
}else if(this.type == "5year"){
|
72
|
this.from = Dates.getDateXYearsAgo(5);
|
73
|
}else if(this.type == "10year"){
|
74
|
this.from = Dates.getDateXYearsAgo(10);
|
75
|
}
|
76
|
}
|
77
|
|
78
|
}
|
79
|
export class OPERATOR{
|
80
|
public static AND: string ="and";
|
81
|
public static OR: string ="or";
|
82
|
public static NOT: string ="not";
|
83
|
|
84
|
}
|
85
|
|
86
|
export class AutoCompleteValue{
|
87
|
public id: string;
|
88
|
public label: string;
|
89
|
}
|