Skip to content

Commit 7e9bdef

Browse files
authored
Merge pull request #587 from ProcessMaker/add_filteringV1
Add filtering v1
2 parents adbb0c8 + e79d005 commit 7e9bdef

3 files changed

Lines changed: 148 additions & 0 deletions

File tree

model/filteringModel.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import { FilteringV1 } from "#pages/filteringV1"
2+
const filter = new FilteringV1()
3+
4+
export class FilteringModel {
5+
/**
6+
* Configures a simple filter for a specific column with multiple conditions
7+
* @param {number} column - The column index to apply the filter to (default: 0)
8+
* @param {Object} payload - The filter configuration object containing conditions and action.
9+
payload = {
10+
conditions:[
11+
{
12+
filter: ">",
13+
value: "123",
14+
},
15+
{
16+
filter: "<",
17+
value: "125",
18+
}
19+
],
20+
action: "Apply"
21+
}
22+
* @param {Array} payload.conditions - Array of filter conditions with filter type and value
23+
* @param {string} payload.action - The action to perform ("Cancel"|"Apply"|"Clear", default: "Cancel")
24+
*/
25+
configureSimpleFilter(column = 0, payload = {}){
26+
filter.openFilter(column)
27+
filter.displayDotFilter(column)
28+
filter.filterModalIsVisible()
29+
payload.conditions.forEach(($filtering, $index) => {
30+
filter.fillFilter($filtering.filter, $index)
31+
filter.fillValue($filtering.value, $index)
32+
filter.addNewFilter()
33+
})
34+
filter.removeFilter(payload.conditions.length)
35+
filter.pressButtonModal(payload.action)
36+
}
37+
38+
/**
39+
* Clears any existing filter for a specific column
40+
* @param {number} column - The column index to clear the filter from (default: 0)
41+
*/
42+
clearFilterByColumn(column = 0){
43+
filter.openFilter(column)
44+
filter.displayDotFilter(column)
45+
filter.pressButtonModal("Clear")
46+
}
47+
48+
/**
49+
* Sorts a column in ascending or descending order
50+
* @param {number} column - The column index to sort (default: 0)
51+
* @param {string} action - The sort action to perform ("Sort Ascending"|"Sort Descending" default: "Sort Ascending")
52+
*/
53+
pressSortButton(column = 0, action = "Sort Ascending"){
54+
filter.openFilter(column)
55+
filter.displayDotFilter(column)
56+
filter.filterModalIsVisible()
57+
filter.pressSortButton(action)
58+
}
59+
}

pages/filteringV1.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import selectors from "#selectors/filtering.js";
2+
3+
export class FilteringV1 {
4+
5+
/**
6+
* Opens the filter dropdown for a specific column by triggering mouseover event
7+
* @param {number} column - Column index (default: 0)
8+
*/
9+
openFilter(column = 0){
10+
cy.get(selectors.openFilter).eq(column).should('be.visible').trigger('mouseover')
11+
}
12+
13+
/**
14+
* Displays the three dots filter menu for a specific column
15+
* @param {number} column - Column index (default: 0)
16+
*/
17+
displayDotFilter(column = 0){
18+
cy.get(selectors.threeDots).eq(column).click({force:true})
19+
}
20+
21+
/**
22+
* Verifies that the filter modal is visible on the page
23+
*/
24+
filterModalIsVisible(){
25+
cy.get(selectors.modalFilter).should('be.visible')
26+
}
27+
28+
/**
29+
* Clicks a button within the filter modal
30+
* @param {string} buttonName - Button name to click ("Cancel"|"Apply"|"Clear", default: "Cancel")
31+
*/
32+
pressButtonModal(buttonName = "Cancel"){
33+
cy.get(selectors.filterForm).within(() => {
34+
cy.contains('button', buttonName).click()
35+
})
36+
}
37+
38+
/**
39+
* Clicks the sort button with the specified action
40+
* @param {string} action - Sort action ("Sort Ascending"|"Sort Descending", default: "Sort Ascending")
41+
*/
42+
pressSortButton(action = "Sort Ascending"){
43+
cy.get(selectors.sortButton).eq(0).contains('button', action).click()
44+
}
45+
46+
/**
47+
* Fills the filter option dropdown for a specific row
48+
* @param {string} option - Filter option to select (default: "=")
49+
* @param {number} row - Row index (default: 0)
50+
*/
51+
fillFilter(option = "=", row = 0){
52+
cy.get(selectors.optionFilter.replace('{row}', row)).select(option)
53+
}
54+
55+
/**
56+
* Fills the filter value input field for a specific row
57+
* @param {string} value - Value to type in the input field (default: "")
58+
* @param {number} row - Row index (default: 0)
59+
*/
60+
fillValue(value = "", row = 0){
61+
cy.get(selectors.valueFilter.replace('{row}', row)).type(value)
62+
63+
}
64+
65+
/**
66+
* Removes a filter for a specific row by clicking the remove button
67+
* @param {number} row - Row index (default: 0)
68+
*/
69+
removeFilter(row = 0){
70+
cy.get(selectors.removeButtonModal.replace('{row}', row)).click()
71+
}
72+
73+
/**
74+
* Adds a new filter row by clicking the add new filter button
75+
*/
76+
addNewFilter(){
77+
cy.get(selectors.addNewFilterButton).parent().parent("button").click()
78+
}
79+
}

selectors/filtering.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,14 @@ export default {
55
filterForm: '[class="pm-filter-form"]',
66
filterFooterBtns: '[class="pm-filter-form"] fieldset',
77
tableRequest: '[class="pm-table-container"]',
8+
//new filteringV1
9+
openFilter: '[class="pm-table-ellipsis-column"] [class="pm-table-column-header"]',
10+
threeDots: '.pm-table-ellipsis-column button',
11+
modalFilter: '[class="pm-filter-form"]',
12+
filterForm: '[class="pm-filter-form"]',
13+
sortButton: '[class="pm-filter-form"] fieldset',
14+
optionFilter: '[data-cy="pmFilterFormArea"] [data-cy="operator{row}"]',
15+
valueFilter: '[data-cy="pmFilterFormArea"] [data-cy="value{row}"]',
16+
removeButtonModal: '[data-cy="pmFilterFormArea"] [data-cy="buttonRemove{row}"]',
17+
addNewFilterButton: '[class="btn pm-filter-form-button btn-light btn-sm"] rect[fill="#D9D9D9"]'
818
};

0 commit comments

Comments
 (0)