feat: add management zone form template and corresponding unit tests
This commit is contained in:
parent
0c1ae3163d
commit
e87fe1531d
2 changed files with 67 additions and 1 deletions
|
|
@ -240,6 +240,7 @@
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
|
||||||
{% block script %}
|
{% block script %}
|
||||||
|
<script src="{% static 'common/layer-switcher-control.js' %}"></script>
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function () {
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
const mapDiv = document.getElementById("zonePickerMap");
|
const mapDiv = document.getElementById("zonePickerMap");
|
||||||
|
|
@ -308,7 +309,68 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
cooperativeGestures: true
|
cooperativeGestures: true
|
||||||
});
|
});
|
||||||
|
|
||||||
map.addControl(new maplibregl.NavigationControl(), 'top-right');
|
// 1. Fond de plan & Orthophotos (LayerSwitcherControl)
|
||||||
|
if (typeof LayerSwitcherControl !== 'undefined') {
|
||||||
|
const layerSwitcher = new LayerSwitcherControl({
|
||||||
|
layers: [{
|
||||||
|
id: 'basemap',
|
||||||
|
name: "{% translate 'Fonds de plan & Orthophotos' %}",
|
||||||
|
icon: 'satellite',
|
||||||
|
group: 'basemap',
|
||||||
|
beforeLayer: function (mapInstance) {
|
||||||
|
if (mapInstance && mapInstance.getLayer('poly-preview-fill')) {
|
||||||
|
return 'poly-preview-fill';
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
},
|
||||||
|
layer: {
|
||||||
|
type: 'raster',
|
||||||
|
paint: { 'raster-opacity': 1 }
|
||||||
|
},
|
||||||
|
basemaps: (window.MAP_BACKGROUNDS && window.MAP_BACKGROUNDS.length > 0) ? window.MAP_BACKGROUNDS : undefined,
|
||||||
|
sublayers: [
|
||||||
|
{
|
||||||
|
id: 'urbis',
|
||||||
|
name: window.MAP_ORTHO_WMS_NAME || 'Urbis (Bruxelles)',
|
||||||
|
default: true,
|
||||||
|
source: {
|
||||||
|
type: 'raster',
|
||||||
|
tiles: [
|
||||||
|
window.MAP_ORTHO_WMS_URL || 'https://geoservices-urbis.irisnet.be/geoserver/urbisgrid/wms?service=WMS&version=1.3.0&request=GetMap&layers=Ortho&styles=&format=image/png&transparent=true&width=256&height=256&crs=EPSG:3857&bbox={bbox-epsg-3857}'
|
||||||
|
],
|
||||||
|
tileSize: 256,
|
||||||
|
attribution: window.MAP_ORTHO_WMS_ATTRIBUTION || '© Brussels UrbIS'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'vlaanderen',
|
||||||
|
name: 'Vlaanderen 2023',
|
||||||
|
source: {
|
||||||
|
type: 'raster',
|
||||||
|
tiles: [
|
||||||
|
'https://geo.api.vlaanderen.be/OMW/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=omwrgb23vl&STYLE=&FORMAT=image/png&TILEMATRIXSET=GoogleMapsVL&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}'
|
||||||
|
],
|
||||||
|
tileSize: 256,
|
||||||
|
attribution: '© Digitaal Vlaanderen - Orthofoto 2023'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
map.addControl(layerSwitcher, 'top-right');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Navigation Control (Zoom +/- & Pitch/Bearing)
|
||||||
|
map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), 'top-right');
|
||||||
|
|
||||||
|
// 3. Outil de recherche d'adresse
|
||||||
|
if (typeof AddressSearchControl !== 'undefined') {
|
||||||
|
const searchCtrl = new AddressSearchControl({
|
||||||
|
autocompleteUrl: "{% url 'common:autocomplete_street' %}",
|
||||||
|
placeholder: "{% translate 'Rechercher une adresse…' %}"
|
||||||
|
});
|
||||||
|
map.addControl(searchCtrl, 'top-left');
|
||||||
|
}
|
||||||
|
|
||||||
function getColor() {
|
function getColor() {
|
||||||
return colorInput ? colorInput.value : "#198754";
|
return colorInput ? colorInput.value : "#198754";
|
||||||
|
|
|
||||||
|
|
@ -364,6 +364,8 @@ class ManagementZonesPermissionAndCRUDTests(TestCase):
|
||||||
self.client.login(username="editor", password="password")
|
self.client.login(username="editor", password="password")
|
||||||
res = self.client.get(url)
|
res = self.client.get(url)
|
||||||
self.assertEqual(res.status_code, 200)
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertContains(res, "layer-switcher-control.js")
|
||||||
|
self.assertContains(res, "AddressSearchControl")
|
||||||
|
|
||||||
# Post valid zone
|
# Post valid zone
|
||||||
geojson_polygon = {
|
geojson_polygon = {
|
||||||
|
|
@ -401,6 +403,8 @@ class ManagementZonesPermissionAndCRUDTests(TestCase):
|
||||||
self.client.login(username="editor", password="password")
|
self.client.login(username="editor", password="password")
|
||||||
res = self.client.get(url)
|
res = self.client.get(url)
|
||||||
self.assertEqual(res.status_code, 200)
|
self.assertEqual(res.status_code, 200)
|
||||||
|
self.assertContains(res, "layer-switcher-control.js")
|
||||||
|
self.assertContains(res, "AddressSearchControl")
|
||||||
|
|
||||||
post_data = {
|
post_data = {
|
||||||
'code': self.zone.code,
|
'code': self.zone.code,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue