Skip to content

Commit

Permalink
Merge pull request #1501 from simon-leech/minmax-filter
Browse files Browse the repository at this point in the history
Pass filter to minmax
  • Loading branch information
dbauszus-glx authored Sep 26, 2024
2 parents 6206229 + 1fd011d commit d2141bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/ui/layers/filters.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ async function generateMinMax(layer, filter) {
layer: layer.key,
table: layer.tableCurrent(),
field: filter.field,
filter: layer.filter?.current
})}`);

// Assign min, max from response if not a number.
Expand Down
19 changes: 18 additions & 1 deletion tests/lib/ui/layers/filters.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function filtersTest(mapview) {
//Delete the min value from the filter
delete filter.min;

//Delte the lte value of the current filter otherwise it will not be changed in the next test
//Delete the lte value of the current filter otherwise it will not be changed in the next test
delete layer.filter.current[filter.field].lte;
});

Expand All @@ -67,5 +67,22 @@ export async function filtersTest(mapview) {
codi.assertEqual(minInput.value, '100', 'The min should return 100.');
codi.assertEqual(maxInput.value, '1000', 'The max should return 1000');
});

await codi.it('Numeric Filter: layer.current specified as `lte: 200` and `gte: 800`', async () => {

layer.filter.current[filter.field].lte = 800
layer.filter.current[filter.field].gte = 200

const numericFilter = await mapp.ui.layers.filters.numeric(layer, filter);
const minInput = numericFilter.querySelector('div > input[type=range]:nth-child(3)');
const maxInput = numericFilter.querySelector('div > input[type=range]:nth-child(4)');

codi.assertEqual(minInput.value, '200', 'The min should return 200.');
codi.assertEqual(maxInput.value, '800', 'The max should return 800');

//Delete the lte/gte value of the current filter otherwise it will not be changed in the next test
delete layer.filter.current[filter.field].lte;
delete layer.filter.current[filter.field].gte;
})
});
}

0 comments on commit d2141bb

Please sign in to comment.