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.
I think it's would be useful to have this feature. When you set values for all of facets (without refreshing results) and only then apply them by clicking "Apply" button or link. It can be some setting in a module (like "Do not apply filters immediatly") + link in a block ("Apply" link in some block). What do you think?
Comment | File | Size | Author |
---|---|---|---|
#22 | interdiff-21-22.txt | 8.16 KB | Loparev |
#22 | ajax_facets-submit_all-2700063-22.patch | 12.32 KB | Loparev |
#21 | interdiff-11237163-16-21.txt | 1.46 KB | monstrfolk |
#21 | 11237163-21.patch | 9.52 KB | monstrfolk |
Comments
Comment #2
Loparev CreditAttribution: Loparev commentedComment #3
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedIt doesn't looks very important. I don't think that I'll implement it for 7.x
Comment #4
monstrfolk CreditAttribution: monstrfolk commentedFrom original thread - https://www.drupal.org/node/2726173 (duplicate)
This patch adds a block that creates a Submit button for this module. Functions like the reset link from https://www.drupal.org/node/2658532. i see that this was committed to dev recently.
This is something that the Facet API in general really needs. Choosing one option, wait for the page to reload, choose another option, wait for the page to reload......takes to long and is not good for user experience.
How patch works.
Add submit block to a search page with facets.
The default behavior when choosing a facet with be overridden and the page will not reload until submit is clicked.
I also made a few adjustments to the Reset link to better work in conjunction with this patch.
There is one bug with this patch.
The option to enforce the limit of only one selection in a facet is not working. Needs to be corrected.
Should patch be moved here?
Comment #5
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedI'll check it, but in first vision your patch looks pretty big for such simple improvement.
Comment #6
Loparev CreditAttribution: Loparev commentedYes. Please, move patch here
Comment #7
monstrfolk CreditAttribution: monstrfolk commentedI had to modify the ajax_facets.block.inc file to add the new block. Most of the code comes from the addition of new block and some changes of reset block.
Comment #8
monstrfolk CreditAttribution: monstrfolk commentedPatched moved.
Comment #9
Loparev CreditAttribution: Loparev commented@monstrfolk, I told about this redundant spaces
Comment #10
Loparev CreditAttribution: Loparev commentedI'll try your patch as soon as possible.
Comment #11
Loparev CreditAttribution: Loparev commentedComment #12
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedI think that both these blocks are very simple and have a two blocks for buttons it's not good idea. I think better to have one block with settings to show/hide buttons and call it Ajax facets controls. What do you think?
Comment #13
monstrfolk CreditAttribution: monstrfolk commentedHaving one block forces both buttons to be in the same location.
I can think of use cases where having both buttons in different locations would much better than being forced to place the buttons next to each other. Also, the way that the code is written a block is not needed. A regular link with the appropriate class can invoke the same behavior for either reset or submit.
Having two blocks is much more versatile for design, but since the same functionality can be had from using CSS classes then one block works. If needed the CSS classes can be used as a substitute.
Attached is a picture from the project I am working on that uses both blocks in different locations.
Comment #14
monstrfolk CreditAttribution: monstrfolk commentedIf one block is the route to take then please document the ability to use the CSS classes for reset and submit on the module overview page. This is a nice feature and would be used if documented.
Comment #15
Loparev CreditAttribution: Loparev commented@monstrfolk, I tried your patch, but it doesn't work. Because of default parameter here
Drupal.ajax_facets.sendAjaxQuery = function ($this, pushStateNeeded, $boundToSubmitOverride = false) {
My browser is Chrome 45.0.2454.85 (64-bit)
Comment #16
monstrfolk CreditAttribution: monstrfolk commentedOk. Thanks.
Removed the default parameter. This patch is based from the small correction patch.
Seems this is an issue with
ES2015 Spec: default value parameter initializers
http://www.ecma-international.org/ecma-262/6.0/#sec-functiondeclarationi...
Comment #17
Loparev CreditAttribution: Loparev commentedIt is easier to review patches with interdiff
I'll try it tomorrow.
Thanks. I really want to see this feature in ajax_facets too)
Comment #18
Loparev CreditAttribution: Loparev commentedHi, @monstrfolk.
I found 2 critical issues in your patch:
1. When you chose some facet values and then click on submit link - everything behave as expected. But if I click on browser's back button then nothing happens (history API integration is broken).
2. When you click on some facet values then quantity of results for each facet should be changed.
I can try to help you with this issues but I can't tell exactly when. Maybe on this weekend.
Comment #19
Loparev CreditAttribution: Loparev commentedI think 2nd one should be optional. Maybe with data-attribute in link on somehow else
Comment #20
monstrfolk CreditAttribution: monstrfolk commented#2. choose option on a filter, call/response from server, choose option on a filter, call/response from server....so on and so on.
That is the default functionality without the page reload that already exists with this module. It seems to me implementing #2 defeats the purpose of this patch.
Comment #21
monstrfolk CreditAttribution: monstrfolk commented@Loparev,
I believe the history issue is resolved.
Another issue is the limit to one selection for a facet. The property limit_active_items is attached to each facet object so this is possible. Each selector type that allows more than on input before refresh needs to be modified. ie..checkbox and select list
Comment #22
Loparev CreditAttribution: Loparev commentedYou are right about "call/response from server....so on and so on". But let's consider an example: search view shows 3 cars. Each car has a color. 2 red cars and 1 blue car. We have facet by colors. So it has options: 1. Checkbox: red (2). 2. Checkbox blue (1). If user select both options and click on submit all link then he/she will get 0 result. Because there is no car with red AND blue color. It may be a little bit confusing for users. That why I suppose that results number should be updated after each click on facet option. It's a goal of facet search in general. So in this example after clicking on 1st checkbox 2nd should be updated and should looks like "blue (0)".
Yes, your new patch fixes the issue. But there was one more issue - broken "Reset all link" because of a typo. Here is a patch with corrections and improvements.
I have defined 2nd parameter of
sendAjaxQuery
as object with options. It has sense if we have more than one option for this function. And fixed broken "reset all" link.Comment #23
monstrfolk CreditAttribution: monstrfolk commentedIf the facet is configured in the display settings to use AND operator and not OR operator.
USE CASE: 3 total cars, 1 is blue, 2 are red
AND case (your example)
[x] blue [x] red - 0 results.
[x] blue [ ] red - 1 result.
[ ] blue [x] red - 2 results.
OR case
[x] blue [x] red - 3 results
[x] blue [ ] red - 1 result
[ ] blue [x] red - 2 results
The reason I wanted the apply button functionality was to reduce unneeded network requests. Updating counts creates a request for every option chosen. Getting zero results back on a facet configured with an AND operator makes sense to a user if the user understands that the facet is operating as such.
A facet configured using an OR operator can also be confusing (getting 3 results back when choosing red and blue, and none of the cars are both colors) if the user does not understand the behavior the particular facet.
My opinion is that all the confusion for the user can be eliminated by how the facet is presented with UI design and context.
Thanks for cleaning up the patch.
Any thoughts on the limit_active_items issue?
Comment #24
Loparev CreditAttribution: Loparev commentedAgree.
Need to think about it. I hope @eugene.ilyin can help us.
Comment #25
monstrfolk CreditAttribution: monstrfolk commentedAnyone thought about the limit_active_items issue?
Fixing that issue and this patch could be ready for commit.
Comment #26
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedI will work on it on the next week
Comment #27
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedI've dived into this issue pretty deep and I have my own vision how it should be. I'll do some refactoring also. I hope that it can be done until the end of the August.
Comment #29
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedPartially done. I'll check #23 soon
Comment #30
monstrfolk CreditAttribution: monstrfolk commentedAwesome
Comment #31
monstrfolk CreditAttribution: monstrfolk commentedI see this in the commit.
+Mode of updating by demand - disabled by default.
+If you will put blocks of the ajax facets and block with ajax facets buttons on the page with search results,
+the facets will be updated right after any filtering. But search results will be updated only after
+ the click on the button "Submit all facets".
There should be some type of mode selector for the user to choose if the facets are updated after every facet option selected or not.
The apply button functionality is a great way to reduce unneeded network requests. Updating counts creates a request for every option chosen which about nullifies the apply button's functionality. It does reduce the amount of data received when selecting a facet, but the bulk of the wait time is not data transmission. It is the requesting, opening, and closing of connections.
Comment #32
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commented@monstrfolk, yes I agree with you. But ajax facets (I mean facets, not the list of the results) should be updated each time when you use any ajax facet filter. Otherwise use exposed filters.
Comment #33
eugene.ilyin CreditAttribution: eugene.ilyin as a volunteer and at DrupalJedi commentedAs I understand, in my solution the trouble with limit_active_items is not actual.
Comment #35
monstrfolk CreditAttribution: monstrfolk commentedI have to reopen this issue. There needs to be an option to disable updating the facets after each facet selection. The current solution does not for for areas with limited bandwidth. The site I use this module for is accessed in remote regions of the world and updating the facets after every selection makes it completely unusable for many visitors of the site.
I believe the best course of action is to add a new option in the ajax facets configuration that allows the facet selection update to be disabled (comment #31).
@eugene.ilyin, can we get an option in this module to disable auto facet update after each selection? I can code it if needed.
Comment #36
monstrfolk CreditAttribution: monstrfolk commentedSee https://www.drupal.org/node/2844412.
Comment #37
alexp999 CreditAttribution: alexp999 commentedThis has caused a regression in functionality for me, I'm having to roll back to 7.x-3.5 for now:
https://www.drupal.org/node/2848888