Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi @rappasoft
this PR will add a new way to generate filter pills fallback value:
at this time a filter pill label is computed as follow, using the first non-empty value:
column
value as the filterkey
and uses itsText
ucwords(strtr($key, ['_' => ' ', '-' => ' ']))
with this implementation a new step is inserted between 2 and 3:
column
value as the filterkey
and uses itsText
name
propertyucwords(strtr($key, ['_' => ' ', '-' => ' ']))
This way, if a filter is defined using a key that doesn't match a column name, the filter label is used for its pill value
eg. a filter is defined like this one:
there is not a matching column, the pill will be rendered as
Filter Breed
instead ofBreed Id
(that is meaningless for the end user)Implementation
filter-pills.blade.php
templates in order to use the filter name before falling back to its keyIMPORTANT
As in filter tests now the actual Livewire render method is called, in tests workflows with prefer-stable options some issues come up because lowest versions of Laravel don't support
->has()
and->class()
methods inComponentAttributeBag
.This could cause errors on projects that use older versions of Laravel. I fixed this by replacing these calls with the old methods. Let me know what do you think about it.
notes
this implementation is backward compatible, when views are published they will keep using the old fallback method instead of the filter label
I added tests for filters, which I've seen are missing: