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

Fix code styling issues

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