From 3ee993fb7791002f3a51e8ed62112cf698c45d12 Mon Sep 17 00:00:00 2001 From: Christian Rijke Date: Mon, 10 Jun 2013 15:18:52 +0200 Subject: [PATCH 1/5] Use GET to retrieve list of values instead of POST. --- lib/assets/javascripts/reporting_engine/reporting/filters.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/assets/javascripts/reporting_engine/reporting/filters.js b/lib/assets/javascripts/reporting_engine/reporting/filters.js index 4b38118e86..3e06eb7149 100644 --- a/lib/assets/javascripts/reporting_engine/reporting/filters.js +++ b/lib/assets/javascripts/reporting_engine/reporting/filters.js @@ -29,6 +29,7 @@ Reporting.Filters = { filter_name: filter_name, values: json_post_select_values }, + method: 'get', insertion: 'bottom', evalScripts: false, onCreate: function (a, b) { From c4756de0d8db9119129bc7ccb3c7fb33b33ce9ea Mon Sep 17 00:00:00 2001 From: Christian Rijke Date: Mon, 10 Jun 2013 16:36:06 +0200 Subject: [PATCH 2/5] Revert "Return html in response instead of redirect url." This reverts commit 8923bd5529451dec35c2bbc94b6484cf6c6ae0ef. --- lib/report/controller.rb | 14 ++++++++++---- lib/widget.rb | 8 ++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/report/controller.rb b/lib/report/controller.rb index 08f14d2324..24e223b0d1 100644 --- a/lib/report/controller.rb +++ b/lib/report/controller.rb @@ -36,13 +36,19 @@ module Report::Controller end def table_without_progress_info - render :text => render_widget(Widget::Table, @query), :layout => !request.xhr? + stream do + render_widget Widget::Table, @query + end end def table_with_progress_info render :text => render_widget(Widget::Table::Progressbar, @query), :layout => !request.xhr? end + def stream(&block) + self.response_body = block + end + ## # Create a new saved query. Returns the redirect url to an XHR or redirects directly def create @@ -50,9 +56,9 @@ module Report::Controller @query.public! if make_query_public? @query.send("#{user_key}=", current_user.id) @query.save! - if request.xhr? - table - else + if request.xhr? # Update via AJAX - return url for redirect + render :text => url_for(:action => "show", :id => @query.id) + else # Redirect to the new record redirect_to :action => "show", :id => @query.id end end diff --git a/lib/widget.rb b/lib/widget.rb index d3b4387735..5c6ebf41f4 100644 --- a/lib/widget.rb +++ b/lib/widget.rb @@ -34,8 +34,12 @@ class Widget < ActionView::Base module RenderWidgetInstanceMethods def render_widget(widget, subject, options = {}, &block) i = widget.new(subject) - i.config = config - i._routes = _routes + if Rails.version.start_with? "3" + i.config = config + i._routes = _routes + else + i.output_buffer = "" + end i._content_for = @_content_for i.controller = respond_to?(:controller) ? controller : self i.render_with_options(options, &block) From 0b5b8764ecca322c9b2e4b1766504f694d68d3c1 Mon Sep 17 00:00:00 2001 From: Christian Rijke Date: Tue, 11 Jun 2013 12:02:41 +0200 Subject: [PATCH 3/5] Inline 'stream' method as it is used only once and passing a block argument and capturing it doesn't work properly for streaming. --- lib/report/controller.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/report/controller.rb b/lib/report/controller.rb index 24e223b0d1..5ace166ce5 100644 --- a/lib/report/controller.rb +++ b/lib/report/controller.rb @@ -36,19 +36,14 @@ module Report::Controller end def table_without_progress_info - stream do - render_widget Widget::Table, @query - end + # stream result to client + self.response_body = render_widget(Widget::Table, @query) end def table_with_progress_info render :text => render_widget(Widget::Table::Progressbar, @query), :layout => !request.xhr? end - def stream(&block) - self.response_body = block - end - ## # Create a new saved query. Returns the redirect url to an XHR or redirects directly def create From 05dfa8fefb27b20383b880be4b3b5416b13e978c Mon Sep 17 00:00:00 2001 From: Christian Rijke Date: Tue, 11 Jun 2013 17:09:27 +0200 Subject: [PATCH 4/5] Revert change of request method. --- lib/assets/javascripts/reporting_engine/reporting/filters.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/assets/javascripts/reporting_engine/reporting/filters.js b/lib/assets/javascripts/reporting_engine/reporting/filters.js index 3e06eb7149..4b38118e86 100644 --- a/lib/assets/javascripts/reporting_engine/reporting/filters.js +++ b/lib/assets/javascripts/reporting_engine/reporting/filters.js @@ -29,7 +29,6 @@ Reporting.Filters = { filter_name: filter_name, values: json_post_select_values }, - method: 'get', insertion: 'bottom', evalScripts: false, onCreate: function (a, b) { From 895c38bc8a3a88e6b2d03b4383833fbd7790451a Mon Sep 17 00:00:00 2001 From: Christian Rijke Date: Tue, 11 Jun 2013 17:09:38 +0200 Subject: [PATCH 5/5] Remove Rails2 specific code. --- lib/widget.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/widget.rb b/lib/widget.rb index 5c6ebf41f4..d3b4387735 100644 --- a/lib/widget.rb +++ b/lib/widget.rb @@ -34,12 +34,8 @@ class Widget < ActionView::Base module RenderWidgetInstanceMethods def render_widget(widget, subject, options = {}, &block) i = widget.new(subject) - if Rails.version.start_with? "3" - i.config = config - i._routes = _routes - else - i.output_buffer = "" - end + i.config = config + i._routes = _routes i._content_for = @_content_for i.controller = respond_to?(:controller) ? controller : self i.render_with_options(options, &block)