Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
7b382af7
Commit
7b382af7
authored
Nov 08, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for quotations
parent
6b4358ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
5 deletions
+36
-5
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
...avascripts/filtered_search/filtered_search_manager.js.es6
+36
-5
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
View file @
7b382af7
...
@@ -68,7 +68,13 @@
...
@@ -68,7 +68,13 @@
if (match) {
if (match) {
const sanitizedKey = key.slice(0, key.indexOf('_'));
const sanitizedKey = key.slice(0, key.indexOf('_'));
inputValue += `${sanitizedKey}:${value} `;
let sanitizedValue = value;
if (match && sanitizedKey === 'label') {
sanitizedValue = sanitizedValue.replace(/%20/g, ' ');
}
inputValue += `${sanitizedKey}:${sanitizedValue} `;
} else if (!match && key === 'search') {
} else if (!match && key === 'search') {
// Sanitize value as URL converts spaces into +
// Sanitize value as URL converts spaces into +
const sanitizedValue = value.replace(/[+]/g, ' ');
const sanitizedValue = value.replace(/[+]/g, ' ');
...
@@ -91,26 +97,51 @@
...
@@ -91,26 +97,51 @@
// Enable clear button
// Enable clear button
document.querySelector('.clear-search').classList.remove('hidden');
document.querySelector('.clear-search').classList.remove('hidden');
// TODO: Current implementation does not support token values that have valid spaces in them
// Example/ label:community contribution
const input = event.target.value;
const input = event.target.value;
const inputs = input.split(' ');
const inputs = input.split(' ');
let searchTerms = '';
let searchTerms = '';
let lastQuotation = '';
let incompleteToken = false;
const addSearchTerm = function addSearchTerm(term) {
const addSearchTerm = function addSearchTerm(term) {
searchTerms += term + ' ';
searchTerms += term + ' ';
}
}
inputs.forEach((i) => {
inputs.forEach((i) => {
if (incompleteToken) {
const prevToken = this.tokens[this.tokens.length - 1];
prevToken.value += ` ${i}`;
// Remove last quotation
const lastQuotationRegex = new RegExp(lastQuotation, 'g');
prevToken.value = prevToken.value.replace(lastQuotationRegex, '');
this.tokens[this.tokens.length - 1] = prevToken;
// Check to see if this quotation completes the token value
if (i.indexOf(lastQuotation)) {
incompleteToken = !incompleteToken;
}
return;
}
const colonIndex = i.indexOf(':');
const colonIndex = i.indexOf(':');
if (colonIndex !== -1) {
if (colonIndex !== -1) {
const tokenKey = i.slice(0, colonIndex).toLowerCase();
const tokenKey = i.slice(0, colonIndex).toLowerCase();
const tokenValue = i.slice(colonIndex + 1);
const tokenValue = i.slice(colonIndex + 1);
const match = validTokenKeys.fi
lter
((v) => {
const match = validTokenKeys.fi
nd
((v) => {
return v.key === tokenKey;
return v.key === tokenKey;
})[0];
});
if (tokenValue.indexOf('"') !== -1) {
lastQuotation = '"';
incompleteToken = true;
} else if (tokenValue.indexOf('\'') !== -1) {
lastQuotation = '\'';
incompleteToken = true;
}
if (match && tokenValue.length > 0) {
if (match && tokenValue.length > 0) {
this.tokens.push({
this.tokens.push({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment