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.
97 lines
3.6 KiB
97 lines
3.6 KiB
11 years ago
|
#-- copyright
|
||
5 years ago
|
# OpenProject is an open source project management software.
|
||
|
# Copyright (C) 2012-2020 the OpenProject GmbH
|
||
11 years ago
|
#
|
||
5 years ago
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License version 3.
|
||
|
#
|
||
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
11 years ago
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
5 years ago
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
11 years ago
|
#
|
||
|
# 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.
|
||
5 years ago
|
#
|
||
|
# See docs/COPYRIGHT.rdoc for more details.
|
||
11 years ago
|
#++
|
||
|
|
||
13 years ago
|
class Widget::GroupBys < Widget::Base
|
||
|
def render_options(group_by_ary)
|
||
10 years ago
|
group_by_ary.sort_by(&:label).map do |group_by|
|
||
13 years ago
|
next unless group_by.selectable?
|
||
10 years ago
|
content_tag :option, value: group_by.underscore_name, :'data-label' => "#{CGI::escapeHTML(h(group_by.label))}" do
|
||
12 years ago
|
h(group_by.label)
|
||
13 years ago
|
end
|
||
|
end.join.html_safe
|
||
|
end
|
||
|
|
||
8 years ago
|
def render_group(type, initially_selected)
|
||
13 years ago
|
initially_selected = initially_selected.map do |group_by|
|
||
12 years ago
|
[group_by.class.underscore_name, h(group_by.class.label)]
|
||
13 years ago
|
end
|
||
13 years ago
|
|
||
8 years ago
|
content_tag :fieldset do
|
||
|
legend = content_tag :legend, I18n.t("reporting.group_by.selected_#{type}"), class: 'hidden-for-sighted'
|
||
|
|
||
|
container = content_tag :div,
|
||
4 years ago
|
id: "group-by--#{type}",
|
||
|
class: 'group-by--container grid-block',
|
||
|
:'data-initially-selected' => initially_selected.to_json.gsub('"', "'") do
|
||
8 years ago
|
out = content_tag :span, class: 'group-by--caption grid-content shrink' do
|
||
|
content_tag :span do
|
||
4 years ago
|
I18n.t(:"label_#{type}")
|
||
8 years ago
|
end
|
||
|
end
|
||
13 years ago
|
|
||
8 years ago
|
out += content_tag :span, '', id: "group-by--selected-#{type}", class: 'group-by--selected-elements grid-block'
|
||
13 years ago
|
|
||
8 years ago
|
out += content_tag :span,
|
||
|
class: 'group-by--control grid-content shrink' do
|
||
|
label = label_tag "group-by--add-#{type}",
|
||
4 years ago
|
I18n.t(:"label_group_by_add") + ' ' +
|
||
4 years ago
|
I18n.t('js.filter.description.text_open_filter'),
|
||
|
class: 'hidden-for-sighted'
|
||
13 years ago
|
|
||
8 years ago
|
label += content_tag :select, id: "group-by--add-#{type}", class: 'advanced-filters--select' do
|
||
4 years ago
|
content = content_tag :option, I18n.t(:label_group_by_add), value: ''
|
||
13 years ago
|
|
||
8 years ago
|
content += engine::GroupBy.all_grouped.sort_by do |label, _group_by_ary|
|
||
4 years ago
|
I18n.t(label)
|
||
8 years ago
|
end.map do |label, group_by_ary|
|
||
4 years ago
|
content_tag :optgroup, label: h(I18n.t(label)) do
|
||
8 years ago
|
render_options group_by_ary
|
||
|
end
|
||
|
end.join.html_safe
|
||
|
content
|
||
13 years ago
|
end
|
||
13 years ago
|
|
||
8 years ago
|
label
|
||
|
end
|
||
|
|
||
|
out
|
||
13 years ago
|
end
|
||
13 years ago
|
|
||
8 years ago
|
legend + container
|
||
13 years ago
|
end
|
||
|
end
|
||
|
|
||
|
def render
|
||
6 years ago
|
write(content_tag(:div, id: 'group-by--area', class: 'autoscroll') do
|
||
8 years ago
|
out = render_group 'columns', @subject.group_bys(:column)
|
||
13 years ago
|
out += render_group 'rows', @subject.group_bys(:row)
|
||
|
out.html_safe
|
||
|
end)
|
||
|
end
|
||
|
end
|