mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-12 04:03:08 +00:00
Makes public and admin project lists work as expected.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/work@2158 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
3697ad1007
commit
1f75a1f957
@ -20,4 +20,12 @@ module AdminHelper
|
||||
options_for_select([[l(:label_all), ''],
|
||||
[l(:status_active), 1]], selected)
|
||||
end
|
||||
|
||||
def css_project_classes(project)
|
||||
s = 'project'
|
||||
s << ' root' if project.root?
|
||||
s << ' child' if project.child?
|
||||
s << (project.leaf? ? ' leaf' : ' parent')
|
||||
s
|
||||
end
|
||||
end
|
||||
|
||||
@ -37,4 +37,34 @@ module ProjectsHelper
|
||||
def project_hierarchy_collection_for_select(projects)
|
||||
projects.sort_by(&:lft).collect {|p| [('>' * p.level) + p.name.to_s, p.id]}
|
||||
end
|
||||
|
||||
# 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(projects)
|
||||
s = ''
|
||||
if projects.any?
|
||||
ancestors = []
|
||||
projects.each do |project|
|
||||
if (ancestors.empty? || project.is_descendant_of?(ancestors.last))
|
||||
s << "<ul class='projects #{ 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')
|
||||
s << "<li class='#{classes}'><div class='#{classes}'>" +
|
||||
link_to(h(project), {:controller => 'projects', :action => 'show', :id => project}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
|
||||
s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank?
|
||||
s << "</div>\n"
|
||||
ancestors << project
|
||||
end
|
||||
s << ("</li></ul>\n" * ancestors.size)
|
||||
end
|
||||
s
|
||||
end
|
||||
end
|
||||
|
||||
@ -251,7 +251,7 @@ class Project < ActiveRecord::Base
|
||||
|
||||
# Returns a short description of the projects (first lines)
|
||||
def short_description(length = 255)
|
||||
description.gsub(/^(.{#{length}}[^\n]*).*$/m, '\1').strip if description
|
||||
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||
end
|
||||
|
||||
def allows_to?(action)
|
||||
|
||||
@ -26,11 +26,11 @@
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% for project in @projects %>
|
||||
<tr class="<%= cycle("odd", "even") %>">
|
||||
<td style="padding-left: <%= project.level %>em;"><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %>
|
||||
<td><%= textilizable project.short_description, :project => project %>
|
||||
<td align="center"><%= image_tag 'true.png' if project.is_public? %>
|
||||
<td align="center"><%= format_date(project.created_on) %>
|
||||
<tr class="<%= cycle("odd", "even") %> <%= css_project_classes(project) %>">
|
||||
<td class="name" style="padding-left: <%= project.level %>em;"><%= project.active? ? link_to(h(project.name), :controller => 'projects', :action => 'settings', :id => project) : h(project.name) %></td>
|
||||
<td><%= textilizable project.short_description, :project => project %></td>
|
||||
<td align="center"><%= image_tag 'true.png' if project.is_public? %></td>
|
||||
<td align="center"><%= format_date(project.created_on) %></td>
|
||||
<td align="center" style="width:10%">
|
||||
<small>
|
||||
<%= link_to(l(:button_archive), { :controller => 'projects', :action => 'archive', :id => project }, :confirm => l(:text_are_you_sure), :method => :post, :class => 'icon icon-lock') if project.active? %>
|
||||
|
||||
@ -6,20 +6,11 @@
|
||||
|
||||
<h2><%=l(:label_project_plural)%></h2>
|
||||
|
||||
<% @project_tree.keys.sort.each do |project| %>
|
||||
<h3><%= link_to h(project.name), {:action => 'show', :id => project}, :class => (User.current.member_of?(project) ? "icon icon-fav" : "") %></h3>
|
||||
<%= textilizable(project.short_description, :project => project) %>
|
||||
|
||||
<% if @project_tree[project].any? %>
|
||||
<p><%= l(:label_subproject_plural) %>:
|
||||
<%= @project_tree[project].sort.collect {|subproject|
|
||||
link_to(h(subproject.name), {:action => 'show', :id => subproject}, :class => (User.current.member_of?(subproject) ? "icon icon-fav" : ""))}.join(', ') %></p>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= render_project_hierarchy(Project.find(:all, :order => 'lft'))%>
|
||||
|
||||
<% if User.current.logged? %>
|
||||
<p style="text-align:right;">
|
||||
<span class="icon icon-fav"><%= l(:label_my_projects) %></span>
|
||||
<span class="my-project"><%= l(:label_my_projects) %></span>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
||||
@ -85,6 +85,9 @@ table.list td { vertical-align: top; }
|
||||
table.list td.id { width: 2%; text-align: center;}
|
||||
table.list td.checkbox { width: 15px; padding: 0px;}
|
||||
|
||||
tr.project td.name a { padding-left: 16px; white-space:nowrap; }
|
||||
tr.project.parent td.name a { background: url('../images/bullet_toggle_minus.png') no-repeat; }
|
||||
|
||||
tr.issue { text-align: center; white-space: nowrap; }
|
||||
tr.issue td.subject, tr.issue td.category, td.assigned_to { white-space: normal; }
|
||||
tr.issue td.subject { text-align: left; }
|
||||
@ -228,6 +231,15 @@ table#time-report tbody tr.last-level { font-style: normal; color: #555; }
|
||||
table#time-report tbody tr.total { font-style: normal; font-weight: bold; color: #555; background-color:#EEEEEE; }
|
||||
table#time-report .hours-dec { font-size: 0.9em; }
|
||||
|
||||
ul.projects { margin: 0; padding-left: 1em; }
|
||||
ul.projects.root { margin: 0; padding: 0; }
|
||||
ul.projects ul { border-left: 3px solid #e0e0e0; }
|
||||
ul.projects li { list-style-type:none; }
|
||||
ul.projects li.root { margin-bottom: 1em; }
|
||||
ul.projects li.child { margin-top: 1em;}
|
||||
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%; }
|
||||
|
||||
ul.properties {padding:0; font-size: 0.9em; color: #777;}
|
||||
ul.properties li {list-style-type:none;}
|
||||
ul.properties li span {font-style:italic;}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user