Compare commits

..

No commits in common. "dc35e7df6d64b7370da228a382cd9a04642633a1" and "5f2e104eec762bc674bbbd0a45bfbcdfe06496fc" have entirely different histories.

8 changed files with 34 additions and 50 deletions

View file

@ -146,13 +146,14 @@ 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._needs_upsert) { if (this._just_married) {
this.sync.upsert(this.toGeoJSON(), null) this.sync.upsert(this.toGeoJSON(), null)
this._needs_upsert = false this._just_married = false
} else { } else {
this.sync.update('geometry', this.geometry, this._geometry_bk) this.sync.update('geometry', this.geometry, this._geometry_bk)
} }

View file

@ -808,10 +808,9 @@ 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}</h6> <h6 hidden=${!name}>${name}</h6>
<div class="umap-pictogram-grid" data-ref=grid></div> <div class="umap-pictogram-grid" data-ref=grid></div>
</div> </div>
`) `)

View file

@ -8,7 +8,6 @@ import { AutocompleteCommunes } from './communesfr.js'
const TEMPLATE = ` const TEMPLATE = `
<h3>Cadastre</h3> <h3>Cadastre</h3>
<p>Importer les données cadastrales dune commune française.</p> <p>Importer les données cadastrales dune 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>
@ -21,7 +20,6 @@ const TEMPLATE = `
</select> </select>
<label id="boundary"> <label id="boundary">
</label> </label>
</div>
` `
export class Importer { export class Importer {

View file

@ -16,17 +16,15 @@ 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('Simplify all geometries to points')} ${translate('Symplify 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) {

View file

@ -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._needs_upsert = true line._just_married = 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._needs_upsert = true poly._just_married = 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._needs_upsert = true point._just_married = true
return point.ui return point.ui
}, },

View file

@ -325,7 +325,6 @@ 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;
} }

View file

@ -32,15 +32,9 @@ FIXTURES = Path(__file__).parent.parent / "fixtures"
@pytest.fixture @pytest.fixture
def pictos(): def pictos():
path = FIXTURES / "star.svg" path = FIXTURES / "star.svg"
Pictogram( Pictogram(name="star", pictogram=ContentFile(path.read_text(), path.name)).save()
name="star", pictogram=ContentFile(path.read_text(), path.name), category="cat1"
).save()
path = FIXTURES / "circle.svg" path = FIXTURES / "circle.svg"
Pictogram( Pictogram(name="circle", pictogram=ContentFile(path.read_text(), path.name)).save()
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):
@ -63,8 +57,6 @@ 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")

View file

@ -1047,15 +1047,12 @@ 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()
if self.request.user.is_authenticated: home_url = reverse("home")
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=redirect_url) return simple_json_response(redirect=home_url)
else: else:
return HttpResponseRedirect(form.data.get("next") or redirect_url) return HttpResponseRedirect(form.data.get("next") or home_url)
class MapClone(PermissionsMixin, View): class MapClone(PermissionsMixin, View):