[Rt-commit] rt branch, 4.6/numbers-in-ticket-autocomplete-search, created. rt-4.4.4-724-g65919abe99
? sunnavy
sunnavy at bestpractical.com
Thu Feb 6 10:03:59 EST 2020
The branch, 4.6/numbers-in-ticket-autocomplete-search has been created
at 65919abe99c8bcded1a3412c9ff810ecc66a9c6d (commit)
- Log -----------------------------------------------------------------
commit 65919abe99c8bcded1a3412c9ff810ecc66a9c6d
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 c4362edb16..af3486cfa3 100644
--- a/share/static/js/autocomplete.js
+++ b/share/static/js/autocomplete.js
@@ -62,14 +62,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' ? ' ' : ", ");
jQuery(this).change();
-----------------------------------------------------------------------
More information about the rt-commit
mailing list