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
Léo-Paul Géneau
gitlab-ce
Commits
46a1f369
Commit
46a1f369
authored
Dec 11, 2016
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor dropdown filters
parent
5c0802de
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
28 additions
and
128 deletions
+28
-128
app/assets/javascripts/filtered_search/dropdown_author.js.es6
...assets/javascripts/filtered_search/dropdown_author.js.es6
+0
-57
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
+1
-1
app/assets/javascripts/filtered_search/dropdown_label.js.es6
app/assets/javascripts/filtered_search/dropdown_label.js.es6
+0
-45
app/assets/javascripts/filtered_search/dropdown_non_user.js.es6
...sets/javascripts/filtered_search/dropdown_non_user.js.es6
+9
-9
app/assets/javascripts/filtered_search/dropdown_user.js.es6
app/assets/javascripts/filtered_search/dropdown_user.js.es6
+5
-9
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
...avascripts/filtered_search/filtered_search_manager.js.es6
+11
-5
app/views/shared/issuable/_search_bar.html.haml
app/views/shared/issuable/_search_bar.html.haml
+2
-2
No files found.
app/assets/javascripts/filtered_search/dropdown_author.js.es6
deleted
100644 → 0
View file @
5c0802de
/* eslint-disable no-param-reassign */
/*= require filtered_search/filtered_search_dropdown */
((global) => {
class DropdownAuthor extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
super(droplab, dropdown, input);
this.listId = 'js-dropdown-author';
this.config = {
droplabAjaxFilter: {
endpoint: '/autocomplete/users.json',
searchKey: 'search',
params: {
per_page: 20,
active: true,
project_id: this.getProjectId(),
current_user: true,
},
searchValueFunction: this.getSearchInput,
loadingTemplate: this.loadingTemplate,
}
};
}
itemClicked(e) {
const username = e.detail.selected.querySelector('.dropdown-light-content').innerText.trim();
gl.FilteredSearchManager.addWordToInput(this.getSelectedText(username));
this.dismissDropdown();
}
renderContent(forceShowList) {
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjaxFilter], this.config);
super.renderContent(forceShowList);
}
getSearchInput() {
const query = document.querySelector('.filtered-search').value;
const { value } = gl.FilteredSearchTokenizer.getLastTokenObject(query);
const valueWithoutColon = value.slice(1);
const hasPrefix = valueWithoutColon[0] === '@';
const valueWithoutPrefix = valueWithoutColon.slice(1);
if (hasPrefix) {
return valueWithoutPrefix;
} else {
return valueWithoutColon;
}
}
configure() {
this.droplab.addHook(this.input, this.dropdown, [droplabAjaxFilter], this.config).init();
}
}
global.DropdownAuthor = DropdownAuthor;
})(window.gl || (window.gl = {}));
app/assets/javascripts/filtered_search/dropdown_hint.js.es6
View file @
46a1f369
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
class DropdownHint extends gl.FilteredSearchDropdown {
class DropdownHint extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
constructor(droplab, dropdown, input) {
super(droplab, dropdown, input);
super(droplab, dropdown, input);
this.listId =
'js-dropdown-hint'
;
this.listId =
dropdown.id
;
this.config = {
this.config = {
droplabFilter: {
droplabFilter: {
template: 'hint',
template: 'hint',
...
...
app/assets/javascripts/filtered_search/dropdown_label.js.es6
deleted
100644 → 0
View file @
5c0802de
/* eslint-disable no-param-reassign */
/*= require filtered_search/filtered_search_dropdown */
((global) => {
class DropdownLabel extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
super(droplab, dropdown, input);
this.listId = 'js-dropdown-label';
this.config = {
droplabAjax: {
endpoint: 'labels.json',
method: 'setData',
loadingTemplate: this.loadingTemplate,
},
droplabFilter: {
filterFunction: this.filterWithSymbol.bind(this, '~'),
}
};
}
itemClicked(e) {
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
const labelTitle = e.detail.selected.querySelector('.label-title').innerText.trim();
const labelName = `~${this.getEscapedText(labelTitle)}`;
gl.FilteredSearchManager.addWordToInput(labelName);
}
// debugger
this.dismissDropdown(!dataValueSet);
}
renderContent(forceShowList) {
this.droplab.changeHookList(this.hookId, this.dropdown, [droplabAjax, droplabFilter], this.config);
super.renderContent(forceShowList);
}
configure() {
this.droplab.addHook(this.input, this.dropdown, [droplabAjax, droplabFilter], this.config).init();
}
}
global.DropdownLabel = DropdownLabel;
})(window.gl || (window.gl = {}));
app/assets/javascripts/filtered_search/dropdown_
milestone
.js.es6
→
app/assets/javascripts/filtered_search/dropdown_
non_user
.js.es6
View file @
46a1f369
...
@@ -2,18 +2,18 @@
...
@@ -2,18 +2,18 @@
/*= require filtered_search/filtered_search_dropdown */
/*= require filtered_search/filtered_search_dropdown */
((global) => {
((global) => {
class Dropdown
Milestone
extends gl.FilteredSearchDropdown {
class Dropdown
NonUser
extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
constructor(droplab, dropdown, input
, endpoint, symbol
) {
super(droplab, dropdown, input);
super(droplab, dropdown, input);
this.listId =
'js-dropdown-milestone'
;
this.listId =
dropdown.id
;
this.config = {
this.config = {
droplabAjax: {
droplabAjax: {
endpoint:
'milestones.json'
,
endpoint:
endpoint
,
method: 'setData',
method: 'setData',
loadingTemplate: this.loadingTemplate,
loadingTemplate: this.loadingTemplate,
},
},
droplabFilter: {
droplabFilter: {
filterFunction: this.filterWithSymbol.bind(this,
'%'
),
filterFunction: this.filterWithSymbol.bind(this,
symbol
),
}
}
};
};
}
}
...
@@ -22,9 +22,9 @@
...
@@ -22,9 +22,9 @@
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
if (!dataValueSet) {
const
milestoneTitle = e.detail.selected.querySelector('.btn-link
').innerText.trim();
const
title = e.detail.selected.querySelector('.js-data-value
').innerText.trim();
const
milestoneName = `%${this.getEscapedText(milestoneT
itle)}`;
const
name = `%${this.getEscapedText(t
itle)}`;
gl.FilteredSearchManager.addWordToInput(this.getSelectedText(
milestoneN
ame));
gl.FilteredSearchManager.addWordToInput(this.getSelectedText(
n
ame));
}
}
this.dismissDropdown(!dataValueSet);
this.dismissDropdown(!dataValueSet);
...
@@ -40,5 +40,5 @@
...
@@ -40,5 +40,5 @@
}
}
}
}
global.Dropdown
Milestone = DropdownMilestone
;
global.Dropdown
NonUser = DropdownNonUser
;
})(window.gl || (window.gl = {}));
})(window.gl || (window.gl = {}));
app/assets/javascripts/filtered_search/dropdown_
assignee
.js.es6
→
app/assets/javascripts/filtered_search/dropdown_
user
.js.es6
View file @
46a1f369
...
@@ -2,10 +2,10 @@
...
@@ -2,10 +2,10 @@
/*= require filtered_search/filtered_search_dropdown */
/*= require filtered_search/filtered_search_dropdown */
((global) => {
((global) => {
class Dropdown
Assignee
extends gl.FilteredSearchDropdown {
class Dropdown
User
extends gl.FilteredSearchDropdown {
constructor(droplab, dropdown, input) {
constructor(droplab, dropdown, input) {
super(droplab, dropdown, input);
super(droplab, dropdown, input);
this.listId =
'js-dropdown-assignee'
;
this.listId =
dropdown.id
;
this.config = {
this.config = {
droplabAjaxFilter: {
droplabAjaxFilter: {
endpoint: '/autocomplete/users.json',
endpoint: '/autocomplete/users.json',
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
},
},
searchValueFunction: this.getSearchInput,
searchValueFunction: this.getSearchInput,
loadingTemplate: this.loadingTemplate,
loadingTemplate: this.loadingTemplate,
}
}
,
};
};
}
}
...
@@ -45,11 +45,7 @@
...
@@ -45,11 +45,7 @@
const hasPrefix = valueWithoutColon[0] === '@';
const hasPrefix = valueWithoutColon[0] === '@';
const valueWithoutPrefix = valueWithoutColon.slice(1);
const valueWithoutPrefix = valueWithoutColon.slice(1);
if (hasPrefix) {
return hasPrefix ? valueWithoutPrefix : valueWithoutColon;
return valueWithoutPrefix;
} else {
return valueWithoutColon;
}
}
}
configure() {
configure() {
...
@@ -57,5 +53,5 @@
...
@@ -57,5 +53,5 @@
}
}
}
}
global.Dropdown
Assignee = DropdownAssignee
;
global.Dropdown
User = DropdownUser
;
})(window.gl || (window.gl = {}));
})(window.gl || (window.gl = {}));
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
View file @
46a1f369
...
@@ -103,22 +103,24 @@
...
@@ -103,22 +103,24 @@
this.mapping = {
this.mapping = {
author: {
author: {
reference: null,
reference: null,
gl: 'Dropdown
Autho
r',
gl: 'Dropdown
Use
r',
element: document.querySelector('#js-dropdown-author'),
element: document.querySelector('#js-dropdown-author'),
},
},
assignee: {
assignee: {
reference: null,
reference: null,
gl: 'Dropdown
Assignee
',
gl: 'Dropdown
User
',
element: document.querySelector('#js-dropdown-assignee'),
element: document.querySelector('#js-dropdown-assignee'),
},
},
milestone: {
milestone: {
reference: null,
reference: null,
gl: 'DropdownMilestone',
gl: 'DropdownNonUser',
extraArguments: ['milestones.json', '%'],
element: document.querySelector('#js-dropdown-milestone'),
element: document.querySelector('#js-dropdown-milestone'),
},
},
label: {
label: {
reference: null,
reference: null,
gl: 'DropdownLabel',
gl: 'DropdownNonUser',
extraArguments: ['labels.json', '~'],
element: document.querySelector('#js-dropdown-label'),
element: document.querySelector('#js-dropdown-label'),
},
},
hint: {
hint: {
...
@@ -160,7 +162,11 @@
...
@@ -160,7 +162,11 @@
let forceShowList = false;
let forceShowList = false;
if (!this.mapping[key].reference) {
if (!this.mapping[key].reference) {
this.mapping[key].reference = new gl[glClass](this.droplab, element, this.filteredSearchInput);
var dl = this.droplab;
const defaultArguments = [null, dl, element, this.filteredSearchInput];
const glArguments = defaultArguments.concat(this.mapping[key].extraArguments || []);
this.mapping[key].reference = new (Function.prototype.bind.apply(gl[glClass], glArguments));
}
}
if (firstLoad) {
if (firstLoad) {
...
...
app/views/shared/issuable/_search_bar.html.haml
View file @
46a1f369
...
@@ -67,7 +67,7 @@
...
@@ -67,7 +67,7 @@
%li
.divider
%li
.divider
%ul
.filter-dropdown
{
'data-dynamic'
=>
true
,
'data-dropdown'
=>
true
}
%ul
.filter-dropdown
{
'data-dynamic'
=>
true
,
'data-dropdown'
=>
true
}
%li
.filter-dropdown-item
%li
.filter-dropdown-item
%button
.btn.btn-link
%button
.btn.btn-link
.js-data-value
{{title}}
{{title}}
#js-dropdown-label
.dropdown-menu
{
'data-dropdown'
=>
true
}
#js-dropdown-label
.dropdown-menu
{
'data-dropdown'
=>
true
}
%ul
{
'data-dropdown'
=>
true
}
%ul
{
'data-dropdown'
=>
true
}
...
@@ -79,7 +79,7 @@
...
@@ -79,7 +79,7 @@
%li
.filter-dropdown-item
%li
.filter-dropdown-item
%button
.btn.btn-link
%button
.btn.btn-link
%span
.dropdown-label-box
{
'style'
:
'
background:
{{
color
}}
'
}
%span
.dropdown-label-box
{
'style'
:
'
background:
{{
color
}}
'
}
%span
.label-title
%span
.label-title
.js-data-value
{{title}}
{{title}}
.pull-right
.pull-right
-
if
boards_page
-
if
boards_page
...
...
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