annotate .svn/pristine/23/23ff873f0bf0f2e45a3709caf12bc84dab7be570.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

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