diff --git a/src/c3nav/editor/forms.py b/src/c3nav/editor/forms.py index c7bb105c..ec9a1c0c 100644 --- a/src/c3nav/editor/forms.py +++ b/src/c3nav/editor/forms.py @@ -422,6 +422,7 @@ def create_editor_form(editor_model): 'color_ground_fill', 'color_obstacles_default_fill', 'color_obstacles_default_border', 'stroke_color', 'stroke_width', 'fill_color', 'interactive', 'point_icon', 'extra_data', 'show_label', 'show_geometry', 'external_url', + 'show_label', 'show_geometry', 'external_url', 'default_geomtype', ] field_names = [field.name for field in editor_model._meta.get_fields() if not field.one_to_many and not isinstance(field, ManyToManyRel)] diff --git a/src/c3nav/editor/static/editor/js/editor.js b/src/c3nav/editor/static/editor/js/editor.js index a76f4643..7fedeb2f 100644 --- a/src/c3nav/editor/static/editor/js/editor.js +++ b/src/c3nav/editor/static/editor/js/editor.js @@ -1370,6 +1370,7 @@ editor = { } form.addClass('creation-lock'); const geomtypes = form.attr('data-geomtype').split(','); + const default_geomtype = form.attr('data-default-geomtype'); const startGeomEditing = (geomtype) => { editor._creating_type = geomtype; @@ -1387,6 +1388,8 @@ editor = { } } + let selected_geomtype = geomtypes[0]; + if (geomtypes.length > 1) { const selector = $(''); const geomtypeNames = { @@ -1395,13 +1398,18 @@ editor = { point: 'Point' }; // TODO: translations for(const geomtype of geomtypes) { - selector.append(``); + const option = $(``); + if (geomtype === default_geomtype) { + option.attr('selected', true); + selected_geomtype = geomtype; + } + selector.append(option); } selector.on('change', e => startGeomEditing(e.target.value)); form.prepend(selector); } - startGeomEditing(geomtypes[0]); + startGeomEditing(selected_geomtype); } } }, diff --git a/src/c3nav/editor/templates/editor/edit.html b/src/c3nav/editor/templates/editor/edit.html index faa0455e..54bae714 100644 --- a/src/c3nav/editor/templates/editor/edit.html +++ b/src/c3nav/editor/templates/editor/edit.html @@ -20,7 +20,7 @@ {% endif %} {% bootstrap_messages %} -