annotate app/helpers/.svn/text-base/settings_helper.rb.svn-base @ 904:0a8317a50fa0 redmine-1.1

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