Project

General

Profile

Feature #11539 » HiearchyPatch.patch

William Roush, 2012-07-30 19:07

View differences:

app/helpers/my_helper.rb Mon Jul 30 01:32:31 2012 +0000 → app/helpers/my_helper.rb Mon Jul 30 12:54:10 2012 -0400
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module MyHelper
# Renders a tree of projects as a nested set of unordered lists
# The given collection may be a subset of the whole project tree
# (eg. some intermediate nodes are private and can not be seen)
def render_project_hierarchy_notifications(projects)
s = ''
if projects.any?
ancestors = []
original_project = @project
projects.each do |project|
# set the project environment to please macros.
@project = project
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
s << "<ul class='projects mypage #{ ancestors.empty? ? 'root' : nil}'>\n"
else
ancestors.pop
s << "</li>"
while (ancestors.any? && !project.is_descendant_of?(ancestors.last))
ancestors.pop
s << "</ul></li>\n"
end
end
classes = (ancestors.empty? ? 'root' : 'child mypage')
s << "<li class='#{classes}'><label>#{check_box_tag 'notified_project_ids[]', project.id, @user.notified_projects_ids.include?(project.id)} #{h project.name}</label>"
ancestors << project
end
s << ("</li></ul>\n" * ancestors.size)
@project = original_project
end
s.html_safe
end
end
app/views/users/_mail_notifications.html.erb Mon Jul 30 01:32:31 2012 +0000 → app/views/users/_mail_notifications.html.erb Mon Jul 30 12:54:10 2012 -0400
) %>
</p>
<%= content_tag 'div', :id => 'notified-projects', :style => (@user.mail_notification == 'selected' ? '' : 'display:none;') do %>
<p>
<% @user.projects.each do |project| %>
<label>
<%= check_box_tag(
'notified_project_ids[]',
project.id,
@user.notified_projects_ids.include?(project.id)
) %>
<%= h(project.name) %>
</label>
<br />
<% end %>
</p>
<%= render_project_hierarchy_notifications(@user.projects.find(:all, :order => 'lft'))%>
<p><em class="info"><%= l(:text_user_mail_option) %></em></p>
<% end %>
<p>
public/stylesheets/application.css Mon Jul 30 01:32:31 2012 +0000 → public/stylesheets/application.css Mon Jul 30 12:54:10 2012 -0400
ul.projects { margin: 0; padding-left: 1em; }
ul.projects.root { margin: 0; padding: 0; }
ul.projects ul.projects { border-left: 3px solid #e0e0e0; }
ul.projects ul.mypage { border-left:none; }
ul.projects li.root { list-style-type:none; margin-bottom: 1em; }
ul.projects li.child { list-style-type:none; margin-top: 1em;}
ul.projects li.mypage { margin:0; }
ul.projects div.root a.project { font-family: "Trebuchet MS", Verdana, sans-serif; font-weight: bold; font-size: 16px; margin: 0 0 10px 0; }
.my-project { padding-left: 18px; background: url(../images/fav.png) no-repeat 0 50%; }
(3-3/3)