|
17 | 17 | import org.labkey.test.components.react.ReactCheckBox; |
18 | 18 | import org.labkey.test.components.ui.grids.FieldReferenceManager.FieldReference; |
19 | 19 | import org.labkey.test.components.ui.search.FilterExpressionPanel; |
| 20 | +import org.labkey.test.components.ui.search.FilterFacetedPanel; |
20 | 21 | import org.labkey.test.params.FieldKey; |
21 | 22 | import org.labkey.test.util.selenium.WebElementUtils; |
22 | 23 | import org.openqa.selenium.Keys; |
|
40 | 41 | import static org.hamcrest.CoreMatchers.is; |
41 | 42 | import static org.hamcrest.MatcherAssert.assertThat; |
42 | 43 | import static org.junit.Assert.assertEquals; |
| 44 | +import static org.labkey.remoteapi.query.Filter.Operator.ARRAY_CONTAINS_ALL; |
| 45 | +import static org.labkey.remoteapi.query.Filter.Operator.ARRAY_CONTAINS_ANY; |
| 46 | +import static org.labkey.remoteapi.query.Filter.Operator.ARRAY_CONTAINS_EXACT; |
| 47 | +import static org.labkey.remoteapi.query.Filter.Operator.ARRAY_CONTAINS_NONE; |
| 48 | +import static org.labkey.remoteapi.query.Filter.Operator.ARRAY_CONTAINS_NOT_EXACT; |
| 49 | +import static org.labkey.remoteapi.query.Filter.Operator.ARRAY_ISEMPTY; |
| 50 | +import static org.labkey.remoteapi.query.Filter.Operator.ARRAY_ISNOTEMPTY; |
43 | 51 | import static org.labkey.test.WebDriverWrapper.waitFor; |
44 | 52 |
|
45 | 53 | public class ResponsiveGrid<T extends ResponsiveGrid<?>> extends WebDriverComponent<ResponsiveGrid<T>.ElementCache> implements UpdatingComponent |
@@ -232,20 +240,33 @@ public String filterColumnExpectingError(CharSequence columnIdentifier, Filter.O |
232 | 240 | return errorMsg; |
233 | 241 | } |
234 | 242 |
|
| 243 | +private static final List<Filter.Operator> ARRAY_OPERATORS = List.of(ARRAY_CONTAINS_ALL, ARRAY_CONTAINS_ANY, ARRAY_CONTAINS_EXACT, ARRAY_CONTAINS_NONE, |
| 244 | + ARRAY_CONTAINS_NOT_EXACT, ARRAY_ISEMPTY, ARRAY_ISNOTEMPTY); |
| 245 | + |
235 | 246 | private GridFilterModal initFilterColumn(CharSequence columnIdentifier, Filter.Operator operator, Object value) |
236 | 247 | { |
237 | 248 | clickColumnMenuItem(columnIdentifier, "Filter...", false); |
238 | 249 | GridFilterModal filterModal = new GridFilterModal(getDriver(), this); |
239 | 250 | if (operator != null) |
240 | 251 | { |
241 | | - if (operator.equals(Filter.Operator.IN) && value instanceof List<?>) |
| 252 | + if (operator.equals(Filter.Operator.IN) && value instanceof List<?> || ARRAY_OPERATORS.contains(operator)) |
242 | 253 | { |
243 | | - List<String> values = (List<String>) value; |
244 | | - filterModal.selectFacetTab().selectValue(values.get(0)); |
245 | | - filterModal.selectFacetTab().checkValues(values.toArray(String[]::new)); |
| 254 | + FilterFacetedPanel filterPanel = filterModal.selectFacetTab(); |
| 255 | + if (ARRAY_OPERATORS.contains(operator)) |
| 256 | + { |
| 257 | + filterPanel.selectArrayFilterOperator(operator); |
| 258 | + } |
| 259 | + if (value != null) |
| 260 | + { |
| 261 | + List<String> values = (List<String>) value; |
| 262 | + filterPanel.selectValue(values.get(0)); |
| 263 | + filterPanel.checkValues(values.toArray(String[]::new)); |
| 264 | + } |
246 | 265 | } |
247 | 266 | else |
| 267 | + { |
248 | 268 | filterModal.selectExpressionTab().setFilter(new FilterExpressionPanel.Expression(operator, value)); |
| 269 | + } |
249 | 270 | } |
250 | 271 | return filterModal; |
251 | 272 | } |
@@ -385,15 +406,16 @@ public T selectRow(int index, boolean checked) |
385 | 406 |
|
386 | 407 | /** |
387 | 408 | * Finds the first row with the specified texts in the specified columns, and sets its checkbox |
388 | | - * @param partialMap key-column (fieldKey, name, or label), value-text in that column |
389 | | - * @param checked the desired checkbox state |
| 409 | + * |
| 410 | + * @param partialMap key-column (fieldKey, name, or label), value-text in that column |
| 411 | + * @param checked the desired checkbox state |
390 | 412 | * @return this grid |
391 | 413 | */ |
392 | 414 | public T selectRow(Map<String, String> partialMap, boolean checked) |
393 | 415 | { |
394 | 416 | GridRow row = getRow(partialMap); |
395 | 417 | selectRowAndVerifyCheckedCounts(row, checked); |
396 | | - getWrapper().log("Row described by map ["+partialMap+"] selection state set to + ["+row.isSelected()+"]"); |
| 418 | + getWrapper().log("Row described by map [" + partialMap + "] selection state set to + [" + row.isSelected() + "]"); |
397 | 419 |
|
398 | 420 | return getThis(); |
399 | 421 | } |
|
0 commit comments