From 366bedd8b4431c087b23bd743250086f857c68ee Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Wed, 27 Apr 2011 16:10:57 +0200 Subject: [PATCH 1/2] Add a short text above the progressbar --- assets/javascripts/reporting/progressbar.js | 1 + config/locales/de.yml | 1 + config/locales/en.yml | 1 + lib/widget/table/progressbar.rb | 22 +++++++++++++-------- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/assets/javascripts/reporting/progressbar.js b/assets/javascripts/reporting/progressbar.js index e2b6a74a36..a33fc45db7 100644 --- a/assets/javascripts/reporting/progressbar.js +++ b/assets/javascripts/reporting/progressbar.js @@ -28,6 +28,7 @@ Reporting.Progress = { var question = bar.getAttribute('data-translation'); if (confirm(question)) { var target = bar.getAttribute("data-target"); + bar.up().show(); Reporting.Progress.replace_with_bar(bar); Reporting.Controls.send_settings_data(target, Reporting.Controls.update_result_table); } else { diff --git a/config/locales/de.yml b/config/locales/de.yml index 2e47d1d7fa..cdc2bce24e 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -26,3 +26,4 @@ de: validation_failure_integer: "ist keine ganze Zahl" load_query_question: "Der Report wird %{size} Tabellen-Zellen haben, was sehr rechenintensiv sein kann. Wollen Sie dennoch versuchen, den Report durch zu führen?" + label_progress_bar_explanation: "Report wird erstellt ..." diff --git a/config/locales/en.yml b/config/locales/en.yml index 39e5d98c76..4164af3478 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -26,3 +26,4 @@ en: validation_failure_integer: "is not a valid integer" load_query_question: "Report will have %{size} table cells and may take some time to render. Do you still want to try rendering it?" + label_progress_bar_explanation: "Generating report..." diff --git a/lib/widget/table/progressbar.rb b/lib/widget/table/progressbar.rb index 720ee05cab..ff9bad6ac0 100644 --- a/lib/widget/table/progressbar.rb +++ b/lib/widget/table/progressbar.rb @@ -2,16 +2,22 @@ class Widget::Table::Progressbar < Widget::Base dont_cache! def render - if Widget::Table::ReportTable.new(@query).cached? || (size = @query.size) <= THRESHHOLD + if Widget::Table::ReportTable.new(@query).cached? || @query.size <= THRESHHOLD render_widget Widget::Table::ReportTable, @query, :to => (@output ||= "".html_safe) else - write(content_tag :div, - :id => "progressbar", - :class => "form_controls", - :"data-query-size" => size, - :"data-translation" => ::I18n.translate(:label_load_query_question, :size => size), - :"data-target" => url_for(:action => 'index', :set_filter => '1', :immediately => true) do - end) + write(content_tag :div, :style => "display:none" do + content_tag(:div, l(:label_progress_bar_explanation).html_safe) + + render_progress_bar + end) end end + + def render_progress_bar + content_tag(:div, "", + :id => "progressbar", + :class => "form_controls", + :"data-query-size" => @query.size, + :"data-translation" => ::I18n.translate(:label_load_query_question, :size => @query.size), + :"data-target" => url_for(:action => 'index', :set_filter => '1', :immediately => true)) + end end From 3390ebce73da0a6a2923e71429054b29ed11da5c Mon Sep 17 00:00:00 2001 From: Tim Felgentreff Date: Wed, 27 Apr 2011 16:11:11 +0200 Subject: [PATCH 2/2] Fix: throw != raise --- lib/widget.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/widget.rb b/lib/widget.rb index 205f7d04b9..2cf4e44ff2 100644 --- a/lib/widget.rb +++ b/lib/widget.rb @@ -31,7 +31,7 @@ class Widget < ActionView::Base begin controller.send(name, *args, &block) rescue NoMethodError - throw NoMethodError, "undefined method `#{name}' for #<#{self.class}:0x#{self.object_id}>" + raise NoMethodError, "undefined method `#{name}' for #<#{self.class}:0x#{self.object_id}>" end end