[Rt-commit] rt branch, 4.2/numbers-in-ticket-autocomplete-search, created. rt-4.2.16-2-g95867dc1b5
? sunnavy
sunnavy at bestpractical.com
Thu Feb 6 10:15:21 EST 2020
The branch, 4.2/numbers-in-ticket-autocomplete-search has been created
at 95867dc1b5312311593c2f75859ad93c9222b6af (commit)
- Log -----------------------------------------------------------------
commit 95867dc1b5312311593c2f75859ad93c9222b6af
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Feb 6 22:37:47 2020 +0800
Remove search string including numbers in ticket autocomplete search on select
Previously we only removed non-integers, which is not enough as the
serch string could be something like "RT 5 alpha", in which case "5"
wouldn't be removed.
Search string starts with non-integers and lasts till the end, so we can
remove all the items after the first non-integer.
Note that integer stringification("var str = term + '';") was only for
the new value. Since now we add the new value a bit later, there is no
need to do it any more.
diff --git a/share/static/js/autocomplete.js b/share/static/js/autocomplete.js
index d5a8af6b27..0bed0037dc 100644
--- a/share/static/js/autocomplete.js
+++ b/share/static/js/autocomplete.js
@@ -46,14 +46,18 @@ window.RT.Autocomplete.bind = function(from) {
options.select = function(event, ui) {
var terms = this.value.split(what == 'Tickets' ? /\s+/ : /,\s*/);
terms.pop(); // remove current input
- terms.push( ui.item.value ); // add selected item
if ( what == 'Tickets' ) {
// remove non-integers in case subject search with spaces in (like "foo bar")
- terms = jQuery.grep(terms, function(term) {
- var str = term + ''; // stringify integers to call .match
- return str.match(/^\d+$/);
- } );
+ var new_terms = [];
+ for ( var i = 0; i < terms.length; i++ ) {
+ if ( terms[i].match(/\D/) ) {
+ break; // Items after the first non-integers are all parts of search string
+ }
+ new_terms.push(terms[i]);
+ }
+ terms = new_terms;
}
+ terms.push( ui.item.value ); // add selected item
terms.push(''); // add trailing delimeter so user can input another value directly
this.value = terms.join(what == 'Tickets' ? ' ' : ", ");
return false;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list