diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-29 10:10:31 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2016-10-29 10:10:31 +0000 |
commit | 8b86d5158e50d27de68a3c69c12b06e1af0deb52 (patch) | |
tree | 724ac0a770438aa579d94a77b6855361a329274c /lib/redmine | |
parent | 6ef3ecc030cfc744244bb15db2f2ef0eb46ed439 (diff) | |
download | redmine-8b86d5158e50d27de68a3c69c12b06e1af0deb52.tar.gz redmine-8b86d5158e50d27de68a3c69c12b06e1af0deb52.zip |
Moves blocks definition to Redmine::MyPage.
git-svn-id: http://svn.redmine.org/redmine/trunk@15930 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib/redmine')
-rw-r--r-- | lib/redmine/my_page.rb | 62 | ||||
-rw-r--r-- | lib/redmine/views/my_page/block.rb | 32 |
2 files changed, 62 insertions, 32 deletions
diff --git a/lib/redmine/my_page.rb b/lib/redmine/my_page.rb new file mode 100644 index 000000000..0c11459e4 --- /dev/null +++ b/lib/redmine/my_page.rb @@ -0,0 +1,62 @@ +# Redmine - project management software +# Copyright (C) 2006-2016 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# 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. + +module Redmine + module MyPage + include Redmine::I18n + + CORE_BLOCKS = { + 'issuesassignedtome' => :label_assigned_to_me_issues, + 'issuesreportedbyme' => :label_reported_issues, + 'issueswatched' => :label_watched_issues, + 'news' => :label_news_latest, + 'calendar' => :label_calendar, + 'documents' => :label_document_plural, + 'timelog' => :label_spent_time + } + + # Returns the available blocks + def self.blocks + CORE_BLOCKS.merge(additional_blocks).freeze + end + + def self.block_options + options = [] + blocks.each do |k, v| + options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize] + end + options + end + + # Returns the additional blocks that are defined by plugin partials + def self.additional_blocks + @@additional_blocks ||= Dir.glob("#{Redmine::Plugin.directory}/*/app/views/my/blocks/_*.{rhtml,erb}").inject({}) do |h,file| + name = File.basename(file).split('.').first.gsub(/^_/, '') + h[name] = name.to_sym + h + end + end + + # Returns the default layout for My Page + def self.default_layout + { + 'left' => ['issuesassignedtome'], + 'right' => ['issuesreportedbyme'] + } + end + end +end diff --git a/lib/redmine/views/my_page/block.rb b/lib/redmine/views/my_page/block.rb deleted file mode 100644 index 07398d788..000000000 --- a/lib/redmine/views/my_page/block.rb +++ /dev/null @@ -1,32 +0,0 @@ -# Redmine - project management software -# Copyright (C) 2006-2016 Jean-Philippe Lang -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# 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. - -module Redmine - module Views - module MyPage - module Block - def self.additional_blocks - @@additional_blocks ||= Dir.glob("#{Redmine::Plugin.directory}/*/app/views/my/blocks/_*.{rhtml,erb}").inject({}) do |h,file| - name = File.basename(file).split('.').first.gsub(/^_/, '') - h[name] = name.to_sym - h - end - end - end - end - end -end |