Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filters - New Functionality - Set Filter - Custom Pill Blade #1107

Closed

Conversation

lrljoe
Copy link
Collaborator

@lrljoe lrljoe commented Mar 17, 2023

This is an initial PR just to test appetite from @rappasoft and others (before I start writing tests/docs)

The intention is to provide the ability for Custom Pills Blades for Filters, for a couple of reasons:

  1. To enhance the capability (particularly with Multi-Select or future Filters) to interact with the data more cleanly (removing individual items for example), rather than having to clear a filter completely.

  2. To allow for customisation of look/feel of Pills on a per-filter basis, without the need to publish the main views, removing some of the issues that crop up due to older published views.

This adds the following new methods:

#Added to Views\Traits\FilterHelpers
##hasCustomPillBlade
Determines whether the filter has a custom blade for the pills

  /**
   * Determine if filter has a Custom Pill Blade
   *
   * @return bool
   */
  public function hasCustomPillBlade(): bool
  {
      return $this->filterCustomPillBlade != null;
  }

##getCustomPillBlade
Retrieves the path for any custom pill blade

/**
 * Get the path to the Custom Pill Blade
 *
 * @return string|null
 */
public function getCustomPillBlade(): ?string
{
    return $this->filterCustomPillBlade ?? null;
}

#Added To Views\Traits\FilterConfiguration

/**
 * @param string $blade
 *
 * @return $this
 */
public function setFilterPillBlade(string $blade): self
{
    $this->filterCustomPillBlade = $blade;

    return $this;
}

#Added parameter to Views\Filter

    protected ?string $filterCustomPillBlade = null;

#filter-pills.blade updated to check (after the checks for applied/null/hidden pills)

@foreach ($component->getAppliedFiltersWithValues() as $filterSelectName => $value)
    @php
        $filter = $component->getFilterByKey($filterSelectName);
    @endphp

    @continue(is_null($filter))
    @continue($filter->isHiddenFromPills())

    @if ($filter->hasCustomPillBlade())
        @include($filter->getCustomPillBlade(), ['filter' => $filter])
    @else
        // Standard Code Here
    @endif
@endforeach

Initial tests are showing that this works quite smoothly, and doesn't appear to impact performance, although I've not yet scaled it up properly.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests and did you add any new tests needed for your feature?
  2. Did you update all templates (if applicable)?
  3. Did you add the relevant documentation (if applicable)?
  4. Did you test locally to make sure your feature works as intended?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@lrljoe lrljoe changed the title Set Filter - Custom Pill Blade Filters - New Functionality - Set Filter - Custom Pill Blade Mar 20, 2023
@lrljoe
Copy link
Collaborator Author

lrljoe commented Mar 20, 2023

See #1111

@lrljoe lrljoe closed this Mar 20, 2023
@rappasoft rappasoft mentioned this pull request Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant