@@ -71,4 +71,14 module SettingsHelper | |||
|
71 | 71 | label = options.delete(:label) |
|
72 | 72 | label != false ? content_tag("label", l(label || "setting_#{setting}")) : '' |
|
73 | 73 | end |
|
74 | ||
|
75 | # Renders a notification field for a Redmine::Notifiable option | |
|
76 | def notification_field(notifiable) | |
|
77 | return content_tag(:label, | |
|
78 | check_box_tag('settings[notified_events][]', | |
|
79 | notifiable.name, | |
|
80 | Setting.notified_events.include?(notifiable.name)) + | |
|
81 | l_or_humanize(notifiable.name, :prefix => 'label_'), | |
|
82 | :class => notifiable.parent.present? ? "parent" : '') | |
|
83 | end | |
|
74 | 84 | end |
@@ -12,11 +12,13 | |||
|
12 | 12 | |
|
13 | 13 | </div> |
|
14 | 14 | |
|
15 |
<fieldset class="box |
|
|
16 | <%= setting_multiselect(:notified_events, | |
|
17 | @notifiables.collect {|notifiable| [l_or_humanize(notifiable, :prefix => 'label_'), notifiable]}, :label => false) %> | |
|
18 | ||
|
19 | <p><%= check_all_links('notified_events') %></p> | |
|
15 | <fieldset class="box" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend> | |
|
16 | <%= hidden_field_tag 'settings[notified_events][]', '' %> | |
|
17 | <% @notifiables.each do |notifiable| %> | |
|
18 | <%= notification_field notifiable %> | |
|
19 | <br /> | |
|
20 | <% end %> | |
|
21 | <p><%= check_all_links('notified_events') %></p> | |
|
20 | 22 | </fieldset> |
|
21 | 23 | |
|
22 | 24 | <fieldset class="box"><legend><%= l(:setting_emails_footer) %></legend> |
@@ -1,22 +1,25 | |||
|
1 | 1 | module Redmine |
|
2 | class Notifiable | |
|
3 | CoreNotifications = [ | |
|
4 | 'issue_added', | |
|
5 | 'issue_updated', | |
|
6 | 'issue_note_added', | |
|
7 | 'issue_status_updated', | |
|
8 | 'issue_priority_updated', | |
|
9 | 'news_added', | |
|
10 | 'document_added', | |
|
11 | 'file_added', | |
|
12 | 'message_posted', | |
|
13 | 'wiki_content_added', | |
|
14 | 'wiki_content_updated' | |
|
15 | ] | |
|
2 | class Notifiable < Struct.new(:name, :parent) | |
|
16 | 3 | |
|
4 | def to_s | |
|
5 | name | |
|
6 | end | |
|
7 | ||
|
17 | 8 | # TODO: Plugin API for adding a new notification? |
|
18 | 9 | def self.all |
|
19 |
|
|
|
10 | notifications = [] | |
|
11 | notifications << Notifiable.new('issue_added') | |
|
12 | notifications << Notifiable.new('issue_updated') | |
|
13 | notifications << Notifiable.new('issue_note_added', 'issue_updated') | |
|
14 | notifications << Notifiable.new('issue_status_updated', 'issue_updated') | |
|
15 | notifications << Notifiable.new('issue_priority_updated', 'issue_updated') | |
|
16 | notifications << Notifiable.new('news_added') | |
|
17 | notifications << Notifiable.new('document_added') | |
|
18 | notifications << Notifiable.new('file_added') | |
|
19 | notifications << Notifiable.new('message_posted') | |
|
20 | notifications << Notifiable.new('wiki_content_added') | |
|
21 | notifications << Notifiable.new('wiki_content_updated') | |
|
22 | notifications | |
|
20 | 23 | end |
|
21 | 24 | end |
|
22 | 25 | end |
@@ -17,6 +17,13 function toggleCheckboxesBySelector(selector) { | |||
|
17 | 17 | for (i = 0; i < boxes.length; i++) { boxes[i].checked = !all_checked; } |
|
18 | 18 | } |
|
19 | 19 | |
|
20 | function setCheckboxesBySelector(checked, selector) { | |
|
21 | var boxes = $$(selector); | |
|
22 | boxes.each(function(ele) { | |
|
23 | ele.checked = checked; | |
|
24 | }); | |
|
25 | } | |
|
26 | ||
|
20 | 27 | function showAndScrollTo(id, focus) { |
|
21 | 28 | Element.show(id); |
|
22 | 29 | if (focus!=null) { Form.Element.focus(focus); } |
@@ -56,7 +63,6 function addFileField() { | |||
|
56 | 63 | dLabel.addClassName('inline'); |
|
57 | 64 | // Pulls the languge value used for Optional Description |
|
58 | 65 | dLabel.update($('attachment_description_label_content').innerHTML) |
|
59 | ||
|
60 | 66 | p = document.getElementById("attachments_fields"); |
|
61 | 67 | p.appendChild(document.createElement("br")); |
|
62 | 68 | p.appendChild(f); |
@@ -419,6 +419,7 input#time_entry_comments { width: 90%;} | |||
|
419 | 419 | .tabular.settings textarea { width: 99%; } |
|
420 | 420 | |
|
421 | 421 | fieldset.settings label { display: block; } |
|
422 | .parent { padding-left: 20px; } | |
|
422 | 423 | |
|
423 | 424 | .required {color: #bb0000;} |
|
424 | 425 | .summary {font-style: italic;} |
@@ -21,18 +21,11 class Redmine::NotifiableTest < ActiveSupport::TestCase | |||
|
21 | 21 | def setup |
|
22 | 22 | end |
|
23 | 23 | |
|
24 | def test_included_core_notifications | |
|
25 |
assert_equal 11, Redmine::Notifiable |
|
|
26 | Redmine::Notifiable::CoreNotifications.length | |
|
24 | def test_all | |
|
25 | assert_equal 11, Redmine::Notifiable.all.length | |
|
27 | 26 | |
|
28 | 27 | %w(issue_added issue_updated issue_note_added issue_status_updated issue_priority_updated news_added document_added file_added message_posted wiki_content_added wiki_content_updated).each do |notifiable| |
|
29 |
assert Redmine::Notifiable |
|
|
30 | end | |
|
31 | end | |
|
32 | ||
|
33 | def test_all_should_include_all_of_the_core_notifications | |
|
34 | Redmine::Notifiable::CoreNotifications.each do |notifiable| | |
|
35 | assert Redmine::Notifiable.all.include?(notifiable), "missing #{notifiable} in #all" | |
|
28 | assert Redmine::Notifiable.all.collect(&:name).include?(notifiable), "missing #{notifiable}" | |
|
36 | 29 | end |
|
37 | 30 | end |
|
38 | 31 | end |
General Comments 0
You need to be logged in to leave comments.
Login now