use List::MoreUtils qw(uniq);
use SL::MoreCommon qw(listify);
use Data::Dumper;
+use Text::ParseWords;
my %filters = (
date => sub { DateTime->from_lxoffice($_[0]) },
if ($key =~ s/:multi//) {
my @multi;
my $orig_key = $key;
- for my $value (split / /, $value) {
+ for my $value (parse_line('\s+', 0, $value)) {
($key, $value) = _apply_all($key, $value, qr/\b:(\w+)/, { %filters, %{ $params{filters} || {} } });
($key, $value) = _apply_all($key, $value, qr/\b::(\w+)/, { %methods, %{ $params{methods} || {} } });
($key, $value) = _dispatch_custom_filters($params{class}, $with_objects, $key, $value) if $params{class};
my $obj_prefix = join '.', @tokens, '';
if ($manager->can('filter')) {
- ($key, $value, my $obj) = $manager->filter($last_token, $value, $obj_prefix);
+ ($key, $value, my $obj) = $manager->filter($last_token, $value, $obj_prefix, $obj_path);
_add_uniq($with_objects, $obj) if $obj;
} else {
_add_uniq($with_objects, $obj_path) if $obj_path;
A search filter will usually search for things in relations of the actual
search target. A search for sales orders may be filtered by the name of the
-customer. L<Rose::DB::Object> alloes you to search for these by filtering them prefixed with their table:
+customer. L<Rose::DB::Object> allows you to search for these by filtering them prefixed with their table:
query => [
'customer.name' => 'John Doe',
'orddate' => [ lt => DateTime->today ],
]
-Unfortunately, if you specify them in you form as these strings, the form
+Unfortunately, if you specify them in your form as these strings, the form
parser will convert them into nested structures like this:
$::form = bless {
[% L.select_tag('filter.salesman.id', ...) %]
-Additionally you can add modifier to the name to set a certain method:
+Additionally you can add a modifier to the name to set a certain method:
[% L.input_tag('filter.department.description:substr::ilike', ...) %]
=head1 LAUNDERING
Unfortunately Template cannot parse the postfixes if you want to
-rerender the filter. For this reason all colons filter keys are by
+rerender the filter. For this reason all colon filter keys are by
default laundered into underscores, so you can use them like this:
[% L.input_tag('filter.price:number::lt', filter.price_number__lt) %]
All of your original entries will stay intact. If you don't want this to
happen pass C<< no_launder => 1 >> as a parameter. Additionally you can pass a
different target for the laundered values with the C<launder_to> parameter. It
-takes an hashref and will deep copy all values in your filter to the target. So
+takes a hashref and will deep copy all values in your filter to the target. So
if you have a filter that looks like this:
$filter = {
]
]
-For more abuot custom filters, see L<SL::DB::Helper::Filtered>.
+For more about custom filters, see L<SL::DB::Helper::Filtered>.
=head1 FILTERS (leading with :)
L.input_tag('customer.name:substr::ilike', ...)
L.input_tag('invoice.customer.name:substr::ilike', ...)
-This will sarch for orders whose invoice has the _same_ customer, which matches
+This will search for orders whose invoice has the _same_ customer, which matches
both inputs. This is because tables are aliased by their name and not by their
position in with_objects.
=item *
-Additional filters shoud be pluggable.
+Additional filters should be pluggable.
=back