Business intelligence made simple
Bug Fix: StupidTable Plugin - fix issues with sorting integers and floats in the results table (#236)
Basil Khancd587aa4639f
diff --git a/app/assets/javascripts/blazer/application.js b/app/assets/javascripts/blazer/application.jsindex 3a3e9453..0cc41843 100644--- a/app/assets/javascripts/blazer/application.js+++ b/app/assets/javascripts/blazer/application.js@@ -1,6 +1,7 @@//= require ./jquery//= require ./jquery-ujs//= require ./stupidtable+//= require ./stupidtable-custom-settings//= require ./jquery.stickytableheaders//= require ./selectize//= require ./highlight.mindiff --git a/app/assets/javascripts/blazer/stupidtable-custom-settings.js b/app/assets/javascripts/blazer/stupidtable-custom-settings.jsnew file mode 100644index 00000000..a59dffb1--- /dev/null+++ b/app/assets/javascripts/blazer/stupidtable-custom-settings.js@@ -0,0 +1,13 @@+function removeCommas(string) {+ return string.replace(/,/g, "")+}++// Remove commas for integers and floats to fix issues with sorting in the stupidtable plugin+var stupidtableCustomSettings = {+ "int": function(a, b) {+ return parseInt(removeCommas(a), 10) - parseInt(removeCommas(b), 10);+ },+ "float": function(a, b) {+ return parseFloat(removeCommas(a)) - parseFloat(removeCommas(b));+ }+}diff --git a/app/views/blazer/dashboards/show.html.erb b/app/views/blazer/dashboards/show.html.erbindex 104e75e9..29496f0f 100644--- a/app/views/blazer/dashboards/show.html.erb+++ b/app/views/blazer/dashboards/show.html.erb@@ -43,7 +43,7 @@runQuery(data, function (data) {$("#chart-<%= i %>").html(data)- $("#chart-<%= i %> table").stupidtable()+ $("#chart-<%= i %> table").stupidtable(stupidtableCustomSettings)}, function (message) {$("#chart-<%= i %>").addClass("query-error").html(message)});diff --git a/app/views/blazer/queries/show.html.erb b/app/views/blazer/queries/show.html.erbindex 1fd93e2c..75d76f63 100644--- a/app/views/blazer/queries/show.html.erb+++ b/app/views/blazer/queries/show.html.erb@@ -49,7 +49,7 @@<script>function showRun(data) {$("#results").html(data)- $("#results table").stupidtable().stickyTableHeaders({fixedOffset: 60})+ $("#results table").stupidtable(stupidtableCustomSettings).stickyTableHeaders({fixedOffset: 60})}function showError(message) {