Only show "CLEAR FILTERS" link on the filters bar when there are filters to clear

XMLWordPrintable

    • COmanage UI 3 Marathon

      The "CLEAR FILTERS" link will appear on the filter bar when a sort has been requested but no active filters are in place.

      In app/View/Elements/search.ctp we have:

      <?php if(!empty($search_params)):?>
      

      but $search_params contains the sort information as well as the search fields. So, when there are no search fields to display, but a sort exists, this will not be empty. Therefore we need a further test around the "CLEAR FILTERS" link.

      We can add a “hasFilters” variable that is false, and set it to true after we’ve bypassed the continue statement (approx. lines 69-71):

      if(!in_array($key, $search_fields)) {
        continue;
      }
      

      Then we can just wrap the #top-search-clear-all-button block with a conditional to only show if hasFilters is true.

            Assignee:
            Arlen Johnson
            Reporter:
            Arlen Johnson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: