FEATURE: displays average for 2 columns tables which support average

This commit is contained in:
Joffrey JAFFEUX 2019-06-04 11:08:26 +02:00 committed by GitHub
parent c9a34aa10c
commit b79d02ff48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -31,6 +31,16 @@ export default Ember.Component.extend({
return reportTotal && total && twoColumns;
},
@computed("model.average", "totalsForSample.1.value", "twoColumns")
showAverage(reportAverage, totalValue, twoColumns) {
return reportAverage && totalValue && twoColumns;
},
@computed("totalsForSample.1.value", "model.data.length")
averageForSample(totals, count) {
return (totals / count).toFixed(0);
},
@computed("model.data.length")
showSortingUI(dataLength) {
return dataLength >= 5;

View File

@ -48,6 +48,18 @@
<td class="admin-report-table-cell number y">{{number model.total}}</td>
</tr>
{{/if}}
{{#if showAverage}}
<tr class="total-row">
<td colspan="2">
{{i18n 'admin.dashboard.reports.average'}}
</td>
</tr>
<tr class="admin-report-table-row">
<td class="admin-report-table-cell date x">—</td>
<td class="admin-report-table-cell number y">{{number averageForSample}}</td>
</tr>
{{/if}}
</tbody>
</table>

View File

@ -3111,6 +3111,7 @@ en:
groups: "All groups"
disabled: "This report is disabled"
totals_for_sample: "Totals for sample"
average_for_sample: "Average for sample"
total: "All time total"
no_data: "No data to display."
trending_search: