Problem/Motivation

I need to move the 'Reset filters' button in Summary Block to the end of all the processors in the block. I attempted to rearrange via the UI, but I don't believe it is possible at this time, although I certainly could have missed something while configuring. No matter what I did, the applied filters would appear below them. Is there a way to do this currently?

Right now, my solution consists of an ugly preprocess hook that targets the processor by title 'Reset filters'. This is far from ideal as we now rely on the configurable title field, so maybe there is at least a better way to do it than that?

Proposed resolution

Ideally there would be a way to reorder the button through the UI and export, like a weight field or similar.

Remaining tasks

TBD

User interface changes

TBD

Comments

trwill created an issue. See original summary.

trwill’s picture

Issue summary: View changes
trwill’s picture

Issue summary: View changes
borisson_’s picture

Title: How to move 'reset button' to end of summary block? » Allow the reset button to be either above or below the rest of the results.
Category: Support request » Feature request

There is currently no option to do this. I assume that it would be a good idea to make this configurable though.

ilya.no’s picture

Status: Active » Needs review
StatusFileSize
new3.23 KB

Attaching initial patch with update.

andypost’s picture

Version: 8.x-1.4 » 8.x-1.x-dev

Nice approach! Meantime I think the option should be string instead of int (more readable for config interdiffs)

ilya.no’s picture

StatusFileSize
new7.58 KB
new5.29 KB

Thanks for the tip! Attaching new patch and interdiff.

andypost’s picture

Now it needs post_update hook to set default value to existing config

andypost’s picture

Status: Needs review » Needs work

NW for that

antonnavi’s picture

Status: Needs work » Needs review
StatusFileSize
new8.76 KB
new1.04 KB

Hi, all here!

post_update hook was added.

andypost’s picture

Status: Needs review » Needs work
+++ b/modules/facets_summary/facets_summary.post_update.php
@@ -0,0 +1,29 @@
+  $facets_summaries = \Drupal::entityTypeManager()->getStorage('facets_summary')->loadMultiple();
+  foreach ($facets_summaries as $facets_summary) {

Please use ConfigEntityUpdater for this kind of upgrades, see https://git.drupalcode.org/project/drupal/blob/8.8.x/core/modules/views/...

antonnavi’s picture

StatusFileSize
new8.83 KB
new1.11 KB

Usage of ConfigEntityUpdater was added.

antonnavi’s picture

Status: Needs work » Needs review
capysara’s picture

StatusFileSize
new62.37 KB

Patch applies cleanly to 1.4 and works great!

* /admin/config/search/facets/facet-summary/[my_facets_summary]/edit
* Under the reset facets link settings there's a new dropdown for Position (see screenshot). I tested all three options Show reset link before facets link (default), Show reset link after facets link, and Show only reset link.

Thanks!

joao.ramos.costa’s picture

Rerolled against 2.x

baluertl’s picture

Title: Allow the reset button to be either above or below the rest of the results. » Allow the reset button to be either above or below the rest of the results
mkalkbrenner’s picture

Version: 8.x-1.x-dev » 2.0.x-dev
Status: Needs review » Needs work
  1. +++ b/modules/facets_summary/facets_summary.post_update.php
    @@ -0,0 +1,32 @@
    +function facets_summary_post_update_set_reset_facets_position(&$sandbox = NULL) {
    

    Since a proper default value is provided, I assume that this post update is not needed.

    If it is needed an update hook should be used instead to modify the configs.

  2. +++ b/modules/facets_summary/src/Plugin/facets_summary/processor/ResetFacetsProcessor.php
    @@ -23,6 +23,21 @@ use Drupal\facets_summary\Processor\ProcessorPluginBase;
    +   * Indicates, that reset link should be positioned after facet links.
    

    Comment is wrong.

joao.ramos.costa’s picture

Hi @mkalkbrenner, thanks for the review. Comment is fixed and update hook is added instead of post_update.

joao.ramos.costa’s picture

Status: Needs work » Needs review

mkalkbrenner’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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