Skip to content

Commit

Permalink
#19 adjustments for transfer table
Browse files Browse the repository at this point in the history
  • Loading branch information
StegSchreck committed May 2, 2017
1 parent db872ac commit 8992395
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion core/static/core/js/table_formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ function numberFormatter(value) {
return value.toLocaleString('de-DE');
}
function moneyFormatter(value) {
return numberFormatter(value) + " €";
if (typeof value === 'number') {
return numberFormatter(value) + " €";
} else {
return value
}
}

window.onload=table_loader;
10 changes: 4 additions & 6 deletions core/static/core/js/transfer_charts_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,21 +221,19 @@ function fillOverviewTable(data){

var header_row = '<tr><th></th>';

var group1Length = data.group1.length;
for (var k = 0; k < group1Length; k++) {
for (var k = 0; k < data.group1.length; k++) {
header_row += '<th>' + data.group1[k] + '</th>'
}
header_row += '</tr>';

$('#TransfersOverviewTable').append(header_row);

var group2Length = data.group2.length;
for (var i = 0; i < group2Length; i++) {
for (var i = 0; i < data.group2.length; i++) {
var row = '<tr><th>' + data.group2[i] + '</th>';

var rowLength = data.medians[i].length;
for (var j = 0; j < rowLength; j++) {
row += '<td>' + data.medians[i][j] + '</td>';
row += '<td>' + moneyFormatter(data.medians[i][j]) + '</td>';
}

row += '</tr>';
Expand Down Expand Up @@ -271,5 +269,5 @@ $(function () {
requestChartDetailData();
requestOverviewTableData();

setTimeout(makeTableSelectable, 1000);
setTimeout(makeTableSelectable, 3000);
});
1 change: 1 addition & 0 deletions core/templates/core/ofm/transfers.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,6 @@ <h1 class="page-header">
</script>

<script src="{% static 'core/js/parsing_overlay.js' %}"></script>
<script src="{% static 'core/js/table_formats.js' %}"></script>
<script src="{% static 'core/js/transfer_charts_handler.js' %}"></script>
{% endblock %}
5 changes: 3 additions & 2 deletions core/views/ofm/transfers_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,10 @@ def _get_medians(group1, prices, group2):
row = []
for group1_item in group1:
try:
row.append("{:,}".format(prices.get_group((group1_item, group2_item)).median()))
formatted_median = prices.get_group((group1_item, group2_item)).median()
row.append(float(formatted_median))
except KeyError:
row.append('NA')
row.append('-')
medians.append(row)
return medians

Expand Down

0 comments on commit 8992395

Please sign in to comment.