| 1 |
module ProjectsHelper |
| 2 |
|
| 3 |
include BlueclothHelper |
| 4 |
|
| 5 |
def get_project_audience_suffix (project) |
| 6 |
project.audience == :members_only ? " (Private)" : "" |
| 7 |
end |
| 8 |
|
| 9 |
|
| 10 |
def render_right_project_extrainfo |
| 11 |
|
| 12 |
out = "<table class='right_default_table'>" |
| 13 |
out << "<tr><th colspan=2>Details</th></tr>" |
| 14 |
out << %Q{<tr><td width=80>Created:</td><td>#{format_datetime_ddmmyyhhmm(@project.created_at)}</td></tr>} |
| 15 |
out << %Q{<tr><td>By:</td><td>#{link_to(h(@project.user.fullname), user_path(@project.user))}</td></tr>} |
| 16 |
out << %Q{<tr><td>Status:</td><td>#{@project.status.to_s.capitalize}</td></tr>} |
| 17 |
out << %Q{<tr><td>Life Cycle:</td><td>#{format_life_cycle(@project.life_cycle)}</td></tr>} |
| 18 |
out << %Q{<tr><td>Audience:</td><td>#{@project.audience.to_s.capitalize}</td></tr>} |
| 19 |
out << %Q{<tr><td>OS:</td><td>#{@project.os.to_s.capitalize}</td></tr>} |
| 20 |
out << %Q{<tr><td>Platform:</td><td>#{@project.platform.to_s.capitalize}</td></tr>} |
| 21 |
out << %Q{<tr><td>License:</td><td>#{h(@project.license)}</td></tr>} |
| 22 |
out << "</table>" |
| 23 |
out |
| 24 |
end |
| 25 |
|
| 26 |
def render_right_project_members |
| 27 |
out = "" |
| 28 |
members = Member.find_by_project(@project.id) |
| 29 |
unless members.empty? |
| 30 |
out << "<table class='right_default_table'>" |
| 31 |
out << "<tr><th>Members</th></tr>" |
| 32 |
for member in members |
| 33 |
|
| 34 |
out << %Q{<tr><td>#{link_to_profile(member.user)} <small><span style='color: #888'>(#{format_member_accesslevel(member.accesslevel)})</span></small></td></tr>} if member.accesslevel != :user |
| 35 |
end |
| 36 |
out << "</table>" |
| 37 |
end |
| 38 |
out |
| 39 |
end |
| 40 |
|
| 41 |
def render_right_popular_projects |
| 42 |
out = "" |
| 43 |
projects = Project.find_popular_projects(current_user) |
| 44 |
unless projects.empty? |
| 45 |
out << "<table class='right_default_table'>" |
| 46 |
out << "<tr><th>Popular Projects</th></tr>" |
| 47 |
for project in projects |
| 48 |
|
| 49 |
out << %Q{<tr><td>#{link_to(project.title, project_path(project))} </span></small></td></tr>} |
| 50 |
end |
| 51 |
out << "</table>" |
| 52 |
end |
| 53 |
out |
| 54 |
end |
| 55 |
|
| 56 |
def project_tab (active_tab, tab) |
| 57 |
title, suffix = Project.tab_settings(tab, @project.wiki_slug) |
| 58 |
path = %Q{/projects/#{@project.slug}#{suffix}} |
| 59 |
active_tab == tab ? %Q{<li>#{link_to(title, path, :class => "active")}</li>} : %Q{<li>#{link_to(title, path)}</li>} |
| 60 |
end |
| 61 |
|
| 62 |
def render_project_tabs (active_tab) |
| 63 |
out = "" |
| 64 |
out << "<ul id='tabmenu'>" |
| 65 |
out << project_tab(active_tab, PRJ_TAB_SUMMARY) |
| 66 |
out << project_tab(active_tab, PRJ_TAB_GIT) |
| 67 |
out << project_tab(active_tab, PRJ_TAB_TEAM) |
| 68 |
out << project_tab(active_tab, PRJ_TAB_TICKETS) |
| 69 |
out << project_tab(active_tab, PRJ_TAB_WIKI) |
| 70 |
out << project_tab(active_tab, PRJ_TAB_ARTICLES) |
| 71 |
out << project_tab(active_tab, PRJ_TAB_FORUM) |
| 72 |
out << project_tab(active_tab, PRJ_TAB_LOG) |
| 73 |
out << project_tab(active_tab, PRJ_TAB_CONFIG) if @is_member |
| 74 |
out << "</ul>" |
| 75 |
out |
| 76 |
end |
| 77 |
|
| 78 |
def breadcrumb_repos_tab(subtab) |
| 79 |
subtab == PRJ_TAB_SUBTAB_NONE ? out = "" : out = breadcrumb_repositories |
| 80 |
case subtab |
| 81 |
when PRJ_TAB_GIT_LOGS |
| 82 |
out << breadcrumb_repository |
| 83 |
when PRJ_TAB_GIT_COMMIT |
| 84 |
out << breadcrumb_repository |
| 85 |
out << breadcrumb_repos_logs |
| 86 |
when PRJ_TAB_GIT_TREE |
| 87 |
out << breadcrumb_repository |
| 88 |
when PRJ_TAB_GIT_MERGEREQUESTS |
| 89 |
end |
| 90 |
out |
| 91 |
end |
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
def render_right_column_project (tab, subtab) |
| 99 |
out = "" |
| 100 |
case tab |
| 101 |
when PRJ_TAB_SUMMARY |
| 102 |
out << actionbox_complex(:allow_shortcuts => true) |
| 103 |
out << render_right_project_extrainfo |
| 104 |
out << render_right_project_roadmap |
| 105 |
out << render_right_project_members |
| 106 |
when PRJ_TAB_GIT |
| 107 |
case subtab |
| 108 |
when PRJ_TAB_SUBTAB_NONE |
| 109 |
out << actionbox_complex(:allow_shortcuts => true, :clone_mainline => true) |
| 110 |
when PRJ_TAB_GIT_SUMMARY |
| 111 |
out << render(:partial => "repositories/ac_right_actionbox_repos_summary") |
| 112 |
when PRJ_TAB_GIT_LOGS |
| 113 |
out << actionbox_basic(:allow_shortcuts => true) |
| 114 |
out << render(:partial => "repositories/ac_right_branches") |
| 115 |
when PRJ_TAB_GIT_COMMIT |
| 116 |
out << actionbox_basic(:allow_shortcuts => true) |
| 117 |
out << render(:partial => "commits/ac_right_diff_mode_selector") |
| 118 |
when PRJ_TAB_GIT_TREE |
| 119 |
out << actionbox_basic(:allow_shortcuts => true) |
| 120 |
out << render(:partial => "trees/ac_right_branches") |
| 121 |
when PRJ_TAB_GIT_MERGEREQUESTS |
| 122 |
out << actionbox_basic(:allow_shortcuts => true) |
| 123 |
end |
| 124 |
when PRJ_TAB_TEAM |
| 125 |
case subtab |
| 126 |
when PRJ_TAB_SUBTAB_NONE |
| 127 |
out << actionbox_complex(:allow_shortcuts => true, :new_member => true, :list_members => true) |
| 128 |
out << render(:partial => "messages/ac_right_actionbox_post_message") if @is_member |
| 129 |
out << render_right_project_members |
| 130 |
when PRJ_TAB_TEAM_NEW |
| 131 |
when PRJ_TAB_TEAM_LIST |
| 132 |
end |
| 133 |
when PRJ_TAB_TICKETS |
| 134 |
case subtab |
| 135 |
when PRJ_TAB_SUBTAB_NONE |
| 136 |
out << actionbox_complex(:allow_shortcuts => true, :new_ticket => true, :manage_milestones => true, :manage_components => true) |
| 137 |
out << render(:partial => "ac_right_ticket_filter") |
| 138 |
out << render_right_project_roadmap |
| 139 |
when PRJ_TAB_TICKETS_SHOW |
| 140 |
out << actionbox_complex(:allow_shortcuts => true, :manage_tickets => true, :edit_ticket => true, :close_ticket => true) |
| 141 |
when PRJ_TAB_TICKETS_NEW, PRJ_TAB_TICKETS_EDIT |
| 142 |
out << actionbox_complex(:allow_shortcuts => true, :manage_tickets => true) |
| 143 |
when PRJ_TAB_TICKETS_MILESTONES_LIST |
| 144 |
out << actionbox_complex(:allow_shortcuts => true, :new_milestone => true, :manage_tickets => true) |
| 145 |
when PRJ_TAB_TICKETS_MILESTONES_NEW, PRJ_TAB_TICKETS_MILESTONES_EDIT |
| 146 |
out << actionbox_complex(:allow_shortcuts => true, :manage_tickets => true, :manage_milestones => true) |
| 147 |
end |
| 148 |
when PRJ_TAB_WIKI |
| 149 |
case subtab |
| 150 |
when PRJ_TAB_WIKI_EDIT, PRJ_TAB_WIKI_NEW |
| 151 |
out << actionbox_basic(:allow_shortcuts => true) |
| 152 |
when PRJ_TAB_WIKI_LIST |
| 153 |
out << actionbox_complex(:allow_shortcuts => true, :new_project_wiki => true) |
| 154 |
else |
| 155 |
out << actionbox_complex(:allow_shortcuts => true, :edit_project_wiki => true, :new_project_wiki => true, |
| 156 |
:manage_project_wikis => true) |
| 157 |
end |
| 158 |
when PRJ_TAB_ARTICLES |
| 159 |
case subtab |
| 160 |
when PRJ_TAB_ARTICLES_EDIT, PRJ_TAB_ARTICLES_NEW |
| 161 |
out << actionbox_basic(:allow_shortcuts => true) |
| 162 |
else |
| 163 |
out << actionbox_complex(:allow_shortcuts => true, :new_article => true) |
| 164 |
end |
| 165 |
when PRJ_TAB_FORUM |
| 166 |
out << actionbox_basic(:allow_shortcuts => true) |
| 167 |
when PRJ_TAB_LOG |
| 168 |
out << actionbox_basic(:allow_shortcuts => true) |
| 169 |
when PRJ_TAB_CONFIG |
| 170 |
out << actionbox_basic(:allow_shortcuts => true) |
| 171 |
end |
| 172 |
out |
| 173 |
end |
| 174 |
|
| 175 |
def render_right_project_roadmap |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
out = "" |
| 180 |
out << "<table class='right_default_table'>" |
| 181 |
out << "<tr><th>Roadmap</th></tr>" |
| 182 |
@milestones = Milestone.roadmap(@project.id, current_user) |
| 183 |
unless @milestones.empty? |
| 184 |
for milestone in @milestones |
| 185 |
|
| 186 |
out << "<tr><td>" |
| 187 |
out << format_date_ddbbyy(milestone.due_date) |
| 188 |
out << ": " << link_to(milestone.name, project_tickets_path(@project.slug)) << " (" << milestone.status.to_s.capitalize << ")" |
| 189 |
|
| 190 |
out << "<table class='progress' width='100%'>" |
| 191 |
out << "<tr>" |
| 192 |
out << "<td class='closed' style='width: " << milestone.progress.to_s << "%'><a href='' title='x of y tickets closed'></a></td>" |
| 193 |
out << "<td class='open' style='width: " << (100 - milestone.progress).to_s << "%'><a href='' title='x of y tickets active'></a></td>" |
| 194 |
out << "</tr>" |
| 195 |
out << "</table>" |
| 196 |
out << "</td></tr>" |
| 197 |
end |
| 198 |
end |
| 199 |
out << "</table>" |
| 200 |
out |
| 201 |
end |
| 202 |
|
| 203 |
|
| 204 |
def format_life_cycle (ls) |
| 205 |
case ls |
| 206 |
when :pre_alpha |
| 207 |
"Pre-Alpha" |
| 208 |
when :mature_frozen |
| 209 |
"Mature Frozen" |
| 210 |
else |
| 211 |
ls.to_s.capitalize |
| 212 |
end |
| 213 |
end |
| 214 |
|
| 215 |
|
| 216 |
def format_member_accesslevel (al) |
| 217 |
case al |
| 218 |
when :readonly |
| 219 |
"read only" |
| 220 |
else |
| 221 |
al.to_s |
| 222 |
end |
| 223 |
end |
| 224 |
|
| 225 |
|
| 226 |
end |