From 028f25424bf00987856c350c06b6035863120b7a Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 9 Jan 2018 09:55:51 +0100 Subject: Workon forms layout --- .../templates/ishtar/blocks/OAWidget.html | 5 ++- ishtar_common/forms.py | 5 ++- ishtar_common/static/js/ishtar.js | 4 +++ .../templates/blocks/bs_form_snippet.html | 37 +++++++++++++--------- ishtar_common/widgets.py | 7 ++-- 5 files changed, 39 insertions(+), 19 deletions(-) diff --git a/archaeological_operations/templates/ishtar/blocks/OAWidget.html b/archaeological_operations/templates/ishtar/blocks/OAWidget.html index a1df5a00c..1cce45909 100644 --- a/archaeological_operations/templates/ishtar/blocks/OAWidget.html +++ b/archaeological_operations/templates/ishtar/blocks/OAWidget.html @@ -1 +1,4 @@ -OA +
+ OA + +
\ No newline at end of file diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py index bdd8e6b09..b31a3143f 100644 --- a/ishtar_common/forms.py +++ b/ishtar_common/forms.py @@ -343,7 +343,10 @@ class IshtarForm(forms.Form): def __init__(self, *args, **kwargs): super(IshtarForm, self).__init__(*args, **kwargs) for k in self.fields: - self.fields[k].widget.attrs['class'] = 'form-control' + cls = 'form-control' + if 'class' in self.fields[k].widget.attrs: + cls = self.fields[k].widget.attrs['class'] + " " + cls + self.fields[k].widget.attrs['class'] = cls class FieldType(object): diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 026151953..31621502d 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -293,6 +293,10 @@ function load_window(url, speed, on_success){ $("#window").append(html); } $("#"+last_window).show(); + // jump to this window + var url = location.href; + location.href = "#" + last_window; + history.replaceState(null, null, url); if (on_success) on_success(); }, error:function(XMLHttpRequest, textStatus, errorThrows){ diff --git a/ishtar_common/templates/blocks/bs_form_snippet.html b/ishtar_common/templates/blocks/bs_form_snippet.html index a6997507c..e58df1832 100644 --- a/ishtar_common/templates/blocks/bs_form_snippet.html +++ b/ishtar_common/templates/blocks/bs_form_snippet.html @@ -63,21 +63,28 @@ {% endif %}
- {{ field.label_tag }} - {{field|safe}} - {% if field.errors %}
- {{ field.errors }} -
{% endif %} - {% if field.help_text %} - -
-
- {{field.help_text}} -
-
- {% endif %} + {{ field.label_tag }} + {% if field.help_text %} +
+ {% endif %} + {{field|safe}} + {% if field.help_text %} + + + +
+
+
+ {{field.help_text}} +
+
+ {% endif %} + {% if field.errors %}
+ {{ field.errors }} +
{% endif %}
{% if forloop.last %} {% if search and forloop.counter0 >= 1 %} diff --git a/ishtar_common/widgets.py b/ishtar_common/widgets.py index 6abaa927b..c34642cf1 100644 --- a/ishtar_common/widgets.py +++ b/ishtar_common/widgets.py @@ -277,6 +277,7 @@ class SquareMeterWidget(forms.TextInput): rendered = t.render(dct) return mark_safe(rendered) + AreaWidget = forms.TextInput if settings.SURFACE_UNIT == 'square-metre': @@ -424,6 +425,8 @@ class JQueryAutoComplete(forms.TextInput): attrs_select['id'] = 'id_select_%s' % name if 'class' not in attrs_select: attrs_select['class'] = 'autocomplete' + + attrs_select['class'] += ' form-control' new = '' if self.new: model_name = self.associated_model._meta.object_name.lower() @@ -440,11 +443,11 @@ class JQueryAutoComplete(forms.TextInput): url_new = reverse(url_new, args=args) new = u' +' % url_new - html = u'''%(new)s\ + html = u"""%(new)s\ \ - ''' % { + """ % { 'attrs_select': flatatt(attrs_select), 'attrs_hidden': flatatt(attrs_hidden), 'js': self.render_js(name), -- cgit v1.2.3