From a4cac1fcab7d033fdd3a35174c825e925c3eb4a7 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Tue, 10 Jul 2018 13:34:38 +0200 Subject: UI: improve layout and action for search --- ishtar_common/forms_common.py | 8 ++-- ishtar_common/static/js/ishtar.js | 7 ++- ishtar_common/static/media/styles.css | 21 --------- .../templates/blocks/bs_field_snippet.html | 2 +- .../templates/ishtar/forms/search_query.html | 18 ++++---- ishtar_common/templates/widgets/search_input.html | 39 +++++++++++------ scss/custom.scss | 50 +++++++++++++++++++++- 7 files changed, 94 insertions(+), 51 deletions(-) diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 43652ba07..397b87815 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -1280,11 +1280,11 @@ AuthorFormset.form_slug = "authors" class SearchQueryForm(forms.Form): - query = forms.CharField(max_length=None, label=_(u"Query"), disabled=True, - initial='*') - search_query = forms.ChoiceField(label=_(u"Search query"), required=False, + query = forms.CharField(max_length=None, label=_(u"Query"), initial='*', + widget=forms.HiddenInput) + search_query = forms.ChoiceField(label="", required=False, choices=[]) - label = forms.CharField(max_length=None, label=_(u"Name"), required=False) + label = forms.CharField(label="", max_length=None, required=False) is_alert = forms.BooleanField(label=_(u"Is an alert"), required=False) create_or_update = forms.ChoiceField( choices=(('create', _(u"Create")), diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 0df286c26..81d080801 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -266,10 +266,13 @@ $(document).ready(function(){ }); $("a.async-link").click(manage_async_link); $(".chosen-select").chosen(); - $(".clear-search").click(function(){ + $("#clear-search-button").click(function(){ $(this).parent().parent().children('input').prop("value", ""); enable_save(); }); + $("#submit-search").click(function(){ + $(".search_button").click(); + }); }); $(document).on("click", '#to_bottom_arrow', function(){ @@ -540,8 +543,10 @@ function get_label_from_input(input){ var enable_save = function(){ if ($(".search-widget input").val()){ $("#save-search-button").removeClass('disabled'); + $("#clear-search-button").removeClass('disabled'); } else { $("#save-search-button").addClass('disabled'); + $("#clear-search-button").addClass('disabled'); } } diff --git a/ishtar_common/static/media/styles.css b/ishtar_common/static/media/styles.css index 6860ca93c..b5e8bab48 100644 --- a/ishtar_common/static/media/styles.css +++ b/ishtar_common/static/media/styles.css @@ -25,10 +25,6 @@ html{ height: auto; } -.form-group span label { - display: inline-block; -} - #window-fixed-menu.hidden #window-fixed-menu-list{ display: none; @@ -39,23 +35,6 @@ html{ font-size: 0.9em; } -.form-group label{ - display: block; -} - -.form-group li label { - display: inline-block; -} - -.form-group li .form-control { - width: auto; -} - -.form-group li input[type="radio"].form-control, -.form-group li input[type="checkbox"].form-control{ - display: inline; -} - #id_parcel_0, #id_parcel_1, #id_parcel_2{ width: 30%; display: inline-block; diff --git a/ishtar_common/templates/blocks/bs_field_snippet.html b/ishtar_common/templates/blocks/bs_field_snippet.html index a164c81d8..6a6ea5360 100644 --- a/ishtar_common/templates/blocks/bs_field_snippet.html +++ b/ishtar_common/templates/blocks/bs_field_snippet.html @@ -1,7 +1,7 @@ {% load i18n %}
- {{ field.label_tag }} + {% if field.label %}{{ field.label_tag }}{% endif %} {% if field.help_text %}
{% endif %} diff --git a/ishtar_common/templates/ishtar/forms/search_query.html b/ishtar_common/templates/ishtar/forms/search_query.html index e842fd591..ff51d483d 100644 --- a/ishtar_common/templates/ishtar/forms/search_query.html +++ b/ishtar_common/templates/ishtar/forms/search_query.html @@ -2,7 +2,7 @@