Fix editing empty geometry collection

Signed-off-by: Maximilian Krög <maxi_kroeg@web.de>
This commit is contained in:
Maximilian Krög 2023-08-14 00:12:43 +02:00
parent 135724f0d4
commit 00d1774c36
No known key found for this signature in database
GPG Key ID: 3C00897BB53AAB9C
2 changed files with 10 additions and 4 deletions

View File

@ -375,7 +375,7 @@ AJAX.registerOnload('gis_data_editor.js', function () {
var noOfGeoms = parseInt($noOfGeomsInput.val(), 10);
var html1 = Messages.strGeometry + ' ' + (noOfGeoms + 1) + ':<br>';
var $geomType = $('select[name=\'gis_data[' + (noOfGeoms - 1) + '][gis_type]\']').clone();
var $geomType = $('#gis_type_template').contents().filter('select').clone();
$geomType.attr('name', 'gis_data[' + noOfGeoms + '][gis_type]').val('POINT');
var html2 = '<br>' + Messages.strPoint + ' :' +
'<label for="x"> ' + Messages.strX + ' </label>' +
@ -384,9 +384,7 @@ AJAX.registerOnload('gis_data_editor.js', function () {
'<input type="text" name="gis_data[' + noOfGeoms + '][POINT][y]" value="">' +
'<br><br>';
$a.before(html1);
$geomType.insertBefore($a);
$a.before(html2);
$a.before(html1, $geomType, html2);
$noOfGeomsInput.val(noOfGeoms + 1);
});
});

View File

@ -46,6 +46,14 @@
<input type="hidden" name="gis_data[GEOMETRYCOLLECTION][geom_count]" value="{{ geom_count }}">
{% endif %}
<template id="gis_type_template">
<select class="gis_type">
{% for gis_type in gis_types|slice(0, 6) %}
<option value="{{ gis_type }}">{{ gis_type }}</option>
{% endfor %}
</select>
</template>
{% for a in 0..geom_count - 1 %}
{% if gis_data[a] is not null %}
{% if geom_type == 'GEOMETRYCOLLECTION' %}