Add ability to click on none as an option

This commit is contained in:
Clement Ho 2016-12-05 16:05:30 -06:00
parent d2ecba6edf
commit f5719c2c48
7 changed files with 46 additions and 14 deletions

View file

@ -9,7 +9,13 @@
}
itemClicked(e) {
console.log('assignee clicked');
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
console.log('set value');
}
this.dismissDropdown();
}
renderContent() {

View file

@ -39,12 +39,7 @@
gl.FilteredSearchManager.addWordToInput(this.getSelectedText(token));
}
this.input.focus();
this.dismissDropdown();
// Propogate input change to FilteredSearchManager
// so that it can determine which dropdowns to open
this.input.dispatchEvent(new Event('input'));
}
renderContent() {

View file

@ -9,7 +9,14 @@
}
itemClicked(e) {
console.log('label clicked');
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
const labelName = `~${e.detail.selected.querySelector('.label-title').innerText.trim()}`;
gl.FilteredSearchManager.addWordToInput(this.getSelectedText(labelName));
}
this.dismissDropdown();
}
renderContent() {

View file

@ -9,7 +9,13 @@
}
itemClicked(e) {
console.log('milestone clicked');
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
console.log('set value');
}
this.dismissDropdown();
}
renderContent() {

View file

@ -41,13 +41,20 @@
return config;
}
dismissDropdown() {
destroy() {
this.input.setAttribute(DATA_DROPDOWN_TRIGGER, '');
droplab.setConfig(this.getFilterConfig());
droplab.setData(this.hookId, []);
this.unbindEvents();
}
dismissDropdown() {
this.input.focus();
// Propogate input change to FilteredSearchManager
// so that it can determine which dropdowns to open
this.input.dispatchEvent(new Event('input'));
}
setAsDropdown() {
this.input.setAttribute(DATA_DROPDOWN_TRIGGER, `#${this.listId}`);
}
@ -56,6 +63,16 @@
this.dropdown.style.left = `${offset}px`;
}
setDataValueIfSelected(selected) {
const dataValue = selected.getAttribute('data-value');
if (dataValue) {
gl.FilteredSearchManager.addWordToInput(dataValue);
}
return dataValue !== null;
}
getCurrentHook() {
return droplab.hooks.filter(h => h.id === this.hookId)[0];
}

View file

@ -160,7 +160,7 @@
dismissCurrentDropdown() {
if (this.currentDropdown === 'hint') {
dropdownHint.dismissDropdown();
dropdownHint.destroy();
}
}

View file

@ -36,7 +36,7 @@
@{{username}}
#js-dropdown-assignee.dropdown-menu{ 'data-dropdown' => true }
%ul
%li.filter-dropdown-item
%li.filter-dropdown-item{ 'data-value': 'none' }
%button.btn.btn-link
No assignee
%li.divider
@ -51,7 +51,7 @@
@{{username}}
#js-dropdown-milestone.dropdown-menu{ 'data-dropdown' => true }
%ul
%li.filter-dropdown-item
%li.filter-dropdown-item{ 'data-value': 'none' }
%button.btn.btn-link
No milestone
%li.divider
@ -61,7 +61,7 @@
{{title}}
#js-dropdown-label.dropdown-menu{ 'data-dropdown' => true }
%ul
%li.filter-dropdown-item
%li.filter-dropdown-item{ 'data-value': 'none' }
%button.btn.btn-link
No label
%li.divider
@ -69,7 +69,8 @@
%li.filter-dropdown-item
%button.btn.btn-link
%span.dropdown-label-box{ 'style': 'background: {{color}}'}
{{title}}
%span.label-title
{{title}}
.pull-right
- if boards_page
#js-boards-seach.issue-boards-search