From: Sven Schöling Date: Wed, 10 Jul 2013 11:45:56 +0000 (+0200) Subject: Bei tab und enter den ersten full match benutzen. nur wenn der nicht eindeutig ist... X-Git-Tag: release-3.1.0beta1~184 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=eff6af2885966e0bbe4b614ef03525012cff92aa;p=kivitendo-erp.git Bei tab und enter den ersten full match benutzen. nur wenn der nicht eindeutig ist resetten oder popup öffnen --- diff --git a/SL/Controller/Part.pm b/SL/Controller/Part.pm index 346a5446d..f0ad1ca9a 100644 --- a/SL/Controller/Part.pm +++ b/SL/Controller/Part.pm @@ -51,6 +51,18 @@ sub action_ajax_autocomplete { $self->{parts} = SL::DB::Manager::Part->get_all(query => [ @filter ], limit => $limit); $self->{value} = $::form->{column} || 'description'; + # if someone types something, and hits enter, assume he entered the full name. + # if something matches, treat that as sole match + if ($::form->{prefer_exact}) { + for my $part (@{ $self->{parts} }) { + if ( lc $part->description eq lc $::form->{term} + || lc $part->partnumber eq lc $::form->{term}) { + $self->{parts} = [ $part ]; + last; + } + } + } + $self->render('part/ajax_autocomplete', { layout => 0, type => 'json' }); } diff --git a/js/autocomplete_part.js b/js/autocomplete_part.js index 61280fd93..90e4312f0 100644 --- a/js/autocomplete_part.js +++ b/js/autocomplete_part.js @@ -115,7 +115,7 @@ namespace('kivi', function(k){ $.ajax({ url: 'controller.pl?action=Part/ajax_autocomplete', dataType: "json", - data: ajax_data($dummy.val()), + data: $.extend( ajax_data($dummy.val()), { prefer_exact: 1 } ), success: function (data){ if (data.length == 1) { set_item(data[0]);