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.
Facet sources are currently limited to views that expose a Page and/or a Block. A view that exposes a REST Export does not qualify for a Facet Source. Is this a known bug that needs work or a deliberate decision?
I have a patch that adds REST Exports as a Facet Source if anyone is interested in taking a peek.
We should provide endpoints to access facets over REST.
Together with this we should ship with a facet source for views REST.
Comment | File | Size | Author |
---|---|---|---|
#56 | Screen Shot 2017-03-08 at 15.59.01.png | 30.04 KB | borisson_ |
#56 | Screen Shot 2017-03-08 at 15.58.44.png | 11.51 KB | borisson_ |
#49 | 2716083-49.patch | 21.25 KB | marthinal |
#42 | interdiff-2716083-37-42.txt | 672 bytes | marthinal |
#37 | 2716083-37.patch | 21.63 KB | marthinal |
Comments
Comment #2
StryKaizerYes, I'm interested, please post that patch! ;)
Comment #3
StryKaizerComment #4
swentel CreditAttribution: swentel at eps & kaas for MuseScore commentedIt's 'relatively' easy to trigger facets on rest resources if you create your own facetResource and play with the isRenderedInCurrentRequest() method. Some code that's actually in production right now.
Might serve as inspiration for a more global rest facet resource.
Moving to task. It's not because it isn't supported that something is a bug.
Comment #5
swentel CreditAttribution: swentel at eps & kaas for MuseScore commentedAnd no patch either
Comment #6
marthinal CreditAttribution: marthinal commentedWorking on it. Thanks @borisson_ and @swentel for the great help :)
1) Creating a new Style plugin for views.
2) Creating a new widget.
Here is the result:
Needs tests and feedback please.
Thanks!!!
Comment #9
borisson_I found a couple of smaller things that should be changed in the patch.
Was this change needed?
so easy, nice!
We might be able to change this from REST widget to ArrayWidget? That makes more sense and it makes it easier for people that they can use it for other custom purposes as well.
let's just remove this line.
I don't think soft limit is useful for this widget, so let's remove it.
Is it possible to add this in the __construct by adding a
create
method?Comment #10
marthinal CreditAttribution: marthinal commented1) Oops Sorry Done.
3) Sure. Makes sense. Done
4) Done
5) Done
6) Sure DI++
Comment #13
borisson_This will need a reroll, I just committed a bunch of issues.
Comment #14
marthinal CreditAttribution: marthinal commentedDone. Needs tests and probably improve comments(and maybe refactor).
Comment #15
borisson_I only found one thing:
Maybe we can extract this into a variable for easier readability.
Comment #16
Wim LeersComment #17
Wim LeersI started reviewing this because I thought this was adding a
@RestResource
plugin. But it's extending Views' REST export support. I don't know enough about that. Posting what I had so far.This sounds super abstract :D
s/url/URL/
s/amount/number/, I think?
FacetsSerializer
Unnecessary parenthesis-wrapping.
Comment #18
borisson_Thanks for the review Wim! I fixed all your remarks and added a unit test for the array widget. I'm adding a webtest now.
Comment #19
marthinal CreditAttribution: marthinal commentedAdding integration test.
Comment #20
borisson_This will fail on the d.o testbots, you'll probably have to do a
strpos($url, 'facets-rest?f[0]=tawny_browed_owl%3Aarticle') !== FALSE
instead.Same here, this won't work either, can we extract this from the json? so let's do
$this->drupalGet($json_decoded->facets[0][0]->url
instead.same here.
I'm not sure about 'active' as a way to define if it's active, a boolean might be better. Url is not correct either.
Comment #23
marthinal CreditAttribution: marthinal commentedSorry it was a copy/paste :D
Well, we can use $base_url?
Let's change active to use a bool instead.
Comment #26
marthinal CreditAttribution: marthinal commentedLocally the integration test looks correct. Let's try to fix the problem with the order.
Comment #29
marthinal CreditAttribution: marthinal commentedFixing the unit tests
Comment #30
borisson_Just some small changes - nothing really changes here.
Comment #33
borisson_I made a booboo.
Comment #34
borisson_Removing tag.
Comment #35
marthinal CreditAttribution: marthinal commentedAwesome! I think we can commit this new feature. As discussed we can open new follow-ups later if needed.
Comment #36
Nick_vhWhat is this doing and why is this necessary? Can we add comments to this?
Why use reset? Reset "resets" the pointer to the first element of the array. We probably want to use "current" because that implies we haven't iterated of the options array yet and it will give us the first element. Why do we default to json? Is there constant or function we should use to find out what the default is?
Aren't we overwriting the processed facets over and over here? Unless it's passed along. I would imagine we need array_merge here.
typo: decode
Just call it $json and $page_output or keep it at $json_decoded.
same here
How come we do not show the processed facet value field as well? Eg Term ID that is processed in to a term name? Or am I missing something here? Is this perhaps present in a property "title"? And if so, can we add it in the test? :)
Comment #37
marthinal CreditAttribution: marthinal commented36.1) Done
36.2) For this endpoint we don't need to add the
_format
to the url. So we want to select the first one and by default the json. As discussed in Milano this is a copy paste from views :)36.3) Done. To cover this part I'm adding 2 facets to the Facet Source.
36.4) Done.
36.5) Done.
36.6) Done.
36.7) AFAIK from the UI we use the term name by default... To be honest not sure what to do here... maybe it is correct as it is :) We should ask @borisson_!
1) Adding the field identifier per facet.
2) From Integration tests I need to use
drupal_flush_all_caches();
when adding 2 facets. Not really sure why.3) Looks like the "or" operator is not working. I'll try to take a look later or tomorrow.
>
Thanks Nick!
Comment #39
borisson_#36.7, this is correct behavior. We're only showing the value as it would be outputted by another facet, meaning that all processors will be executed as for other facets.
Comment #41
marthinal CreditAttribution: marthinal commented@borisson_ Perfect thanks!
So I'll continue later.
Comment #42
marthinal CreditAttribution: marthinal commentedFixing integration tests. Locally it looks ok.
Comment #45
marthinal CreditAttribution: marthinal commentedFixing unit tests.
Show numbers config option now works.
Comment #47
borisson_I think the sorting here isn't working as expected in php7, there's a difference between how php7 and php5 handle sorting, so we'll have to add more explicit sorting configuration here, or remove the order of the items from the test.
Comment #48
marthinal CreditAttribution: marthinal commentedYeahh really interesting. When the result is the same, the order is different depending on the php version...
Comment #49
marthinal CreditAttribution: marthinal commented@borisson_ Not sure if "banana" and "strawberry" should disappear filtering by item here because the result is 0. The OR operator works as expected for the Type facet but not sure about the behavior of a second facet. Perhaps create a followup?
Comment #50
borisson_We can create a followup if we need, I feel we can commit this but I'd love to discuss this a little more.
Comment #51
marthinal CreditAttribution: marthinal commentedComment #53
marthinal CreditAttribution: marthinal commentedThank you Joris
Comment #55
Kartoffelsalat CreditAttribution: Kartoffelsalat commentedThank you for the hard work for this patch.
I have the problem that a view with a "REST export" display based upon a Search API indexed content type ignores the facet filters. The main view display supports facet filtering. I have added both paths (main view display and REST export display) to the facet (in the blocks overview).
Which steps did I forget to enable facet filters for the "REST export" view display?
Comment #56
borisson_@Kartoffelsalat: next time, please create a new issue instead of commenting on a 8month old issue ;)
You need to create the facets to the correct facet source. This is not possible trough the block UI, as blocks don't show up on rest pages. You will have to create facets for every display of the view.
First of all, make sure the rest view uses the correct serializer.
Create your facets for the correct facet source.