Revision 954eb9c0
Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt
SL/Controller/Project.pm | ||
---|---|---|
100 | 100 |
|
101 | 101 |
# if someone types something, and hits enter, assume he entered the full name. |
102 | 102 |
# if something matches, treat that as the sole match |
103 |
# unfortunately get_models can't do more than one per package atm, so we do it
|
|
104 |
# the oldfashioned way.
|
|
103 |
# since we need a second get models instance with different filters for that,
|
|
104 |
# we only modify the original filter temporarily in place
|
|
105 | 105 |
if ($::form->{prefer_exact}) { |
106 |
local $::form->{filter}{'all::ilike'} = delete local $::form->{filter}{'all:substr:multi::ilike'}; |
|
107 |
# active and valid filters are use as they are |
|
108 |
|
|
109 |
my $exact_models = SL::Controller::Helper::GetModels->new( |
|
110 |
controller => $self, |
|
111 |
sorted => 0, |
|
112 |
paginated => { per_page => 2 }, |
|
113 |
with_objects => [ 'customer', 'project_status', 'project_type' ], |
|
114 |
); |
|
106 | 115 |
my $exact_matches; |
107 |
if (1 == scalar @{ $exact_matches = SL::DB::Manager::Project->get_all( |
|
108 |
query => [ |
|
109 |
valid => 1, |
|
110 |
or => [ |
|
111 |
description => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, |
|
112 |
projectnumber => { ilike => $::form->{filter}{'all:substr:multi::ilike'} }, |
|
113 |
] |
|
114 |
], |
|
115 |
limit => 2, |
|
116 |
) }) { |
|
117 |
$self->projects($exact_matches); |
|
116 |
if (1 == scalar @{ $exact_matches = $exact_models->get }) { |
|
117 |
$self->project($exact_matches); |
|
118 | 118 |
} |
119 | 119 |
} |
120 | 120 |
|
Auch abrufbar als: Unified diff
Projekt-Picker: exact match auf GetModels umgestellt