mirror of
https://github.com/umap-project/umap.git
synced 2025-05-04 21:51:50 +02:00
Compare commits
10 commits
5f2e104eec
...
dc35e7df6d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
dc35e7df6d | ||
![]() |
d9378a484d | ||
![]() |
cfcdfb9ed8 | ||
![]() |
0b8c7ee381 | ||
![]() |
36e9433cf9 | ||
![]() |
425f66b181 | ||
![]() |
18f0b6e2a7 | ||
![]() |
50f23b4e02 | ||
![]() |
36d58993a0 | ||
![]() |
5c38bc7970 |
8 changed files with 50 additions and 34 deletions
|
@ -146,14 +146,13 @@ class Feature {
|
||||||
}
|
}
|
||||||
|
|
||||||
onCommit() {
|
onCommit() {
|
||||||
|
this.pullGeometry(false)
|
||||||
// When the layer is a remote layer, we don't want to sync the creation of the
|
// When the layer is a remote layer, we don't want to sync the creation of the
|
||||||
// points via the websocket, as the other peers will get them themselves.
|
// points via the websocket, as the other peers will get them themselves.
|
||||||
const oldGeoJSON = this._just_married ? null : Utils.CopyJSON(this.toGeoJSON())
|
|
||||||
this.pullGeometry(false)
|
|
||||||
if (this.datalayer?.isRemoteLayer()) return
|
if (this.datalayer?.isRemoteLayer()) return
|
||||||
if (this._just_married) {
|
if (this._needs_upsert) {
|
||||||
this.sync.upsert(this.toGeoJSON(), null)
|
this.sync.upsert(this.toGeoJSON(), null)
|
||||||
this._just_married = false
|
this._needs_upsert = false
|
||||||
} else {
|
} else {
|
||||||
this.sync.update('geometry', this.geometry, this._geometry_bk)
|
this.sync.update('geometry', this.geometry, this._geometry_bk)
|
||||||
}
|
}
|
||||||
|
|
|
@ -808,9 +808,10 @@ Fields.IconUrl = class extends Fields.BlurInput {
|
||||||
}
|
}
|
||||||
|
|
||||||
addCategory(items, name) {
|
addCategory(items, name) {
|
||||||
|
const hidden = name ? '' : ' hidden'
|
||||||
const [parent, { grid }] = Utils.loadTemplateWithRefs(`
|
const [parent, { grid }] = Utils.loadTemplateWithRefs(`
|
||||||
<div class="umap-pictogram-category">
|
<div class="umap-pictogram-category">
|
||||||
<h6 hidden=${!name}>${name}</h6>
|
<h6${hidden}>${name}</h6>
|
||||||
<div class="umap-pictogram-grid" data-ref=grid></div>
|
<div class="umap-pictogram-grid" data-ref=grid></div>
|
||||||
</div>
|
</div>
|
||||||
`)
|
`)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { AutocompleteCommunes } from './communesfr.js'
|
||||||
const TEMPLATE = `
|
const TEMPLATE = `
|
||||||
<h3>Cadastre</h3>
|
<h3>Cadastre</h3>
|
||||||
<p>Importer les données cadastrales d’une commune française.</p>
|
<p>Importer les données cadastrales d’une commune française.</p>
|
||||||
|
<div class="formbox">
|
||||||
<select name="theme">
|
<select name="theme">
|
||||||
<option value="batiments">Bâtiments</option>
|
<option value="batiments">Bâtiments</option>
|
||||||
<option value="communes">Communes</option>
|
<option value="communes">Communes</option>
|
||||||
|
@ -20,6 +21,7 @@ const TEMPLATE = `
|
||||||
</select>
|
</select>
|
||||||
<label id="boundary">
|
<label id="boundary">
|
||||||
</label>
|
</label>
|
||||||
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
export class Importer {
|
export class Importer {
|
||||||
|
|
|
@ -16,15 +16,17 @@ const BOUNDARY_TYPES = {
|
||||||
const TEMPLATE = `
|
const TEMPLATE = `
|
||||||
<h3>GeoDataMine</h3>
|
<h3>GeoDataMine</h3>
|
||||||
<p>${translate('GeoDataMine: thematic data from OpenStreetMap')}.</p>
|
<p>${translate('GeoDataMine: thematic data from OpenStreetMap')}.</p>
|
||||||
|
<div class="formbox">
|
||||||
<select name="theme">
|
<select name="theme">
|
||||||
<option value="">${translate('Choose a theme')}</option>
|
<option value="">${translate('Choose a theme')}</option>
|
||||||
</select>
|
</select>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" name="aspoint" />
|
<input type="checkbox" name="aspoint" />
|
||||||
${translate('Symplify all geometries to points')}
|
${translate('Simplify all geometries to points')}
|
||||||
</label>
|
</label>
|
||||||
<label id="boundary">
|
<label id="boundary">
|
||||||
</label>
|
</label>
|
||||||
|
</div>
|
||||||
`
|
`
|
||||||
|
|
||||||
class Autocomplete extends SingleMixin(BaseAjax) {
|
class Autocomplete extends SingleMixin(BaseAjax) {
|
||||||
|
|
|
@ -629,7 +629,7 @@ U.Editable = L.Editable.extend({
|
||||||
const line = new U.LineString(this._umap, datalayer, {
|
const line = new U.LineString(this._umap, datalayer, {
|
||||||
geometry: { type: 'LineString', coordinates: [] },
|
geometry: { type: 'LineString', coordinates: [] },
|
||||||
})
|
})
|
||||||
line._just_married = true
|
line._needs_upsert = true
|
||||||
return line.ui
|
return line.ui
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ U.Editable = L.Editable.extend({
|
||||||
const poly = new U.Polygon(this._umap, datalayer, {
|
const poly = new U.Polygon(this._umap, datalayer, {
|
||||||
geometry: { type: 'Polygon', coordinates: [] },
|
geometry: { type: 'Polygon', coordinates: [] },
|
||||||
})
|
})
|
||||||
poly._just_married = true
|
poly._needs_upsert = true
|
||||||
return poly.ui
|
return poly.ui
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ U.Editable = L.Editable.extend({
|
||||||
const point = new U.Point(this._umap, datalayer, {
|
const point = new U.Point(this._umap, datalayer, {
|
||||||
geometry: { type: 'Point', coordinates: [latlng.lng, latlng.lat] },
|
geometry: { type: 'Point', coordinates: [latlng.lng, latlng.lat] },
|
||||||
})
|
})
|
||||||
point._just_married = true
|
point._needs_upsert = true
|
||||||
return point.ui
|
return point.ui
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -325,6 +325,7 @@ ul.photon-autocomplete {
|
||||||
}
|
}
|
||||||
.umap-edit-enabled .photon-autocomplete li.on .search-result-tools {
|
.umap-edit-enabled .photon-autocomplete li.on .search-result-tools {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,15 @@ FIXTURES = Path(__file__).parent.parent / "fixtures"
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def pictos():
|
def pictos():
|
||||||
path = FIXTURES / "star.svg"
|
path = FIXTURES / "star.svg"
|
||||||
Pictogram(name="star", pictogram=ContentFile(path.read_text(), path.name)).save()
|
Pictogram(
|
||||||
|
name="star", pictogram=ContentFile(path.read_text(), path.name), category="cat1"
|
||||||
|
).save()
|
||||||
path = FIXTURES / "circle.svg"
|
path = FIXTURES / "circle.svg"
|
||||||
Pictogram(name="circle", pictogram=ContentFile(path.read_text(), path.name)).save()
|
Pictogram(
|
||||||
|
name="circle",
|
||||||
|
pictogram=ContentFile(path.read_text(), path.name),
|
||||||
|
category="cat2",
|
||||||
|
).save()
|
||||||
|
|
||||||
|
|
||||||
def test_can_change_picto_at_map_level(openmap, live_server, page, pictos):
|
def test_can_change_picto_at_map_level(openmap, live_server, page, pictos):
|
||||||
|
@ -57,6 +63,8 @@ def test_can_change_picto_at_map_level(openmap, live_server, page, pictos):
|
||||||
define.click()
|
define.click()
|
||||||
# No picto defined yet, so recent should not be visible
|
# No picto defined yet, so recent should not be visible
|
||||||
expect(page.get_by_text("Recent")).to_be_hidden()
|
expect(page.get_by_text("Recent")).to_be_hidden()
|
||||||
|
expect(page.get_by_text("cat1")).to_be_visible()
|
||||||
|
expect(page.get_by_text("cat2")).to_be_visible()
|
||||||
symbols = page.locator(".umap-pictogram-body .umap-pictogram-choice")
|
symbols = page.locator(".umap-pictogram-body .umap-pictogram-choice")
|
||||||
expect(symbols).to_have_count(2)
|
expect(symbols).to_have_count(2)
|
||||||
search = page.locator(".umap-pictogram-body input")
|
search = page.locator(".umap-pictogram-body input")
|
||||||
|
|
|
@ -1047,12 +1047,15 @@ class MapDelete(DeleteView):
|
||||||
if not self.object.can_delete(self.request):
|
if not self.object.can_delete(self.request):
|
||||||
return HttpResponseForbidden(_("Only its owner can delete the map."))
|
return HttpResponseForbidden(_("Only its owner can delete the map."))
|
||||||
self.object.move_to_trash()
|
self.object.move_to_trash()
|
||||||
home_url = reverse("home")
|
if self.request.user.is_authenticated:
|
||||||
|
redirect_url = reverse("user_dashboard")
|
||||||
|
else:
|
||||||
|
redirect_url = reverse("home")
|
||||||
messages.info(self.request, _("Map successfully deleted."))
|
messages.info(self.request, _("Map successfully deleted."))
|
||||||
if is_ajax(self.request):
|
if is_ajax(self.request):
|
||||||
return simple_json_response(redirect=home_url)
|
return simple_json_response(redirect=redirect_url)
|
||||||
else:
|
else:
|
||||||
return HttpResponseRedirect(form.data.get("next") or home_url)
|
return HttpResponseRedirect(form.data.get("next") or redirect_url)
|
||||||
|
|
||||||
|
|
||||||
class MapClone(PermissionsMixin, View):
|
class MapClone(PermissionsMixin, View):
|
||||||
|
|
Loading…
Reference in a new issue