|
|
|
@ -18,13 +18,13 @@ class MyController < ApplicationController |
|
|
|
|
menu_item :account, :only => [:account] |
|
|
|
|
menu_item :password, :only => [:password] |
|
|
|
|
|
|
|
|
|
BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_work_packages, |
|
|
|
|
DEFAULT_BLOCKS = { 'issuesassignedtome' => :label_assigned_to_me_work_packages, |
|
|
|
|
'issuesreportedbyme' => :label_reported_work_packages, |
|
|
|
|
'issueswatched' => :label_watched_work_packages, |
|
|
|
|
'news' => :label_news_latest, |
|
|
|
|
'calendar' => :label_calendar, |
|
|
|
|
'timelog' => :label_spent_time |
|
|
|
|
}.merge(Redmine::Views::MyPage::Block.additional_blocks).freeze |
|
|
|
|
}.freeze |
|
|
|
|
|
|
|
|
|
DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'], |
|
|
|
|
'right' => ['issuesreportedbyme'] |
|
|
|
@ -33,6 +33,11 @@ class MyController < ApplicationController |
|
|
|
|
verify :xhr => true, |
|
|
|
|
:only => [:add_block, :remove_block, :order_blocks] |
|
|
|
|
|
|
|
|
|
def self.available_blocks |
|
|
|
|
@available_blocks ||= DEFAULT_BLOCKS.merge(Redmine::Views::MyPage::Block.additional_blocks) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Show user's page |
|
|
|
|
def index |
|
|
|
|
@user = User.current |
|
|
|
@ -131,7 +136,7 @@ class MyController < ApplicationController |
|
|
|
|
@user = User.current |
|
|
|
|
@blocks = @user.pref[:my_page_layout] || DEFAULT_LAYOUT.dup |
|
|
|
|
@block_options = [] |
|
|
|
|
BLOCKS.each {|k, v| @block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]} |
|
|
|
|
MyController.available_blocks.each {|k, v| @block_options << [l("my.blocks.#{v}", :default => [v, v.to_s.humanize]), k.dasherize]} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# Add a block to user's page |
|
|
|
@ -139,7 +144,7 @@ class MyController < ApplicationController |
|
|
|
|
# params[:block] : id of the block to add |
|
|
|
|
def add_block |
|
|
|
|
block = params[:block].to_s.underscore |
|
|
|
|
(render :nothing => true; return) unless block && (BLOCKS.keys.include? block) |
|
|
|
|
(render :nothing => true; return) unless block && (MyController.available_blocks.keys.include? block) |
|
|
|
|
@user = User.current |
|
|
|
|
layout = @user.pref[:my_page_layout] || {} |
|
|
|
|
# remove if already present in a group |
|
|
|
|