From 3dc63f67909d90012f75e7956f9c160a00c20b80 Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Wed, 1 Nov 2023 10:39:08 +0000 Subject: [PATCH] update in filter for empty options array. --- lib/ui/layers/filters.mjs | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lib/ui/layers/filters.mjs b/lib/ui/layers/filters.mjs index 97d442b8c..51ef15d57 100644 --- a/lib/ui/layers/filters.mjs +++ b/lib/ui/layers/filters.mjs @@ -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); @@ -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')) }