Closed (fixed)
Project:
Facets
Version:
8.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
29 Nov 2015 at 12:49 UTC
Updated:
8 Feb 2016 at 09:44 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
michiellucas commentedFor a project we are using your dev version of facets for a search page, we would need the facets to act as OR filters.
Can you point us to the right direction to create this feature for facets?
Thanks
Comment #3
borisson_Hi,
First of all, this would need an extra setting in the facet entity / schema. I'd suggest something like:
comparison_operatorthat defaults to "AND". Not sure if that's a good name. (naming things, it's hard.)-
src/FacetInterface.php-> extra getter and setter.-
src/Entity/Facet-> implementation of the new getter & setter. + addition to theconfig_exportin the annotation.-
config/schema/facets.facet.schema.ymlOf course this will need to be set in the Form as well and saved on the entity.
You can have a look at the patch in #2625188: Allow limiting to one active item on how to do that, that also adds a new setting for the facet entity. (everything in patch; except for the part in the widget is quite similar to what you would need to do.)
The rest of the patch will probably have to go into the
DefaultFacetManager. Not sure how this should be solved though, I'd suggest you have a look at how facet_api in d7 solved this problem.If you need more anything else, you can ask here; or find us on irc in #drupal-search-api.
Anyway, thank you for taking a look at this!
Comment #4
michiellucas commentedHi,
i added the query_operator variable to the options array, is that ok ?
I changed also the query and now have a working version of the OR implementation. I added a patch, can you please have a look and give me some feedback?
Next thing on my list is create checkboxes.
Thanks
Comment #5
borisson_We have a different issue for the checkboxes, but it can surely be added trough this issue as well, we can close #2596337: Widget: CheckboxWidget.
I found a few very small issues with the patch:
There's one newline too much here.
Doesn't need the extra comment here.
Otherwise this looks great, we haven't enabled tests yet on the issue queue; so I hope that all tests still pass.
Comment #6
michiellucas commentedIt's ok the new ticket, i will work on it there https://www.drupal.org/node/2596337
I fixed your issues. Thanks for the feedback!
Comment #7
michiellucas commentedProblem that i now have is that i also need to show the facet items that are not active. Example
Dogs(12)
Cats(4) -> if cats is active, dogs disappears but that needs to change. When operator OR is chosen the facet needs to render al available filters.
I am looking into public function fillFacetsWithResults($facets) { where i can add the "not-active" facets.
If anyone has a better idea, shoot.
Thanks
Comment #8
michiellucas commentedRemoved the checkbox plugin from patch, was a mistake
Comment #9
borisson_I had a really small code style fix; otherwise this is already looking great.
It looks like tests pass but they needed a fix for something else, just committed that.
I'll write a specific test for this now.
Comment #10
ricovandevin commentedFor OR we also need an option to display the non-active options within a facet after one option is made active as michiellucas already stated. Do we tackle this in this issue too or do we create a separate issue for that?
Comment #11
borisson_I added a test, that currently fails. When that test passes, this functionality is ok.
@michiellucas, if you have time to work on this, that would of course be greatly appreciated, I don't think I'll be able to do a lot this week.
Comment #12
borisson_@ricovandevin: Sorry for the late response, I think we should also solve that in this issue, yes.
Comment #13
strykaizer#10 showing inactive items is addressed in the attached patch.
We still need to fix the count for inactive items (which shows 0 at the moment).
I also removed the count-check on a widget-level, as the widget should not care about this (It should be managed on another level).
Comment #14
borisson_So where should the count-check go to?
Comment #15
strykaizer#14, its already in the QueryTypeString plugin if I'm not mistaken.
Comment #16
borisson_Oh, it is, awesome. We still have to fix the tests, before we can get this in.
Comment #17
strykaizerTodo for this issue:
- tests
- fix the count for inactive items (which shows 0 at the moment).
Comment #18
borisson_Setting to NR for the bot.
Comment #20
borisson_This patch didn't apply anymore, it does now. I also removed the changes made in the checkbox widget. That widget is being reworked in #2596337: Widget: CheckboxWidget.
Comment #21
borisson_Go testbot, go!
Comment #23
borisson_Let's try this again.
Comment #25
borisson_One of the tests that currently fails because of this is the
LinksWidgetTest::testHideEmptyCounttest. Because we removed that functionality out of the widget but left it in the test.The functionality still works but we don't have a test to prove it, if we get in #2596337: Widget: CheckboxWidget, that adds a WidgetIntegrationTest - that would be great spot to add this test in. This should take us back to 1 fail.
Comment #27
borisson_Because we're using 'OR' by default, this assertion had to be updated. Tests are green.
Next up is getting the count right again.
Comment #28
borisson_This works locally, needs more tests and a big cleanup to make sure that everything works as possible + needs update to interface but it looks like it works. Woo!
Comment #30
borisson_Attached patch should fix the broken tests.
Comment #31
borisson_Comment #32
borisson_This needed a reroll because of the other recent commits. Writing a hide empty count integration test now - we removed that unit test in #25.
Comment #33
borisson_Added extra tests as mentioned in #32.
Comment #34
borisson_@StryKaizer mentioned in irc that the that this could benifit from extra comments, so I added some and renamed
$query2to$unfiltered_query.Comment #35
borisson_The discussion in irc mentioned some things about "supportsFeature", this adds that to the interface + the search api base-plugin. Not sure how to continue here.
Comment #37
borisson_Fixed tests.
Comment #50
borisson_So this is one that we actually need to reroll.
Comment #51
borisson_Comment #52
borisson_Can @Nick_vh or @StryKaizer help me explain where we have to go with the
supportsFeaturecode?I was happy with #34 and I'm not sure I know how to continue now.
Comment #53
borisson_Let's reroll and commit #34 we can do the other part in a followup later.
Comment #54
borisson_Attached a reroll of #34, if the tests pass I'll commit this.
Comment #56
borisson_Committed, thanks a bunch for your contributions @StryKaizer & @michiellucas.