OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add basic layout for showing notification rows in the daily email
Henriette Dargea374212d8c28
diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rbindex bd3e9411f9a..3bfaed2df54 100644--- a/app/helpers/mail_digest_helper.rb+++ b/app/helpers/mail_digest_helper.rb@@ -43,6 +43,12 @@ module MailDigestHelperraw(I18n.t(:"mail.digests.work_packages.#{journal.initial? ? 'created_at' : 'updated_at'}",user: user,- timestamp: format_time(journal.created_at)))+ timestamp: time_ago_in_words(journal.created_at)))+ end++ def unique_reasons_of_notifications(notifications)+ notifications+ .map { |notification| notification.reason_mail_digest }+ .uniqendenddiff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rbindex 91c9e6973b2..9a6fae4b42d 100644--- a/app/mailers/digest_mailer.rb+++ b/app/mailers/digest_mailer.rb@@ -54,11 +54,14 @@ class DigestMailer < ApplicationMaileropen_project_headers User: recipient.namemessage_id nil, recipient+ @aggregated_notifications = load_notifications(notification_ids)+ .group_by(&:resource)+@notifications_by_project = load_notifications(notification_ids).group_by(&:project).transform_values { |of_project| of_project.group_by(&:resource) }- return if @notifications_by_project.empty?+ return if @aggregated_notifications.empty?with_locale_for(recipient) domail to: recipient.mail,diff --git a/app/views/digest_mailer/work_packages.html.erb b/app/views/digest_mailer/work_packages.html.erbindex 4eb1cd7b8d1..70ec764cddc 100644--- a/app/views/digest_mailer/work_packages.html.erb+++ b/app/views/digest_mailer/work_packages.html.erb@@ -1,25 +1,91 @@+<% @aggregated_notifications.each do | work_package, notifications_by_work_package| %>+ <div style="border: 1px solid #dadada; margin-bottom: 10px; padding: 10px; border-radius: 10px;">+ <table width="100%" border="0" cellpadding="0" cellspacing="0" style="margin-bottom: 10px">+ <tr>+ <td style="background-color: #00CC00;+ 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) %>+ <% 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">+ <tr>+ <td>+ <%= work_package.type.to_s.upcase %>+ </td>+ <td width="100%" style="padding-left: 5px">+ <%= work_package.subject %>+ </td>+ </tr>+ </table>+ <table width="100%" border="0" cellpadding="0" cellspacing="0">+ <% notifications_by_work_package.each do | notification | %>+ <% notification.journal.details.each do |detail| %>+ <tr style="color: #878787; line-height: 20px; white-space: nowrap;">+ <td>+ <%= notification.journal.render_detail(detail, only_path: false) %>+ <%= digest_notification_timestamp_text(notification) %>+ </td>+ </tr>+ <% end %>+ <% end %>+ </table>+ </div>+<% end %>+<!--+<div style="color: #777; font-weight: bold">- <%= digest_timespan_text %>+ <%#= digest_timespan_text %></div>-<% @notifications_by_project.each do |project, notifications_by_work_package| %>++<%# @notifications_by_project.each do |project, notifications_by_work_package| %><section style="margin-bottom: 3em; margin-top: 5em">- <h1 style="font-size: 2em; margin-bottom: 1.5em"><%= link_to_project(project, only_path: false) %></h1>+ <h1 style="font-size: 2em; margin-bottom: 1.5em"><%#= link_to_project(project, only_path: false) %></h1>- <% notifications_by_work_package.each do |work_package, notifications| %>+ <%# notifications_by_work_package.each do |work_package, notifications| %><section style="margin-bottom: 3em;">- <h2 style="margin-bottom: 1em; font-size: 1.5em;"><%= link_to_work_package work_package, status: true, only_path: false, no_hidden: true %></h2>+ <h2 style="margin-bottom: 1em; font-size: 1.5em;"><%#= link_to_work_package work_package, status: true, only_path: false, no_hidden: true %></h2>- <% notifications.sort_by(&:created_at).each do |notification| %>+ <%# notifications.sort_by(&:created_at).each do |notification| %><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="20px"></td><td style="font-weight: normal; font-size: 1.1em;">- <%= digest_notification_timestamp_text(notification) %>+ <%#= digest_notification_timestamp_text(notification) %></td><td style="text-align: right">- <%= I18n.t(+ <%#= I18n.t(:"mail.digests.work_packages.reason.#{notification.reason_mail_digest || :unknown}",default: '-') %></td>@@ -27,32 +93,33 @@</tr></table>- <% journal = notification.journal %>+ <%# journal = notification.journal %><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="20px"></td><td>- <%= format_text(journal.notes,+ <%#= format_text(journal.notes,only_path: false,object: notification.resource,project: notification.project) %>- <% if journal.notes.present? && journal.details.any? %>+ <%# if journal.notes.present? && journal.details.any? %><div style="margin-bottom: 2em"></div>- <% end %>+ <%# end %><ul>- <% journal.details.each do |detail| %>- <li><%= journal.render_detail(detail, only_path: false) %></li>- <% end %>+ <%# journal.details.each do |detail| %>+ <li><%#= journal.render_detail(detail, only_path: false) %></li>+ <%# end %></ul></td></tr></table><div style="margin-bottom: 3em"></div>- <% end %>+ <%# end %></section>- <% end %>+ <%# end %></section>-<% end %>+<%# end %>+-->diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erbindex 878021f2af6..117a987cf11 100644--- a/app/views/layouts/mailer.html.erb+++ b/app/views/layouts/mailer.html.erb@@ -40,13 +40,6 @@ See COPYRIGHT and LICENSE files for more details.color: #484848;background: #FFFFFF;}-- @media (prefers-color-scheme: dark) {- body {- color: #CCC !important;- background: #222222 !important;- }- }h1, h2, h3 { font-family: "Trebuchet MS", Verdana, sans-serif; margin: 0px; }h1 { font-size: 1.2em; }diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 21af890dcd6..a631cb103f1 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1969,7 +1969,7 @@ en:digests:time_frame: 'Summary of all events you subscribed to in the period between %{start} and %{end}'work_packages:- created_at: '%{user} created at %{timestamp}'+ created_at: 'by %{user} %{timestamp} ago'reason:watched: 'watched'involved: 'assignee or responsible'@@ -1977,7 +1977,7 @@ en:subscribed: 'all'prefix: 'Received because of the notification setting: %{reason}'subject: 'Daily project summary for %{date} - %{number} updates'- updated_at: '%{user} updated at %{timestamp}'+ updated_at: '%{timestamp} ago by %{user}'mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"mail_body_account_information: "Your account information"