kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.1 KiB
71 lines
2.1 KiB
11 years ago
|
#-- 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.
|
||
|
#++
|
||
|
|
||
13 years ago
|
class Widget::Table < Widget::Base
|
||
|
extend Report::InheritedAttribute
|
||
|
include ReportingHelper
|
||
|
|
||
|
attr_accessor :debug
|
||
|
attr_accessor :fields
|
||
|
attr_accessor :mapping
|
||
|
|
||
|
def initialize(query)
|
||
10 years ago
|
raise ArgumentError, 'Tables only work on Reports!' unless query.is_a? Report
|
||
13 years ago
|
super
|
||
|
end
|
||
|
|
||
|
def resolve_table
|
||
|
if @subject.group_bys.size == 0
|
||
|
self.class.detailed_table
|
||
|
elsif @subject.group_bys.size == 1
|
||
|
self.class.simple_table
|
||
|
else
|
||
|
self.class.fancy_table
|
||
|
end
|
||
|
end
|
||
|
|
||
10 years ago
|
def self.detailed_table(klass = nil)
|
||
13 years ago
|
@@detail_table = klass if klass
|
||
|
defined?(@@detail_table) ? @@detail_table : fancy_table
|
||
|
end
|
||
|
|
||
10 years ago
|
def self.simple_table(klass = nil)
|
||
13 years ago
|
@@simple_table = klass if klass
|
||
|
defined?(@@simple_table) ? @@simple_table : fancy_table
|
||
|
end
|
||
|
|
||
10 years ago
|
def self.fancy_table(klass = nil)
|
||
13 years ago
|
@@fancy_table = klass if klass
|
||
|
@@fancy_table
|
||
|
end
|
||
|
fancy_table Widget::Table::ReportTable
|
||
|
|
||
|
def render
|
||
10 years ago
|
write('<!-- table start -->')
|
||
13 years ago
|
if @subject.result.count <= 0
|
||
9 years ago
|
write(content_tag(:div, '', class: 'generic-table--no-results-container') do
|
||
|
content_tag(:i, '', class: 'icon-info1') + content_tag(:h2, l(:no_results_title_text), class: 'generic-table--no-results-title')
|
||
|
end)
|
||
13 years ago
|
else
|
||
10 years ago
|
str = render_widget(resolve_table, @subject, @options.reverse_merge(to: @output))
|
||
13 years ago
|
@cache_output.write(str.html_safe) if @cache_output
|
||
|
end
|
||
|
end
|
||
|
end
|