diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-07-09 20:59:24 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:03 +0200 |
| commit | 5848f96f633d63248eefbabd325b17f6e36bd0e8 (patch) | |
| tree | 59990ede30849daf44a9323d7e9a18e17d707285 /ishtar_common/templates/ishtar | |
| parent | 721229d393b6820619c5a006fa4b97889315932a (diff) | |
| download | Ishtar-5848f96f633d63248eefbabd325b17f6e36bd0e8.tar.bz2 Ishtar-5848f96f633d63248eefbabd325b17f6e36bd0e8.zip | |
Save search queries
Diffstat (limited to 'ishtar_common/templates/ishtar')
| -rw-r--r-- | ishtar_common/templates/ishtar/forms/search_query.html | 122 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/forms/success.html | 20 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/wizard/search.html | 2 |
3 files changed, 143 insertions, 1 deletions
diff --git a/ishtar_common/templates/ishtar/forms/search_query.html b/ishtar_common/templates/ishtar/forms/search_query.html new file mode 100644 index 000000000..e842fd591 --- /dev/null +++ b/ishtar_common/templates/ishtar/forms/search_query.html @@ -0,0 +1,122 @@ +{% load i18n inline_formset table_form %} +<div class="modal-dialog modal-sm" id="save-search-div"> + <div class="modal-content"> + <div class="modal-header"> + <h5>{% trans "Save search" %}</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <form enctype="multipart/form-data" + action="{% url 'save-search-query' app_label model %}" + method="post" + id="save-search-form"> + <div class="modal-body form-row"> + {% csrf_token %} + + <div class='form'> + + {% if form.non_field_errors %} + <div class="alert alert-danger" role="alert"> + {{form.non_field_errors}} + </div> + {% endif %} + + {% for hidden in form.hidden_fields %} + {{hidden}} + {% if hidden.errors %}<div class="invalid-feedback"> + {{ hidden.errors }} + </div>{% endif %} + {% endfor %} + + <div class="form-row"> + <div class="form-group col-lg-12"> + {{form.query}} + </div> + </div> + {% if form.search_query %} + <div class="form-row"> + <input type="radio" name="create_or_update" value="create" + id="create-choice" checked > + <label for="create-choice">{% trans "New" %}</label> + </div> + {% else %} + <input type="hidden" name="create_or_update" value="create"> + {% endif %} + <div id="new-search-query"> + <div class="form-row"> + {% with form.label as field %} + {% include "blocks/bs_field_snippet.html" %} + {% endwith %} + </div> + <div class="form-row"> + {% with form.is_alert as field %} + {% include "blocks/bs_field_snippet.html" %} + {% endwith %} + </div> + </div> + {% if form.search_query %} + <div class="form-row"> + <input type="radio" name="create_or_update" value="update" + id="update-choice"> + <label for="update-choice">{% trans "Update" %}</label> + </div> + <div id="update-search-query"> + <div class="form-row"> + {% with form.search_query as field %} + {% include "blocks/bs_field_snippet.html" %} + {% endwith %} + </div> + </div> + {% endif %} + </div> + </div> + <div class="modal-footer"> + <div class="col-sm"> + <button type="button" id="search-save-submit" + name='validate' + value="validate" class="btn btn-success"> + {% trans "Validate" %} + </button> + </div> + </div> + </form> + </div> +</div> + +<script type='text/javascript'> + +var update_form_display = function(){ + if ($("#create-choice:checked").length){ + $("#update-search-query").hide(); + $("#new-search-query").show(); + } else { + $("#new-search-query").hide(); + $("#update-search-query").show(); + } +} + +$(document).ready(function(){ + $("#id_query").val($(".search-vector").val()); + $("#search-save-submit").click( + function(){ + $.ajax({ + type: "POST", + url: "{% url 'save-search-query' app_label model %}", + data: $("#save-search-form").serialize(), + success: function(data){ + $("#save-search-div").parent().html(data); + }, + dataType: 'html' + }); + return false; + } + ); + $("#create-choice").click(update_form_display); + $("#update-choice").click(update_form_display); + update_form_display(); +}); + +</script> + + diff --git a/ishtar_common/templates/ishtar/forms/success.html b/ishtar_common/templates/ishtar/forms/success.html new file mode 100644 index 000000000..125ba62e7 --- /dev/null +++ b/ishtar_common/templates/ishtar/forms/success.html @@ -0,0 +1,20 @@ +{% load i18n inline_formset table_form %} +<script type='text/javascript'> + +$(document).ready(function(){ + $("#form-result-div").parent().modal("hide"); +}); + +</script> +<div class="modal-dialog modal-sm" id="form-result-div"> + <div class="modal-content"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body form-row"> + {% trans "Form successfully submited" %} + </div> + </div> +</div> diff --git a/ishtar_common/templates/ishtar/wizard/search.html b/ishtar_common/templates/ishtar/wizard/search.html index e1f2433ea..eebd58d89 100644 --- a/ishtar_common/templates/ishtar/wizard/search.html +++ b/ishtar_common/templates/ishtar/wizard/search.html @@ -18,7 +18,7 @@ <form action="." class='wizard-form' id="wizard-form" method="post" name='wizard'>{% csrf_token %} {% if wizard.form.forms %} <div class='form'> -<div class='top_button'><input type="submit" id="submit_form" value="{% trans "Validate" %}"/></div> +<div class='top_button'><input type="submit" id="submit_form" value="{% trans 'Validate' %}"/></div> <table class='formset'> {%if wizard.form.non_form_errors%}<tr class='error'><th colspan='2'>{{wizard.form.non_form_errors}}</th></tr>{%endif%} {{ wizard.form.management_form }} |
