diff --git a/assets/javascripts/reporting.js b/assets/javascripts/reporting.js index fd347d9c7b..d8c7183714 100644 --- a/assets/javascripts/reporting.js +++ b/assets/javascripts/reporting.js @@ -27,6 +27,7 @@ Reporting.require("filters"); Reporting.require("group_bys"); Reporting.require("restore_query"); Reporting.require("controls"); +Reporting.require("table"); // // function hide_category(tr_field) { diff --git a/assets/javascripts/reporting/table.js b/assets/javascripts/reporting/table.js new file mode 100644 index 0000000000..a427b22354 --- /dev/null +++ b/assets/javascripts/reporting/table.js @@ -0,0 +1,9 @@ +/*jslint white: false, nomen: true, devel: true, on: true, debug: false, evil: true, onevar: false, browser: true, white: false, indent: 2 */ +/*global window, $, $$, Reporting, Effect, Ajax */ + +Reporting.Table = { +}; + +Reporting.onload(function () { + Reporting.RestoreQuery.restore_group_bys(); +}); diff --git a/lib/report.rb b/lib/report.rb index 978eb108f6..7ba4949dab 100644 --- a/lib/report.rb +++ b/lib/report.rb @@ -123,7 +123,7 @@ class Report < ActiveRecord::Base def_delegators :transformer, :column_first, :row_first def_delegators :chain, :empty_chain, :top, :bottom, :chain_collect, :sql_statement, :all_group_fields, :child, :clear, :result def_delegators :result, :each_direct_result, :recursive_each, :recursive_each_with_level, :each, :each_row, :count, - :units, :size, :final_number + :units, :final_number def_delegators :table, :row_index, :colum_index def to_a @@ -134,21 +134,27 @@ class Report < ActiveRecord::Base chain.to_s end + def size + size = 0 + recursive_each {|r| size += r.size } + size + end + def hash report_string = "" - + report_string.concat('filters: [') - report_string.concat(filters.map { |f| - f.class.underscore_name + f.operator.to_s + (f.values ? f.values.to_json : "") + report_string.concat(filters.map { |f| + f.class.underscore_name + f.operator.to_s + (f.values ? f.values.to_json : "") }.sort.join(', ')) report_string.concat(']') report_string.concat(', group_bys: {') - report_string.concat(group_bys.group_by(&:type).map { |t, gbs| + report_string.concat(group_bys.group_by(&:type).map { |t, gbs| "#{t} : [#{gbs.collect(&:class).collect(&:underscore_name).join(', ')}]" }.join(', ')) - + report_string.concat('}') report_string.hash diff --git a/lib/report/controller.rb b/lib/report/controller.rb index f94f58efaf..899b0ec1ae 100644 --- a/lib/report/controller.rb +++ b/lib/report/controller.rb @@ -29,6 +29,10 @@ module Report::Controller render :partial => 'table' if set_filter? end + def table_without_progress_info + render :partial => 'table_without_progress_info' if set_filter? + end + ## # Create a new saved query. Returns the redirect url to an XHR or redirects directly def create diff --git a/lib/widget/table/progressbar.rb b/lib/widget/table/progressbar.rb new file mode 100644 index 0000000000..a372b0cd67 --- /dev/null +++ b/lib/widget/table/progressbar.rb @@ -0,0 +1,20 @@ +class Widget::Table::Progressbar < Widget::Base + attr_accessor :threshhold + + def render + @threshhold ||= 5 + size = @query.size + content_tag :div, :class => "progressbar", :style => "display:none", + :"data-query-size" => size do + if size > @threshhold + content_tag :div, :id => "progressbar-load-table-question" do + tag(:span, ::I18n.t(:load_query_question, size), :id => "progressbar-text") + tag(:span, ::I18n.t(:label_yes), :id => "progressbar-yes") + tag(:span, ::I18n.t(:label_no), :id => "progressbar-no") + end + else + tag :span, :id => "progressbar-load-table-directly" + end + end + end +end