Merge pull request #88 from finnlabs/fix/remove_progressbar

Fix/remove progressbar
pull/6827/head
ulferts 8 years ago committed by GitHub
commit 318e0186a1
  1. 22
      lib/report/controller.rb
  2. 2
      lib/widget/filters.rb
  3. 50
      lib/widget/table/progressbar.rb

@ -34,7 +34,6 @@ module Report::Controller
before_action :prepare_query, only: [:index, :create]
before_action :find_optional_report, only: [:index, :show, :update, :destroy, :rename]
before_action :possibly_only_narrow_values
before_action { @no_progress = no_progress? }
end
end
@ -46,23 +45,10 @@ module Report::Controller
# Render the report. Renders either the complete index or the table only
def table
if set_filter? && request.xhr?
if no_progress?
table_without_progress_info
else
table_with_progress_info
end
self.response_body = render_widget(Widget::Table, @query)
end
end
def table_without_progress_info
# stream result to client
self.response_body = render_widget(Widget::Table, @query)
end
def table_with_progress_info
render plain: render_widget(Widget::Table::Progressbar, @query), layout: !request.xhr? and return
end
##
# Create a new saved query. Returns the redirect url to an XHR or redirects directly
def create
@ -187,12 +173,6 @@ module Report::Controller
params[:set_filter].to_i == 1
end
##
# Determines if the requested table should be rendered with a progressbar
def no_progress?
!!params[:immediately]
end
##
# Return the active filters
def filter_params

@ -82,7 +82,7 @@ class Widget::Filters < Widget::Base
elsif engine::Operator.time_operators.all? { |o| f_cls.available_operators.include? o }
render_widget Date, f, to: html
elsif engine::Operator.integer_operators.all? { |o| f_cls.available_operators.include? o }
if f_cls.available_values.empty?
if f_cls.available_values.nil? || f_cls.available_values.empty?
render_widget TextBox, f, to: html
else
render_widget MultiValues, f, to: html, lazy: true

@ -1,50 +0,0 @@
#-- copyright
# ReportingEngine
#
# Copyright (C) 2010 - 2014 the OpenProject Foundation (OPF)
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#++
class Widget::Table::Progressbar < Widget::Base
dont_cache!
# Defines the minimum number of cells for a 'big' report
# Big reports may be handled differently in the UI - i.e. ask the user
# if he's really sure to execute such a heavy report
THRESHHOLD = 2000
def render
if render_table?
render_widget Widget::Table, @subject, to: (@output ||= ''.html_safe)
else
write(content_tag(:label, style: 'display:none') do
content_tag(:div, l(:label_progress_bar_explanation).html_safe) + render_progress_bar
end)
end
end
def render_table?
Widget::Table.new(@subject).resolve_table.new(@subject).cached? || @subject.size <= THRESHHOLD
end
def render_progress_bar
content_tag(:div, '',
id: 'progressbar',
class: 'form_controls',
:"data-query-size" => @subject.size,
:"data-translation" => ::I18n.translate(:label_load_query_question, size: @subject.size),
:"data-target" => url_for(action: 'index', set_filter: '1', immediately: true))
end
end
Loading…
Cancel
Save