-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfilteringModel.js
More file actions
59 lines (56 loc) · 2.15 KB
/
filteringModel.js
File metadata and controls
59 lines (56 loc) · 2.15 KB
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
import { FilteringV1 } from "#pages/filteringV1"
const filter = new FilteringV1()
export class FilteringModel {
/**
* Configures a simple filter for a specific column with multiple conditions
* @param {number} column - The column index to apply the filter to (default: 0)
* @param {Object} payload - The filter configuration object containing conditions and action.
payload = {
conditions:[
{
filter: ">",
value: "123",
},
{
filter: "<",
value: "125",
}
],
action: "Apply"
}
* @param {Array} payload.conditions - Array of filter conditions with filter type and value
* @param {string} payload.action - The action to perform ("Cancel"|"Apply"|"Clear", default: "Cancel")
*/
configureSimpleFilter(column = 0, payload = {}){
filter.openFilter(column)
filter.displayDotFilter(column)
filter.filterModalIsVisible()
payload.conditions.forEach(($filtering, $index) => {
filter.fillFilter($filtering.filter, $index)
filter.fillValue($filtering.value, $index)
filter.addNewFilter()
})
filter.removeFilter(payload.conditions.length)
filter.pressButtonModal(payload.action)
}
/**
* Clears any existing filter for a specific column
* @param {number} column - The column index to clear the filter from (default: 0)
*/
clearFilterByColumn(column = 0){
filter.openFilter(column)
filter.displayDotFilter(column)
filter.pressButtonModal("Clear")
}
/**
* Sorts a column in ascending or descending order
* @param {number} column - The column index to sort (default: 0)
* @param {string} action - The sort action to perform ("Sort Ascending"|"Sort Descending" default: "Sort Ascending")
*/
pressSortButton(column = 0, action = "Sort Ascending"){
filter.openFilter(column)
filter.displayDotFilter(column)
filter.filterModalIsVisible()
filter.pressSortButton(action)
}
}