Module: Redmine::MyPage
- Includes:
- I18n
- Defined in:
- lib/redmine/my_page.rb
Overview
Constant Summary collapse
- CORE_GROUPS =
['top', 'left', 'right']
- CORE_BLOCKS =
{ 'issuesassignedtome' => {:label => :label_assigned_to_me_issues}, 'issuesreportedbyme' => {:label => :label_reported_issues}, 'issueswatched' => {:label => :label_watched_issues}, 'issuequery' => {:label => :label_issue_plural, :max_occurs => 3}, 'news' => {:label => :label_news_latest}, 'calendar' => {:label => :label_calendar}, 'documents' => {:label => :label_document_plural}, 'timelog' => {:label => :label_spent_time} }
Class Method Summary collapse
-
.additional_blocks ⇒ Object
Returns the additional blocks that are defined by plugin partials.
- .block_options(blocks_in_use = []) ⇒ Object
-
.blocks ⇒ Object
Returns the available blocks.
-
.default_layout ⇒ Object
Returns the default layout for My Page.
- .find_block(block) ⇒ Object
- .groups ⇒ Object
- .valid_block?(block, blocks_in_use = []) ⇒ Boolean
Methods included from I18n
#current_language, #day_letter, #day_name, #find_language, #format_date, #format_hours, #format_time, #l, #l_hours, #l_hours_short, #l_or_humanize, #languages_options, #ll, #lu, #month_name, #set_language_if_valid, #valid_languages
Class Method Details
.additional_blocks ⇒ Object
Returns the additional blocks that are defined by plugin partials
75 76 77 78 79 80 81 |
# File 'lib/redmine/my_page.rb', line 75 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] = {:label => name.to_sym, :partial => "my/blocks/#{name}"} h end end |
.block_options(blocks_in_use = []) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/redmine/my_page.rb', line 44 def self.(blocks_in_use=[]) = [] blocks.each do |block, | indexes = blocks_in_use.map {|n| if n =~ /\A#{block}(__(\d+))?\z/ $2.to_i end }.compact occurs = indexes.size block_id = indexes.any? ? "#{block}__#{indexes.max + 1}" : block disabled = (occurs >= (Redmine::MyPage.blocks[block][:max_occurs] || 1)) block_id = nil if disabled label = [:label] << [l("my.blocks.#{label}", :default => [label, label.to_s.humanize]), block_id] end end |
.blocks ⇒ Object
Returns the available blocks
40 41 42 |
# File 'lib/redmine/my_page.rb', line 40 def self.blocks CORE_BLOCKS.merge(additional_blocks).freeze end |
.default_layout ⇒ Object
Returns the default layout for My Page
84 85 86 87 88 89 |
# File 'lib/redmine/my_page.rb', line 84 def self.default_layout { 'left' => ['issuesassignedtome'], 'right' => ['issuesreportedbyme'] } end |
.find_block(block) ⇒ Object
68 69 70 71 72 |
# File 'lib/redmine/my_page.rb', line 68 def self.find_block(block) block.to_s =~ /\A(.*?)(__\d+)?\z/ name = $1 blocks.has_key?(name) ? blocks[name].merge(:name => name) : nil end |
.groups ⇒ Object
35 36 37 |
# File 'lib/redmine/my_page.rb', line 35 def self.groups CORE_GROUPS.dup.freeze end |
.valid_block?(block, blocks_in_use = []) ⇒ Boolean
64 65 66 |
# File 'lib/redmine/my_page.rb', line 64 def self.valid_block?(block, blocks_in_use=[]) block.present? && (blocks_in_use).map(&:last).include?(block) end |