Display meta-fields in datatables (#1116)

This commit is contained in:
Kevin Papst
2019-09-19 20:28:31 +02:00
committed by GitHub
parent 24cbe3d281
commit 5aa422dde1
71 changed files with 1461 additions and 212 deletions

View File

@@ -1,4 +1,5 @@
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% extends 'invoice/layout.html.twig' %}
{% block invoice %}
@@ -29,6 +30,9 @@
<tr>
<th>{{ 'label.date'|trans }}</th>
<th>{{ 'label.description'|trans }}</th>
{% for field in metaColumns %}
<th>{{ field.label|trans }}</th>
{% endfor %}
<th>{{ 'label.hours'|trans }}</th>
</tr>
</thead>
@@ -50,6 +54,9 @@
{{ 'label.customer'|trans }}: {{ entry.project.customer.name }}
</span>
</td>
{% for field in metaColumns %}
<td>{{ tables.datatable_meta_column(entry, field) }}</td>
{% endfor %}
<td class="text-nowrap">{{ entry.duration|duration }}</td>
</tr>
{% endfor %}
@@ -57,6 +64,9 @@
<tfoot>
<tr>
<th></th>
{% for field in metaColumns %}
<th></th>
{% endfor %}
<th>{{ 'invoice.total_working_time'|trans }}</th>
<th>{{ timeWorked|duration }}</th>
</tr>

View File

@@ -27,6 +27,13 @@
'activity': 'hidden-xs hidden-sm',
'description': 'hidden-xs hidden-sm',
'tags': {'class': 'hidden-xs hidden-sm', 'orderBy': false},
}) %}
{% for field in metaColumns %}
{% set columns = columns|merge({
(field.name): {'title': field.label, 'class': 'hidden-xs hidden-sm', 'orderBy': false}
}) %}
{% endfor %}
{% set columns = columns|merge({
'actions': 'actions alwaysVisible',
}) %}
@@ -54,7 +61,7 @@
{% set day = entry.begin|date_short %}
{% endif %}
{%- if showSummary and day is not same as(entry.begin|date_short) -%}
{{ timesheet.summary(day, dayDuration, dayRate, columns, canSeeRate, showStartEndTime, tableName) }}
{{ timesheet.summary(day, dayDuration, dayRate, columns, canSeeRate, showStartEndTime, tableName, metaColumns) }}
{% set day = entry.begin|date_short %}
{% set dayDuration = 0 %}
{% set dayRate = {} %}
@@ -96,6 +103,11 @@
<td class="{{ tables.data_table_column_class(tableName, columns, 'activity') }}">{{ widgets.label_activity(entry.activity) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }} timesheet-description">{{ entry.description|escape|desc2html }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'tags') }}">{{ widgets.tag_list(entry.tags) }}</td>
{% for field in metaColumns %}
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, field.name) }}">
{{ tables.datatable_meta_column(entry, field) }}
</td>
{% endfor %}
<td class="actions">
{{- actions.timesheet(entry, 'index') -}}
</td>
@@ -110,7 +122,7 @@
{% endfor %}
{% if showSummary %}
{{ timesheet.summary(day, dayDuration, dayRate, columns, canSeeRate, showStartEndTime, tableName) }}
{{ timesheet.summary(day, dayDuration, dayRate, columns, canSeeRate, showStartEndTime, tableName, metaColumns) }}
{% endif %}
{{ tables.data_table_footer(entries, 'timesheet_paginated') }}
@@ -118,7 +130,7 @@
{% endblock %}
{% macro summary(day, duration, dayRates, columns, canSeeRate, showStartEndTime, tableName) %}
{% macro summary(day, duration, dayRates, columns, canSeeRate, showStartEndTime, tableName, metaColumns) %}
{% import "macros/datatables.html.twig" as tables %}
<tr class="summary info">
<td class="text-nowrap">{{ day }}</td>
@@ -142,6 +154,9 @@
<td class="{{ tables.data_table_column_class(tableName, columns, 'activity') }}"></td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }}"></td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'tags') }}"></td>
{% for field in metaColumns %}
<td class="{{ tables.data_table_column_class(tableName, columns, field.name) }}"></td>
{% endfor %}
<td class="actions"></td>
</tr>
{% endmacro %}