-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathGridContext.cls
81 lines (61 loc) · 1.59 KB
/
GridContext.cls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**
* DTO class that is used to represent the current state of a Grid component instance.
*/
public with sharing class GridContext {
public String searchTerm;
public Integer currentPage;
public Integer pageSize;
public String sortedBy;
public String sortedDirection;
public Map<String, String> activeFilters;
public Map<String, String> hiddenFilters;
public Map<String, List<FilterOption>> filterOptions;
public Integer totalFilteredRecords;
public Integer totalRecords;
public GridContext() {
initialize();
}
public void initialize() {
if(searchTerm == null)
searchTerm = '';
if(currentPage == null)
currentPage = 1;
if(pageSize == null)
pageSize = 50;
if(sortedBy == null)
sortedBy = '';
if(sortedDirection == null)
sortedDirection = '';
if(activeFilters == null)
activeFilters = new Map<String, String>();
if(hiddenFilters == null)
hiddenFilters = new Map<String, String>();
if(filterOptions == null)
filterOptions = new Map<String, List<FilterOption>>();
}
public class FilterOption implements Comparable {
public String value;
public String label;
public Boolean checked;
public FilterOption(String value, String label, Boolean checked) {
this.value = value;
this.label = label;
this.checked = checked;
}
public FilterOption(String value, String label) {
this(value, label, false);
}
public Integer compareTo(Object o) {
FilterOption other = (FilterOption)o;
if(label == null) {
if(other.label == null)
return 0;
else
return 1;
}
else {
return label.compareTo(other.label);
}
}
}
}