Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: displays average for 2 columns tables which support average

Joffrey JAFFEUXb79d02ff485a
diff --git a/app/assets/javascripts/admin/components/admin-report-table.js.es6 b/app/assets/javascripts/admin/components/admin-report-table.js.es6
index 0b52599a9b5..bba15f0ec20 100644
--- a/app/assets/javascripts/admin/components/admin-report-table.js.es6
+++ b/app/assets/javascripts/admin/components/admin-report-table.js.es6
@@ -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;
diff --git a/app/assets/javascripts/admin/templates/components/admin-report-table.hbs b/app/assets/javascripts/admin/templates/components/admin-report-table.hbs
index 6011407673c..0fccf35c250 100644
--- a/app/assets/javascripts/admin/templates/components/admin-report-table.hbs
+++ b/app/assets/javascripts/admin/templates/components/admin-report-table.hbs
@@ -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>
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 030d754a826..65b7a27f4ef 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -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: