summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/filtered_search
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2017-01-28 11:25:15 -0600
committerMike Greiling <mike@pixelcog.com>2017-01-28 11:25:15 -0600
commitc454dec170da32fc83b8d78c61c3f452c819f0ed (patch)
treedf05c491f06e845a0e8266afcb23962e95160a4a /app/assets/javascripts/filtered_search
parenta5f7934420e1d26682700e02aa8fc9333e808f47 (diff)
parentb78d06b78143b16dccc5d5afaa8796473b68bea1 (diff)
downloadgitlab-ce-c454dec170da32fc83b8d78c61c3f452c819f0ed.tar.gz
Merge branch 'master' into go-go-gadget-webpack
* master: (33 commits) Improved code style on the issue_sidebar_spec.rb add CHAGELOG.md entry for !8831 remove assets:compile step from relative_url docs update scripts and docs to reference the newly namespaced rake task namespace assets rake tasks to gitlab:assets:* correct gzip files if they exist as well automatically correct CSS urls on assets:precompile remove hard-coded assets path for ace editor modules Fixed cancel button in the services form not redirecting back to the integrations settings view Fix search bar search param encoding Fix a transient failure in the `Explore::ProjectsController` spec Fix filtering with multiple words Fix project name label's for reference in project settings Fixed merge request tabs extra margin Don't call `#uniq` on a relation Move Gitlab::Shell and Gitlab::ShellAdapter files to lib/ Move ApplicationSetting DEFAULTS to `.defaults` instead Move a begin/rescue clause to ApplicationSetting.expire Use badge partial as single source of truth instead of having 2 partials doing the same Changes after review ...
Diffstat (limited to 'app/assets/javascripts/filtered_search')
-rw-r--r--app/assets/javascripts/filtered_search/dropdown_utils.js.es610
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_manager.js.es63
2 files changed, 10 insertions, 3 deletions
diff --git a/app/assets/javascripts/filtered_search/dropdown_utils.js.es6 b/app/assets/javascripts/filtered_search/dropdown_utils.js.es6
index eeab10fba17..de3fa116717 100644
--- a/app/assets/javascripts/filtered_search/dropdown_utils.js.es6
+++ b/app/assets/javascripts/filtered_search/dropdown_utils.js.es6
@@ -28,7 +28,12 @@
if (lastToken !== searchToken) {
const title = updatedItem.title.toLowerCase();
let value = lastToken.value.toLowerCase();
- value = value.replace(/"(.*?)"/g, str => str.slice(1).slice(0, -1));
+
+ // Removes the first character if it is a quotation so that we can search
+ // with multiple words
+ if ((value[0] === '"' || value[0] === '\'') && title.indexOf(' ') !== -1) {
+ value = value.slice(1);
+ }
// Eg. filterSymbol = ~ for labels
const matchWithoutSymbol = lastToken.symbol === filterSymbol && title.indexOf(value) !== -1;
@@ -83,8 +88,9 @@
const selectionStart = input.selectionStart;
let inputValue = input.value;
// Replace all spaces inside quote marks with underscores
+ // (will continue to match entire string until an end quote is found if any)
// This helps with matching the beginning & end of a token:key
- inputValue = inputValue.replace(/("(.*?)"|:\s+)/g, str => str.replace(/\s/g, '_'));
+ inputValue = inputValue.replace(/(('[^']*'{0,1})|("[^"]*"{0,1})|:\s+)/g, str => str.replace(/\s/g, '_'));
// Get the right position for the word selected
// Regex matches first space
diff --git a/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
index 8d62324b79f..029564ffc61 100644
--- a/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
+++ b/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
@@ -196,7 +196,8 @@
});
if (searchToken) {
- paths.push(`search=${encodeURIComponent(searchToken)}`);
+ const sanitized = searchToken.split(' ').map(t => encodeURIComponent(t)).join('+');
+ paths.push(`search=${sanitized}`);
}
Turbolinks.visit(`?scope=all&utf8=✓&${paths.join('&')}`);