Commit a54546bc authored by Martin Keereman's avatar Martin Keereman
Browse files

Issue #3115485 by jacobbell84: Additional support for grouped filters

parent 63c3d70d
......@@ -21,7 +21,7 @@ class DatePickers extends FilterWidgetBase {
/** @var \Drupal\views\Plugin\views\filter\FilterPluginBase $filter */
$is_applicable = FALSE;
if (is_a($filter, 'Drupal\views\Plugin\views\filter\Date') || !empty($filter->date_handler)) {
if ((is_a($filter, 'Drupal\views\Plugin\views\filter\Date') || !empty($filter->date_handler)) && !$filter->isAGroup()) {
$is_applicable = TRUE;
}
......
......@@ -53,6 +53,10 @@ abstract class FilterWidgetBase extends BetterExposedFiltersWidgetBase implement
}
}
if ($filter->isAGroup()) {
$is_applicable = TRUE;
}
return $is_applicable;
}
......@@ -113,7 +117,7 @@ abstract class FilterWidgetBase extends BetterExposedFiltersWidgetBase implement
// filters allow unlimited filter options via textfields, so we can't
// offer rewriting for those.
// @TODO: check other core filter types
if (!$filter instanceof StringFilter && !$filter instanceof NumericFilter) {
if ((!$filter instanceof StringFilter && !$filter instanceof NumericFilter) || $filter->isAGroup()) {
$form['advanced']['rewrite']['filter_rewrite_values'] = [
'#type' => 'textarea',
'#title' => $this->t('Rewrite the text displayed'),
......@@ -187,12 +191,23 @@ abstract class FilterWidgetBase extends BetterExposedFiltersWidgetBase implement
//}
}
// Identify all exposed filter elements.
$identifier = $filter_id;
$exposed_label = $filter->options['expose']['label'];
$exposed_description = $filter->options['expose']['description'];
if ($filter->isAGroup()) {
$identifier = $filter->options['group_info']['identifier'];
$exposed_label = $filter->options['group_info']['label'];
$exposed_description = $filter->options['group_info']['description'];
}
// If selected, collect our collapsible filter form element and put it in
// a details element.
if ($is_collapsible) {
$form[$field_id . '_collapsible'] = [
'#type' => 'details',
'#title' => $filter->options['expose']['label'],
'#title' => $exposed_label,
];
if ($is_secondary) {
......@@ -201,13 +216,6 @@ abstract class FilterWidgetBase extends BetterExposedFiltersWidgetBase implement
}
}
// Identify all exposed filter elements.
if ($filter->options['is_grouped']) {
$identifier = $filter->options['group_info']['identifier'];
}
else {
$identifier = $filter_id;
}
$filter_elements = [
$identifier,
$filter->options['expose']['operator_id'],
......@@ -225,8 +233,8 @@ abstract class FilterWidgetBase extends BetterExposedFiltersWidgetBase implement
$this->addElementToGroup($form, $form_state, $element, $field_id . '_collapsible');
}
else {
$form[$element]['#title'] = $filter->options['expose']['label'];
$form[$element]['#description'] = $filter->options['expose']['description'];
$form[$element]['#title'] = $exposed_label;
$form[$element]['#description'] = $exposed_description;
// Move secondary elements.
if ($is_secondary) {
......
......@@ -26,7 +26,7 @@ class Single extends FilterWidgetBase {
return $is_applicable;
}
if (is_a($filter, 'Drupal\views\Plugin\views\filter\BooleanOperator')) {
if (is_a($filter, 'Drupal\views\Plugin\views\filter\BooleanOperator') || ($filter->isAGroup() && sizeOf($filter->options['group_info']['group_items']) == 1)) {
$is_applicable = TRUE;
}
......
......@@ -52,7 +52,7 @@ class Sliders extends FilterWidgetBase {
$is_numeric_filter = is_a($filter, 'Drupal\views\Plugin\views\filter\NumericFilter');
$is_range_filter = is_a($filter, 'Drupal\range\Plugin\views\filter\Range');
$is_date_filter = is_a($filter, 'Drupal\views\Plugin\views\filter\Date');
if (($is_numeric_filter || $is_range_filter) && !$is_date_filter) {
if (($is_numeric_filter || $is_range_filter) && !$is_date_filter && !$filter->isAGroup()) {
$is_applicable = TRUE;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment