mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-04 19:53:19 +08:00
Fix smart annotations [SCI-9605][SCI-9772]
This commit is contained in:
parent
0c5171911e
commit
f6783b219b
13 changed files with 47 additions and 9 deletions
|
@ -48,6 +48,7 @@ module StepsActions
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: checklist_item.text,
|
||||
subject: step,
|
||||
title: t('notifications.checklist_title',
|
||||
user: current_user.full_name,
|
||||
step: step.name),
|
||||
|
@ -59,6 +60,7 @@ module StepsActions
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: step_text.text,
|
||||
subject: step,
|
||||
title: t('notifications.step_text_title',
|
||||
user: current_user.full_name,
|
||||
step: step.name),
|
||||
|
@ -70,6 +72,7 @@ module StepsActions
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: checklist.name,
|
||||
subject: step,
|
||||
title: t('notifications.checklist_title',
|
||||
user: current_user.full_name,
|
||||
step: step.name),
|
||||
|
@ -81,6 +84,7 @@ module StepsActions
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: step.description,
|
||||
subject: step,
|
||||
title: t('notifications.step_description_title',
|
||||
user: current_user.full_name,
|
||||
step: step.name),
|
||||
|
|
|
@ -602,6 +602,7 @@ class ExperimentsController < ApplicationController
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: @experiment.description,
|
||||
subject: @experiment,
|
||||
title: t('notifications.experiment_annotation_title',
|
||||
experiment: @experiment.name,
|
||||
user: current_user.full_name),
|
||||
|
|
|
@ -264,6 +264,7 @@ class MyModuleRepositoriesController < ApplicationController
|
|||
smart_annotation_notification(
|
||||
old_text: nil,
|
||||
new_text: comment,
|
||||
subject: module_repository_row.repository_row,
|
||||
title: t('notifications.my_module_consumption_comment_annotation_title',
|
||||
repository_item: module_repository_row.repository_row.name,
|
||||
repository: @repository.name,
|
||||
|
|
|
@ -561,6 +561,7 @@ class MyModulesController < ApplicationController
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: @my_module.description,
|
||||
subject: @my_module,
|
||||
title: t('notifications.my_module_description_annotation_title',
|
||||
my_module: @my_module.name,
|
||||
user: current_user.full_name),
|
||||
|
@ -575,6 +576,7 @@ class MyModulesController < ApplicationController
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: @my_module.protocol.description,
|
||||
subject: @my_module,
|
||||
title: t('notifications.my_module_protocol_annotation_title',
|
||||
my_module: @my_module.name,
|
||||
user: current_user.full_name),
|
||||
|
|
|
@ -1079,6 +1079,7 @@ class ProtocolsController < ApplicationController
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: @protocol.description,
|
||||
subject: @protocol,
|
||||
title: t('notifications.protocol_description_annotation_title',
|
||||
user: current_user.full_name,
|
||||
protocol: @protocol.name),
|
||||
|
|
|
@ -452,6 +452,7 @@ class RepositoryRowsController < ApplicationController
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: cell.value.data,
|
||||
subject: cell.repository_column.repository,
|
||||
title: t('notifications.repository_annotation_title',
|
||||
user: current_user.full_name,
|
||||
column: cell.repository_column.name,
|
||||
|
|
|
@ -100,6 +100,7 @@ module ResultElements
|
|||
smart_annotation_notification(
|
||||
old_text: (old_text if old_text),
|
||||
new_text: @result_text.text,
|
||||
subject: @result,
|
||||
title: t('notifications.result_annotation_title',
|
||||
result: @result.name,
|
||||
user: current_user.full_name),
|
||||
|
|
|
@ -121,6 +121,7 @@ class ResultTextsController < ApplicationController
|
|||
smart_annotation_notification(
|
||||
old_text: (old_text if old_text),
|
||||
new_text: @result_text.text,
|
||||
subject: @result,
|
||||
title: t('notifications.result_annotation_title',
|
||||
result: @result.name,
|
||||
user: current_user.full_name),
|
||||
|
|
|
@ -71,6 +71,7 @@ module ApplicationHelper
|
|||
message = options.fetch(:message) { :message_must_be_present }
|
||||
old_text = options[:old_text] || ''
|
||||
new_text = options[:new_text]
|
||||
subject = options[:subject]
|
||||
return if new_text.blank?
|
||||
|
||||
sa_user = /\[\@(.*?)~([0-9a-zA-Z]+)\]/
|
||||
|
@ -96,15 +97,19 @@ module ApplicationHelper
|
|||
target_user = User.find_by_id(user_id)
|
||||
next unless target_user
|
||||
|
||||
generate_annotation_notification(target_user, title, message)
|
||||
generate_annotation_notification(target_user, title, subject)
|
||||
end
|
||||
end
|
||||
|
||||
def generate_annotation_notification(target_user, title, message)
|
||||
GeneralNotification.with(
|
||||
title: sanitize_input(title),
|
||||
message: sanitize_input(message)
|
||||
).deliver_later(target_user)
|
||||
def generate_annotation_notification(target_user, title, subject)
|
||||
GeneralNotification.send_notifications(
|
||||
{
|
||||
type: :smart_annotation_added,
|
||||
title: sanitize_input(title),
|
||||
subject: subject,
|
||||
user: target_user
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
def custom_link_open_new_tab(text)
|
||||
|
|
|
@ -125,6 +125,7 @@ module CommentHelper
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: comment.message,
|
||||
subject: result,
|
||||
title: t('notifications.result_comment_annotation_title',
|
||||
result: result.name,
|
||||
user: current_user.full_name),
|
||||
|
@ -147,6 +148,7 @@ module CommentHelper
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: comment.message,
|
||||
subject: project,
|
||||
title: t('notifications.project_comment_annotation_title',
|
||||
project: project.name,
|
||||
user: current_user.full_name),
|
||||
|
@ -160,6 +162,7 @@ module CommentHelper
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: comment.message,
|
||||
subject: step,
|
||||
title: t('notifications.step_comment_annotation_title',
|
||||
step: step.name,
|
||||
user: current_user.full_name),
|
||||
|
@ -184,6 +187,7 @@ module CommentHelper
|
|||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: comment.message,
|
||||
subject: my_module,
|
||||
title: t('notifications.my_module_comment_annotation_title',
|
||||
my_module: my_module.name,
|
||||
user: current_user.full_name),
|
||||
|
|
|
@ -12,4 +12,8 @@ class GeneralNotification < BaseNotification
|
|||
def subtype
|
||||
params[:type]
|
||||
end
|
||||
|
||||
def subject
|
||||
params[:subject]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Recipients
|
||||
class DesignateToMyModuleRecipients < MyModuleDesignatedRecipients
|
||||
private
|
||||
|
||||
def activity_recipients
|
||||
activity = Activity.find(@params[:activity_id])
|
||||
user = User.find_by(id: activity.values.dig('message_items', 'user_target', 'id'))
|
||||
[user]
|
||||
end
|
||||
end
|
||||
end
|
|
@ -4,11 +4,11 @@ class NotificationExtends
|
|||
NOTIFICATIONS_TYPES = {
|
||||
designate_user_to_my_module_activity: {
|
||||
code: 13,
|
||||
recipients_module: :MyModuleDesignatedRecipients
|
||||
recipients_module: :DesignateToMyModuleRecipients
|
||||
},
|
||||
undesignate_user_from_my_module_activity: {
|
||||
code: 14,
|
||||
recipients_module: :MyModuleDesignatedRecipients
|
||||
recipients_module: :DesignateToMyModuleRecipients
|
||||
},
|
||||
my_module_due_date_reminder: {
|
||||
recipients_module: :MyModuleDesignatedRecipients
|
||||
|
@ -84,7 +84,7 @@ class NotificationExtends
|
|||
recipients_module: :RepositoryRowCreator
|
||||
},
|
||||
smart_annotation_added: {
|
||||
recipients_module: :AnnotatedRecipients
|
||||
recipients_module: :DirectRecipient
|
||||
},
|
||||
invite_user_to_team: {
|
||||
code: 92,
|
||||
|
|
Loading…
Reference in a new issue