From 899239516bae83c26507ee2bb0269e958b9b64d6 Mon Sep 17 00:00:00 2001 From: Sebastian Schreck Date: Tue, 2 May 2017 18:59:32 +0200 Subject: [PATCH] #19 adjustments for transfer table --- core/static/core/js/table_formats.js | 6 +++++- core/static/core/js/transfer_charts_handler.js | 10 ++++------ core/templates/core/ofm/transfers.html | 1 + core/views/ofm/transfers_views.py | 5 +++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/core/static/core/js/table_formats.js b/core/static/core/js/table_formats.js index 389630c..fdddf3a 100644 --- a/core/static/core/js/table_formats.js +++ b/core/static/core/js/table_formats.js @@ -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; diff --git a/core/static/core/js/transfer_charts_handler.js b/core/static/core/js/transfer_charts_handler.js index f219cdf..ddc6063 100644 --- a/core/static/core/js/transfer_charts_handler.js +++ b/core/static/core/js/transfer_charts_handler.js @@ -221,21 +221,19 @@ function fillOverviewTable(data){ var header_row = ''; - var group1Length = data.group1.length; - for (var k = 0; k < group1Length; k++) { + for (var k = 0; k < data.group1.length; k++) { header_row += '' + data.group1[k] + '' } header_row += ''; $('#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 = '' + data.group2[i] + ''; var rowLength = data.medians[i].length; for (var j = 0; j < rowLength; j++) { - row += '' + data.medians[i][j] + ''; + row += '' + moneyFormatter(data.medians[i][j]) + ''; } row += ''; @@ -271,5 +269,5 @@ $(function () { requestChartDetailData(); requestOverviewTableData(); - setTimeout(makeTableSelectable, 1000); + setTimeout(makeTableSelectable, 3000); }); diff --git a/core/templates/core/ofm/transfers.html b/core/templates/core/ofm/transfers.html index bd40368..fc15328 100644 --- a/core/templates/core/ofm/transfers.html +++ b/core/templates/core/ofm/transfers.html @@ -115,5 +115,6 @@

+ {% endblock %} diff --git a/core/views/ofm/transfers_views.py b/core/views/ofm/transfers_views.py index 8c2a03f..66d353f 100644 --- a/core/views/ofm/transfers_views.py +++ b/core/views/ofm/transfers_views.py @@ -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