Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
drupal.org
better_exposed_filters
Commits
a54546bc
Commit
a54546bc
authored
Feb 29, 2020
by
Martin Keereman
Browse files
Issue #3115485 by jacobbell84: Additional support for grouped filters
parent
63c3d70d
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/Plugin/better_exposed_filters/filter/DatePickers.php
View file @
a54546bc
...
...
@@ -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
;
}
...
...
src/Plugin/better_exposed_filters/filter/FilterWidgetBase.php
View file @
a54546bc
...
...
@@ -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'
=>
$expose
d_
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'
]
=
$expose
d_
label
;
$form
[
$element
][
'#description'
]
=
$expose
d_
description
;
// Move secondary elements.
if
(
$is_secondary
)
{
...
...
src/Plugin/better_exposed_filters/filter/Single.php
View file @
a54546bc
...
...
@@ -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
;
}
...
...
src/Plugin/better_exposed_filters/filter/Sliders.php
View file @
a54546bc
...
...
@@ -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
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment