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.
The current JS implementation blindly applies the checkbox behavior and show/hide behavior to all block facets even if the type of widget is something totally different.
This is possibly relevant for the tagcloud, slider, and other possible block implementations. If nothing else, the JS should be faster if we don't try to do that extra processing.
Comment | File | Size | Author |
---|---|---|---|
#18 | 1175718-18.patch | 3.43 KB | pwolanin |
#17 | 1175718-17.patch | 3.32 KB | pwolanin |
#8 | 1175718-8.patch | 2.49 KB | pwolanin |
#7 | 1175718-7.patch | 1.69 KB | pwolanin |
#5 | 1175750-5.patch | 3.35 KB | pwolanin |
Comments
Comment #1
pwolanin CreditAttribution: pwolanin commentedsacrificing the 'type' setting, since we are debating making that an array or even how it's relevant.
Comment #2
cpliakas CreditAttribution: cpliakas commentedI see what you are getting at. Could you further explain the "widgetFamily" to me? We already have the machine readable name of the widget. Couldn't we use that for the conditional?
Changing to a feature request because I think the functionality works as-is and I don't see it conflicting with future widgets. Obviously I could be missing something.
Comment #3
pwolanin CreditAttribution: pwolanin commentedWell, I did not want to hard-code the allowed widget names there. Imagine I want to make another widget that derives from FacetapiWidgetLinks and wants to use the soft/hard limit feature.
By having this "family" notion, we allow this new custom widget to benefit from the JS defined by the main module.
The alternative I initially considered was having a setting that lists all the link-type widget names, but that was a bit uglier in terms of implementation and further bloats the JS settings.
Comment #4
pwolanin CreditAttribution: pwolanin commentedper discussion with Chris, making this more targeted as part of the settings, since the "Family" concept is not necessarily clear.
Comment #5
pwolanin CreditAttribution: pwolanin commentedAfter more discussion - a simplified patch.
Comment #6
pwolanin CreditAttribution: pwolanin commentedComment #7
pwolanin CreditAttribution: pwolanin commentedFollow-up to better target the adding of checkboxes and minimize the JS overhead.
Also replaces the class rather than adding another.
Comment #8
pwolanin CreditAttribution: pwolanin commentedbetter comments and method names too.
Comment #9
cpliakas CreditAttribution: cpliakas commentedLooks good to me.
Comment #10
pwolanin CreditAttribution: pwolanin commentedGiven the other checks we have, we can probable even remove the condition
what do you think?
Comment #11
cpliakas CreditAttribution: cpliakas commentedI think that makes sense. I want to try to get away from hard-coding the realms if possible. I created a task a while ago at #1147500: Improve the JavaScript API to remember to improve the JS API. I am even tpying with the idea of specifying the method or methods that are invoked per-facet in the jsSettings. For example:
The methods would be out checkbox functionality or show more / show less stuff. That way we can eliminate any checks all together. Would like to hear thoughts on that approach.
Comment #12
pwolanin CreditAttribution: pwolanin commentedWhat's the use case for such dynamic specification of the methods? Two facet widgets with the same 'limit' setting but different ways of handling it? Seems clearer to just have a different setting name?
Comment #13
cpliakas CreditAttribution: cpliakas commentedHow I see it, this would allow for different widgets to reuse the same settings. For example:
This way you could reuse settings without having to do the conditionals we have been working with. Also, as it stands every JS file associated with a widget has to iterate over the settings and do their own conditional to apply their own settings. Check out the for loop in the Chart Facets module's JS file. Defining the callbacks would eliminate the need for the widgets to loop through the settings in order to figure out which widgets should be acted on.
Comment #14
pwolanin CreditAttribution: pwolanin commentedAny concern about bloating the settings?
Comment #15
cpliakas CreditAttribution: cpliakas commentedIn what way? Are you concerned about the amount of data being transferred as JS settings, the actual $this->jsSettings variable getting too big and unwieldy, or something else I am not thinking of?
Comment #16
pwolanin CreditAttribution: pwolanin commentedMore the JS settings in the page getting big, though really it's not going to make much difference if there are only a half dozen fcets displayed on a page.
Comment #17
pwolanin CreditAttribution: pwolanin commentedHere's a version with somewhat more changes that reduces code duplication and should be more compatible to defining a single callback.
Comment #18
pwolanin CreditAttribution: pwolanin commentedMake code clearer by removing repeated use of
$(this)
Comment #19
pwolanin CreditAttribution: pwolanin commentedcommitted
Comment #20
cpliakas CreditAttribution: cpliakas commentedAwesome. Love the elimination of all that code. Moving the "callbacks" functionality to a post at #1147500: Improve the JavaScript API.