Skip to content

Commit 750b255

Browse files
authored
Merge pull request #1584 from thfries/ui-autocomplete-search
UI - removed old dropdown for searchfilters
2 parents abce37f + c9a6d5e commit 750b255

File tree

3 files changed

+5
-33
lines changed

3 files changed

+5
-33
lines changed

ui/modules/things/searchFilter.js

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ const FILTER_PLACEHOLDER = '...';
3636
let autoCompleteJS;
3737

3838
const dom = {
39-
filterList: null,
4039
favIcon: null,
4140
searchFilterEdit: null,
4241
searchThings: null,
@@ -61,12 +60,6 @@ export async function ready() {
6160
fillSearchFilterEdit(selection.rql);
6261
});
6362

64-
dom.filterList.addEventListener('click', (event) => {
65-
if (event.target && event.target.classList.contains('dropdown-item')) {
66-
fillSearchFilterEdit(event.target.textContent);
67-
}
68-
});
69-
7063
dom.searchThings.onclick = () => {
7164
fillHistory(dom.searchFilterEdit.value);
7265
ThingsSearch.searchTriggered(dom.searchFilterEdit.value);
@@ -106,7 +99,6 @@ function onEnvironmentChanged() {
10699
if (!Environments.current()['pinnedThings']) {
107100
Environments.current().pinnedThings = [];
108101
}
109-
updateFilterList();
110102
}
111103

112104
function fillSearchFilterEdit(fillString) {
@@ -119,19 +111,6 @@ function fillSearchFilterEdit(fillString) {
119111
}
120112
}
121113

122-
/**
123-
* Updates the UI filterList
124-
*/
125-
function updateFilterList() {
126-
dom.filterList.innerHTML = '';
127-
Utils.addDropDownEntries(dom.filterList, ['Favorite search filters'], true);
128-
Utils.addDropDownEntries(dom.filterList, Environments.current().filterList ?? []);
129-
Utils.addDropDownEntries(dom.filterList, ['Example search filters'], true);
130-
Utils.addDropDownEntries(dom.filterList, filterExamples);
131-
Utils.addDropDownEntries(dom.filterList, ['Recent search filters'], true);
132-
Utils.addDropDownEntries(dom.filterList, filterHistory);
133-
}
134-
135114
async function createFilterList(query) {
136115
const date24h = new Date();
137116
const date1h = new Date();
@@ -181,11 +160,6 @@ async function createFilterList(query) {
181160
rql: `like(thingId,"${FILTER_PLACEHOLDER}*")`,
182161
group: 'ThingId',
183162
},
184-
{
185-
label: `exists ${FILTER_PLACEHOLDER}`,
186-
rql: `exists(${FILTER_PLACEHOLDER})`,
187-
group: 'Other',
188-
},
189163
...(Environments.current().filterList ?? []).map((f) => ({label: f, rql: f, group: 'Favorite'})),
190164
...(Environments.current().fieldList ?? []).map((f) => ({
191165
label: `${f.label} = ${FILTER_PLACEHOLDER}`,
@@ -198,6 +172,7 @@ async function createFilterList(query) {
198172
group: 'Field',
199173
})),
200174
...filterHistory.map((f) => ({label: f, rql: f, group: 'Recent'})),
175+
...filterExamples.map((f) => ({label: f, rql: f, group: 'Example'})),
201176
];
202177
}
203178

@@ -247,7 +222,6 @@ function checkAndMarkParameter() {
247222
function fillHistory(filter) {
248223
if (!filterHistory.includes(filter)) {
249224
filterHistory.unshift(filter);
250-
updateFilterList();
251225
}
252226
}
253227

ui/modules/things/things.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ <h5>Things</h5>
2222
title="Toggle favorite for search filter">
2323
<i id="favIcon" class="bi bi-star"></i>
2424
</button>
25-
<button class="btn btn-outline-secondary btn-sm dropdown-toggle dropdown-toggle-split"
26-
data-bs-toggle="dropdown"></button>
27-
<ul id="filterList" class="dropdown-menu" style="position: fixed; top: auto;"></ul>
2825
</div>
2926
<input type="search" class="form-control form-control-sm"
3027
id="searchFilterEdit" spellcheck=false autocomplete="off"></input>

ui/modules/utils.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ export function createAutoComplete(selector, src, placeHolder) {
321321
selector: selector,
322322
data: {
323323
src: src,
324-
keys: ['label'],
324+
keys: ['label', 'group'],
325325
},
326326
placeHolder: placeHolder,
327327
resultsList: {
@@ -333,8 +333,9 @@ export function createAutoComplete(selector, src, placeHolder) {
333333
highlight: true,
334334
element: (item, data) => {
335335
item.style = 'display: flex;';
336-
item.innerHTML = `<span style="flex-grow: 1;" >${data.match}</span>
337-
<span style="color: 3a8c9a;" class="fw-light fst-italic ms-1">${data.value.group}</span>`;
336+
item.innerHTML = `<span style="flex-grow: 1;" >${data.key === 'label' ? data.match : data.value.label}</span>
337+
<span style="color: 3a8c9a;" class="fw-light fst-italic ms-1">
338+
${data.key === 'group' ? data.match : data.value.group}</span>`;
338339
},
339340
},
340341
events: {

0 commit comments

Comments
 (0)