Compare commits

..

10 commits

Author SHA1 Message Date
Yohan Boniface
dc35e7df6d
fix: fix pictogram categories always hidden (#2630)
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
2025-04-09 17:17:29 +02:00
Yohan Boniface
d9378a484d fix: fix pictogram categories always hidden 2025-04-09 16:06:20 +02:00
Yohan Boniface
cfcdfb9ed8
chore: add missing margin-bottom in importers (#2627) 2025-04-09 15:59:00 +02:00
Yohan Boniface
0b8c7ee381
chore: redirect to user dashboard after map delete (#2626)
If user is authenticated.

We do not display alert messages on the home page.
2025-04-09 15:45:11 +02:00
Yohan Boniface
36e9433cf9
Apply suggestions from code review
Co-authored-by: David Larlet <3556+davidbgk@users.noreply.github.com>
2025-04-09 15:44:36 +02:00
Yohan Boniface
425f66b181
fix: fix text overflow on search results (#2628)
Before:
![Screenshot From 2025-04-09
09-41-21](https://github.com/user-attachments/assets/727ead82-7bb7-4cdb-b676-994f84ed8eaf)

After:
![Screenshot From 2025-04-09
09-40-58](https://github.com/user-attachments/assets/e778ba59-a255-4230-9531-cdba67c444cc)

(Please don't ask :p )
2025-04-09 15:42:57 +02:00
Yohan Boniface
18f0b6e2a7 chore: rename variable to make it more explicit 2025-04-09 11:27:29 +02:00
Yohan Boniface
50f23b4e02 fix: fix text overflow on search results 2025-04-09 09:41:37 +02:00
Yohan Boniface
36d58993a0 chore: add missing margin-bottom in importers 2025-04-09 09:32:54 +02:00
Yohan Boniface
5c38bc7970 chore: redirect to user dashboard after map delete
If user is authenticated.

We do not display alert messages on the home page.
2025-04-09 08:54:44 +02:00
8 changed files with 50 additions and 34 deletions

View file

@ -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)
} }

View file

@ -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>
`) `)

View file

@ -8,18 +8,20 @@ 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>
<select name="theme"> <div class="formbox">
<option value="batiments">Bâtiments</option> <select name="theme">
<option value="communes">Communes</option> <option value="batiments">Bâtiments</option>
<option value="feuilles">Feuilles</option> <option value="communes">Communes</option>
<option value="lieux_dits">Lieux dits</option> <option value="feuilles">Feuilles</option>
<option value="parcelles" selected>Parcelles</option> <option value="lieux_dits">Lieux dits</option>
<option value="prefixes_sections">Préfixes sections</option> <option value="parcelles" selected>Parcelles</option>
<option value="sections">Sections</option> <option value="prefixes_sections">Préfixes sections</option>
<option value="subdivisions_fiscales">Subdivisions fiscales</option> <option value="sections">Sections</option>
</select> <option value="subdivisions_fiscales">Subdivisions fiscales</option>
<label id="boundary"> </select>
</label> <label id="boundary">
</label>
</div>
` `
export class Importer { export class Importer {

View file

@ -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>
<select name="theme"> <div class="formbox">
<option value="">${translate('Choose a theme')}</option> <select name="theme">
</select> <option value="">${translate('Choose a theme')}</option>
<label> </select>
<input type="checkbox" name="aspoint" /> <label>
${translate('Symplify all geometries to points')} <input type="checkbox" name="aspoint" />
</label> ${translate('Simplify all geometries to points')}
<label id="boundary"> </label>
</label> <label id="boundary">
</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._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
}, },

View file

@ -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;
} }

View file

@ -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")

View file

@ -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):