summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/widgets/search_input.html
blob: d8ad26d8d5fbd6c77a242bc9afced7c9466d5214 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{% 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 in the main search area.{% endblocktrans %}</p>

        <h4>{% trans "Open search" %}</h4>
        <p>{% blocktrans %}In the search by criteria, 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 items whose denomination is exactly "éclat", while "denomination='éclat*'" will return all items 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 "-" in the main search area.{% endblocktrans %}</p>
        <p><em>{% blocktrans %}Example: the search "-material='metal'" will exclude all metal finds from the search.{% endblocktrans %}</em></p>

        <h4>{% trans "Filled/empty" %}</h4>
        <p>{% blocktrans %}If you want to get items with a specific criteria filled, set the value to "*". Instead if you want to get items with a specific criteria empty, set the value to "*", then prefix the criterion with "-".{% endblocktrans %}</p>
        <p><em>{% blocktrans %}Example: "material='*'" will return only all items with a material set, "-material='*'" return all items with material not set.{% 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 "=&gt;" or "=&lt;", depending on the desired result.{% endblocktrans %}</p>
        <p><em>{% blocktrans %}Example: the search "year=&gt;'2019'" will return all items from 2019 and onwards.{% endblocktrans %}</em></p>

        <h4>{% trans "Today" %}</h4>
        <p>{% blocktrans %}Searches can be performed in relation to today's date using the keyword "today". "+" and "-" sign can be used in order to add or remove day to the current date.{% endblocktrans %}</p>
        <p><em>{% blocktrans %}Example: the search "created=&gt;'today-10'" will return all items created in the last 10 days.{% endblocktrans %}</em></p>

        <h4>{% trans "OR operator" %}</h4>
        <p>{% blocktrans %}An OR operator is available for searches that include, for example, different criteria. This operator uses the notation "&nbsp;||&nbsp;".{% endblocktrans %}</p>
        <p><em>{% blocktrans %}Example: the search "material='Metal' || object-type='ingot'" will include in the search all metallic finds as well as all finds whose object type is ingot.{% endblocktrans %}</em></p>

        <h4>{% trans "AND operator" %}</h4>
        <p>{% blocktrans %}An AND operator is available to search on the same criterion with several values. This operator uses the notation "&nbsp;&amp;&amp;&nbsp;".{% endblocktrans %}</p>
        <p><em>{% blocktrans %}Example: the search "material='Metal' &amp;&amp; material='wood'" will only include finds made of metal <strong>and</strong> wood.{% endblocktrans %}</em></p>

        <p class="text-center"><em><a href="https://ishtar.readthedocs.io/fr/{{widget.ISHTAR_DOCUMENT_VERSION}}/interface-utilisateur.html#barre-de-recherche" 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>