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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Loparev created an issue. See original summary.

Loparev’s picture

Assigned: Loparev » Unassigned
Category: Feature request » Support request
eugene.ilyin’s picture

Status: Active » Postponed

It doesn't looks very important. I don't think that I'll implement it for 7.x

monstrfolk’s picture

From 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?

eugene.ilyin’s picture

I'll check it, but in first vision your patch looks pretty big for such simple improvement.

Loparev’s picture

Yes. Please, move patch here

monstrfolk’s picture

I 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.

monstrfolk’s picture

FileSize
9.79 KB

Patched moved.

Loparev’s picture

@monstrfolk, I told about this redundant spaces

Loparev’s picture

I'll try your patch as soon as possible.

Loparev’s picture

Status: Postponed » Needs review
eugene.ilyin’s picture

Status: Needs review » Needs work

I 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?

monstrfolk’s picture

Having 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.

monstrfolk’s picture

If 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.

Loparev’s picture

@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)

monstrfolk’s picture

FileSize
9.78 KB

Ok. 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...

Loparev’s picture

It is easier to review patches with interdiff

I'll try it tomorrow.

Thanks. I really want to see this feature in ajax_facets too)

Loparev’s picture

Hi, @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.

Loparev’s picture

I think 2nd one should be optional. Maybe with data-attribute in link on somehow else

monstrfolk’s picture

#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.

monstrfolk’s picture

FileSize
9.52 KB
1.46 KB

@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

Loparev’s picture

You 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.

monstrfolk’s picture

If 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?

Loparev’s picture

My opinion is that all the confusion for the user can be eliminated by how the facet is presented with UI design and context.

Agree.

Any thoughts on the limit_active_items issue?

Need to think about it. I hope @eugene.ilyin can help us.

monstrfolk’s picture

Anyone thought about the limit_active_items issue?

Fixing that issue and this patch could be ready for commit.

eugene.ilyin’s picture

I will work on it on the next week

eugene.ilyin’s picture

I'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.

  • eugene.ilyin committed 34d15bc on 7.x-3.x
    Issue #2700063 by monstrfolk, Loparev, eugene.ilyin: Add "Apply" button...
  • eugene.ilyin committed c925542 on 7.x-3.x
    Issue #2700063 by monstrfolk, Loparev, eugene.ilyin: Add "Apply" button...
eugene.ilyin’s picture

Partially done. I'll check #23 soon

monstrfolk’s picture

Awesome

monstrfolk’s picture

I 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.

eugene.ilyin’s picture

@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.

eugene.ilyin’s picture

Status: Needs work » Fixed

As I understand, in my solution the trouble with limit_active_items is not actual.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

monstrfolk’s picture

I 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.

monstrfolk’s picture

alexp999’s picture

This 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