To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / helpers / settings_helper.rb @ 442:753f1380d6bc
History | View | Annotate | Download (3.84 KB)
| 1 | 0:513646585e45 | Chris | # Redmine - project management software
|
|---|---|---|---|
| 2 | 441:cbce1fd3b1b7 | Chris | # Copyright (C) 2006-2011 Jean-Philippe Lang
|
| 3 | 0:513646585e45 | Chris | #
|
| 4 | # This program is free software; you can redistribute it and/or
|
||
| 5 | # modify it under the terms of the GNU General Public License
|
||
| 6 | # as published by the Free Software Foundation; either version 2
|
||
| 7 | # of the License, or (at your option) any later version.
|
||
| 8 | 441:cbce1fd3b1b7 | Chris | #
|
| 9 | 0:513646585e45 | Chris | # This program is distributed in the hope that it will be useful,
|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
| 12 | # GNU General Public License for more details.
|
||
| 13 | 441:cbce1fd3b1b7 | Chris | #
|
| 14 | 0:513646585e45 | Chris | # You should have received a copy of the GNU General Public License
|
| 15 | # along with this program; if not, write to the Free Software
|
||
| 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
| 17 | |||
| 18 | module SettingsHelper |
||
| 19 | def administration_settings_tabs |
||
| 20 | tabs = [{:name => 'general', :partial => 'settings/general', :label => :label_general},
|
||
| 21 | {:name => 'display', :partial => 'settings/display', :label => :label_display},
|
||
| 22 | {:name => 'authentication', :partial => 'settings/authentication', :label => :label_authentication},
|
||
| 23 | {:name => 'projects', :partial => 'settings/projects', :label => :label_project_plural},
|
||
| 24 | {:name => 'issues', :partial => 'settings/issues', :label => :label_issue_tracking},
|
||
| 25 | {:name => 'notifications', :partial => 'settings/notifications', :label => :field_mail_notification},
|
||
| 26 | {:name => 'mail_handler', :partial => 'settings/mail_handler', :label => :label_incoming_emails},
|
||
| 27 | {:name => 'repositories', :partial => 'settings/repositories', :label => :label_repository_plural}
|
||
| 28 | ] |
||
| 29 | end
|
||
| 30 | 441:cbce1fd3b1b7 | Chris | |
| 31 | 0:513646585e45 | Chris | def setting_select(setting, choices, options={}) |
| 32 | if blank_text = options.delete(:blank) |
||
| 33 | choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices |
||
| 34 | end
|
||
| 35 | setting_label(setting, options) + |
||
| 36 | 441:cbce1fd3b1b7 | Chris | select_tag("settings[#{setting}]",
|
| 37 | options_for_select(choices, Setting.send(setting).to_s),
|
||
| 38 | options) |
||
| 39 | 0:513646585e45 | Chris | end
|
| 40 | 441:cbce1fd3b1b7 | Chris | |
| 41 | 0:513646585e45 | Chris | def setting_multiselect(setting, choices, options={}) |
| 42 | setting_values = Setting.send(setting)
|
||
| 43 | setting_values = [] unless setting_values.is_a?(Array) |
||
| 44 | 441:cbce1fd3b1b7 | Chris | |
| 45 | 0:513646585e45 | Chris | setting_label(setting, options) + |
| 46 | hidden_field_tag("settings[#{setting}][]", '') + |
||
| 47 | choices.collect do |choice|
|
||
| 48 | 441:cbce1fd3b1b7 | Chris | text, value = (choice.is_a?(Array) ? choice : [choice, choice])
|
| 49 | content_tag( |
||
| 50 | 'label',
|
||
| 51 | check_box_tag( |
||
| 52 | "settings[#{setting}][]",
|
||
| 53 | value, |
||
| 54 | Setting.send(setting).include?(value)
|
||
| 55 | ) + text.to_s, |
||
| 56 | 0:513646585e45 | Chris | :class => 'block' |
| 57 | 441:cbce1fd3b1b7 | Chris | ) |
| 58 | 0:513646585e45 | Chris | end.join
|
| 59 | end
|
||
| 60 | 441:cbce1fd3b1b7 | Chris | |
| 61 | 0:513646585e45 | Chris | def setting_text_field(setting, options={}) |
| 62 | setting_label(setting, options) + |
||
| 63 | text_field_tag("settings[#{setting}]", Setting.send(setting), options) |
||
| 64 | end
|
||
| 65 | 441:cbce1fd3b1b7 | Chris | |
| 66 | 0:513646585e45 | Chris | def setting_text_area(setting, options={}) |
| 67 | setting_label(setting, options) + |
||
| 68 | text_area_tag("settings[#{setting}]", Setting.send(setting), options) |
||
| 69 | end
|
||
| 70 | 441:cbce1fd3b1b7 | Chris | |
| 71 | 0:513646585e45 | Chris | def setting_check_box(setting, options={}) |
| 72 | setting_label(setting, options) + |
||
| 73 | hidden_field_tag("settings[#{setting}]", 0) + |
||
| 74 | 441:cbce1fd3b1b7 | Chris | check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options) |
| 75 | 0:513646585e45 | Chris | end
|
| 76 | 441:cbce1fd3b1b7 | Chris | |
| 77 | 0:513646585e45 | Chris | def setting_label(setting, options={}) |
| 78 | label = options.delete(:label)
|
||
| 79 | label != false ? content_tag("label", l(label || "setting_#{setting}")) : '' |
||
| 80 | end
|
||
| 81 | 37:94944d00e43c | chris | |
| 82 | # Renders a notification field for a Redmine::Notifiable option
|
||
| 83 | def notification_field(notifiable) |
||
| 84 | return content_tag(:label, |
||
| 85 | check_box_tag('settings[notified_events][]',
|
||
| 86 | notifiable.name, |
||
| 87 | Setting.notified_events.include?(notifiable.name)) +
|
||
| 88 | l_or_humanize(notifiable.name, :prefix => 'label_'), |
||
| 89 | :class => notifiable.parent.present? ? "parent" : '') |
||
| 90 | end
|
||
| 91 | 0:513646585e45 | Chris | end |