BigW Consortium Gitlab

Commit 2bbc44cb by Clement Ho

Refactor itemClicked

parent 6c811d47
......@@ -20,15 +20,10 @@
}
itemClicked(e) {
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
super.itemClicked(e, (selected) => {
const title = e.detail.selected.querySelector('.js-data-value').innerText.trim();
const name = `${this.symbol}${this.getEscapedText(title)}`;
gl.FilteredSearchDropdownManager.addWordToInput(this.getSelectedText(name));
}
this.dismissDropdown(!dataValueSet);
return `${this.symbol}${this.getEscapedText(title)}`;
});
}
getEscapedText(text) {
......
......@@ -23,14 +23,9 @@
}
itemClicked(e) {
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
const username = e.detail.selected.querySelector('.dropdown-light-content').innerText.trim();
gl.FilteredSearchDropdownManager.addWordToInput(this.getSelectedText(username));
}
this.dismissDropdown(!dataValueSet);
super.itemClicked(e, (selected) => {
return selected.querySelector('.dropdown-light-content').innerText.trim();
});
}
renderContent(forceShowList = false) {
......
......@@ -35,8 +35,15 @@
return lastWordIndex === -1 ? selectedToken : selectedToken.slice(lastWord.length);
}
itemClicked(e) {
// Overridden by dropdown sub class
itemClicked(e, getValueFunction) {
const dataValueSet = this.setDataValueIfSelected(e.detail.selected);
if (!dataValueSet) {
const value = getValueFunction(e.detail.selected)
gl.FilteredSearchDropdownManager.addWordToInput(this.getSelectedText(value));
}
this.dismissDropdown();
}
renderContent(forceShowList = false) {
......
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