mirror of
https://github.com/redmine/redmine.git
synced 2025-11-15 17:56:03 +01:00
Adds helpers for rendering my page blocks.
git-svn-id: http://svn.redmine.org/redmine/trunk@15927 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -18,6 +18,41 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
module MyHelper
|
module MyHelper
|
||||||
|
# Renders the blocks
|
||||||
|
def render_blocks(blocks, user, options={})
|
||||||
|
s = ''.html_safe
|
||||||
|
|
||||||
|
if blocks.present?
|
||||||
|
blocks.each do |block|
|
||||||
|
content = render_block_content(block, user)
|
||||||
|
if content.present?
|
||||||
|
if options[:edit]
|
||||||
|
close = link_to("", {:action => "remove_block", :block => block}, :method => 'post', :class => "close-icon")
|
||||||
|
content = close + content_tag('div', content, :class => 'handle')
|
||||||
|
end
|
||||||
|
|
||||||
|
s << content_tag('div', content, :class => "mypage-box", :id => "block-#{block}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
s
|
||||||
|
end
|
||||||
|
|
||||||
|
# Renders a single block content
|
||||||
|
def render_block_content(block, user)
|
||||||
|
unless MyController::BLOCKS.keys.include?(block)
|
||||||
|
Rails.logger.warn("Unknown block \"#{block}\" found in #{user.login} (id=#{user.id}) preferences")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
begin
|
||||||
|
render(:partial => "my/blocks/#{block}", :locals => {:user => user})
|
||||||
|
rescue ActionView::MissingTemplate
|
||||||
|
Rails.logger.warn("Template missing for block \"#{block}\" found in #{user.login} (id=#{user.id}) preferences")
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def calendar_items(startdt, enddt)
|
def calendar_items(startdt, enddt)
|
||||||
Issue.visible.
|
Issue.visible.
|
||||||
where(:project_id => User.current.projects.map(&:id)).
|
where(:project_id => User.current.projects.map(&:id)).
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
<div id="block_<%= block_name.dasherize %>" class="mypage-box">
|
|
||||||
|
|
||||||
<div style="float:right;margin-right:16px;z-index:500;">
|
|
||||||
<%= link_to "", {:action => "remove_block", :block => block_name}, :method => 'post', :class => "close-icon" %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="handle">
|
|
||||||
<%= render :partial => "my/blocks/#{block_name}", :locals => { :user => user } %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -5,30 +5,15 @@
|
|||||||
<h2><%=l(:label_my_page)%></h2>
|
<h2><%=l(:label_my_page)%></h2>
|
||||||
|
|
||||||
<div id="list-top">
|
<div id="list-top">
|
||||||
<% @blocks['top'].each do |b|
|
<%= render_blocks(@blocks['top'], @user) %>
|
||||||
next unless MyController::BLOCKS.keys.include? b %>
|
|
||||||
<div class="mypage-box">
|
|
||||||
<%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %>
|
|
||||||
</div>
|
|
||||||
<% end if @blocks['top'] %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="list-left" class="splitcontentleft">
|
<div id="list-left" class="splitcontentleft">
|
||||||
<% @blocks['left'].each do |b|
|
<%= render_blocks(@blocks['left'], @user) %>
|
||||||
next unless MyController::BLOCKS.keys.include? b %>
|
|
||||||
<div class="mypage-box">
|
|
||||||
<%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %>
|
|
||||||
</div>
|
|
||||||
<% end if @blocks['left'] %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="list-right" class="splitcontentright">
|
<div id="list-right" class="splitcontentright">
|
||||||
<% @blocks['right'].each do |b|
|
<%= render_blocks(@blocks['right'], @user) %>
|
||||||
next unless MyController::BLOCKS.keys.include? b %>
|
|
||||||
<div class="mypage-box">
|
|
||||||
<%= render :partial => "my/blocks/#{b}", :locals => { :user => @user } %>
|
|
||||||
</div>
|
|
||||||
<% end if @blocks['right'] %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= context_menu issues_context_menu_path %>
|
<%= context_menu issues_context_menu_path %>
|
||||||
|
|||||||
@@ -14,24 +14,15 @@
|
|||||||
<h2><%=l(:label_my_page)%></h2>
|
<h2><%=l(:label_my_page)%></h2>
|
||||||
|
|
||||||
<div id="list-top" class="block-receiver">
|
<div id="list-top" class="block-receiver">
|
||||||
<% @blocks['top'].each do |b|
|
<%= render_blocks(@blocks['top'], @user, :edit => true) %>
|
||||||
next unless MyController::BLOCKS.keys.include? b %>
|
|
||||||
<%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
|
|
||||||
<% end if @blocks['top'] %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="list-left" class="splitcontentleft block-receiver">
|
<div id="list-left" class="splitcontentleft block-receiver">
|
||||||
<% @blocks['left'].each do |b|
|
<%= render_blocks(@blocks['left'], @user, :edit => true) %>
|
||||||
next unless MyController::BLOCKS.keys.include? b %>
|
|
||||||
<%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
|
|
||||||
<% end if @blocks['left'] %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="list-right" class="splitcontentright block-receiver">
|
<div id="list-right" class="splitcontentright block-receiver">
|
||||||
<% @blocks['right'].each do |b|
|
<%= render_blocks(@blocks['right'], @user, :edit => true) %>
|
||||||
next unless MyController::BLOCKS.keys.include? b %>
|
|
||||||
<%= render :partial => 'block', :locals => {:user => @user, :block_name => b} %>
|
|
||||||
<% end if @blocks['right'] %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= javascript_tag "initMyPageSortable('top', '#{ escape_javascript url_for(:action => "order_blocks", :group => "top") }');" %>
|
<%= javascript_tag "initMyPageSortable('top', '#{ escape_javascript url_for(:action => "order_blocks", :group => "top") }');" %>
|
||||||
|
|||||||
@@ -1077,6 +1077,10 @@ div.wiki img {vertical-align:middle; max-width:100%;}
|
|||||||
color:#505050;
|
color:#505050;
|
||||||
line-height:1.5em;
|
line-height:1.5em;
|
||||||
}
|
}
|
||||||
|
.mypage-box .close-icon {
|
||||||
|
float:right;
|
||||||
|
z-index:500;
|
||||||
|
}
|
||||||
|
|
||||||
.handle {cursor: move;}
|
.handle {cursor: move;}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user