diff --git a/src/c3nav/editor/forms.py b/src/c3nav/editor/forms.py index 5e40dea6..9fb81f07 100644 --- a/src/c3nav/editor/forms.py +++ b/src/c3nav/editor/forms.py @@ -8,8 +8,8 @@ from django.conf import settings from django.core.cache import cache from django.core.exceptions import FieldDoesNotExist from django.db.models import Q -from django.forms import (BooleanField, CharField, ChoiceField, Form, ModelChoiceField, ModelForm, MultipleChoiceField, - Select, ValidationError) +from django.forms import (BooleanField, CharField, ChoiceField, DecimalField, Form, ModelChoiceField, ModelForm, + MultipleChoiceField, Select, ValidationError) from django.forms.widgets import HiddenInput from django.utils.translation import ugettext_lazy as _ from shapely.geometry.geo import mapping @@ -52,6 +52,26 @@ class EditorFormBase(I18nModelFormMixin, ModelForm): all_names = set(os.listdir(settings.SOURCES_ROOT)) self.fields['name'].widget = Select(choices=tuple((s, s) for s in sorted(all_names-used_names))) + self.fields['fixed_x'] = DecimalField(label='fixed x', required=False, + max_digits=7, decimal_places=3, initial=0) + self.fields['fixed_y'] = DecimalField(label='fixed y', required=False, + max_digits=7, decimal_places=3, initial=0) + self.fields['scale_x'] = DecimalField(label='scale x (m/px)', required=False, + max_digits=7, decimal_places=3, initial=1) + self.fields['scale_y'] = DecimalField(label='scale y (m/px)', required=False, + max_digits=7, decimal_places=3, initial=1) + self.fields['lock_aspect'] = BooleanField(label='lock aspect ratio', required=False, initial=True) + self.fields['lock_scale'] = BooleanField(label='lock scale (for moving)', required=False, initial=True) + + self.fields.move_to_end('lock_scale', last=False) + self.fields.move_to_end('lock_aspect', last=False) + self.fields.move_to_end('scale_y', last=False) + self.fields.move_to_end('scale_x', last=False) + self.fields.move_to_end('fixed_y', last=False) + self.fields.move_to_end('fixed_x', last=False) + self.fields.move_to_end('access_restriction', last=False) + self.fields.move_to_end('name', last=False) + if self._meta.model.__name__ == 'AccessRestriction': AccessRestrictionGroup = self.request.changeset.wrap_model('AccessRestrictionGroup') diff --git a/src/c3nav/editor/static/editor/css/editor.css b/src/c3nav/editor/static/editor/css/editor.css index f38ee21e..0030638b 100644 --- a/src/c3nav/editor/static/editor/css/editor.css +++ b/src/c3nav/editor/static/editor/css/editor.css @@ -52,7 +52,7 @@ body:not(.map-enabled) #sidebar { padding:12px 12px 0; margin:auto; } -#sidebar .content form .form-group:last-child { +#sidebar .content form>.form-group:last-child { margin-bottom:0; padding:0 0 12px; position:sticky; @@ -61,6 +61,18 @@ body:not(.map-enabled) #sidebar { background-color: #ffffff; box-shadow: 0 0 10px 10px #ffffff; } +#sidebar .form-group-group { + display: flex; +} +#sidebar .form-group-group .form-group { + flex-grow: 1; +} +#sidebar .form-group-group .form-group:not(:last-child) { + margin-right: 15px; +} +#sidebar form:not(.show-source-wizard) .source-wizard { + display: none; +} #noscript { font-weight:bold; color:red; diff --git a/src/c3nav/editor/static/editor/js/editor.js b/src/c3nav/editor/static/editor/js/editor.js index 5a56083e..196bf925 100644 --- a/src/c3nav/editor/static/editor/js/editor.js +++ b/src/c3nav/editor/static/editor/js/editor.js @@ -9,7 +9,7 @@ editor = { renderer: L.svg({ padding: 2 }), zoom: 2, maxZoom: 10, - minZoom: 0, + minZoom: -5, crs: L.CRS.Simple, editable: true, zoomSnap: 0 @@ -150,6 +150,51 @@ editor = { $('#navbar-collapse').find('.nav').html(nav.html()); } + if (editor._source_image_layer) { + editor._source_image_layer.remove(); + editor._source_image_layer = null; + } + + var group; + if (content.find('[name=fixed_x]')) { + $('[name=name]').change(editor._source_name_selected).change(); + if (!content.find('[data-new]').length) { + var bounds = [[parseFloat(content.find('[name=left]').val()), parseFloat(content.find('[name=bottom]').val())], [parseFloat(content.find('[name=right]').val()), parseFloat(content.find('[name=top]').val())]]; + bounds = L.GeoJSON.coordsToLatLngs(bounds); + editor.map.fitBounds(bounds, {padding: [30, 50]}); + } + + group = $('