Commit 78b9e7c6 authored by Clement Ho's avatar Clement Ho

Add author dropdown

parent ce124772
/* 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 = {}));
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
} }
let dropdownHint; let dropdownHint;
let dropdownAuthor;
let dropdownAssignee; let dropdownAssignee;
class FilteredSearchManager { class FilteredSearchManager {
...@@ -103,10 +104,14 @@ ...@@ -103,10 +104,14 @@
this.dismissCurrentDropdown(); this.dismissCurrentDropdown();
this.currentDropdown = match.key; this.currentDropdown = match.key;
if (match.key === 'assignee') { if (match.key === 'author') {
if (!dropdownAssignee) { 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')); dropdownAssignee = new gl.DropdownAssignee(document.querySelector('#js-dropdown-assignee'), document.querySelector('.filtered-search'));
} }
...@@ -119,7 +124,7 @@ ...@@ -119,7 +124,7 @@
this.currentDropdown = 'hint'; this.currentDropdown = 'hint';
if (!dropdownHint) { 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(); dropdownHint.render();
} }
......
...@@ -24,6 +24,15 @@ ...@@ -24,6 +24,15 @@
{{hint}} {{hint}}
%span.js-filter-tag %span.js-filter-tag
{{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 } #js-dropdown-assignee.dropdown-menu{ 'data-dropdown' => true }
%ul{ 'data-dynamic' => true } %ul{ 'data-dynamic' => true }
%li %li
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment