From: Bernd Bleßmann Date: Thu, 14 Jan 2021 10:47:23 +0000 (+0100) Subject: Projekt-Picker: exact match auf GetModels umgestellt X-Git-Tag: kivitendo-mebil_0.1-0~9^2~516 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=954eb9c0ecad0e5acf697e39ea0ad1418bd7cca9;p=kivitendo-erp.git Projekt-Picker: exact match auf GetModels umgestellt --- diff --git a/SL/Controller/Project.pm b/SL/Controller/Project.pm index 80833b0a1..72f9bd4b2 100644 --- a/SL/Controller/Project.pm +++ b/SL/Controller/Project.pm @@ -100,21 +100,21 @@ sub action_ajax_autocomplete { # if someone types something, and hits enter, assume he entered the full name. # if something matches, treat that as the sole match - # unfortunately get_models can't do more than one per package atm, so we do it - # the oldfashioned way. + # since we need a second get models instance with different filters for that, + # we only modify the original filter temporarily in place if ($::form->{prefer_exact}) { + local $::form->{filter}{'all::ilike'} = delete local $::form->{filter}{'all:substr:multi::ilike'}; + # active and valid filters are use as they are + + my $exact_models = SL::Controller::Helper::GetModels->new( + controller => $self, + sorted => 0, + paginated => { per_page => 2 }, + with_objects => [ 'customer', 'project_status', 'project_type' ], + ); my $exact_matches; - if (1 == scalar @{ $exact_matches = SL::DB::Manager::Project->get_all( - query => [ - valid => 1, - or => [ - description => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, - projectnumber => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, - ] - ], - limit => 2, - ) }) { - $self->projects($exact_matches); + if (1 == scalar @{ $exact_matches = $exact_models->get }) { + $self->project($exact_matches); } }