annotate .svn/pristine/74/74371bacf9dc462e3a98cdd896bf9656d288af0c.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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