comparison app/helpers/settings_helper.rb @ 1339:c03a6c3c4db9 luisf

Merge
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 20 Jun 2013 14:34:42 +0100
parents 433d4f72a19b
children 622f24f53b42
comparison
equal deleted inserted replaced
1079:413d1d9c3efa 1339:c03a6c3c4db9
1 # encoding: utf-8 1 # encoding: utf-8
2 # 2 #
3 # Redmine - project management software 3 # Redmine - project management software
4 # Copyright (C) 2006-2011 Jean-Philippe Lang 4 # Copyright (C) 2006-2012 Jean-Philippe Lang
5 # 5 #
6 # This program is free software; you can redistribute it and/or 6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License 7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2 8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version. 9 # of the License, or (at your option) any later version.
42 42
43 def setting_multiselect(setting, choices, options={}) 43 def setting_multiselect(setting, choices, options={})
44 setting_values = Setting.send(setting) 44 setting_values = Setting.send(setting)
45 setting_values = [] unless setting_values.is_a?(Array) 45 setting_values = [] unless setting_values.is_a?(Array)
46 46
47 setting_label(setting, options).html_safe + 47 content_tag("label", l(options[:label] || "setting_#{setting}")) +
48 hidden_field_tag("settings[#{setting}][]", '').html_safe + 48 hidden_field_tag("settings[#{setting}][]", '').html_safe +
49 choices.collect do |choice| 49 choices.collect do |choice|
50 text, value = (choice.is_a?(Array) ? choice : [choice, choice]) 50 text, value = (choice.is_a?(Array) ? choice : [choice, choice])
51 content_tag( 51 content_tag(
52 'label', 52 'label',
53 check_box_tag( 53 check_box_tag(
54 "settings[#{setting}][]", 54 "settings[#{setting}][]",
55 value, 55 value,
56 Setting.send(setting).include?(value) 56 Setting.send(setting).include?(value),
57 :id => nil
57 ) + text.to_s, 58 ) + text.to_s,
58 :class => 'block' 59 :class => (options[:inline] ? 'inline' : 'block')
59 ) 60 )
60 end.join.html_safe 61 end.join.html_safe
61 end 62 end
62 63
63 def setting_text_field(setting, options={}) 64 def setting_text_field(setting, options={})
70 text_area_tag("settings[#{setting}]", Setting.send(setting), options).html_safe 71 text_area_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
71 end 72 end
72 73
73 def setting_check_box(setting, options={}) 74 def setting_check_box(setting, options={})
74 setting_label(setting, options).html_safe + 75 setting_label(setting, options).html_safe +
75 hidden_field_tag("settings[#{setting}]", 0).html_safe + 76 hidden_field_tag("settings[#{setting}]", 0, :id => nil).html_safe +
76 check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe 77 check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
77 end 78 end
78 79
79 def setting_label(setting, options={}) 80 def setting_label(setting, options={})
80 label = options.delete(:label) 81 label = options.delete(:label)
81 label != false ? content_tag("label", l(label || "setting_#{setting}")).html_safe : '' 82 label != false ? label_tag("settings_#{setting}", l(label || "setting_#{setting}")).html_safe : ''
82 end 83 end
83 84
84 # Renders a notification field for a Redmine::Notifiable option 85 # Renders a notification field for a Redmine::Notifiable option
85 def notification_field(notifiable) 86 def notification_field(notifiable)
86 return content_tag(:label, 87 return content_tag(:label,
87 check_box_tag('settings[notified_events][]', 88 check_box_tag('settings[notified_events][]',
88 notifiable.name, 89 notifiable.name,
89 Setting.notified_events.include?(notifiable.name)).html_safe + 90 Setting.notified_events.include?(notifiable.name), :id => nil).html_safe +
90 l_or_humanize(notifiable.name, :prefix => 'label_').html_safe, 91 l_or_humanize(notifiable.name, :prefix => 'label_').html_safe,
91 :class => notifiable.parent.present? ? "parent" : '').html_safe 92 :class => notifiable.parent.present? ? "parent" : '').html_safe
92 end 93 end
94
95 def cross_project_subtasks_options
96 options = [
97 [:label_disabled, ''],
98 [:label_cross_project_system, 'system'],
99 [:label_cross_project_tree, 'tree'],
100 [:label_cross_project_hierarchy, 'hierarchy'],
101 [:label_cross_project_descendants, 'descendants']
102 ]
103
104 options.map {|label, value| [l(label), value.to_s]}
105 end
93 end 106 end