Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions assets/src/legacy/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,10 @@ var lizLayerFilterTool = function () {
if (filterMethod == 'simple') {
// Use a simple filter only for the getmap and other WMS/WFS queries
lizMap.triggerLayerFilter(layerName, filter);

// Show the "deactivate current filter" button in the layer switcher
lizMap.lizmapLayerFilterActive = layerName;
$('#layerActionUnfilter').toggle(true);
} else {
// Get the filtered features fids
var pkField = lizMap.config.attributeLayers[layerName]['primaryKey'];
Expand Down Expand Up @@ -1077,6 +1081,12 @@ var lizLayerFilterTool = function () {
// Use a simple filter only for the getmap and other WMS/WFS queries
lizMap.deactivateMaplayerFilter(layerName);

// Hide the "deactivate current filter" button in the layer switcher
if (lizMap.lizmapLayerFilterActive === layerName) {
lizMap.lizmapLayerFilterActive = null;
}
$('#layerActionUnfilter').toggle((lizMap.lizmapLayerFilterActive !== null));

// Refresh plots
lizMap.events.triggerEvent("layerFilterParamChanged",
{
Expand Down
28 changes: 28 additions & 0 deletions tests/end2end/playwright/form-filter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,32 @@ test.describe('Form filter', () => {
await expect(page.locator('#ui-id-2 .ui-menu-item')).toHaveCount(1);
await expect(page.locator('#ui-id-2 .ui-menu-item div')).toHaveText('monuments');
});

test('Deactivate filter button shows up with the "simple" filter method', async ({ page }) => {
// Force the 'simple' filtering method (bypasses the attribute table code path)
// https://github.com/3liz/lizmap-web-client/issues/6775
await page.evaluate(() => { globalThis['filterConfigData'].filterMethod = 'simple'; });

const unfilterButton = page.locator('#layerActionUnfilter');

// The "Deactivate current filter" button lives in the layer switcher dock,
// opening it switches away from the filter dock (docks are mutually exclusive)
await page.locator('#button-switcher').click();
await expect(unfilterButton).toBeHidden();

// Re-open the filter dock to apply the filter
await page.locator('#button-filter').click();
await page.locator('#liz-filter-field-test_filter').selectOption('_uvres_d_art_et_monuments_de_l_espace_urbain');
await expect(page.locator('#liz-filter-item-layer-total-count')).toHaveText('1');

// Bug #6775: this button stayed hidden before the fix
await page.locator('#button-switcher').click();
await expect(unfilterButton).toBeVisible();

await unfilterButton.click();
await expect(unfilterButton).toBeHidden();

await page.locator('#button-filter').click();
await expect(page.locator('#liz-filter-item-layer-total-count')).toHaveText('4');
});
});
Loading