summaryrefslogtreecommitdiff
path: root/ishtar_common/templates/blocks/bs_form_snippet.html
blob: caa20b0160d9ea824fcc8ce846d976de929e7f5b (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
{% load i18n from_dict %}
{% 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 %}

{% csrf_token %}
{% for field in form.visible_fields %}
{% if form.SEARCH_AND_SELECT %}
{{field}}
{% elif field.name == 'search_vector' and forloop.counter0 == 0 %}
<div class="form-row">
    <div class="form-group col-lg-12">
        {{field|safe}}
        {% if field.help_text %}
        <small><a data-toggle="collapse" href="#{{field.auto_id}}_help"
                  aria-expanded="false" aria-controls="{{field.auto_id}}_help">
            {% trans 'help'%}</a></small>{% endif %}
        {% if field.errors %}
        <div class="invalid-feedback">
            {{ field.errors }}
        </div>{% endif %}
    </div>

    {% if field.help_text %}
    <div class="collapse" id="{{field.auto_id}}_help">
        <div class="card card-body">
            {{field.help_text}}
        </div>
    </div>
    {% endif %}
</div>
{% else %}
{% if search and forloop.counter0 == 1 %}
<div class="modal" id="modal-advanced-search" tabindex="-1" role="dialog"
     data-backdrop="static" data-keyboard="true" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5>{% trans "Criteria search" %}</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <div class="form-group col-12" id="advanced-search-info"></div>
            </div>
            <div class="modal-body body-scroll search-fields">
                <div class="form-row justify-content-md-center">
                    <div class="form-row col-md-6">
                        <div class="input-group search-widget">
                            <span class="input-group-prepend">
                                <span class="input-group-text" title="{% trans 'Filter...' %}">
                                    <i class="fa fa-filter" aria-hidden="true"></i>
                                </span>
                            </span>
                            <input type="text" id="search-input-filter"
                                   class="form-control"
                                   placeholder="{% trans 'Begin to type to filter search fields' %}" />
                            <span class="input-group-append">
                                <span class="input-group-text input-link disabled" id="clear-filter-button" title="Clear">
                                    <i class="fa fa-times" aria-hidden="true"></i>
                                </span>
                            </span>
                        </div>
                    </div>
                </div>
            <hr>

{% endif %}
{% if field.name in form.HEADERS %}
{% if forloop.counter0 %}
</div>{% endif %}

{% if form.current_header %}
    {{form.current_header|call:'render_end'}}
{% endif %}

{% with "headers,"|add:field.name as call_arg %}
{{form|call:call_arg|call:"render"}}
{% endwith %}

<div class="form-row{% if odd %} odd{% endif %}">
{% elif not search and not forloop.counter0 or search and forloop.counter0 == 1 %}
  <div class="form-row{% if odd %} odd{% endif %}">
{% endif %}
      {% include "blocks/bs_field_snippet.html" %}
{% if forloop.last %}

{% if form.current_header %}
    {{form.current_header|call:'render_end'}}
{% endif %}

{% if search and forloop.counter0 >= 1 %}
            </div>
        </div>
        <div class="modal-footer">
            <div class="form-group col-12">
                <p class="text-center">
                    <button type="button"
                            class="btn btn-primary advanced-search-valid">
                        {% trans "Add" %}</button>
                    <button type="button"
                            class="btn btn-secondary advanced-search-clear">
                        {% trans 'Clear' %}</button>
                    <button type="button" class="btn btn-secondary"
                            data-dismiss="modal">{% trans 'Close' %}</button>
                </p>
            </div>
        </div>
    </div>
    </div>
{% endif %}
</div>
{% endif %}
{% endif %}
{% endfor %}

{% if search %}
<script type="text/javascript">
$(register_advanced_search);
</script>
{% endif %}