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
Jérome Perrin
gitlab-ce
Commits
da8ab2bc
Commit
da8ab2bc
authored
Dec 06, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add escape quotations for selected labels from dropdown
parent
60c9240b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
3 deletions
+22
-3
app/assets/javascripts/filtered_search/dropdown_label.js.es6
app/assets/javascripts/filtered_search/dropdown_label.js.es6
+16
-2
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
...avascripts/filtered_search/filtered_search_manager.js.es6
+6
-1
No files found.
app/assets/javascripts/filtered_search/dropdown_label.js.es6
View file @
da8ab2bc
...
@@ -12,8 +12,22 @@
...
@@ -12,8 +12,22 @@
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
if (!dataValueSet) {
const labelName = `~${e.detail.selected.querySelector('.label-title').innerText.trim()}`;
let labelTitle = e.detail.selected.querySelector('.label-title').innerText.trim();
gl.FilteredSearchManager.addWordToInput(this.getSelectedText(labelName));
// Encapsulate label with quotes if it has spaces
if (labelTitle.indexOf(' ') !== -1) {
if (labelTitle.indexOf('"') !== -1) {
// Use single quotes if label title contains double quotes
labelTitle = `'${labelTitle}'`;
} else {
// Known side effect: Label's with both single and double quotes
// won't escape properly
labelTitle = `"${labelTitle}"`;
}
}
const labelName = `~${labelTitle}`;
gl.FilteredSearchManager.addWordToInput(labelName);
}
}
this.dismissDropdown();
this.dismissDropdown();
...
...
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
View file @
da8ab2bc
...
@@ -97,7 +97,12 @@
...
@@ -97,7 +97,12 @@
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(filteredSearchValue);
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(filteredSearchValue);
if (lastToken.hasOwnProperty('key')) {
if (lastToken.hasOwnProperty('key')) {
document.querySelector('.filtered-search').value = filteredSearchValue.slice(0, -1 * (lastToken.value.length));
console.log(lastToken);
// Spaces inside the token means that the token value will be escaped by quotes
const hasQuotes = lastToken.value.indexOf(' ') !== -1;
const lengthToRemove = hasQuotes ? lastToken.value.length + 2 : lastToken.value.length;
document.querySelector('.filtered-search').value = filteredSearchValue.slice(0, -1 * (lengthToRemove));
}
}
document.querySelector('.filtered-search').value += hasExistingValue && addSpace ? ` ${word}` : word;
document.querySelector('.filtered-search').value += hasExistingValue && addSpace ? ` ${word}` : word;
...
...
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