gitlab-org--gitlab-foss/app/assets/javascripts/filtered_search/dropdown_hint.js.es6

49 lines
1.2 KiB
JavaScript
Raw Normal View History

2016-11-30 21:25:10 +00:00
/* eslint-disable no-param-reassign */
2016-12-02 21:04:10 +00:00
/*= require filtered_search/filtered_search_dropdown */
2016-11-30 21:25:10 +00:00
((global) => {
const dropdownData = [{
icon: 'fa-pencil',
hint: 'author:',
tag: '<author>'
},{
icon: 'fa-user',
hint: 'assignee:',
tag: '<assignee>',
},{
icon: 'fa-clock-o',
hint: 'milestone:',
tag: '<milestone>',
},{
icon: 'fa-tag',
hint: 'label:',
tag: '<label>',
}];
2016-12-02 21:04:10 +00:00
class DropdownHint extends gl.FilteredSearchDropdown {
constructor(dropdown, input, filterKeyword) {
super(dropdown, input);
this.listId = 'js-dropdown-hint';
this.filterKeyword = filterKeyword;
2016-11-30 21:25:10 +00:00
}
itemClicked(e) {
2016-12-05 18:35:28 +00:00
const token = e.detail.selected.querySelector('.js-filter-hint').innerText.trim();
const tag = e.detail.selected.querySelector('.js-filter-tag').innerText.trim();
2016-11-30 21:25:10 +00:00
if (tag.length) {
gl.FilteredSearchManager.addWordToInput(this.getSelectedText(token));
}
this.dismissDropdown();
}
2016-12-02 21:04:10 +00:00
renderContent() {
super.renderContent();
droplab.setData(this.hookId, dropdownData);
2016-11-30 21:25:10 +00:00
}
}
global.DropdownHint = DropdownHint;
})(window.gl || (window.gl = {}));