summaryrefslogtreecommitdiff
path: root/tuskar_ui/infrastructure/templates/formset_table/_table.html
blob: be90b78656f842abd267ba0e50d94166bd063408 (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
{% extends 'horizon/common/_data_table.html' %}
{% load i18n %}

{% block table_columns %}
  {% if not table.is_browser_table %}
  <tr>
    {% for column in columns %}
        <th {{ column.attr_string|safe }}><span
            {% if column.name in table.get_required_columns %}
                class="required"
            {% endif %}
        >{{ column }}</span></th>
    {% endfor %}
  </tr>
  {% endif %}
{% endblock table_columns %}

{% block table %}
    {% with table.get_formset as formset %}
        {{ formset.management_form }}
        {% if formset.non_field_errors %}
            <div class="alert alert-error">
                {{ formset.non_field_errors }}
            </div>
        {% endif %}
    {% endwith %}
    {{ block.super }}

<script type="text/javascript">
    (window.$ || window.addHorizonLoadEvent)(function () {
        // prepare the js-enabled parts of the formset data table
        var prefix = '{{ table.name|escapejs }}';
        var empty_row_html = '{% filter escapejs %}{% include "formset_table/_row.html" with row=table.get_empty_row %}{% endfilter %}';
        {% if table.formset_class.extra %}
        var add_label = '{% filter escapejs %}{% trans "Add a row" %}{% endfilter %}';
        {% else %}
        var add_label = '';
        {% endif %}

        tuskar.formset_table.init(prefix, empty_row_html, add_label);
    });
</script>
{% endblock table %}