Commit f5719c2c authored by Clement Ho's avatar Clement Ho

Add ability to click on none as an option

parent d2ecba6e
...@@ -9,7 +9,13 @@ ...@@ -9,7 +9,13 @@
} }
itemClicked(e) { itemClicked(e) {
console.log('assignee clicked'); const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
console.log('set value');
}
this.dismissDropdown();
} }
renderContent() { renderContent() {
......
...@@ -39,12 +39,7 @@ ...@@ -39,12 +39,7 @@
gl.FilteredSearchManager.addWordToInput(this.getSelectedText(token)); gl.FilteredSearchManager.addWordToInput(this.getSelectedText(token));
} }
this.input.focus();
this.dismissDropdown(); this.dismissDropdown();
// Propogate input change to FilteredSearchManager
// so that it can determine which dropdowns to open
this.input.dispatchEvent(new Event('input'));
} }
renderContent() { renderContent() {
......
...@@ -9,7 +9,14 @@ ...@@ -9,7 +9,14 @@
} }
itemClicked(e) { 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() { renderContent() {
......
...@@ -9,7 +9,13 @@ ...@@ -9,7 +9,13 @@
} }
itemClicked(e) { itemClicked(e) {
console.log('milestone clicked'); const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
console.log('set value');
}
this.dismissDropdown();
} }
renderContent() { renderContent() {
......
...@@ -41,13 +41,20 @@ ...@@ -41,13 +41,20 @@
return config; return config;
} }
dismissDropdown() { destroy() {
this.input.setAttribute(DATA_DROPDOWN_TRIGGER, ''); this.input.setAttribute(DATA_DROPDOWN_TRIGGER, '');
droplab.setConfig(this.getFilterConfig()); droplab.setConfig(this.getFilterConfig());
droplab.setData(this.hookId, []); droplab.setData(this.hookId, []);
this.unbindEvents(); 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() { setAsDropdown() {
this.input.setAttribute(DATA_DROPDOWN_TRIGGER, `#${this.listId}`); this.input.setAttribute(DATA_DROPDOWN_TRIGGER, `#${this.listId}`);
} }
...@@ -56,6 +63,16 @@ ...@@ -56,6 +63,16 @@
this.dropdown.style.left = `${offset}px`; this.dropdown.style.left = `${offset}px`;
} }
setDataValueIfSelected(selected) {
const dataValue = selected.getAttribute('data-value');
if (dataValue) {
gl.FilteredSearchManager.addWordToInput(dataValue);
}
return dataValue !== null;
}
getCurrentHook() { getCurrentHook() {
return droplab.hooks.filter(h => h.id === this.hookId)[0]; return droplab.hooks.filter(h => h.id === this.hookId)[0];
} }
......
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
dismissCurrentDropdown() { dismissCurrentDropdown() {
if (this.currentDropdown === 'hint') { if (this.currentDropdown === 'hint') {
dropdownHint.dismissDropdown(); dropdownHint.destroy();
} }
} }
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
@{{username}} @{{username}}
#js-dropdown-assignee.dropdown-menu{ 'data-dropdown' => true } #js-dropdown-assignee.dropdown-menu{ 'data-dropdown' => true }
%ul %ul
%li.filter-dropdown-item %li.filter-dropdown-item{ 'data-value': 'none' }
%button.btn.btn-link %button.btn.btn-link
No assignee No assignee
%li.divider %li.divider
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
@{{username}} @{{username}}
#js-dropdown-milestone.dropdown-menu{ 'data-dropdown' => true } #js-dropdown-milestone.dropdown-menu{ 'data-dropdown' => true }
%ul %ul
%li.filter-dropdown-item %li.filter-dropdown-item{ 'data-value': 'none' }
%button.btn.btn-link %button.btn.btn-link
No milestone No milestone
%li.divider %li.divider
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
{{title}} {{title}}
#js-dropdown-label.dropdown-menu{ 'data-dropdown' => true } #js-dropdown-label.dropdown-menu{ 'data-dropdown' => true }
%ul %ul
%li.filter-dropdown-item %li.filter-dropdown-item{ 'data-value': 'none' }
%button.btn.btn-link %button.btn.btn-link
No label No label
%li.divider %li.divider
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,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
{{title}} {{title}}
.pull-right .pull-right
- if boards_page - if boards_page
......
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