annotate .svn/pristine/73/730b0be38b3536bd59aa6606d63f9f7f7307e8be.svn-base @ 1327:287f201c2802 redmine-2.2-integration

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