Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If I use the "OtherFacet" condition, is it possible to filter for "not empty"? So, can I create a hierarchy of facets, where one facet will only be displayed if the parent facet has any value?
Comment | File | Size | Author |
---|---|---|---|
#35 | 2792847-35.patch | 14.12 KB | mpp |
#34 | 2792847-34.patch | 14.09 KB | jummonk |
#31 | 2792847-31.patch | 14.04 KB | mpp |
#19 | 2792847-19.patch | 14.02 KB | mpp |
#19 | interdiff.txt | 789 bytes | mpp |
Comments
Comment #2
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedWhat about multiple dependencies? As in, more than one other facet?
Comment #3
borisson_That's not yet implemented but sounds like a great feature!
Comment #4
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedLet's see if this actually passes existing tests. Probably not.
Reworked condition settings like this:
- list all existing facets as a single checkbox each
- present a condition "mode" selection
-- facet present (current behavior)
-- facet not empty (point of this issue)
-- specific facet values enabled (see #2784945)
- you can choose to negate this for every facet
- settings will only show up when facet condition itself is enabled (#states form handling)
This rework allows the users to
- create a hierarchy of facets
- depend on more than one facet
- define multiple values to be set (#2784945)
TODO:
- Tests. None are added, existing ones not touched
- Wording, descriptions, etc. - Somebody natively English speaking would be good
- Styling (?)
- Rename this condition? "Other facet" is not really that helpful. Maybe just "Facets"?
Comment #5
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedTODO: Oh, and updating existing settings, if that is an issue
Comment #7
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedTests hopefully fixed.
Comment #9
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedOtherFacetTest locally passes. IntegrationTest gives weired results probably unrelated to this.
Comment #11
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedK, this is hopefully it. Cannot test IntegrationTest locally, as it effectively requires 8.2
Comment #12
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedLeftover TODOs:
- Review
- Wording, descriptions, etc. - Somebody natively English speaking would be good
- Styling (?)
- Rename this condition? "Other facet" is not really that helpful. Maybe just "Facets"?
- updating existing settings, if that is an issue
Please provide feedback.
Comment #13
borisson_From the leftover todo's in #12.
- Review.
I'll do that when work's done (so later today). For upcoming patches please also provide interdiffs, I had taken a look at the first patch but have no idea about the changes since.
- Wording, descriptions, etc. - Somebody natively English speaking would be good.
I'm not a native english speaker but I'll have a look as part of the review.
- Styling (?)
Not sure if that'll be needed, this should all be drupal core's task? I'll have a look at how it looks during review so we might have to add some changes our selves or open a core-issue.
- Rename this condition? "Other facet" is not really that helpful. Maybe just "Facets"?
Yeah, that makes sense I guess.
- updating existing settings, if that is an issue
Not while we haven't reached the beta phase, no. We'll start providing upgrade paths as soon as we hit beta. But that won't happen before Search Api reaches beta.
Comment #14
ChristianAdamski CreditAttribution: ChristianAdamski as a volunteer commentedOver in Core Views Facets I already implemented AJAX handling. Specifically, when Views refreshes via AJAX, the facets using that view as source will also be updated.
I now run into the issue, that facet-blocks using this condition are simply not present, so can't be updated of course, even though the facet content itself is available.
This is not relevant when doing a full page-load on each click, but once facets introduces AJAX handling, it will become an issue.
I have yet to come up with a workable approach to this.
Comment #15
borisson_Overall this is looking good, I had some nitpicks though.
Let's use
$this->t()
here instead.I like this change, much clearer!
This comment is not very useful, let's remove it or replace it with something that happens in the code.
This looks like it's indented very weird.
Comment #16
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedChanged title as this patch also covers the problem of multiple facets in #2784945.
Comment #17
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedFixed the following warning: Invalid argument supplied for foreach() in Drupal\facets\Plugin\Condition\OtherFacet->evaluate() (line 220 of modules/contrib/facets/src/Plugin/Condition/OtherFacet.php).
Comment #18
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedComment #19
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedAdded some help text to the UI.
Comment #21
ndrake86 CreditAttribution: ndrake86 at Workday, Inc. commentedI tested out the latest patch and its working correctly for me. I was just thinking of a possible case where this function does something odd.
Say I have facet A and facet B with facet B only visible when facet A is selected. Currently if you have an item in facet A selected and and then select an item in facet B then unselect the item in facet A the selection for facet B is still selected but now it is hidden as the nothing is selected in facet A.
I was wondering if this should have be if the parent filter is unselected then all the dependent filters values that are only shown when the parent is selected are unselected.
I hope this sort of made some sense. I will attempt a patch later for this specific set of events but wanted to throw this out there.
Nick
Comment #22
dangelo5 CreditAttribution: dangelo5 commentedThis is looking great. I've been testing this out most of today.
I agree with @ndrake86. It would be awesome if when a user unselects a parent facet, then any dependent facet selections would be cleared. This is one area that threw me off initially and I think clearing the dependent filters when the parent is unselected would make the feature very usable.
Comment #29
borisson_Tests 'll need to be fixed for this as well. Otherwise I like the direction here.
Comment #30
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedNext to tests #19 needs a reroll (due to changes in #2834754).
Comment #31
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedRerolled #19.
Comment #32
borisson_Let's see what the testbot thinks.
Comment #34
jummonk CreditAttribution: jummonk commentedNew patch. Previous one failed because of ...
Comment #35
mpp CreditAttribution: mpp as a volunteer and at AmeXio commentedInterdiff:
- if (!is_array($enabled_conditions)) {
+ if (!is_array($enabled_conditions) || empty($enabled_conditions)) {
Comment #37
borisson_So, we're trying to rewrite the condition to a processor instead of an actual condition. I'm not sure if we should continue this work first. I'd say we should probably postpone this?
Comment #38
borisson_Postponing this on the work in #2796569: New Dependent Facet processor
Comment #39
borisson_The issue this was postponed on was committed recently. So work on this can start again.
Comment #40
borisson_Since this is now implemented as a processor - this is no longer a condition plugin. This feature still is a something we can improve but the current patch isn't really useable anymore.
Comment #41
mkalkbrenner