show.rhtml

Andrew R Jackson, 2010-07-23 16:34

Download (7.7 KB)

 
1
<div class="contextual">
2
  <% if User.current.allowed_to?(:add_subprojects, @project) %>
3
      <%= link_to l(:label_subproject_new), {:controller => 'projects', :action => 'add', :parent_id => @project}, :class => 'icon icon-add' %>
4
  <% end %>
5
</div>
6

    
7
<h2><%=l(:label_overview)%></h2>
8

    
9
<div class="splitcontentleft">
10
        <%= textilizable @project.description %>
11
        <ul>
12
        <% unless @project.homepage.blank? %><li><%=l(:field_homepage)%>: <%= link_to(h(@project.homepage), @project.homepage) %></li><% end %>
13
        </ul>
14
  <% if @subprojects.any? %>
15
    <% showHideOnclick = "onclick=\"showHide('#{@project.id}','#{@project.id}span')\"" %>
16
    <table class="list">
17
      <tbody>
18
        <tr class="open show parent subprojectRoot" id="<%= @project.id.to_s + "span" %>" >
19
          <td class="name" style="padding-left: 0em;">
20
            <span class="expander" <%=showHideOnclick%> >&nbsp; </span>
21
            <%= h("Sub Projects") %><span class="empty" <%=showHideOnclick%> >&nbsp;</span>
22
          </td>
23
        </tr>
24
<%
25
      # First, let's put the full project sub-tree into a nice array structure
26
            projTree = [ @project ]
27
            currIdx = 1
28
            loop {
29
        currParent = projTree[currIdx - 1]
30
        break if(currParent.nil?)
31
        if(!currParent.children.empty?)
32
          currParent.children.each_index { |ii|
33
            projTree[currIdx + ii,0] = currParent.children[ii]
34
          }
35
        end
36
        currIdx += 1
37
      }
38

39
      # Next, loop over the sub-tree array elements and make the HTML rows
40
            projTree.each_index { |ii|
41
        if(ii > 0)  # We'll skip the tree root
42
          rowid = classes = spanicon = openonclick = ""
43
          project = tmpProj = projTree[ii]
44
          # Getting the full ancestor of each project need only take a little iteration code
45
          ancestorIds = []
46
          (ii-1).downto(0) { |jj|
47
            if(tmpProj.parent_id == projTree[jj].id)  # We found the parent of tmpProj, next find ITS parent, etc
48
              ancestorIds << projTree[jj].id
49
              tmpProj = projTree[jj]
50
            end
51
          }
52
          # Let's only show the immediate subprojects (sub-sub projects will be hidden until user expands)
53
          if(project.parent_id == @project.id)
54
            classes += " show "
55
          else
56
            classes += " hide "
57
          end
58
          # Set up classes and such for the rows, depending on whether has children or not
59
          if(!project.children.empty?)
60
            projIdStr = project.id.to_s
61
            classes += " closed parent " + cycle("odd", "even")
62
            rowid = "id=\"#{projIdStr}span\""
63
            openonclick = "onclick=\"showHide('#{projIdStr}','#{projIdStr}span')\""
64
            spanicon = "<span #{openonclick} class=\"expander\">&nbsp; </span>"
65
          else
66
            classes += " closed child " + cycle("odd", "even")
67
          end
68
          classes += " #{ancestorIds.join(' ')} "
69
          baseurl = url_for(:controller => 'plugin_assets', :action => 'index')
70
          # Does this project have boards? If so, we'll provide a direct link to its Forums page
71
          if(!project.boards.empty?)
72
            forumsStr = "<a href=\"#{url_for({ :controller => 'projects', :action => 'show', :id => project})}/boards\"><span class=\"forumsLink\">" +
73
                        "<img alt=\"Forums\" title=\"Forums\" src=\"#{baseurl}/projects_tree_view/images/user_comment.png\"></span></a>"
74
          else
75
            forumsStr = ""
76
          end
77
          # Does this project have a wiki? If so, we'll provide a direct link to its main Wiki page
78
          if(project.wiki)
79
            wikiStr = "<a href=\"#{url_for({ :controller => 'projects', :action => 'show', :id => project})}/wiki\"><span class=\"wikiLink\">" +
80
                      "<img alt=\"Wiki\" title=\"Wiki\" src=\"#{baseurl}/projects_tree_view/images/page_white_wrench.png\"></span></a>"
81
          else
82
            wikiStr = ""
83
          end
84
%>
85
          <tr class="<%= classes %>" <%= rowid %> >
86
            <td class="name" style="padding-left: <%= 2*project.level %>em;">
87
              <%= spanicon %>
88
              <%= project.active? ? link_to(h(project.name), {:controller => 'projects', :action => 'show', :id => project}, :class => "project") : h(project.name) %>
89
              <span <%= openonclick %> class="empty <%=User.current.member_of?(project) ? 'my-project' : nil%>">&nbsp;</span>
90
              <%= forumsStr %><%= wikiStr %>
91
            </td>
92
          </tr>
93
<%
94
        end
95
      }
