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

Add Custom FIlter Input Attributes, Cleanup Filter Tests #2131

Merged

Conversation

lrljoe
Copy link
Collaborator

@lrljoe lrljoe commented Dec 24, 2024

Key changes:

Addition of setInputAttributes

Allows for customising the attributes that will apply to the input field for the filter.

Not all Filters are supported in this PR, this is an interim PR to allow testing.

By default, this replaces the default classes on the Filter Input, if you would like to keep them, set the default-styling and/or default-colors flags to true.

TextFilter Example

The following would:

  • Set a maxlength of 75
  • Set a placeholder of "Enter a Name"
  • Replace the default colors
  • Retain the default styling (e.g. rounding/shadow)
public function filters(): array
{
    return [
        TextFilter::make('Name')
        ->setInputAttributes([
            'maxlength' => '75',
            'placeholder' => 'Enter a Name',
            'class' => 'text-white bg-red-500 dark:bg-red-500',
            'default-colors' => false,
            'default-styling' => true,
        ]),
    ];
}

NumberFilter Example

The following would:

  • Set a min of 5
  • Set a max of 20
  • Set steps to be 0.5
  • Keep the default colors & styling
public function filters(): array
{
    return [
        NumberFilter::make('Age')
        ->setInputAttributes([
            'min' => '5',
            'max' => '20',
            'step' => '0.5',
            'default-colors' => true,
            'default-styling' => true,
        ]),
    ];
}

Tests

  • Add several FilterVisualsTests
  • Migrate all FilterTests to use base FilterTest class
  • Add Groups to several tests to smooth testing

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?

Copy link

codecov bot commented Dec 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.67%. Comparing base (493959c) to head (1372c46).
Report is 1 commits behind head on development.

Additional details and impacted files
@@                Coverage Diff                @@
##             development    #2131      +/-   ##
=================================================
+ Coverage          90.51%   90.67%   +0.15%     
- Complexity          1945     1966      +21     
=================================================
  Files                201      203       +2     
  Lines               4388     4463      +75     
=================================================
+ Hits                3972     4047      +75     
  Misses               416      416              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lrljoe lrljoe merged commit 4bb6b3d into rappasoft:development Dec 24, 2024
11 checks passed
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.

[Feature Request]: Allow for any attribute to be added to the config of filters
1 participant