reachweb / statamic-livewire-filters

Other
11 stars 0 forks source link

Add Livewire component that can display the active filters as "pills" with option to remove #24

Closed afonic closed 6 months ago

de-raaf-media commented 6 months ago

You did it? Very nice. Gonna try it next week.

afonic commented 6 months ago

It's a first try but it seems to be working and all the tests pass! Lets see!

de-raaf-media commented 6 months ago

Should this already be in v1.6.0? I get an error:

Unable to find component: [lf-tags]

afonic commented 6 months ago

You should get v1.8.0, maybe you are kept back by the Statamic version?

de-raaf-media commented 6 months ago

Yeah, that seems to have been the issue. I do get an error now:

"Undefined array key 1" (statamic-livewire-filters/src/Http/Livewire/LfTags.php:75)

If I die and dump the value and key on that line is see the result:

"products" // vendor/reachweb/statamic-livewire-filters/src/Http/Livewire/LfTags.php:75
"as" // vendor/reachweb/statamic-livewire-filters/src/Http/Livewire/LfTags.php:75
afonic commented 6 months ago

I re-open this because it looks like a bug. It seems something gets passed as a parameter that shouldn't. Probably something like as="products" ?

Can you show me your livewire-collection tag and your LfTags tag?

de-raaf-media commented 6 months ago

Sure, here you go:

{{
  livewire-collection:products
  paginate="12" as="products"
  :blueprint:is="'product_variants_vaste-planten'"
}}

{{ livewire:lf-tags blueprint="products.product_variants_vaste-planten" fields="categorieen|bloemkleur" }}

Update: if I remove as="products" it works. Don't remember why I added this to the original collection query but I don't think I need this anymore.

Update 2: it does show tags that are not specified in fields (like groenblijvend en the blueprint): [

Scherm­afbeelding 2024-04-26 om 12 48 52

](url)

afonic commented 6 months ago

Yeah the as="products" is not really needed in the tag, I will add some filters for unsupported tags. The :blueprint:is="'product_variants_vaste-planten'" also needs to be fixed the same way.

It should display all the labels of the fields categorieen|bloemkleur correctly, do you mind sharing the filters you gave active?

de-raaf-media commented 6 months ago

Yeah it does show categorieen and bloemkleur so that's good. But it also shows groenblijvend which IS a working filter but is not a part of the fields specified in the lf-tags tag. So I would expect it to not show up as a tag.

afonic commented 6 months ago

Yeah you are right, I will fix this at my side.

Why are they all lowercase? If it was loading them correctly they should be Categorieen: Siergrassen it should take the display value of the field and the title of the tag or label of another field and fallback only if it cannot find them.

afonic commented 6 months ago

Try v1.8.1 when you have a chance.

de-raaf-media commented 6 months ago

Fixed! Nice! Also tags show in Title case now.

afonic commented 6 months ago

Good to hear!