96
%>
97
          </tbody>
98
        </table>
99
  <% end %>
100
        <% @project.custom_values.each do |custom_value| %>
101
        <% if !custom_value.value.empty? %>
102
           <li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
103
        <% end %>
104
        <% end %>
105

    
106
  <% if User.current.allowed_to?(:view_issues, @project) %>
107
  <div class="box">
108
    <h3 class="icon22 icon22-tracker"><%=l(:label_issue_tracking)%></h3>
109
    <ul>
110
    <% for tracker in @trackers %>
111
      <li><%= link_to tracker.name, :controller => 'issues', :action => 'index', :project_id => @project,
112
                                                :set_filter => 1,
113
                                                "tracker_id" => tracker.id %>:
114
                                        <%= l(:label_x_open_issues_abbr_on_total, :count => @open_issues_by_tracker[tracker].to_i,
115
                                                                                                                                                                                                                :total => @total_issues_by_tracker[tracker].to_i) %>
116
                        </li>
117
    <% end %>
118
    </ul>
119
    <p><%= link_to l(:label_issue_view_all), :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 %></p>
120
  </div>
121
  <% end %>
122
  <%= call_hook(:view_projects_show_left, :project => @project) %>
123
</div>
124

    
125
<div class="splitcontentright">
126
<% if users_by_role_implemented %>
127
        <% if @members_by_role.any? %>
128
          <div class="box">
129
                <h3 class="icon22 icon22-users"><%=l(:label_member_plural)%></h3>
130
                <p><% @members_by_role.keys.sort.each do |role| %>
131
                <%= role.name %>:
132
                <%= @members_by_role[role].collect(&:user).sort.collect{|u| link_to_user u}.join(", ") %>
133
                <br />
134
                <% end %></p>
135
          </div>
136
        <% end %>
137
<% else %>
138
        <% if @users_by_role.any? %>
139
          <div class="box">
140
                <h3 class="icon22 icon22-users"><%=l(:label_member_plural)%></h3>
141
                <p><% @users_by_role.keys.sort.each do |role| %>
142
                <%=h role %>: <%= @users_by_role[role].sort.collect{|u| link_to_user u}.join(", ") %><br />
143
                <% end %></p>
144
          </div>
145
        <% end %>
146
<% end %>
147

    
148
  <% if @news.any? && authorize_for('news', 'index') %>
149
  <div class="box">
150
    <h3><%=l(:label_news_latest)%></h3>
151
    <%= render :partial => 'news/news', :collection => @news %>
152
    <p><%= link_to l(:label_news_view_all), :controller => 'news', :action => 'index', :project_id => @project %></p>
153
  </div>
154
  <% end %>
155
  <%= call_hook(:view_projects_show_right, :project => @project) %>
156
</div>
157

    
158
<% content_for :sidebar do %>
159
    <% planning_links = []
160
      planning_links << link_to_if_authorized(l(:label_calendar), :controller => 'issues', :action => 'calendar', :project_id => @project)
161
      planning_links << link_to_if_authorized(l(:label_gantt), :controller => 'issues', :action => 'gantt', :project_id => @project)
162
      planning_links.compact!
163
      unless planning_links.empty? %>
164
    <h3><%= l(:label_planning) %></h3>
165
    <p><%= planning_links.join(' | ') %></p>
166
    <% end %>
167

    
168
    <% if @total_hours && User.current.allowed_to?(:view_time_entries, @project) %>
169
    <h3><%= l(:label_spent_time) %></h3>
170
    <p><span class="icon icon-time"><%= l_hours(@total_hours) %></span></p>
171
    <p><%= link_to(l(:label_details), {:controller => 'timelog', :action => 'details', :project_id => @project}) %> |
172
    <%= link_to(l(:label_report), {:controller => 'timelog', :action => 'report', :project_id => @project}) %></p>
173
    <% end %>
174
<% end %>
175

    
176
<% content_for :header_tags do %>
177
<%= auto_discovery_link_tag(:atom, {:action => 'activity', :id => @project, :format => 'atom', :key => User.current.rss_key}) %>
178
<% end %>
179

    
180
<% html_title(l(:label_overview)) -%>