Skip to content

Commit

Permalink
update in filter for empty options array.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbauszus-glx committed Nov 1, 2023
1 parent 6887135 commit 3dc63f6
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions lib/ui/layers/filters.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ export default {

let timeout;

function applyFilter(layer, zoom) {
clearTimeout(timeout);
function applyFilter(layer) {

// enable zoomToExtent button.
let btn = layer.view.querySelector('[data-id=zoomToExtent]')
if (btn) btn.disabled = false;
clearTimeout(timeout);

// Debounce layer reload by 500
timeout = setTimeout(() => {
timeout = null;
layer.reload();
layer.mapview.Map.getTargetElement().dispatchEvent(new Event('changeEnd'))
}, 500);
Expand Down Expand Up @@ -192,11 +188,20 @@ async function filter_in(layer, filter) {
})),
callback: async (e, options) => {

Object.assign(layer.filter.current, {
[filter.field]:{
[filter.type]: options
}
})
if (!options.length) {

// Remove empty array filter.
delete layer.filter.current[filter.field]
} else {

// Set filter values array from options.
Object.assign(layer.filter.current, {
[filter.field]:{
[filter.type]: options
}
})
}

layer.reload()
layer.mapview.Map.getTargetElement().dispatchEvent(new Event('changeEnd'))
}
Expand Down

0 comments on commit 3dc63f6

Please sign in to comment.