Compare commits

..

6 commits

Author SHA1 Message Date
Yohan Boniface
815ff046ff chore: mention nginx mapping in asgi documentation
Some checks failed
Test & Docs / tests (postgresql, 3.10) (push) Has been cancelled
Test & Docs / tests (postgresql, 3.12) (push) Has been cancelled
Test & Docs / lint (push) Has been cancelled
Test & Docs / docs (push) Has been cancelled
Co-authored-by: David Larlet <david@larlet.fr>
2025-02-07 16:25:34 +01:00
Yohan Boniface
76c13a61a6 fixup: do not show empty helpText for editors and owner fields 2025-02-07 15:35:49 +01:00
Yohan Boniface
ad51f674ef
fix: do not import empty features (#2485) 2025-02-07 15:26:42 +01:00
Yohan Boniface
8949d6fa71
fix: do not sync twice a point move (#2486) 2025-02-07 15:26:25 +01:00
Yohan Boniface
009b32c818 fix: do not sync twice a point move 2025-02-07 10:08:58 +01:00
Yohan Boniface
9af74b0a4e fix: do not import empty features 2025-02-07 09:11:16 +01:00
6 changed files with 81 additions and 6 deletions

View file

@ -22,6 +22,15 @@ location / {
} }
``` ```
Also add this mapping for the `$connection_upgrade` variable:
```
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
```
## Uvicorn ## Uvicorn
Uvicorn must be installed in the umap virtualenv: Uvicorn must be installed in the umap virtualenv:

View file

@ -564,6 +564,10 @@ class Feature {
return false return false
} }
isEmpty() {
return !this.coordinates.length
}
clone() { clone() {
const geojson = this.toGeoJSON() const geojson = this.toGeoJSON()
delete geojson.id delete geojson.id
@ -951,10 +955,6 @@ export class LineString extends Path {
return { coordinates, type } return { coordinates, type }
} }
isEmpty() {
return !this.coordinates.length
}
getUIClass() { getUIClass() {
return super.getUIClass() || LeafletPolyline return super.getUIClass() || LeafletPolyline
} }

View file

@ -522,7 +522,7 @@ export class DataLayer extends ServerStored {
}) })
) )
} }
if (feature) { if (feature && !feature.isEmpty()) {
this.addFeature(feature) this.addFeature(feature)
if (sync) feature.onCommit() if (sync) feature.onCommit()
return feature return feature

View file

@ -1251,6 +1251,7 @@ Fields.Range = class extends Fields.FloatInput {
Fields.ManageOwner = class extends BaseElement { Fields.ManageOwner = class extends BaseElement {
build() { build() {
super.build()
const options = { const options = {
className: 'edit-owner', className: 'edit-owner',
on_select: L.bind(this.onSelect, this), on_select: L.bind(this.onSelect, this),
@ -1281,6 +1282,7 @@ Fields.ManageOwner = class extends BaseElement {
Fields.ManageEditors = class extends BaseElement { Fields.ManageEditors = class extends BaseElement {
build() { build() {
super.build()
const options = { const options = {
className: 'edit-editors', className: 'edit-editors',
on_select: L.bind(this.onSelect, this), on_select: L.bind(this.onSelect, this),

View file

@ -119,7 +119,7 @@ const PointMixin = {
this.on('dragend', (event) => { this.on('dragend', (event) => {
this.isDirty = true this.isDirty = true
this.feature.edit(event) this.feature.edit(event)
this.feature.pullGeometry() this.feature.pullGeometry(false)
}) })
if (!this.feature.isReadOnly()) this.on('mouseover', this._enableDragging) if (!this.feature.isReadOnly()) this.on('mouseover', this._enableDragging)
this.on('mouseout', this._onMouseOut) this.on('mouseout', this._onMouseOut)

View file

@ -500,6 +500,70 @@ def test_import_multipolyline(live_server, page, tilelayer):
expect(paths).to_have_count(1) expect(paths).to_have_count(1)
def test_should_not_import_empty_coordinates(live_server, page, tilelayer):
data = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {"name": "An empty polygon"},
"geometry": {
"type": "Polygon",
"coordinates": [],
},
},
{
"type": "Feature",
"properties": {"name": "An empty linestring"},
"geometry": {
"type": "LineString",
"coordinates": [],
},
},
{
"type": "Feature",
"properties": {"name": "An empty point"},
"geometry": {
"type": "Point",
"coordinates": [],
},
},
{
"geometry": {
"type": "Point",
"coordinates": [6.922931671142578, 47.481161607175736],
},
"type": "Feature",
"properties": {"name": "A point"},
},
{
"geometry": {
"type": "LineString",
"coordinates": [
[2.4609375, 48.88639177703194],
[2.48291015625, 48.76343113791796],
[2.164306640625, 48.719961222646276],
],
},
"type": "Feature",
"properties": {
"name": "A linestring",
},
},
],
}
page.goto(f"{live_server.url}/map/new/")
page.get_by_title("Open browser").click()
page.get_by_title("Import data").click()
textarea = page.locator(".umap-import textarea")
textarea.fill(json.dumps(data))
page.locator('select[name="format"]').select_option("geojson")
page.get_by_role("button", name="Import data", exact=True).click()
page.locator("#map").click(button="right")
page.get_by_role("button", name="browse data").click()
expect(page.locator("li.feature")).to_have_count(2)
def test_import_csv_without_valid_latlon_headers(tilelayer, live_server, page): def test_import_csv_without_valid_latlon_headers(tilelayer, live_server, page):
page.goto(f"{live_server.url}/map/new/") page.goto(f"{live_server.url}/map/new/")
page.get_by_title("Open browser").click() page.get_by_title("Open browser").click()