Changed the notifications to use a hierarchy UI
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4222 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
4c9f261a24
commit
26ef9da02b
|
@ -71,4 +71,14 @@ module SettingsHelper
|
||||||
label = options.delete(:label)
|
label = options.delete(:label)
|
||||||
label != false ? content_tag("label", l(label || "setting_#{setting}")) : ''
|
label != false ? content_tag("label", l(label || "setting_#{setting}")) : ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Renders a notification field for a Redmine::Notifiable option
|
||||||
|
def notification_field(notifiable)
|
||||||
|
return content_tag(:label,
|
||||||
|
check_box_tag('settings[notified_events][]',
|
||||||
|
notifiable.name,
|
||||||
|
Setting.notified_events.include?(notifiable.name)) +
|
||||||
|
l_or_humanize(notifiable.name, :prefix => 'label_'),
|
||||||
|
:class => notifiable.parent.present? ? "parent" : '')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,11 +12,13 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<fieldset class="box settings" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend>
|
<fieldset class="box" id="notified_events"><legend><%=l(:text_select_mail_notifications)%></legend>
|
||||||
<%= setting_multiselect(:notified_events,
|
<%= hidden_field_tag 'settings[notified_events][]', '' %>
|
||||||
@notifiables.collect {|notifiable| [l_or_humanize(notifiable, :prefix => 'label_'), notifiable]}, :label => false) %>
|
<% @notifiables.each do |notifiable| %>
|
||||||
|
<%= notification_field notifiable %>
|
||||||
<p><%= check_all_links('notified_events') %></p>
|
<br />
|
||||||
|
<% end %>
|
||||||
|
<p><%= check_all_links('notified_events') %></p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="box"><legend><%= l(:setting_emails_footer) %></legend>
|
<fieldset class="box"><legend><%= l(:setting_emails_footer) %></legend>
|
||||||
|
|
|
@ -1,22 +1,25 @@
|
||||||
module Redmine
|
module Redmine
|
||||||
class Notifiable
|
class Notifiable < Struct.new(:name, :parent)
|
||||||
CoreNotifications = [
|
|
||||||
'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'
|
|
||||||
]
|
|
||||||
|
|
||||||
|
def to_s
|
||||||
|
name
|
||||||
|
end
|
||||||
|
|
||||||
# TODO: Plugin API for adding a new notification?
|
# TODO: Plugin API for adding a new notification?
|
||||||
def self.all
|
def self.all
|
||||||
CoreNotifications
|
notifications = []
|
||||||
|
notifications << Notifiable.new('issue_added')
|
||||||
|
notifications << Notifiable.new('issue_updated')
|
||||||
|
notifications << Notifiable.new('issue_note_added', 'issue_updated')
|
||||||
|
notifications << Notifiable.new('issue_status_updated', 'issue_updated')
|
||||||
|
notifications << Notifiable.new('issue_priority_updated', 'issue_updated')
|
||||||
|
notifications << Notifiable.new('news_added')
|
||||||
|
notifications << Notifiable.new('document_added')
|
||||||
|
notifications << Notifiable.new('file_added')
|
||||||
|
notifications << Notifiable.new('message_posted')
|
||||||
|
notifications << Notifiable.new('wiki_content_added')
|
||||||
|
notifications << Notifiable.new('wiki_content_updated')
|
||||||
|
notifications
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,6 +17,13 @@ function toggleCheckboxesBySelector(selector) {
|
||||||
for (i = 0; i < boxes.length; i++) { boxes[i].checked = !all_checked; }
|
for (i = 0; i < boxes.length; i++) { boxes[i].checked = !all_checked; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCheckboxesBySelector(checked, selector) {
|
||||||
|
var boxes = $$(selector);
|
||||||
|
boxes.each(function(ele) {
|
||||||
|
ele.checked = checked;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function showAndScrollTo(id, focus) {
|
function showAndScrollTo(id, focus) {
|
||||||
Element.show(id);
|
Element.show(id);
|
||||||
if (focus!=null) { Form.Element.focus(focus); }
|
if (focus!=null) { Form.Element.focus(focus); }
|
||||||
|
@ -56,7 +63,6 @@ function addFileField() {
|
||||||
dLabel.addClassName('inline');
|
dLabel.addClassName('inline');
|
||||||
// Pulls the languge value used for Optional Description
|
// Pulls the languge value used for Optional Description
|
||||||
dLabel.update($('attachment_description_label_content').innerHTML)
|
dLabel.update($('attachment_description_label_content').innerHTML)
|
||||||
|
|
||||||
p = document.getElementById("attachments_fields");
|
p = document.getElementById("attachments_fields");
|
||||||
p.appendChild(document.createElement("br"));
|
p.appendChild(document.createElement("br"));
|
||||||
p.appendChild(f);
|
p.appendChild(f);
|
||||||
|
|
|
@ -419,6 +419,7 @@ input#time_entry_comments { width: 90%;}
|
||||||
.tabular.settings textarea { width: 99%; }
|
.tabular.settings textarea { width: 99%; }
|
||||||
|
|
||||||
fieldset.settings label { display: block; }
|
fieldset.settings label { display: block; }
|
||||||
|
.parent { padding-left: 20px; }
|
||||||
|
|
||||||
.required {color: #bb0000;}
|
.required {color: #bb0000;}
|
||||||
.summary {font-style: italic;}
|
.summary {font-style: italic;}
|
||||||
|
|
|
@ -21,18 +21,11 @@ class Redmine::NotifiableTest < ActiveSupport::TestCase
|
||||||
def setup
|
def setup
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_included_core_notifications
|
def test_all
|
||||||
assert_equal 11, Redmine::Notifiable::CoreNotifications.length
|
assert_equal 11, Redmine::Notifiable.all.length
|
||||||
Redmine::Notifiable::CoreNotifications.length
|
|
||||||
|
|
||||||
%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|
|
%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|
|
||||||
assert Redmine::Notifiable::CoreNotifications.include?(notifiable), "missing #{notifiable}"
|
assert Redmine::Notifiable.all.collect(&:name).include?(notifiable), "missing #{notifiable}"
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_all_should_include_all_of_the_core_notifications
|
|
||||||
Redmine::Notifiable::CoreNotifications.each do |notifiable|
|
|
||||||
assert Redmine::Notifiable.all.include?(notifiable), "missing #{notifiable} in #all"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue