allow to hide rate or duration in html export summary (#1370)

This commit is contained in:
Kevin Papst
2020-01-14 13:46:07 +01:00
committed by GitHub
parent a8824f92a1
commit 28c5357f11
2 changed files with 56 additions and 21 deletions

View File

@@ -51,6 +51,29 @@
document.getElementById('summary-show').addEventListener('click', function(event) { document.getElementById('summary-show').addEventListener('click', function(event) {
document.getElementById('export-summary').style.display = event.target.checked ? 'block' : 'none'; document.getElementById('export-summary').style.display = event.target.checked ? 'block' : 'none';
}); });
document.getElementById('summary-duration').addEventListener('click', function(event) {
if (!document.getElementById('summary-rate').checked) {
return;
}
document.getElementById('summary-rate').disabled = !event.target.checked;
var cells = document.getElementsByClassName('summary-duration');
for (var columnCell of cells) {
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
}
});
document.getElementById('summary-rate').addEventListener('click', function(event) {
if (!document.getElementById('summary-duration').checked) {
return;
}
document.getElementById('summary-duration').disabled = !event.target.checked;
var cells = document.getElementsByClassName('summary-rate');
for (var columnCell of cells) {
columnCell.style.display = event.target.checked ? 'table-cell' : 'none';
}
});
document.getElementById('summary-show').addEventListener('click', function(event) {
document.getElementById('export-summary').style.display = event.target.checked ? 'block' : 'none';
});
document.getElementById('records-show').addEventListener('click', function(event) { document.getElementById('records-show').addEventListener('click', function(event) {
document.getElementById('export-records').style.display = event.target.checked ? 'block' : 'none'; document.getElementById('export-records').style.display = event.target.checked ? 'block' : 'none';
}); });
@@ -107,6 +130,18 @@
{{ 'label.activity'|trans }} {{ 'label.activity'|trans }}
</label> </label>
</div> </div>
<div class="form-group">
<label class="control-label" for="summary-duration">
<input type="checkbox" id="summary-duration" name="summary-duration" checked>
{{ 'label.duration'|trans }}
</label>
</div>
<div class="form-group">
<label class="control-label" for="summary-rate">
<input type="checkbox" id="summary-rate" name="summary-rate" checked>
{{ 'label.rate'|trans }}
</label>
</div>
</form> </form>
<form class="navbar-form"> <form class="navbar-form">
@@ -149,8 +184,8 @@
<tr> <tr>
<th>{{ 'label.customer'|trans }}</th> <th>{{ 'label.customer'|trans }}</th>
<th>{{ 'label.project'|trans }}</th> <th>{{ 'label.project'|trans }}</th>
<th class="duration">{{ 'label.duration'|trans }}</th> <th class="duration summary-duration">{{ 'label.duration'|trans }}</th>
<th class="cost">{{ 'label.rate'|trans }}</th> <th class="cost summary-rate">{{ 'label.rate'|trans }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -166,8 +201,8 @@
{% if customer is not same as(summary.customer) %} {% if customer is not same as(summary.customer) %}
<tr class="summary"> <tr class="summary">
<td colspan="2"></td> <td colspan="2"></td>
<td class="totals duration">{{ customerDuration|duration }}</td> <td class="totals duration summary-duration">{{ customerDuration|duration }}</td>
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td> <td class="totals cost summary-rate">{{ customerRate|money(customerCurrency) }}</td>
</tr> </tr>
{% set customerCurrency = summary.currency %} {% set customerCurrency = summary.currency %}
{% set customer = summary.customer %} {% set customer = summary.customer %}
@@ -177,8 +212,8 @@
<tr> <tr>
<td>{{ summary.customer }}</td> <td>{{ summary.customer }}</td>
<td>{{ summary.project }}</td> <td>{{ summary.project }}</td>
<td class="duration">{{ summary.duration|duration }}</td> <td class="duration summary-duration">{{ summary.duration|duration }}</td>
<td class="cost">{{ summary.rate|money(summary.currency) }}</td> <td class="cost summary-rate">{{ summary.rate|money(summary.currency) }}</td>
</tr> </tr>
{% set customerDuration = customerDuration + summary.duration %} {% set customerDuration = customerDuration + summary.duration %}
{% set customerRate = customerRate + summary.rate %} {% set customerRate = customerRate + summary.rate %}
@@ -186,8 +221,8 @@
{% if customer is not same as(null) %} {% if customer is not same as(null) %}
<tr class="summary"> <tr class="summary">
<td colspan="2"></td> <td colspan="2"></td>
<td class="totals duration">{{ customerDuration|duration }}</td> <td class="totals duration summary-duration">{{ customerDuration|duration }}</td>
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td> <td class="totals cost summary-rate">{{ customerRate|money(customerCurrency) }}</td>
</tr> </tr>
{% endif %} {% endif %}
</tbody> </tbody>
@@ -199,8 +234,8 @@
<th>{{ 'label.customer'|trans }}</th> <th>{{ 'label.customer'|trans }}</th>
<th>{{ 'label.project'|trans }}</th> <th>{{ 'label.project'|trans }}</th>
<th>{{ 'label.activity'|trans }}</th> <th>{{ 'label.activity'|trans }}</th>
<th class="duration">{{ 'label.duration'|trans }}</th> <th class="duration summary-duration">{{ 'label.duration'|trans }}</th>
<th class="cost">{{ 'label.rate'|trans }}</th> <th class="cost summary-rate">{{ 'label.rate'|trans }}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -216,8 +251,8 @@
{% if customer is not same as(summary.customer) %} {% if customer is not same as(summary.customer) %}
<tr class="summary"> <tr class="summary">
<td colspan="3"></td> <td colspan="3"></td>
<td class="totals duration">{{ customerDuration|duration }}</td> <td class="totals duration summary-duration">{{ customerDuration|duration }}</td>
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td> <td class="totals cost summary-rate">{{ customerRate|money(customerCurrency) }}</td>
</tr> </tr>
{% set customerCurrency = summary.currency %} {% set customerCurrency = summary.currency %}
{% set customer = summary.customer %} {% set customer = summary.customer %}
@@ -229,8 +264,8 @@
<td>{{ summary.customer }}</td> <td>{{ summary.customer }}</td>
<td>{{ summary.project }}</td> <td>{{ summary.project }}</td>
<td>{{ activitySummary.activity }}</td> <td>{{ activitySummary.activity }}</td>
<td class="duration">{{ activitySummary.duration|duration }}</td> <td class="duration summary-duration">{{ activitySummary.duration|duration }}</td>
<td class="cost">{{ activitySummary.rate|money(activitySummary.currency) }}</td> <td class="cost summary-rate">{{ activitySummary.rate|money(activitySummary.currency) }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
{% set customerDuration = customerDuration + summary.duration %} {% set customerDuration = customerDuration + summary.duration %}
@@ -239,8 +274,8 @@
{% if customer is not same as(null) %} {% if customer is not same as(null) %}
<tr class="summary"> <tr class="summary">
<td colspan="3"></td> <td colspan="3"></td>
<td class="totals duration">{{ customerDuration|duration }}</td> <td class="totals duration summary-duration">{{ customerDuration|duration }}</td>
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td> <td class="totals cost summary-rate">{{ customerRate|money(customerCurrency) }}</td>
</tr> </tr>
{% endif %} {% endif %}
</tbody> </tbody>
@@ -364,14 +399,14 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
<th class="text-nowrap column-duration"> <th class="text-nowrap column-duration">
{{ timeWorked|duration }} {{- timeWorked|duration -}}
</th> </th>
<th class="text-nowrap column-rate"> <th class="text-nowrap column-rate">
{% if currency is not null and currency is not same as(false) %} {%- if currency is not null and currency is not same as(false) %}
{{ rateTotal|money(currency) }} {{ rateTotal|money(currency) }}
{% else %} {% else %}
{{ rateTotal|money }} {{ rateTotal|money }}
{% endif %} {% endif -%}
</th> </th>
</tr> </tr>
</tbody> </tbody>

View File

@@ -59,8 +59,8 @@ class HtmlRendererTest extends AbstractRendererTest
$this->assertStringContainsString('<td>Customer Name</td>', $content); $this->assertStringContainsString('<td>Customer Name</td>', $content);
$this->assertStringContainsString('<td>project name</td>', $content); $this->assertStringContainsString('<td>project name</td>', $content);
$this->assertStringContainsString('<td class="duration">01:50 h</td>', $content); $this->assertStringContainsString('<td class="duration summary-duration">01:50 h</td>', $content);
$this->assertStringContainsString('<td class="cost">€2,437.12</td>', $content); $this->assertStringContainsString('<td class="cost summary-rate">€2,437.12</td>', $content);
// 5 times in the "full list" and once in the "summary with activities" // 5 times in the "full list" and once in the "summary with activities"
$this->assertEquals(6, substr_count($content, 'activity description')); $this->assertEquals(6, substr_count($content, 'activity description'));