Comments

30equals’s picture

Status: Active » Needs review
StatusFileSize
new990 bytes

I added a patch which basicly swithces the key and values of the options array when the facet is active. There's probably a more elegant way to do this. But now because i switch keys and values and reverse the array, the default is not actually been forced, but falls back to the first option still, but that's the option of the chosen facet now. so you need to select the default first label to reset it.

Hope this makes sense.

finex’s picture

Maybe if a value is selected, the label "--Choose--" should be changed to something like "--View All--". This could help the user to understand the UI. What do you think?

rp7’s picture

Attached patch is another way to do it.

rp7’s picture

Exploratus’s picture

Tried #4, got

Notice: Undefined index: default_value in facetapi_select_facet_form() (line 10 of /******/facetapi_select/facetapi_select.module).
Notice: Undefined index: default_value in facetapi_select_facet_form() (line 11 of /******/facetapi_select/facetapi_select.module).

Exploratus’s picture

Also, when I go back to no selection, it sends me to the homepage...

Exploratus’s picture

Applied #1 and that worked beautifully. Also changed the text from Choose to view all as suggested by #2. Works perfectly! Thanks!

jody lynn’s picture

jody lynn’s picture

I think the approach in comment 4 is cleaner, but it needs work to resolve the issues in comments 5 (easy) and 6.

jody lynn’s picture

Status: Needs review » Needs work
khiminrm’s picture

Hi, everyone! I've found this issue and want to share my idea. In one of my projects I need this feature https://drupal.org/node/2284099 and also to show default element for reseting facets. I've written the code in case when facetapi_pretty_paths installed.

khiminrm’s picture

I think my patch from #11 is usefull after applying patch from issue https://drupal.org/node/2283201, when active element is shown.

alcroito’s picture

Hi.

I'm attaching a patch that rewrites the code pretty heavily to allow:
- Customizable reset label with a reset link for the current facet only
- Option to pre-select active facet. (this was inspired and incorporated from https://drupal.org/node/2283201 , thanks mparker17)

In conjunction with the facet api patch here https://drupal.org/node/1393928 , you can create for example 3 select field facets, you can only choose one value from each, and easily reset one of the values chosen.

alcroito’s picture

Status: Needs work » Needs review
mparker17’s picture

@Placinta's patch in #13 includes the functionality of #2283201: Provide an option to pre-select the active facet, which I've closed as a duplicate of this patch.

mparker17’s picture

The patch works great for me.

The code looks good, except for two coding-standards problems:

  1. +++ b/facetapi_select.module
    @@ -54,36 +59,84 @@ class FacetapiSelectDropdowns extends FacetapiWidgetLinks {
    +      $select_options[$url] = $item['#markup'].' ('.$item['#count'].')';
    

    Always use a space between the dot and the concatenated parts to improve readability.

  2. +++ b/facetapi_select.module
    @@ -54,36 +59,84 @@ class FacetapiSelectDropdowns extends FacetapiWidgetLinks {
    +        // Store the key of the active facet and the reset url that is attached to it.
    ...
    +    // The reset URL that needs to be clicked to remove the currently active facet value.
    ...
    +    // Otherwise add reset label and set the active item as the default option, if the settings flag was set.
    ...
    +      // The actual active facet will have the reset url, we need to change it to be the current URL instead.
    ...
    +      // First we get the active item label, then we ask for the current URL and query params.
    +      // Finally we append it to the new options array, which makes it appear directly after the reset label, and before the rest of the items.
    ...
    +      // Remove the old active facet item from the select options, which is keyed by the reset URL.
    

    All comments should wrap at 80 characters.

... once these have been fixed, I'd say the patch in #13 is RTBC!

alcroito’s picture

StatusFileSize
new8.3 KB
new4.23 KB

Installed coder module, and fixed all the warnings that it gave me.
Attaching updated patch and inter diff.

mparker17’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me! @Placinta, thanks for all your help and hard work!

ssoulless’s picture

it works!

alcroito’s picture

StatusFileSize
new8.52 KB
new1.96 KB

Attaching an updated patch and interdiff, which adds the #states FAPI key, to make the Facet API select settings appear only when it is the active widget chosen. Without this change, if any other widget was selected as active, the Facet API select settings were still shown.

ssoulless’s picture

Status: Reviewed & tested by the community » Needs review
rooby’s picture

Is this related to #2336857: Unable to de-select a value?
Possible duplicate?

I'm going based on just the original post of both issues so I could be way off.

pamelad’s picture

Status: Needs review » Reviewed & tested by the community

The patch in #20 works for me, and the change makes sense.

sagesolutions’s picture

The patch #20 also worked for me! Thanks a bunch!

dagomar’s picture

Status: Reviewed & tested by the community » Needs work

This does not work as I would expect.

When the facet is not active I have an 'Display all' option (which I added under Default Option Label)

When I choose a facet the 'Display all' is missing. Is my configuration amiss?

dagomar’s picture

Ok - I got it working with some additional configuration. Apparently you have to choose OR for this to work. I didn't want that, I want that it just displays the one that you chose, I think it should work that way, but now the options get filtered out.

EDIT

Oh my gosh how confusing. I think I got it working the way I want it, by selecting OR but 'Limit to one active item' checked. Not sure if this patch should take into account different ways of enabling this option.

grndlvl’s picture

StatusFileSize
new7.83 KB

Re-roll against 7.x-1.x.

Still testing and going over logic before committing.

thierrydallacroce’s picture

StatusFileSize
new7.78 KB

#27 failed to patch on 2 out of 3 hunks, so attempting to remedy to it with the attached patch #28. Let me know if that applies and works as intended.

thierrydallacroce’s picture

StatusFileSize
new7.78 KB

#29 replaces #28 by addressing a coding standard issue on one line.

dagomar’s picture

Patch #29 works for me.

grndlvl’s picture

Status: Needs work » Closed (duplicate)

I realized a lot of work has happened here, but I believe another ticket that resolves this better, which also has had a lot of work, resolves this issue nicely. #2336857: Unable to de-select a value

With that I am actually going to mark this one as a dupe.