Patch #43990 » 0001-Add-detailed-issue-notifications.patch
| app/assets/stylesheets/application.css | ||
|---|---|---|
|
fieldset.settings label { display: block; }
|
||
|
fieldset#notified_events .parent { padding-inline-start: 20px; }
|
||
|
fieldset#notified_events .notification-details { padding-inline-start: 40px; border: 0px;}
|
||
|
span.required {color: var(--oc-red-9);}
|
||
|
.summary {font-style: italic;}
|
||
| app/helpers/settings_helper.rb | ||
|---|---|---|
|
# Renders a notification field for a Redmine::Notifiable option
|
||
|
def notification_field(notifiable)
|
||
|
checked = setting_value('notified_events').include?(notifiable.name)
|
||
|
tag_data =
|
||
|
if notifiable.parent.present?
|
||
|
{:parent_notifiable => notifiable.parent}
|
||
|
{:parent_notifiable => notifiable.parent,
|
||
|
:disables => "fieldset[data-parent-notifiable=#{notifiable.name}]"}
|
||
|
else
|
||
|
{:disables => "input[data-parent-notifiable=#{notifiable.name}]"}
|
||
|
end
|
||
|
tag = check_box_tag('settings[notified_events][]',
|
||
|
notifiable.name,
|
||
|
setting_value('notified_events').include?(notifiable.name),
|
||
|
checked,
|
||
|
:id => nil,
|
||
|
:data => tag_data)
|
||
|
text = l_or_humanize(notifiable.name, :prefix => 'label_')
|
||
| ... | ... | |
|
if notifiable.parent.present?
|
||
|
options[:class] = "parent"
|
||
|
end
|
||
|
content_tag(:label, tag + text, options)
|
||
|
label = content_tag(:label, tag + text, options)
|
||
|
if detailed_notifiable?(notifiable)
|
||
|
label + notification_details_fieldset(notifiable, checked)
|
||
|
else
|
||
|
label + "<br />".html_safe
|
||
|
end
|
||
|
end
|
||
|
def session_lifetime_options
|
||
| ... | ... | |
|
['Retro', 'retro'],
|
||
|
['Robohash', 'robohash']]
|
||
|
end
|
||
|
def issue_attribute_options(except: [])
|
||
|
attrs = Issue.new.safe_attribute_names
|
||
|
options = attrs.filter_map do |attr|
|
||
|
next if except.include?(attr)
|
||
|
label = l("field_#{attr.gsub(/_id$/, '')}", default: nil)
|
||
|
[label, attr] if label.present?
|
||
|
end
|
||
|
options << [l(:label_subtask_plural), 'child_id']
|
||
|
options << [l(:field_parent_issue), 'parent_id']
|
||
|
options.sort_by(&:first)
|
||
|
end
|
||
|
def issue_custom_field_options
|
||
|
IssueCustomField
|
||
|
.sorted
|
||
|
.map { |cf| [cf.name, cf.id.to_s] }
|
||
|
end
|
||
|
def issue_relation_options
|
||
|
IssueRelation::TYPES.map do |name, _|
|
||
|
[l("label_relation_#{name}", default: nil) ||
|
||
|
l("label_#{name}_to", default: nil) ||
|
||
|
l("label_#{name}_by", default: nil) ||
|
||
|
l("label_#{name}", default: nil) || name, name]
|
||
|
end
|
||
|
end
|
||
|
def notification_details_fieldset(notifiable, checked)
|
||
|
notifiable_setting_key = "notified_event_#{notifiable.name}_details"
|
||
|
content_tag(
|
||
|
:fieldset,
|
||
|
class: 'notification-details',
|
||
|
disabled: checked,
|
||
|
data: { parent_notifiable: notifiable.name }
|
||
|
) do
|
||
|
select_tag(
|
||
|
"settings[#{notifiable_setting_key}][]",
|
||
|
options_for_select(
|
||
|
notifiable_field_options(notifiable),
|
||
|
setting_value(notifiable_setting_key)
|
||
|
),
|
||
|
multiple: true,
|
||
|
size: 6,
|
||
|
class: 'multiselect wide'
|
||
|
) +
|
||
|
hidden_field_tag("settings[#{notifiable_setting_key}][]", "", id: nil)
|
||
|
end
|
||
|
end
|
||
|
def notifiable_field_options(notifiable)
|
||
|
case notifiable.name
|
||
|
when 'issue_attr_updated'
|
||
|
issue_attribute_options(except: %w[notes])
|
||
|
when 'issue_relation_updated'
|
||
|
issue_relation_options
|
||
|
when 'issue_cf_updated'
|
||
|
issue_custom_field_options
|
||
|
else
|
||
|
[]
|
||
|
end
|
||
|
end
|
||
|
def detailed_notifiable?(notifiable)
|
||
|
notifiable_field_options(notifiable).present?
|
||
|
end
|
||
|
end
|
||
| app/models/journal.rb | ||
|---|---|---|
|
(
|
||
|
Setting.notified_events.include?('issue_updated') ||
|
||
|
(Setting.notified_events.include?('issue_note_added') && notes.present?) ||
|
||
|
(Setting.notified_events.include?('issue_status_updated') && new_status.present?) ||
|
||
|
(Setting.notified_events.include?('issue_assigned_to_updated') && detail_for_attribute('assigned_to_id').present?) ||
|
||
|
(Setting.notified_events.include?('issue_priority_updated') && new_value_for('priority_id').present?) ||
|
||
|
(Setting.notified_events.include?('issue_fixed_version_updated') && detail_for_attribute('fixed_version_id').present?) ||
|
||
|
(Setting.notified_events.include?('issue_attachment_added') && details.any? {|d| d.property == 'attachment' && d.value })
|
||
|
(Setting.notified_events.include?('issue_attachment_added') && details.any? {|d| d.property == 'attachment' && d.value }) ||
|
||
|
notify_by_details?(Setting.notified_events.include?('issue_attr_updated'), 'attr', Setting.notified_event_issue_attr_updated_details) ||
|
||
|
notify_by_details?(Setting.notified_events.include?('issue_relation_updated'), 'relation', Setting.notified_event_issue_relation_updated_details) ||
|
||
|
notify_by_details?(Setting.notified_events.include?('issue_cf_updated'), 'cf', Setting.notified_event_issue_cf_updated_details)
|
||
|
)
|
||
|
Mailer.deliver_issue_edit(self)
|
||
|
end
|
||
| ... | ... | |
|
end
|
||
|
notified
|
||
|
end
|
||
|
def notify_by_details?(notify_all, property, prop_keys)
|
||
|
return false unless notify_all || prop_keys.present?
|
||
|
relevant_details = details.select { |d| d.property == property }
|
||
|
return false if relevant_details.empty?
|
||
|
return true if notify_all
|
||
|
allowed = Array(prop_keys).map(&:to_s)
|
||
|
relevant_details.any? do |detail|
|
||
|
allowed.include?(detail.prop_key.to_s)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| app/views/settings/_notifications.html.erb | ||
|---|---|---|
|
<%= hidden_field_tag 'settings[notified_events][]', '' %>
|
||
|
<% @notifiables.each do |notifiable| %>
|
||
|
<%= notification_field notifiable %>
|
||
|
<br />
|
||
|
<% end %>
|
||
|
<p><%= check_all_links('notified_events') %></p>
|
||
|
</fieldset>
|
||
| config/settings.yml | ||
|---|---|---|
|
default:
|
||
|
- issue_added
|
||
|
- issue_updated
|
||
|
notified_event_issue_attr_updated_details:
|
||
|
serialized: true
|
||
|
default: []
|
||
|
notified_event_issue_relation_updated_details:
|
||
|
serialized: true
|
||
|
default: []
|
||
|
notified_event_issue_cf_updated_details:
|
||
|
serialized: true
|
||
|
default: []
|
||
|
mail_handler_body_delimiters:
|
||
|
default: ''
|
||
|
mail_handler_enable_regex_delimiters:
|
||
| lib/redmine/notifiable.rb | ||
|---|---|---|
|
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_assigned_to_updated', 'issue_updated')
|
||
|
notifications << Notifiable.new('issue_priority_updated', 'issue_updated')
|
||
|
notifications << Notifiable.new('issue_fixed_version_updated', 'issue_updated')
|
||
|
notifications << Notifiable.new('issue_attachment_added', 'issue_updated')
|
||
|
notifications << Notifiable.new('issue_attr_updated', 'issue_updated')
|
||
|
notifications << Notifiable.new('issue_relation_updated', 'issue_updated')
|
||
|
notifications << Notifiable.new('issue_cf_updated', 'issue_updated')
|
||
|
notifications << Notifiable.new('news_added')
|
||
|
notifications << Notifiable.new('news_comment_added')
|
||
|
notifications << Notifiable.new('document_added')
|
||