Files
kimai2/templates/macros/datatables.html.twig

119 lines
5.4 KiB
Twig

{% macro data_table_column_modal(name, columns) %}
<div class="modal fade" id="modal_{{ name }}" data-column-visibility="{{ name }}" tabindex="-1" role="dialog" aria-labelledby="data_table_modal_label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="{{ 'action.close'|trans }}"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="data_table_modal_label">{{ 'modal.columns.title'|trans }}</h4>
</div>
<div class="modal-body">
<form name="{{ name }}_visibility">
{% for title, class in columns %}
{% if 'alwaysVisible' not in class %}
<div class="form-group">
<input type="checkbox" id="column_{{ title }}" name="{{ title }}"{% if is_visible_column(name, title) %} checked="checked"{% endif %}>
<label class="control-label" for="column_{{ title }}">{{ ('label.' ~ title)|trans }}</label>
</div>
{% endif %}
{% endfor %}
</form>
<p>{{ 'modal.columns.description'|trans }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary pull-left" data-type="save">{{ 'action.save'|trans }}</button>
<button type="button" class="btn btn-warning pull-left" data-type="reset">{{ 'action.delete'|trans }}</button>
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'action.close'|trans }}</button>
</div>
</div>
</div>
</div>
{% endmacro %}
{% macro data_table_column_class(name, columns, column) %}
{% apply spaceless %}
{% set class = '' %}
{% set always = false %}
{% if columns[column] is defined %}
{% set classes = columns[column] %}
{% if 'alwaysVisible' in classes %}
{# as this column should always be visible, we remove every class that includes hidden #}
{% for tmp in classes|split(' ') %}
{% if 'hidden' not in tmp %}
{% set class = class ~ ' ' ~ tmp %}
{% endif %}
{% endfor %}
{% else %}
{% if not is_visible_column(name, column) %}
{% set classes = classes ~ ' hidden' %}
{% elseif not is_datatable_configured(name) %}
{% for tmp in classes|split(' ') %}
{% if 'hidden' == tmp %}
{% set classes = classes|replace({(tmp): ''}) %}
{% endif %}
{% endfor %}
{% else %}
{% for tmp in classes|split(' ') %}
{% if 'hidden' in tmp %}
{% set classes = classes|replace({(tmp): ''}) %}
{% endif %}
{% endfor %}
{% endif %}
{% set class = classes %}
{% endif %}
{% endif %}
{% if not class is empty %}
{{ class }}
{% endif %}
{% endapply %}
{% endmacro %}
{% macro data_table_header_options(name, columns, options) %}
{% set skipStripped = options.skipStripped|default(false) %}
{% set reloadEvent = options.reloadEvent|default('') %}
{% set translationDomain = options.translationDomain|default('messages') %}
{# |default does not work here, as the prefix might be an empty string #}
{% set translationPrefix = 'label.' %}
{% if options.translationPrefix is defined %}
{% set translationPrefix = options.translationPrefix %}
{% endif %}
{% import _self as macro %}
<div class="box box-{{ admin_lte_context.widget.type }} data_table" id="datatable_{{ name }}">
<div class="box-body no-padding">
<div class="dataTables_wrapper form-inline dt-bootstrap">
<div class="row">
<div class="col-sm-12">
<table class="table {% if not skipStripped %}table-striped {% endif %}table-hover dataTable" role="grid" data-reload-event="{{ reloadEvent }}">
<thead>
<tr>
{%- for title, class in columns -%}
<th data-field="{{ title }}" class="{{ macro.data_table_column_class(name, columns, title) }}">{% if title is not empty and title != 'actions' %}{{ (translationPrefix ~ title)|trans({}, translationDomain) }}{% endif %}</th>
{%- endfor -%}
</tr>
</thead>
<tbody>
{% endmacro %}
{% macro data_table_header(name, columns, skipStripped, reloadEvent) %}
{% import _self as macro %}
{{ macro.data_table_header_options(name, columns, {'skipStripped': skipStripped, 'reloadEvent': reloadEvent}) }}
{% endmacro %}
{% macro data_table_footer(entries, route) %}
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
{% if route is not empty and entries is not null%}
<div class="navigation text-center no-print">
{{ pagerfanta(entries, 'twitter_bootstrap3_translated', { proximity: 1, routeName: route }) }}
</div>
{% endif %}
{% endmacro %}