summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/ishtar/forms/search_query.html
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/templates/ishtar/forms/search_query.html')
-rw-r--r--ishtar_common/templates/ishtar/forms/search_query.html122
1 files changed, 122 insertions, 0 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">&times;</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 >
+ &nbsp;<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">
+ &nbsp;<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>
+
+