Commit 6eafd748 authored by Clement Ho's avatar Clement Ho

Fix code styling issues

parent 16e3fe3f
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
} }
itemClicked(e) { itemClicked(e) {
const selected = e.detail.selected; const { selected } = e.detail;
if (selected.hasAttribute('data-value')) { if (selected.hasAttribute('data-value')) {
this.dismissDropdown(); this.dismissDropdown();
......
...@@ -24,14 +24,15 @@ ...@@ -24,14 +24,15 @@
} }
getCurrentHook() { getCurrentHook() {
return this.droplab.hooks.filter(h => h.id === this.hookId)[0]; return this.droplab.hooks.filter(h => h.id === this.hookId)[0] || null;
} }
itemClicked(e, getValueFunction) { itemClicked(e, getValueFunction) {
const dataValueSet = this.setDataValueIfSelected(e.detail.selected); const { selected } = e.detail;
const dataValueSet = this.setDataValueIfSelected(selected);
if (!dataValueSet) { if (!dataValueSet) {
const value = getValueFunction(e.detail.selected); const value = getValueFunction(selected);
gl.FilteredSearchDropdownManager.addWordToInput(value); gl.FilteredSearchDropdownManager.addWordToInput(value);
} }
...@@ -67,7 +68,7 @@ ...@@ -67,7 +68,7 @@
this.setAsDropdown(); this.setAsDropdown();
const currentHook = this.getCurrentHook(); const currentHook = this.getCurrentHook();
const firstTimeInitialized = currentHook === undefined; const firstTimeInitialized = currentHook === null;
if (firstTimeInitialized || forceRenderContent) { if (firstTimeInitialized || forceRenderContent) {
this.renderContent(forceShowList); this.renderContent(forceShowList);
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
} }
static addWordToInput(word, addSpace = false) { static addWordToInput(word, addSpace = false) {
const input = document.querySelector('.filtered-search') const input = document.querySelector('.filtered-search');
const value = input.value; const value = input.value;
const hasExistingValue = value.length !== 0; const hasExistingValue = value.length !== 0;
const { lastToken } = gl.FilteredSearchTokenizer.processTokens(value); const { lastToken } = gl.FilteredSearchTokenizer.processTokens(value);
...@@ -88,22 +88,22 @@ ...@@ -88,22 +88,22 @@
} }
load(key, firstLoad = false) { load(key, firstLoad = false) {
console.log(`🦄 load ${key} dropdown`); const mappingKey = this.mapping[key];
const glClass = this.mapping[key].gl; const glClass = mappingKey.gl;
const element = this.mapping[key].element; const element = mappingKey.element;
let forceShowList = false; let forceShowList = false;
if (!this.mapping[key].reference) { if (!mappingKey.reference) {
const dl = this.droplab; const dl = this.droplab;
const defaultArguments = [null, dl, element, this.filteredSearchInput]; const defaultArguments = [null, dl, element, this.filteredSearchInput];
const glArguments = defaultArguments.concat(this.mapping[key].extraArguments || []); const glArguments = defaultArguments.concat(mappingKey.extraArguments || []);
// Passing glArguments to `new gl[glClass](<arguments>)` // Passing glArguments to `new gl[glClass](<arguments>)`
this.mapping[key].reference = new (Function.prototype.bind.apply(gl[glClass], glArguments)); mappingKey.reference = new (Function.prototype.bind.apply(gl[glClass], glArguments));
} }
if (firstLoad) { if (firstLoad) {
this.mapping[key].reference.init(); mappingKey.reference.init();
} }
if (this.currentDropdown === 'hint') { if (this.currentDropdown === 'hint') {
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
} }
this.updateDropdownOffset(key); this.updateDropdownOffset(key);
this.mapping[key].reference.render(firstLoad, forceShowList); mappingKey.reference.render(firstLoad, forceShowList);
this.currentDropdown = key; this.currentDropdown = key;
} }
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
loadDropdown(dropdownName = '') { loadDropdown(dropdownName = '') {
let firstLoad = false; let firstLoad = false;
if(!this.droplab) { if (!this.droplab) {
firstLoad = true; firstLoad = true;
this.droplab = new DropLab(); this.droplab = new DropLab();
} }
......
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