summaryrefslogtreecommitdiffstats
path: root/app/helpers/settings_helper.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2016-12-13 18:46:29 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2016-12-13 18:46:29 +0000
commitf30462595e83f512cd5f29246a4542773595a224 (patch)
tree56eb7ce08ea5a8c6e0c21806e067c8c652e652b9 /app/helpers/settings_helper.rb
parent3186130966cea85d842faf5c038006f8fb40bb61 (diff)
downloadredmine-f30462595e83f512cd5f29246a4542773595a224.tar.gz
redmine-f30462595e83f512cd5f29246a4542773595a224.zip
Optional Regex delimiters to truncate incoming emails (#5864).
git-svn-id: http://svn.redmine.org/redmine/trunk@16065 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/settings_helper.rb')
-rw-r--r--app/helpers/settings_helper.rb29
1 files changed, 23 insertions, 6 deletions
diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb
index 2c657f0df..1bba0f9fa 100644
--- a/app/helpers/settings_helper.rb
+++ b/app/helpers/settings_helper.rb
@@ -32,18 +32,35 @@ module SettingsHelper
]
end
+ def render_settings_error(errors)
+ return if errors.blank?
+ s = ''.html_safe
+ errors.each do |name, message|
+ s << content_tag('li', content_tag('b', l("setting_#{name}")) + " " + message)
+ end
+ content_tag('div', content_tag('ul', s), :id => 'errorExplanation')
+ end
+
+ def setting_value(setting)
+ value = nil
+ if params[:settings]
+ value = params[:settings][setting]
+ end
+ value || Setting.send(setting)
+ end
+
def setting_select(setting, choices, options={})
if blank_text = options.delete(:blank)
choices = [[blank_text.is_a?(Symbol) ? l(blank_text) : blank_text, '']] + choices
end
setting_label(setting, options).html_safe +
select_tag("settings[#{setting}]",
- options_for_select(choices, Setting.send(setting).to_s),
+ options_for_select(choices, setting_value(setting).to_s),
options).html_safe
end
def setting_multiselect(setting, choices, options={})
- setting_values = Setting.send(setting)
+ setting_values = setting_value(setting)
setting_values = [] unless setting_values.is_a?(Array)
content_tag("label", l(options[:label] || "setting_#{setting}")) +
@@ -65,18 +82,18 @@ module SettingsHelper
def setting_text_field(setting, options={})
setting_label(setting, options).html_safe +
- text_field_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
+ text_field_tag("settings[#{setting}]", setting_value(setting), options).html_safe
end
def setting_text_area(setting, options={})
setting_label(setting, options).html_safe +
- text_area_tag("settings[#{setting}]", Setting.send(setting), options).html_safe
+ text_area_tag("settings[#{setting}]", setting_value(setting), options).html_safe
end
def setting_check_box(setting, options={})
setting_label(setting, options).html_safe +
hidden_field_tag("settings[#{setting}]", 0, :id => nil).html_safe +
- check_box_tag("settings[#{setting}]", 1, Setting.send("#{setting}?"), options).html_safe
+ check_box_tag("settings[#{setting}]", 1, setting_value(setting).to_s != '0', options).html_safe
end
def setting_label(setting, options={})
@@ -97,7 +114,7 @@ module SettingsHelper
tag = check_box_tag('settings[notified_events][]',
notifiable.name,
- Setting.notified_events.include?(notifiable.name),
+ setting_value('notified_events').include?(notifiable.name),
:id => nil,
:data => tag_data)