@@ -1,84 +1,93 | |||||
1 | # encoding: utf-8 |
|
1 | # encoding: utf-8 | |
2 | # |
|
2 | # | |
3 | # Redmine - project management software |
|
3 | # Redmine - project management software | |
4 | # Copyright (C) 2006-2014 Jean-Philippe Lang |
|
4 | # Copyright (C) 2006-2014 Jean-Philippe Lang | |
5 | # |
|
5 | # | |
6 | # This program is free software; you can redistribute it and/or |
|
6 | # This program is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU General Public License |
|
7 | # modify it under the terms of the GNU General Public License | |
8 | # as published by the Free Software Foundation; either version 2 |
|
8 | # as published by the Free Software Foundation; either version 2 | |
9 | # of the License, or (at your option) any later version. |
|
9 | # of the License, or (at your option) any later version. | |
10 | # |
|
10 | # | |
11 | # This program is distributed in the hope that it will be useful, |
|
11 | # This program is distributed in the hope that it will be useful, | |
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | # GNU General Public License for more details. |
|
14 | # GNU General Public License for more details. | |
15 | # |
|
15 | # | |
16 | # You should have received a copy of the GNU General Public License |
|
16 | # You should have received a copy of the GNU General Public License | |
17 | # along with this program; if not, write to the Free Software |
|
17 | # along with this program; if not, write to the Free Software | |
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 |
|
19 | |||
20 | module ProjectsHelper |
|
20 | module ProjectsHelper | |
21 | def link_to_version(version, options = {}) |
|
21 | def link_to_version(version, options = {}) | |
22 | return '' unless version && version.is_a?(Version) |
|
22 | return '' unless version && version.is_a?(Version) | |
23 | link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options |
|
23 | link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options | |
24 | end |
|
24 | end | |
25 |
|
25 | |||
26 | def project_settings_tabs |
|
26 | def project_settings_tabs | |
27 | tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, |
|
27 | tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, | |
28 | {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, |
|
28 | {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, | |
29 | {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}, |
|
29 | {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}, | |
30 | {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}, |
|
30 | {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}, | |
31 | {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, |
|
31 | {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, | |
32 | {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, |
|
32 | {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, | |
33 | {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural}, |
|
33 | {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural}, | |
34 | {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, |
|
34 | {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, | |
35 | {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} |
|
35 | {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} | |
36 | ] |
|
36 | ] | |
37 | tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} |
|
37 | tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} | |
38 | end |
|
38 | end | |
39 |
|
39 | |||
40 | def parent_project_select_tag(project) |
|
40 | def parent_project_select_tag(project) | |
41 | selected = project.parent |
|
41 | selected = project.parent | |
42 | # retrieve the requested parent project |
|
42 | # retrieve the requested parent project | |
43 | parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id] |
|
43 | parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id] | |
44 | if parent_id |
|
44 | if parent_id | |
45 | selected = (parent_id.blank? ? nil : Project.find(parent_id)) |
|
45 | selected = (parent_id.blank? ? nil : Project.find(parent_id)) | |
46 | end |
|
46 | end | |
47 |
|
47 | |||
48 | options = '' |
|
48 | options = '' | |
49 | options << "<option value=''> </option>" if project.allowed_parents.include?(nil) |
|
49 | options << "<option value=''> </option>" if project.allowed_parents.include?(nil) | |
50 | options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) |
|
50 | options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) | |
51 | content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id') |
|
51 | content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id') | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
|
54 | def render_project_action_links | |||
|
55 | links = [] | |||
|
56 | links << link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) | |||
|
57 | links << link_to(l(:label_issue_view_all), issues_path) if User.current.allowed_to?(:view_issues, nil, :global => true) | |||
|
58 | links << link_to(l(:label_overall_spent_time), time_entries_path) if User.current.allowed_to?(:view_time_entries, nil, :global => true) | |||
|
59 | links << link_to(l(:label_overall_activity), { :controller => 'activities', :action => 'index', :id => nil }) | |||
|
60 | links.join(" | ").html_safe | |||
|
61 | end | |||
|
62 | ||||
54 | # Renders the projects index |
|
63 | # Renders the projects index | |
55 | def render_project_hierarchy(projects) |
|
64 | def render_project_hierarchy(projects) | |
56 | render_project_nested_lists(projects) do |project| |
|
65 | render_project_nested_lists(projects) do |project| | |
57 | s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") |
|
66 | s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}") | |
58 | if project.description.present? |
|
67 | if project.description.present? | |
59 | s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description') |
|
68 | s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description') | |
60 | end |
|
69 | end | |
61 | s |
|
70 | s | |
62 | end |
|
71 | end | |
63 | end |
|
72 | end | |
64 |
|
73 | |||
65 | # Returns a set of options for a select field, grouped by project. |
|
74 | # Returns a set of options for a select field, grouped by project. | |
66 | def version_options_for_select(versions, selected=nil) |
|
75 | def version_options_for_select(versions, selected=nil) | |
67 | grouped = Hash.new {|h,k| h[k] = []} |
|
76 | grouped = Hash.new {|h,k| h[k] = []} | |
68 | versions.each do |version| |
|
77 | versions.each do |version| | |
69 | grouped[version.project.name] << [version.name, version.id] |
|
78 | grouped[version.project.name] << [version.name, version.id] | |
70 | end |
|
79 | end | |
71 |
|
80 | |||
72 | selected = selected.is_a?(Version) ? selected.id : selected |
|
81 | selected = selected.is_a?(Version) ? selected.id : selected | |
73 | if grouped.keys.size > 1 |
|
82 | if grouped.keys.size > 1 | |
74 | grouped_options_for_select(grouped, selected) |
|
83 | grouped_options_for_select(grouped, selected) | |
75 | else |
|
84 | else | |
76 | options_for_select((grouped.values.first || []), selected) |
|
85 | options_for_select((grouped.values.first || []), selected) | |
77 | end |
|
86 | end | |
78 | end |
|
87 | end | |
79 |
|
88 | |||
80 | def format_version_sharing(sharing) |
|
89 | def format_version_sharing(sharing) | |
81 | sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing) |
|
90 | sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing) | |
82 | l("label_version_sharing_#{sharing}") |
|
91 | l("label_version_sharing_#{sharing}") | |
83 | end |
|
92 | end | |
84 | end |
|
93 | end |
@@ -1,38 +1,33 | |||||
1 | <% content_for :header_tags do %> |
|
1 | <% content_for :header_tags do %> | |
2 | <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> |
|
2 | <%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %> | |
3 | <% end %> |
|
3 | <% end %> | |
4 |
|
4 | |||
5 | <div class="contextual"> |
|
5 | <div class="contextual"> | |
6 | <%= link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') + ' |' if User.current.allowed_to?(:add_project, nil, :global => true) %> |
|
6 | <%= render_project_action_links %> | |
7 | <%= link_to(l(:label_issue_view_all), issues_path) + ' |' if User.current.allowed_to?(:view_issues, nil, :global => true) %> |
|
|||
8 | <%= link_to(l(:label_overall_spent_time), time_entries_path) + ' |' if User.current.allowed_to?(:view_time_entries, nil, :global => true) %> |
|
|||
9 | <%= link_to l(:label_overall_activity), |
|
|||
10 | { :controller => 'activities', :action => 'index', |
|
|||
11 | :id => nil } %> |
|
|||
12 | </div> |
|
7 | </div> | |
13 |
|
8 | |||
14 | <h2><%= l(:label_project_plural) %></h2> |
|
9 | <h2><%= l(:label_project_plural) %></h2> | |
15 |
|
10 | |||
16 | <div id="projects-index"> |
|
11 | <div id="projects-index"> | |
17 | <%= render_project_hierarchy(@projects) %> |
|
12 | <%= render_project_hierarchy(@projects) %> | |
18 | </div> |
|
13 | </div> | |
19 |
|
14 | |||
20 | <% if User.current.logged? %> |
|
15 | <% if User.current.logged? %> | |
21 | <p style="text-align:right;"> |
|
16 | <p style="text-align:right;"> | |
22 | <span class="my-project"><%= l(:label_my_projects) %></span> |
|
17 | <span class="my-project"><%= l(:label_my_projects) %></span> | |
23 | </p> |
|
18 | </p> | |
24 | <% end %> |
|
19 | <% end %> | |
25 |
|
20 | |||
26 | <% other_formats_links do |f| %> |
|
21 | <% other_formats_links do |f| %> | |
27 | <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> |
|
22 | <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> | |
28 | <% end %> |
|
23 | <% end %> | |
29 |
|
24 | |||
30 | <% content_for :sidebar do %> |
|
25 | <% content_for :sidebar do %> | |
31 | <%= form_tag({}, :method => :get) do %> |
|
26 | <%= form_tag({}, :method => :get) do %> | |
32 | <h3><%= l(:label_project_plural) %></h3> |
|
27 | <h3><%= l(:label_project_plural) %></h3> | |
33 | <label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_projects) %></label> |
|
28 | <label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_projects) %></label> | |
34 | <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> |
|
29 | <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> | |
35 | <% end %> |
|
30 | <% end %> | |
36 | <% end %> |
|
31 | <% end %> | |
37 |
|
32 | |||
38 | <% html_title(l(:label_project_plural)) -%> |
|
33 | <% html_title(l(:label_project_plural)) -%> |
General Comments 0
You need to be logged in to leave comments.
Login now