##// END OF EJS Templates
Removed duplicate ids....
Jean-Philippe Lang -
r9942:1e6938a1197b
parent child
Show More
@@ -1,93 +1,94
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2012 Jean-Philippe Lang
4 # Copyright (C) 2006-2012 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 SettingsHelper
20 module SettingsHelper
21 def administration_settings_tabs
21 def administration_settings_tabs
22 tabs = [{:name => 'general', :partial => 'settings/general', :label => :label_general},
22 tabs = [{:name => 'general', :partial => 'settings/general', :label => :label_general},
23 {:name => 'display', :partial => 'settings/display', :label => :label_display},
23 {:name => 'display', :partial => 'settings/display', :label => :label_display},
24 {:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication},
24 {:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication},
25 {:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
25 {:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
26 {:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
26 {:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
27 {:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification},
27 {:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification},
28 {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails},
28 {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails},
29 {:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
29 {:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
30 ]
30 ]
31 end
31 end
32
32
33 def setting_select(setting, choices, options={})
33 def setting_select(setting, choices, options={})
34 if blank_text = options.delete(:blank)
34 if blank_text = options.delete(:blank)
35 choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
35 choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
36 end
36 end
37 setting_label(setting, options).html_safe +
37 setting_label(setting, options).html_safe +
38 select_tag("settings[#{setting}]",
38 select_tag("settings[#{setting}]",
39 options_for_select(choices, Setting.send(setting).to_s),
39 options_for_select(choices, Setting.send(setting).to_s),
40 options).html_safe
40 options).html_safe
41 end
41 end
42
42
43 def setting_multiselect(setting, choices, options={})
43 def setting_multiselect(setting, choices, options={})
44 setting_values = Setting.send(setting)
44 setting_values = Setting.send(setting)
45 setting_values = [] unless setting_values.is_a?(Array)
45 setting_values = [] unless setting_values.is_a?(Array)
46
46
47 setting_label(setting, options).html_safe +
47 setting_label(setting, options).html_safe +
48 hidden_field_tag("settings[#{setting}][]", '').html_safe +
48 hidden_field_tag("settings[#{setting}][]", '').html_safe +
49 choices.collect do |choice|
49 choices.collect do |choice|
50 text, value = (choice.is_a?(Array) ? choice : [choice, choice])
50 text, value = (choice.is_a?(Array) ? choice : [choice, choice])
51 content_tag(
51 content_tag(
52 'label',
52 'label',
53 check_box_tag(
53 check_box_tag(
54 "settings[#{setting}][]",
54 "settings[#{setting}][]",
55 value,
55 value,
56 Setting.send(setting).include?(value)
56 Setting.send(setting).include?(value),
57 :id => nil
57 ) + text.to_s,
58 ) + text.to_s,
58 :class => 'block'
59 :class => 'block'
59 )
60 )
60 end.join.html_safe
61 end.join.html_safe
61 end
62 end
62
63
63 def setting_text_field(setting, options={})
64 def setting_text_field(setting, options={})
64 setting_label(setting, options).html_safe +
65 setting_label(setting, options).html_safe +
65 text_field_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
66 text_field_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
66 end
67 end
67
68
68 def setting_text_area(setting, options={})
69 def setting_text_area(setting, options={})
69 setting_label(setting, options).html_safe +
70 setting_label(setting, options).html_safe +
70 text_area_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
71 text_area_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
71 end
72 end
72
73
73 def setting_check_box(setting, options={})
74 def setting_check_box(setting, options={})
74 setting_label(setting, options).html_safe +
75 setting_label(setting, options).html_safe +
75 hidden_field_tag("settings[#{setting}]", 0).html_safe +
76 hidden_field_tag("settings[#{setting}]", 0, :id => nil).html_safe +
76 check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
77 check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
77 end
78 end
78
79
79 def setting_label(setting, options={})
80 def setting_label(setting, options={})
80 label = options.delete(:label)
81 label = options.delete(:label)
81 label != false ? content_tag("label", l(label || "setting_#{setting}")).html_safe : ''
82 label != false ? content_tag("label", l(label || "setting_#{setting}")).html_safe : ''
82 end
83 end
83
84
84 # Renders a notification field for a Redmine::Notifiable option
85 # Renders a notification field for a Redmine::Notifiable option
85 def notification_field(notifiable)
86 def notification_field(notifiable)
86 return content_tag(:label,
87 return content_tag(:label,
87 check_box_tag('settings[notified_events][]',
88 check_box_tag('settings[notified_events][]',
88 notifiable.name,
89 notifiable.name,
89 Setting.notified_events.include?(notifiable.name)).html_safe +
90 Setting.notified_events.include?(notifiable.name), :id => nil).html_safe +
90 l_or_humanize(notifiable.name, :prefix => 'label_').html_safe,
91 l_or_humanize(notifiable.name, :prefix => 'label_').html_safe,
91 :class => notifiable.parent.present? ? "parent" : '').html_safe
92 :class => notifiable.parent.present? ? "parent" : '').html_safe
92 end
93 end
93 end
94 end
@@ -1,97 +1,92
1 <%= form_tag({:action => 'edit', :tab => 'repositories'}) do %>
1 <%= form_tag({:action => 'edit', :tab => 'repositories'}) do %>
2
2
3 <fieldset class="box settings enabled_scm">
3 <fieldset class="box settings enabled_scm">
4 <%= hidden_field_tag 'settings[enabled_scm][]', '' %>
4 <%= hidden_field_tag 'settings[enabled_scm][]', '' %>
5 <legend><%= l(:setting_enabled_scm) %></legend>
5 <legend><%= l(:setting_enabled_scm) %></legend>
6 <table>
6 <table>
7 <tr>
7 <tr>
8 <th></th>
8 <th></th>
9 <th><%= l(:text_scm_command) %></th>
9 <th><%= l(:text_scm_command) %></th>
10 <th><%= l(:text_scm_command_version) %></th>
10 <th><%= l(:text_scm_command_version) %></th>
11 </tr>
11 </tr>
12 <% Redmine::Scm::Base.all.collect do |choice| %>
12 <% Redmine::Scm::Base.all.collect do |choice| %>
13 <% scm_class = "Repository::#{choice}".constantize %>
13 <% scm_class = "Repository::#{choice}".constantize %>
14 <% text, value = (choice.is_a?(Array) ? choice : [choice, choice]) %>
14 <% text, value = (choice.is_a?(Array) ? choice : [choice, choice]) %>
15 <% setting = :enabled_scm %>
15 <% setting = :enabled_scm %>
16 <% enabled = Setting.send(setting).include?(value) %>
16 <% enabled = Setting.send(setting).include?(value) %>
17 <tr>
17 <tr>
18 <td class="scm_name">
18 <td class="scm_name">
19 <%=
19 <%= check_box_tag("settings[#{setting}][]", value, enabled, :id => nil) %>
20 check_box_tag(
21 "settings[#{setting}][]",
22 value,
23 enabled)
24 %>
25 <%= text.to_s %>
20 <%= text.to_s %>
26 </td>
21 </td>
27 <td>
22 <td>
28 <% if enabled %>
23 <% if enabled %>
29 <%=
24 <%=
30 image_tag(
25 image_tag(
31 (scm_class.scm_available ? 'true.png' : 'exclamation.png'),
26 (scm_class.scm_available ? 'true.png' : 'exclamation.png'),
32 :style => "vertical-align:bottom;"
27 :style => "vertical-align:bottom;"
33 )
28 )
34 %>
29 %>
35 <%= scm_class.scm_command %>
30 <%= scm_class.scm_command %>
36 <% end %>
31 <% end %>
37 </td>
32 </td>
38 <td>
33 <td>
39 <%= scm_class.scm_version_string if enabled %>
34 <%= scm_class.scm_version_string if enabled %>
40 </td>
35 </td>
41 </tr>
36 </tr>
42 <% end %>
37 <% end %>
43 </table>
38 </table>
44 <p><em class="info"><%= l(:text_scm_config) %></em></p>
39 <p><em class="info"><%= l(:text_scm_config) %></em></p>
45 </fieldset>
40 </fieldset>
46
41
47 <div class="box tabular settings">
42 <div class="box tabular settings">
48 <p><%= setting_check_box :autofetch_changesets %></p>
43 <p><%= setting_check_box :autofetch_changesets %></p>
49
44
50 <p><%= setting_check_box :sys_api_enabled,
45 <p><%= setting_check_box :sys_api_enabled,
51 :onclick =>
46 :onclick =>
52 "if (this.checked) { $('#settings_sys_api_key').removeAttr('disabled'); } else { $('#settings_sys_api_key').attr('disabled', true); }" %></p>
47 "if (this.checked) { $('#settings_sys_api_key').removeAttr('disabled'); } else { $('#settings_sys_api_key').attr('disabled', true); }" %></p>
53
48
54 <p><%= setting_text_field :sys_api_key,
49 <p><%= setting_text_field :sys_api_key,
55 :size => 30,
50 :size => 30,
56 :id => 'settings_sys_api_key',
51 :id => 'settings_sys_api_key',
57 :disabled => !Setting.sys_api_enabled?,
52 :disabled => !Setting.sys_api_enabled?,
58 :label => :setting_mail_handler_api_key %>
53 :label => :setting_mail_handler_api_key %>
59 <%= link_to_function l(:label_generate_key),
54 <%= link_to_function l(:label_generate_key),
60 "if (!$('#settings_sys_api_key').attr('disabled')) { $('#settings_sys_api_key').val(randomKey(20)) }" %>
55 "if (!$('#settings_sys_api_key').attr('disabled')) { $('#settings_sys_api_key').val(randomKey(20)) }" %>
61 </p>
56 </p>
62
57
63 <p><%= setting_text_field :repository_log_display_limit, :size => 6 %></p>
58 <p><%= setting_text_field :repository_log_display_limit, :size => 6 %></p>
64 </div>
59 </div>
65
60
66 <fieldset class="box tabular settings">
61 <fieldset class="box tabular settings">
67 <legend><%= l(:text_issues_ref_in_commit_messages) %></legend>
62 <legend><%= l(:text_issues_ref_in_commit_messages) %></legend>
68 <p><%= setting_text_field :commit_ref_keywords, :size => 30 %>
63 <p><%= setting_text_field :commit_ref_keywords, :size => 30 %>
69 <em class="info"><%= l(:text_comma_separated) %></em></p>
64 <em class="info"><%= l(:text_comma_separated) %></em></p>
70
65
71 <p><%= setting_text_field :commit_fix_keywords, :size => 30 %>
66 <p><%= setting_text_field :commit_fix_keywords, :size => 30 %>
72 &nbsp;<%= l(:label_applied_status) %>: <%= setting_select :commit_fix_status_id,
67 &nbsp;<%= l(:label_applied_status) %>: <%= setting_select :commit_fix_status_id,
73 [["", 0]] +
68 [["", 0]] +
74 IssueStatus.find(:all).collect{
69 IssueStatus.find(:all).collect{
75 |status| [status.name, status.id.to_s]
70 |status| [status.name, status.id.to_s]
76 },
71 },
77 :label => false %>
72 :label => false %>
78 &nbsp;<%= l(:field_done_ratio) %>: <%= setting_select :commit_fix_done_ratio,
73 &nbsp;<%= l(:field_done_ratio) %>: <%= setting_select :commit_fix_done_ratio,
79 (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] },
74 (0..10).to_a.collect {|r| ["#{r*10} %", "#{r*10}"] },
80 :blank => :label_no_change_option,
75 :blank => :label_no_change_option,
81 :label => false %>
76 :label => false %>
82 <em class="info"><%= l(:text_comma_separated) %></em></p>
77 <em class="info"><%= l(:text_comma_separated) %></em></p>
83
78
84 <p><%= setting_check_box :commit_cross_project_ref %></p>
79 <p><%= setting_check_box :commit_cross_project_ref %></p>
85
80
86 <p><%= setting_check_box :commit_logtime_enabled,
81 <p><%= setting_check_box :commit_logtime_enabled,
87 :onclick =>
82 :onclick =>
88 "if (this.checked) { $('#settings_commit_logtime_activity_id').removeAttr('disabled'); } else { $('#settings_commit_logtime_activity_id').attr('disabled', true); }"%></p>
83 "if (this.checked) { $('#settings_commit_logtime_activity_id').removeAttr('disabled'); } else { $('#settings_commit_logtime_activity_id').attr('disabled', true); }"%></p>
89
84
90 <p><%= setting_select :commit_logtime_activity_id,
85 <p><%= setting_select :commit_logtime_activity_id,
91 [[l(:label_default), 0]] +
86 [[l(:label_default), 0]] +
92 TimeEntryActivity.shared.active.collect{|activity| [activity.name, activity.id.to_s]},
87 TimeEntryActivity.shared.active.collect{|activity| [activity.name, activity.id.to_s]},
93 :disabled => !Setting.commit_logtime_enabled?%></p>
88 :disabled => !Setting.commit_logtime_enabled?%></p>
94 </fieldset>
89 </fieldset>
95
90
96 <%= submit_tag l(:button_save) %>
91 <%= submit_tag l(:button_save) %>
97 <% end %>
92 <% end %>
General Comments 0
You need to be logged in to leave comments. Login now