fixes email link [fixes SCI-765]

This commit is contained in:
zmagod 2017-03-24 12:10:07 +01:00
parent 94732c6d18
commit 023b3213e8
9 changed files with 53 additions and 8 deletions

View file

@ -30,6 +30,7 @@ $color-cloud: rgba(0, 0, 0, .1);
// Miscelaneous colors
$color-mystic: #eaeff2;
$color-candlelight: #ffda23;
$color-orange: #ff900b;
$color-saturated-green: #008600;
// Red colors

View file

@ -69,6 +69,17 @@
padding-top: 5px;
width: 30px;
}
.deliver {
background-color: $color-orange;
border-radius: 50%;
color: $color-wild-sand;
display: inline-block;
font-size: 13px;
height: 30px;
padding-top: 5px;
width: 30px;
}
}

View file

@ -149,6 +149,17 @@ table {
width: 45px;
}
.deliver {
background-color: $color-orange;
border-radius: 50%;
color: $color-wild-sand;
display: block;
font-size: 23px;
height: 45px;
padding-top: 5px;
width: 45px;
}
.system-message {
background-color: $color-theme-secondary;
border-radius: 50%;
@ -1952,4 +1963,4 @@ th.custom-field .modal-tooltiptext {
.my_module-state-buttons {
padding-top: 6px;
}
}

View file

@ -1,6 +1,3 @@
require 'zip'
require 'fileutils'
class ZipExportsController < ApplicationController
before_action :load_var
before_action :check_edit_permissions

View file

@ -2,7 +2,6 @@ require 'zip'
require 'fileutils'
class ZipExport < ActiveRecord::Base
include Rails.application.routes.url_helpers
belongs_to :user
has_attached_file :zip_file
validates_attachment :zip_file,
@ -70,7 +69,11 @@ class ZipExport < ActiveRecord::Base
notification = Notification.create(
type_of: :deliver,
title: I18n.t('zip_export.notification_title'),
message: "<a href='#{zip_exports_download_path(self)}'>" \
message: "<a data-id='#{id}' " \
"href='#{Rails.application
.routes
.url_helpers
.zip_exports_download_path(self)}'>" \
"#{zip_file_file_name}</a>"
)
UserNotification.create(notification: notification, user: user)
@ -85,4 +88,10 @@ class ZipExport < ActiveRecord::Base
end
end
end
protected
def default_url_options
Rails.application.config.active_job.default_url_options
end
end

View file

@ -3,7 +3,7 @@
<div class="row">
<div class="col-xs-3 col-md-1">
<span style="display: none;" data-hook="user-notification-list-item"></span>
<% if notification.type_of == 'recent_changes' %>
<% if notification.type_of == 'recent_changes' %>
<div class="text-center">
<%= image_tag avatar_path(notification.generator_user, :icon_small), class: 'avatar img-circle' %>
</div>
@ -18,6 +18,12 @@
<span class="system-message"><i class="glyphicon glyphicon-tower" aria-hidden="true"></i></span>
</div>
<% end %>
<% if notification.type_of == 'deliver' %>
<div class="text-center">
<span class="deliver"><%= fa_icon 'truck' %></span>
</div>
<% end %>
</div>
<div class="col-xs-9 col-md-11">
<strong><%= sanitize_input(notification.title) %></strong> <br>

View file

@ -18,6 +18,11 @@
<span class="system-message"><i class="glyphicon glyphicon-tower" aria-hidden="true"></i></span>
</div>
<% end %>
<% if notification.type_of == 'deliver' %>
<div class="text-center">
<span class="deliver"><%= fa_icon 'truck' %></span>
</div>
<% end %>
</div>
<div class="col-xs-10">

View file

@ -5,7 +5,7 @@
<p>Type: <%= I18n.t("notifications.types.#{@notification.type_of}") %></p>
<p>
<% if @notification.system_message? %>
<% if @notification.system_message? || @notification.deliver? %>
<% # We assume the system notification is clean %>
<%= @notification.title.html_safe %>
<% else %>
@ -17,6 +17,10 @@
<% if @notification.system_message? %>
<% # We assume the system notification is clean %>
<%= @notification.message.html_safe %>
<% elsif @notification.deliver? %>
<% # work around the problem with inserting the link of zipExport %>
<% zip_id = /data-id='(\d*)'/.match(@notification.message)[1] %>
<%= @notification.message.gsub(/href='.+'/, "href='#{zip_exports_download_url(zip_id)}'").html_safe %>
<% else %>
<%= sanitize_input(prepend_server_url_to_links(@notification.message)) %>
<% end %>

View file

@ -1517,6 +1517,7 @@ en:
assignment: "Assignment"
recent_changes: "Recent changes"
system_message: "sciNote system message"
deliver: 'Exportable content'
email_title: "You've received a sciNote notification!"
assign_user_to_team: "<i>%{assigned_user}</i> was added as %{role} to team <strong>%{team}</strong> by <i>%{assigned_by_user}</i>."
unassign_user_from_team: "<i>%{unassigned_user}</i> was removed from team <strong>%{team}</strong> by <i>%{unassigned_by_user}</i>."