summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/widgets/search_input.html
blob: 9cbae011ec977ad344d6348ab8f945a11eb3ea28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
{% load i18n l10n %}<div class="input-group search-widget">
    <input type="{{ widget.type }}" name="{{ widget.name }}"
           {% if widget.value != None %} value="{{ widget.value|stringformat:'s' }}"{% endif %}{% include "django/forms/widgets/attrs.html" %} />
    <span class="input-group-append">
        <span class="input-group-text input-link bg-primary text-white"
              title="{% trans 'Search' %}"
              id="submit-search">
            <i class="fa fa-search" aria-hidden="true"></i>
        </span>
        <button type="button" class="input-group-text input-link" data-toggle="modal"
                data-target="#modal-advanced-search"
                title="{% trans 'Criteria' %}">
            <i class="fa fa-cog" aria-hidden="true"></i>
        </button>
        <span class="input-group-text input-link disabled"
              id="clear-search-button"
              title="{% trans 'Clear' %}">
            <i class="fa fa-times" aria-hidden="true"></i>
        </span>
        <span class="input-group-text input-sep">
        </span>
        <span class="input-group-text input-link"
              id="pin-search-button"
              data-item-type="{{pin_model}}"
              title="{% trans 'Pin the current search' %}">
            <i class="fa fa-thumb-tack" aria-hidden="true"></i>
        </span>
        <a class="input-group-text input-link async-link disabled"
           id="save-search-button"
           data-target="#modal-dynamic-form"
           data-modal-open="#modal-dynamic-form"
           title="{% trans 'Bookmark this search' %}"
           href="{% url 'save-search-query' app_name pin_model %}">
            <i class="fa fa-star-o" aria-hidden="true"></i>
        </a>
        <span class="input-group-text input-link dropdown-toggle"
              data-toggle="dropdown"
              title="{% trans 'Bookmarks' %}"
              id="load-bookmark">
            <i class="fa fa-bookmark" aria-hidden="true"></i>
        </span>
        <div class="dropdown-menu" id="bookmark-list"></div>
        <a class="input-group-text" data-toggle="collapse"
           href="#{{field.auto_id}}_help"
           aria-expanded="false" aria-controls="{{field.auto_id}}_help">
           <i class="fa fa-question-circle" aria-hidden="true"></i>
        </a>
        {% comment %}
        <a class="input-group-text input-link async-link disabled"
           id="generate-qrcode"
           data-target="#modal-dynamic-form"
           data-modal-open="#modal-dynamic-form"
           title="{% trans 'Generate a QR Code' %}"
           href="{% url 'search-qrcode' %}">
            <i class="fa fa-qrcode" aria-hidden="true"></i>
        </a>
        {% endcomment %}
    </span>
</div>

<div class="collapse help-text-parent" id="{{field.auto_id}}_help">
    <div class="card card-body help-text">
        <h3>{% trans "Free search" %}</h3>
        <p>{% trans "Each item in the database is indexed to ensure consistent results for free-entry searches." %}</p>
        <p><em>{% blocktrans %}Example: "071234" in an operation search will return the operation with the corresponding operation code in the Operation search field, and finds linked to the same operation in the Find search field.{% endblocktrans %}</em></p>

        <h3>{% trans "Criteria search" %}</h3>
        <p>{% blocktrans %}Clicking on the <i class="fa fa-cog" aria-hidden="true"></i> icon takes you to a form that allows you to simply construct your search by criteria. Once this search query has been built up, the query can be adjusted.{% endblocktrans %}</p>

        <h4>{% trans "Open search" %}</h4>
        <p>{% blocktrans %}In the criterion search, the engine searches exactly for the value entered. If you want an open search such as "contains the value", add an asterisk * to the value.{% endblocktrans %}</p>

        <p><em>{% blocktrans %}Example: "denomination='éclat'" will return only those elements whose denomination is exactly "éclat", while "denomination='éclat*'" will return all elements whose denomination contains the word "éclat", e.g. batches of "éclats", "éclat retouché", etc.{% endblocktrans %}}</em></p>

        <h4>{% trans "Exclude" %}</h4>
        <p>{% blocktrans %}To exclude items from the search, add the criterion from the form, then prefix the criterion with "-".{% endblocktrans %}</p>
        <p><em>{% blocktrans %}Example: the search "-material='metal'" will exclude all metal finds from the search.{% endblocktrans %}</em></p>

        <h4>{% trans "Greater than, lower than, before, after" %}</h4>
        <p>{% blocktrans %}For searches such as larger, smaller (for numeric fields), before, after (for date fields), add the criterion from the form, then change the "=" sign to "=>" or "=<", depending on the desired result.{% endblocktrans %}</p>
        <p><em>{% blocktrans %}Example: the search 'year=>"2019"' will return all items from 2019 and onwards.{% endblocktrans %}</em></p>

        <p class="text-center"><em><a href="https://ishtar.readthedocs.io/fr/{{widget.ISHTAR_DOCUMENT_VERSION}}/interface-utilisateur.html#recherche-textuelle-et-par-criteres" target="_blank">{% trans "Full documentation for searches." %}</a></em></p>

    </div>
</div>

<script type="text/javascript">{% localize off %}
var bookmark_url = "{% url 'bookmark-list' app_name pin_model %}";

if (typeof enable_save == "undefined") {
    enable_save = function(){};
}

if (typeof load_bookmark_list == "undefined") {
    load_bookmark_list = function(){};
}

$(document).ready(function(){
    $(".search-widget input").keypress(function(e) {
        var key = e.key;
        if (key === "Enter") {
            $(".search_button").click();
            $(this).focus();
            e.stopPropagation();
            return false;
        } else {
            $("#id_search_vector").addClass('input-progress');
        }
        if (key === "Escape") {
            $("#clear-search-button").click();
            $(this).focus();
        }
    });
    $(".search-widget input").keyup(function(e) {
        enable_save();
    });
    enable_save();
    load_bookmark_list();
});
{% endlocalize %}</script>