Add author dropdown

This commit is contained in:
Clement Ho 2016-12-02 16:30:19 -06:00
parent ce1247727d
commit 78b9e7c6b5
3 changed files with 40 additions and 4 deletions

View File

@ -0,0 +1,22 @@
/* eslint-disable no-param-reassign */
/*= require filtered_search/filtered_search_dropdown */
((global) => {
class DropdownAuthor extends gl.FilteredSearchDropdown {
constructor(dropdown, input) {
super(dropdown, input);
this.listId = 'js-dropdown-author';
}
itemClicked(e) {
console.log('author clicked');
}
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=&current_user=true&push_code_to_protected_branches=&author_id=&skip_users=');
}
}
global.DropdownAuthor = DropdownAuthor;
})(window.gl || (window.gl = {}));

View File

@ -78,6 +78,7 @@
}
let dropdownHint;
let dropdownAuthor;
let dropdownAssignee;
class FilteredSearchManager {
@ -103,10 +104,14 @@
this.dismissCurrentDropdown();
this.currentDropdown = match.key;
if (match.key === 'assignee') {
if (!dropdownAssignee) {
if (match.key === 'author') {
if (!dropdownAuthor) {
dropdownAuthor = new gl.DropdownAuthor(document.querySelector('#js-dropdown-author'), document.querySelector('.filtered-search'));
}
// document.querySelector('.filtered-search').setAttribute('data-dropdown-trigger', '#js-dropdown-assignee');
dropdownAuthor.render();
} else if (match.key === 'assignee') {
if (!dropdownAssignee) {
dropdownAssignee = new gl.DropdownAssignee(document.querySelector('#js-dropdown-assignee'), document.querySelector('.filtered-search'));
}
@ -119,7 +124,7 @@
this.currentDropdown = 'hint';
if (!dropdownHint) {
dropdownHint = new gl.DropdownHint(document.querySelector('#js-dropdown-hint'), document.querySelector('.filtered-search'), 'hint');
dropdownHint = new gl.DropdownHint(document.querySelector('#js-dropdown-hint'), document.querySelector('.filtered-search'), this.currentDropdown);
}
dropdownHint.render();
}

View File

@ -24,6 +24,15 @@
{{hint}}
%span.js-filter-tag
{{tag}}
#js-dropdown-author.dropdown-menu{ 'data-dropdown' => true }
%ul{ 'data-dynamic' => true }
%li
%button.btn.btn-link
%img.avatar.avatar-inline{ 'src': '{{avatar_url}}', width: '30' }
%strong
{{name}}
%span
{{username}}
#js-dropdown-assignee.dropdown-menu{ 'data-dropdown' => true }
%ul{ 'data-dynamic' => true }
%li