From ea69f0a3b91a88efe1fc030d0f1bdf1fb255f46e Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Fri, 25 Feb 2011 15:25:22 +0100 Subject: [PATCH] on query request failure, show an error flash --- assets/javascripts/reporting.js | 7 +++++++ assets/javascripts/reporting/controls.js | 10 ++++++++-- assets/stylesheets/reporting.css | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/reporting.js b/assets/javascripts/reporting.js index 02581171f2..04bf9536d5 100644 --- a/assets/javascripts/reporting.js +++ b/assets/javascripts/reporting.js @@ -20,6 +20,13 @@ window.Reporting = { onload: function (func) { document.observe("dom:loaded", func); + }, + + flash: function (string, type) { + if (type === undefined) { + type = "error"; + } + $("content").insert({before: "
" + string + "
"}); } }; diff --git a/assets/javascripts/reporting/controls.js b/assets/javascripts/reporting/controls.js index 6f063cfc36..231b3c70bf 100644 --- a/assets/javascripts/reporting/controls.js +++ b/assets/javascripts/reporting/controls.js @@ -62,7 +62,12 @@ Reporting.Controls = { e.preventDefault(); }, - send_settings_data: function (targetUrl, callback) { + send_settings_data: function (targetUrl, callback, failureCallback) { + if (failureCallback === undefined) { + failureCallback = function () { + Reporting.flash("There was an error getting the results. The administrator has been informed."); + }; + } selectAllOptions('group_by_rows'); selectAllOptions('group_by_columns'); var updater = new Ajax.Request( @@ -70,7 +75,8 @@ Reporting.Controls = { { asynchronous: true, evalScripts: true, postBody: Form.serialize('query_form'), - onSuccess: callback }); + onSuccess: callback, + onFailure: failureCallback}); }, attach_settings_callback: function (element, callback) { diff --git a/assets/stylesheets/reporting.css b/assets/stylesheets/reporting.css index 8d78b8ba39..67cab0ca83 100644 --- a/assets/stylesheets/reporting.css +++ b/assets/stylesheets/reporting.css @@ -410,6 +410,27 @@ div.button_form p * { margin: 2px; } +/***** Flash ******/ +#flash_error { + font-size: large; + line-height: 1; + text-align: center; + width: 90%; + background-color: #D55; + padding: 5px; + margin-bottom: 1em; +} + +#flash_info { + font-size: large; + line-height: 1; + text-align: center; + width: 90%; + background-color: #FC6; + padding: 5px; + margin-bottom: 1em; +} + /***** Ajax indicator ******/ #ajax-indicator { font-family: Verdana, sans-serif;