doefom / currency-fieldtype

A Statamic addon that provides a currency fieldtype.
1 stars 2 forks source link

[1.x] Feature: List view filtering for Currency fieldtype #12

Closed caseydwyer closed 6 months ago

caseydwyer commented 6 months ago

As of v1.2.3, the Currency fieldtype doesn't override the filter method available via Statamic's Fieldtype class. Instead, it's using the default, which is just a standard filter intended for simple text comparisons/queries. That doesn't play nicely with the numeric values returned by the Currency fieldtype. Here's what that currently looks like, on a collection's list view in the CP:

Before

currency-before

This PR introduces a new, custom filter that's specific to the Currency fieldtype, but inherits the majority of its functionality from Statamic's underlying number filter. That filter has all the basic nuts and bolts needed for numeric filtering—we just add a small check on top of the apply method, to account for subunit storage by updating the searched value, if/when it's enabled. Here's how things look, with this update applied:

After

currency-after

Let me know if we need to tweak anything else, here—hope you're having a great week, Dominik!

doefom commented 6 months ago

That's so cool, @caseydwyer! Thanks for contributing to this fieldtype that much, appreciate it!

caseydwyer commented 6 months ago

@doefom no problem, appreciate the package and thanks for the quick merge, here! 👏