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
Tatuya Kamada
gitlab-ce
Commits
d91d586a
Commit
d91d586a
authored
Dec 06, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add filter by last token
parent
00ed5aaf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
6 deletions
+77
-6
app/assets/javascripts/droplab/droplab_filter.js
app/assets/javascripts/droplab/droplab_filter.js
+11
-2
app/assets/javascripts/filtered_search/dropdown_author.js.es6
...assets/javascripts/filtered_search/dropdown_author.js.es6
+8
-0
app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
...vascripts/filtered_search/filtered_search_dropdown.js.es6
+9
-4
app/assets/javascripts/filtered_search/filtered_search_tokenizer.es6
...javascripts/filtered_search/filtered_search_tokenizer.es6
+49
-0
No files found.
app/assets/javascripts/droplab/droplab_filter.js
View file @
d91d586a
...
@@ -10,13 +10,22 @@ droplab.plugin(function init(DropLab) {
...
@@ -10,13 +10,22 @@ droplab.plugin(function init(DropLab) {
var
matches
=
[];
var
matches
=
[];
// will only work on dynamically set data
// will only work on dynamically set data
// and if a config text property is set
// and if a config text property is set
if
(
!
data
||
!
config
.
hasOwnProperty
(
'
text
'
)){
if
(
!
data
||
(
!
config
.
hasOwnProperty
(
'
text
'
)
&&
!
config
.
hasOwnProperty
(
'
filter
'
)
)){
return
;
return
;
}
}
matches
=
data
.
map
(
function
(
o
){
var
filterFunction
=
function
(
o
){
// cheap string search
// cheap string search
o
.
droplab_hidden
=
o
[
config
.
text
].
toLowerCase
().
indexOf
(
value
)
===
-
1
;
o
.
droplab_hidden
=
o
[
config
.
text
].
toLowerCase
().
indexOf
(
value
)
===
-
1
;
return
o
;
return
o
;
};
if
(
config
.
hasOwnProperty
(
'
filter
'
)
&&
config
.
filter
!==
undefined
)
{
filterFunction
=
config
.
filter
;
}
matches
=
data
.
map
(
function
(
o
)
{
return
filterFunction
(
o
,
value
);
});
});
list
.
render
(
matches
);
list
.
render
(
matches
);
}
}
...
...
app/assets/javascripts/filtered_search/dropdown_author.js.es6
View file @
d91d586a
...
@@ -19,6 +19,14 @@
...
@@ -19,6 +19,14 @@
super.renderContent();
super.renderContent();
droplab.setData(this.hookId, '/autocomplete/users.json?search=&per_page=20&active=true&project_id=2&group_id=&skip_ldap=&todo_filter=&todo_state_filter=¤t_user=true&push_code_to_protected_branches=&author_id=&skip_users=');
droplab.setData(this.hookId, '/autocomplete/users.json?search=&per_page=20&active=true&project_id=2&group_id=&skip_ldap=&todo_filter=&todo_state_filter=¤t_user=true&push_code_to_protected_branches=&author_id=&skip_users=');
}
}
filterMethod(item, query) {
const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
const valueWithoutPrefix = value.slice(1);
item.droplab_hidden = item['username'].indexOf(valueWithoutPrefix) === -1;
return item;
}
}
}
global.DropdownAuthor = DropdownAuthor;
global.DropdownAuthor = DropdownAuthor;
...
...
app/assets/javascripts/filtered_search/filtered_search_dropdown.js.es6
View file @
d91d586a
...
@@ -50,12 +50,17 @@
...
@@ -50,12 +50,17 @@
getFilterConfig(filterKeyword) {
getFilterConfig(filterKeyword) {
const config = {};
const config = {};
const filterConfig = {
const filterConfig = {};
text: filterKeyword,
};
config[this.hookId] = filterKeyword ? filterConfig : {};
if (filterKeyword) {
filterConfig.text = filterKeyword;
}
if (this.filterMethod) {
filterConfig.filter = this.filterMethod;
}
config[this.hookId] = filterConfig;
return config;
return config;
}
}
...
...
app/assets/javascripts/filtered_search/filtered_search_tokenizer.es6
View file @
d91d586a
...
@@ -29,6 +29,55 @@
...
@@ -29,6 +29,55 @@
}
}
}
}
static getLastTokenObject(input) {
const token = FilteredSearchTokenizer.getLastToken(input);
const colonIndex = token.indexOf(':');
const key = colonIndex !== -1 ? token.slice(0, colonIndex) : '';
const value = colonIndex !== -1 ? token.slice(colonIndex) : token;
return {
key,
value,
}
}
static getLastToken(input) {
let completeToken = false;
let completeQuotation = true;
let lastQuotation = '';
let i = input.length;
const doubleQuote = '"';
const singleQuote = '\'';
while(!completeToken && i >= 0) {
const isDoubleQuote = input[i] === doubleQuote;
const isSingleQuote = input[i] === singleQuote;
// If the second quotation is found
if ((lastQuotation === doubleQuote && input[i] === doubleQuote) ||
(lastQuotation === singleQuote && input[i] === singleQuote)) {
completeQuotation = true;
}
// Save the first quotation
if ((input[i] === doubleQuote && lastQuotation === '') ||
(input[i] === singleQuote && lastQuotation === '')) {
lastQuotation = input[i];
completeQuotation = false;
}
if (completeQuotation && input[i] === ' ') {
completeToken = true;
} else {
i--;
}
}
// Adjust by 1 because of empty space
return input.slice(i + 1);
}
static processTokens(input) {
static processTokens(input) {
let tokens = [];
let tokens = [];
let searchToken = '';
let searchToken = '';
...
...
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