@@ -1,104 +1,104 | |||
|
1 | 1 | # redMine - project management software |
|
2 | 2 | # Copyright (C) 2006 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | module ProjectsHelper |
|
19 | 19 | def link_to_version(version, options = {}) |
|
20 | 20 | return '' unless version && version.is_a?(Version) |
|
21 | 21 | link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options |
|
22 | 22 | end |
|
23 | 23 | |
|
24 | 24 | def project_settings_tabs |
|
25 | 25 | tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, |
|
26 | 26 | {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, |
|
27 | 27 | {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}, |
|
28 | 28 | {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}, |
|
29 | 29 | {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, |
|
30 | 30 | {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, |
|
31 | 31 | {:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository}, |
|
32 | 32 | {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, |
|
33 | 33 | {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} |
|
34 | 34 | ] |
|
35 | 35 | tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} |
|
36 | 36 | end |
|
37 | 37 | |
|
38 | 38 | def parent_project_select_tag(project) |
|
39 | 39 | selected = project.parent |
|
40 | 40 | # retrieve the requested parent project |
|
41 | 41 | parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id] |
|
42 | 42 | if parent_id |
|
43 | 43 | selected = (parent_id.blank? ? nil : Project.find(parent_id)) |
|
44 | 44 | end |
|
45 | 45 | |
|
46 | 46 | options = '' |
|
47 | 47 | options << "<option value=''></option>" if project.allowed_parents.include?(nil) |
|
48 | 48 | options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) |
|
49 | content_tag('select', options, :name => 'project[parent_id]') | |
|
49 | content_tag('select', options, :name => 'project[parent_id]', :id => 'project_parent_id') | |
|
50 | 50 | end |
|
51 | 51 | |
|
52 | 52 | # Renders a tree of projects as a nested set of unordered lists |
|
53 | 53 | # The given collection may be a subset of the whole project tree |
|
54 | 54 | # (eg. some intermediate nodes are private and can not be seen) |
|
55 | 55 | def render_project_hierarchy(projects) |
|
56 | 56 | s = '' |
|
57 | 57 | if projects.any? |
|
58 | 58 | ancestors = [] |
|
59 | 59 | projects.each do |project| |
|
60 | 60 | if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) |
|
61 | 61 | s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" |
|
62 | 62 | else |
|
63 | 63 | ancestors.pop |
|
64 | 64 | s << "</li>" |
|
65 | 65 | while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) |
|
66 | 66 | ancestors.pop |
|
67 | 67 | s << "</ul></li>\n" |
|
68 | 68 | end |
|
69 | 69 | end |
|
70 | 70 | classes = (ancestors.empty? ? 'root' : 'child') |
|
71 | 71 | s << "<li class='#{classes}'><div class='#{classes}'>" + |
|
72 | 72 | link_to(h(project), {:controller => 'projects', :action => 'show', :id => project}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}") |
|
73 | 73 | s << "<div class='wiki description'>#{textilizable(project.short_description, :project => project)}</div>" unless project.description.blank? |
|
74 | 74 | s << "</div>\n" |
|
75 | 75 | ancestors << project |
|
76 | 76 | end |
|
77 | 77 | s << ("</li></ul>\n" * ancestors.size) |
|
78 | 78 | end |
|
79 | 79 | s |
|
80 | 80 | end |
|
81 | 81 | |
|
82 | 82 | # Returns a set of options for a select field, grouped by project. |
|
83 | 83 | def version_options_for_select(versions, selected=nil) |
|
84 | 84 | grouped = Hash.new {|h,k| h[k] = []} |
|
85 | 85 | versions.each do |version| |
|
86 | 86 | grouped[version.project.name] << [version.name, version.id] |
|
87 | 87 | end |
|
88 | 88 | # Add in the selected |
|
89 | 89 | if selected && !versions.include?(selected) |
|
90 | 90 | grouped[selected.project.name] << [selected.name, selected.id] |
|
91 | 91 | end |
|
92 | 92 | |
|
93 | 93 | if grouped.keys.size > 1 |
|
94 | 94 | grouped_options_for_select(grouped, selected && selected.id) |
|
95 | 95 | else |
|
96 | 96 | options_for_select((grouped.values.first || []), selected && selected.id) |
|
97 | 97 | end |
|
98 | 98 | end |
|
99 | 99 | |
|
100 | 100 | def format_version_sharing(sharing) |
|
101 | 101 | sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing) |
|
102 | 102 | l("label_version_sharing_#{sharing}") |
|
103 | 103 | end |
|
104 | 104 | end |
@@ -1,49 +1,49 | |||
|
1 | 1 | <%= error_messages_for 'project' %> |
|
2 | 2 | |
|
3 | 3 | <div class="box"> |
|
4 | 4 | <!--[form:project]--> |
|
5 | 5 | <p><%= f.text_field :name, :required => true %><br /><em><%= l(:text_caracters_maximum, 30) %></em></p> |
|
6 | 6 | |
|
7 | 7 | <% unless @project.allowed_parents.compact.empty? %> |
|
8 |
<p><label |
|
|
8 | <p><%= label(:project, :parent_id, l(:field_parent)) %><%= parent_project_select_tag(@project) %></p> | |
|
9 | 9 | <% end %> |
|
10 | 10 | |
|
11 | 11 | <p><%= f.text_area :description, :rows => 5, :class => 'wiki-edit' %></p> |
|
12 | 12 | <p><%= f.text_field :identifier, :required => true, :disabled => @project.identifier_frozen? %> |
|
13 | 13 | <% unless @project.identifier_frozen? %> |
|
14 | 14 | <br /><em><%= l(:text_length_between, :min => 1, :max => 20) %> <%= l(:text_project_identifier_info) %></em> |
|
15 | 15 | <% end %></p> |
|
16 | 16 | <p><%= f.text_field :homepage, :size => 60 %></p> |
|
17 | 17 | <p><%= f.check_box :is_public %></p> |
|
18 | 18 | <%= wikitoolbar_for 'project_description' %> |
|
19 | 19 | |
|
20 | 20 | <% @project.custom_field_values.each do |value| %> |
|
21 | 21 | <p><%= custom_field_tag_with_label :project, value %></p> |
|
22 | 22 | <% end %> |
|
23 | 23 | <%= call_hook(:view_projects_form, :project => @project, :form => f) %> |
|
24 | 24 | </div> |
|
25 | 25 | |
|
26 | 26 | <% unless @trackers.empty? %> |
|
27 | 27 | <fieldset class="box"><legend><%=l(:label_tracker_plural)%></legend> |
|
28 | 28 | <% @trackers.each do |tracker| %> |
|
29 | 29 | <label class="floating"> |
|
30 | 30 | <%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.include?(tracker) %> |
|
31 | 31 | <%= tracker %> |
|
32 | 32 | </label> |
|
33 | 33 | <% end %> |
|
34 | 34 | <%= hidden_field_tag 'project[tracker_ids][]', '' %> |
|
35 | 35 | </fieldset> |
|
36 | 36 | <% end %> |
|
37 | 37 | |
|
38 | 38 | <% unless @issue_custom_fields.empty? %> |
|
39 | 39 | <fieldset class="box"><legend><%=l(:label_custom_field_plural)%></legend> |
|
40 | 40 | <% @issue_custom_fields.each do |custom_field| %> |
|
41 | 41 | <label class="floating"> |
|
42 | 42 | <%= check_box_tag 'project[issue_custom_field_ids][]', custom_field.id, (@project.all_issue_custom_fields.include? custom_field), (custom_field.is_for_all? ? {:disabled => "disabled"} : {}) %> |
|
43 | 43 | <%= custom_field.name %> |
|
44 | 44 | </label> |
|
45 | 45 | <% end %> |
|
46 | 46 | <%= hidden_field_tag 'project[issue_custom_field_ids][]', '' %> |
|
47 | 47 | </fieldset> |
|
48 | 48 | <% end %> |
|
49 | 49 | <!--[eoform:project]--> |
@@ -1,17 +1,19 | |||
|
1 | 1 | <% form_for :project, @project, |
|
2 | 2 | :url => { :action => 'modules', :id => @project }, |
|
3 | 3 | :html => {:id => 'modules-form'} do |f| %> |
|
4 | 4 | |
|
5 | <div class=box> | |
|
6 | <strong><%= l(:text_select_project_modules) %></strong> | |
|
5 | <div class="box"> | |
|
6 | <fieldset> | |
|
7 | <legend><%= l(:text_select_project_modules) %></legend> | |
|
7 | 8 | |
|
8 | 9 | <% Redmine::AccessControl.available_project_modules.each do |m| %> |
|
9 | 10 | <p><label><%= check_box_tag 'enabled_modules[]', m, @project.module_enabled?(m) -%> |
|
10 | 11 | <%= l_or_humanize(m, :prefix => "project_module_") %></label></p> |
|
11 | 12 | <% end %> |
|
13 | </fieldset> | |
|
12 | 14 | </div> |
|
13 | 15 | |
|
14 | 16 | <p><%= check_all_links 'modules-form' %></p> |
|
15 | 17 | <p><%= submit_tag l(:button_save) %></p> |
|
16 | 18 | |
|
17 | 19 | <% end %> |
@@ -1,24 +1,24 | |||
|
1 | 1 | <% remote_form_for :repository, @repository, |
|
2 | 2 | :url => { :controller => 'repositories', :action => 'edit', :id => @project }, |
|
3 | 3 | :builder => TabularFormBuilder, |
|
4 | 4 | :lang => current_language do |f| %> |
|
5 | 5 | |
|
6 | 6 | <%= error_messages_for 'repository' %> |
|
7 | 7 | |
|
8 | 8 | <div class="box tabular"> |
|
9 |
<p> |
|
|
9 | <p><%= label_tag('repository_scm', l(:label_scm)) %><%= scm_select_tag(@repository) %></p> | |
|
10 | 10 | <%= repository_field_tags(f, @repository) if @repository %> |
|
11 | 11 | </div> |
|
12 | 12 | |
|
13 | 13 | <div class="contextual"> |
|
14 | 14 | <% if @repository && !@repository.new_record? %> |
|
15 | 15 | <%= link_to(l(:label_user_plural), {:controller => 'repositories', :action => 'committers', :id => @project}, :class => 'icon icon-user') %> |
|
16 | 16 | <%= link_to(l(:button_delete), {:controller => 'repositories', :action => 'destroy', :id => @project}, |
|
17 | 17 | :confirm => l(:text_are_you_sure), |
|
18 | 18 | :method => :post, |
|
19 | 19 | :class => 'icon icon-del') %> |
|
20 | 20 | <% end %> |
|
21 | 21 | </div> |
|
22 | 22 | |
|
23 | 23 | <%= submit_tag((@repository.nil? || @repository.new_record?) ? l(:button_create) : l(:button_save), :disabled => @repository.nil?) %> |
|
24 | 24 | <% end %> |
General Comments 0
You need to be logged in to leave comments.
Login now