mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
parent
c14ab4198f
commit
c58964d797
3 changed files with 27 additions and 2 deletions
|
@ -508,7 +508,12 @@ class Feature {
|
|||
|
||||
matchFilter(filter, keys) {
|
||||
filter = filter.toLowerCase()
|
||||
if (Utils.hasVar(keys)) {
|
||||
// When user hasn't touched settings, when a feature has no name
|
||||
// it will use the datalayer's name, so let's make the filtering
|
||||
// consistent.
|
||||
// Also, if the user has defined a labelKey with vars, let's
|
||||
// compute before filtering
|
||||
if (Utils.hasVar(keys) || keys === 'displayName') {
|
||||
return this.getDisplayName().toLowerCase().indexOf(filter) !== -1
|
||||
}
|
||||
keys = keys.split(',')
|
||||
|
|
|
@ -1115,7 +1115,7 @@ export class DataLayer {
|
|||
if (this.map.options.filterKey) return this.map.options.filterKey
|
||||
if (this.getOption('labelKey')) return this.getOption('labelKey')
|
||||
if (this.map.options.sortKey) return this.map.options.sortKey
|
||||
return 'name'
|
||||
return 'displayName'
|
||||
}
|
||||
|
||||
renderLegend(container) {
|
||||
|
|
|
@ -176,6 +176,26 @@ def test_filter_works_with_variable_in_labelKey(live_server, page, map):
|
|||
expect(paths).to_have_count(1) # Only polygon
|
||||
|
||||
|
||||
def test_filter_works_with_missing_name(live_server, page, map):
|
||||
map.settings["properties"]["onLoadPanel"] = "databrowser"
|
||||
map.save()
|
||||
data = deepcopy(DATALAYER_DATA)
|
||||
del data["features"][0]["properties"]["name"]
|
||||
DataLayerFactory(map=map, data=data, name="foobar")
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}")
|
||||
expect(page.get_by_title("Features in this layer: 3")).to_be_visible()
|
||||
markers = page.locator(".leaflet-marker-icon")
|
||||
paths = page.locator(".leaflet-overlay-pane path")
|
||||
expect(markers).to_have_count(1)
|
||||
expect(paths).to_have_count(2)
|
||||
page.locator(".filters summary").click()
|
||||
filter_ = page.locator("input[name='filter']")
|
||||
expect(filter_).to_be_visible()
|
||||
filter_.type("foob")
|
||||
expect(markers).to_have_count(1)
|
||||
expect(paths).to_have_count(0)
|
||||
|
||||
|
||||
def test_data_browser_can_show_only_visible_features(live_server, page, bootstrap, map):
|
||||
# Zoom on France
|
||||
page.goto(f"{live_server.url}{map.get_absolute_url()}#6/51.000/2.000")
|
||||
|
|
Loading…
Reference in a new issue