parent
4017151d25
commit
51ec3c91c6
@ -0,0 +1,58 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- copyright |
||||
# OpenProject is an open source project management software. |
||||
# Copyright (C) 2012-2021 the OpenProject GmbH |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License version 3. |
||||
# |
||||
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: |
||||
# Copyright (C) 2006-2013 Jean-Philippe Lang |
||||
# Copyright (C) 2010-2013 the ChiliProject Team |
||||
# |
||||
# This program is free software; you can redistribute it and/or |
||||
# modify it under the terms of the GNU General Public License |
||||
# as published by the Free Software Foundation; either version 2 |
||||
# of the License, or (at your option) any later version. |
||||
# |
||||
# This program is distributed in the hope that it will be useful, |
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
# GNU General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU General Public License |
||||
# along with this program; if not, write to the Free Software |
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
||||
# |
||||
# See docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
module MailNotificationHelper |
||||
include ::ColorsHelper |
||||
|
||||
def email_image_tag(image, **options) |
||||
attachments[image] = File.read(Rails.root.join("app/assets/images/#{image}")) |
||||
image_tag attachments[image].url, **options |
||||
end |
||||
|
||||
def unique_reasons_of_notifications(notifications) |
||||
notifications |
||||
.map(&:reason_mail_digest) |
||||
.uniq |
||||
end |
||||
|
||||
def notifications_path(id) |
||||
notifications_center_url(['details', id, 'activity']) |
||||
end |
||||
|
||||
def type_color(type, default_fallback) |
||||
color_id = selected_color(type) |
||||
color_id ? Color.find(color_id).hexcode : default_fallback |
||||
end |
||||
|
||||
def status_colors(status) |
||||
color_id = selected_color(status) |
||||
Color.find(color_id).color_styles.map { |k, v| "#{k}:#{v};" }.join(' ') if color_id |
||||
end |
||||
end |
@ -0,0 +1,30 @@ |
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-bottom: 1px solid #cccccc; margin-bottom: 30px;"> |
||||
<tr> |
||||
<td style="width: 82px; height: 82px; vertical-align: top;"> |
||||
<%= email_image_tag("logo_openproject_narrow.svg", alt: I18n.t(:'mail.logo_alt_text')) %> |
||||
</td> |
||||
<td width="100%" style="padding-top: 8px;"> |
||||
<table> |
||||
<tr> |
||||
<td style="font-size: 24px; color: #333333; padding-bottom: 5px;"> |
||||
<%= I18n.t(:'mail.salutation', user: @user.firstname) %> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td style="font-size:14px; color: #1A67A3; font-weight: bold; padding-bottom: 10px;"> |
||||
<%= summary %> |
||||
</td> |
||||
</tr> |
||||
<tr> |
||||
<td style="padding: 10px 0 25px 0;"> |
||||
<a href="<%= notifications_center_url %>" |
||||
target="_blank" |
||||
style="background: #D1E5F5; padding: 8px 12px; color: #1A67A3; border: 1px solid #1A67A3; border-radius: 16px; text-decoration: none;"> |
||||
<%= I18n.t(:'mail.notification.center') %> |
||||
</a> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
</td> |
||||
</tr> |
||||
</table> |
@ -0,0 +1,61 @@ |
||||
<a style="border: 1px solid #E0E0E0; |
||||
margin-bottom: 15px; |
||||
padding: 12px; |
||||
border-radius: 10px; |
||||
text-decoration: none; |
||||
display: block;" |
||||
href="<%= notifications_path(work_package.id) %>" |
||||
target="_blank"> |
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin-bottom: 10px; font-size: 12px;"> |
||||
<tr> |
||||
<td style="color: #333333; |
||||
background-color: #FFFFFF; |
||||
<%= status_colors(work_package.status) %> |
||||
white-space: nowrap; |
||||
padding: 0 5px;"> |
||||
<%= work_package.status %> |
||||
</td> |
||||
<td style="padding-left: 5px; |
||||
color: #878787;"> |
||||
#<%= work_package.id %> |
||||
</td> |
||||
<td style="white-space: nowrap; |
||||
padding-left: 5px; |
||||
color: #878787;"> |
||||
- <%= work_package.project %> |
||||
</td> |
||||
<td style="padding-left: 5px; |
||||
color: #878787; |
||||
white-space: nowrap;"> |
||||
<% unique_reasons = unique_reasons_of_notifications(notifications_by_work_package) %> |
||||
<%= ' - ' unless unique_reasons.length === 1 && unique_reasons.first.nil? %> |
||||
<% unique_reasons.each_with_index do |reason, index| %> |
||||
<%= I18n.t( |
||||
:"mail.digests.work_packages.reason.#{reason || :unknown}", |
||||
default: '') %><%= ', ' unless unique_reasons.size-1 == index %> |
||||
<% end %> |
||||
</td> |
||||
<td width="100%" style="text-align: right;"> |
||||
<span style="background-color: #00A3FF; |
||||
color: white; |
||||
border-radius: 8px; |
||||
padding: 2px 7px; |
||||
font-size: 10px;"> |
||||
<%= notifications_by_work_package.length %> |
||||
</span> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin-bottom: 10px; font-size: 14px; font-weight: bold;"> |
||||
<tr> |
||||
<td style="color: <%= type_color(work_package.type, '#333333') %>;"> |
||||
<%= work_package.type.to_s.upcase %> |
||||
</td> |
||||
<td width="100%" style="padding-left: 5px; color: #333333;"> |
||||
<%= work_package.subject %> |
||||
</td> |
||||
</tr> |
||||
</table> |
||||
|
||||
<%= yield %> |
||||
</a> |
@ -0,0 +1,5 @@ |
||||
<a href="<%= my_notifications_url %>" |
||||
target="_blank" |
||||
style="padding: 8px 12px; color: #333333; border: 1px solid #878787; border-radius: 16px; text-decoration: none; white-space: nowrap;"> |
||||
<%= I18n.t(:'mail.notification.settings') %> |
||||
</a> |
Loading…
Reference in new issue