mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-05 20:54:27 +08:00
add notification for my_module/project comments
This commit is contained in:
parent
b398bb7516
commit
046b608018
4 changed files with 49 additions and 3 deletions
|
@ -2,6 +2,7 @@ class MyModuleCommentsController < ApplicationController
|
|||
include ActionView::Helpers::TextHelper
|
||||
include InputSanitizeHelper
|
||||
include ApplicationHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
before_action :load_vars
|
||||
before_action :check_view_permissions, only: :index
|
||||
|
@ -51,6 +52,8 @@ class MyModuleCommentsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
if @comment.save
|
||||
|
||||
my_module_comment_annotation_notification
|
||||
# Generate activity
|
||||
Activity.create(
|
||||
type_of: :add_comment_to_module,
|
||||
|
@ -102,10 +105,13 @@ class MyModuleCommentsController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
old_text = @comment.message
|
||||
@comment.message = comment_params[:message]
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
if @comment.save
|
||||
|
||||
my_module_comment_annotation_notification(old_text)
|
||||
# Generate activity
|
||||
Activity.create(
|
||||
type_of: :edit_module_comment,
|
||||
|
@ -190,4 +196,23 @@ class MyModuleCommentsController < ApplicationController
|
|||
def comment_params
|
||||
params.require(:comment).permit(:message)
|
||||
end
|
||||
|
||||
def my_module_comment_annotation_notification(old_text = nil)
|
||||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: @comment.message,
|
||||
title: t('notifications.my_module_comment_annotation_title',
|
||||
my_module: @my_module.name,
|
||||
user: current_user.full_name),
|
||||
message: t('notifications.my_module_annotation_message_html',
|
||||
project: link_to(@my_module.experiment.project.name,
|
||||
project_url(@my_module
|
||||
.experiment
|
||||
.project)),
|
||||
my_module: link_to(@my_module.name,
|
||||
protocols_my_module_url(
|
||||
@my_module
|
||||
)))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,6 +2,7 @@ class ProjectCommentsController < ApplicationController
|
|||
include ActionView::Helpers::TextHelper
|
||||
include InputSanitizeHelper
|
||||
include ApplicationHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
before_action :load_vars
|
||||
before_action :check_view_permissions, only: :index
|
||||
|
@ -50,6 +51,7 @@ class ProjectCommentsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
if @comment.save
|
||||
project_comment_annotation_notification
|
||||
# Generate activity
|
||||
Activity.create(
|
||||
type_of: :add_comment_to_project,
|
||||
|
@ -99,10 +101,13 @@ class ProjectCommentsController < ApplicationController
|
|||
end
|
||||
|
||||
def update
|
||||
old_text = @comment.message
|
||||
@comment.message = comment_params[:message]
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
if @comment.save
|
||||
|
||||
project_comment_annotation_notification(old_text)
|
||||
# Generate activity
|
||||
Activity.create(
|
||||
type_of: :edit_project_comment,
|
||||
|
@ -185,4 +190,16 @@ class ProjectCommentsController < ApplicationController
|
|||
def comment_params
|
||||
params.require(:comment).permit(:message)
|
||||
end
|
||||
|
||||
def project_comment_annotation_notification(old_text = nil)
|
||||
smart_annotation_notification(
|
||||
old_text: old_text,
|
||||
new_text: @comment.message,
|
||||
title: t('notifications.project_comment_annotation_title',
|
||||
project: @project.name,
|
||||
user: current_user.full_name),
|
||||
message: t('notifications.project_annotation_message_html',
|
||||
project: link_to(@project.name, project_url(@project)))
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -209,7 +209,7 @@ class StepCommentsController < ApplicationController
|
|||
smart_annotation_notification(
|
||||
old_text: (old_text if old_text),
|
||||
new_text: comment_params[:message],
|
||||
title: t('notifications.comment_annotation_title',
|
||||
title: t('notifications.step_comment_annotation_title',
|
||||
step: @step.name,
|
||||
user: current_user.full_name),
|
||||
message: t('notifications.step_annotation_message_html',
|
||||
|
|
|
@ -1516,9 +1516,13 @@ en:
|
|||
recent_changes: "Recent changes"
|
||||
system_message: "sciNote system message"
|
||||
deliver: 'Exportable content'
|
||||
comment_annotation_title: "%{user} mentioned you %{step} step comment."
|
||||
project_comment_annotation_title: "%{user} mentioned you in %{project} project comment."
|
||||
project_annotation_message_html: "Project: %{project}"
|
||||
my_module_comment_annotation_title: "%{user} mentioned you in %{my_module} task comment."
|
||||
my_module_annotation_message_html: "Project: %{project} | Task: %{my_module}"
|
||||
step_comment_annotation_title: "%{user} mentioned you in %{step} step comment."
|
||||
step_description_title: "%{user} mentioned you %{step} step description."
|
||||
checklist_title: "%{user} mentioned you %{step} step checklist."
|
||||
checklist_title: "%{user} mentioned you in %{step} step checklist."
|
||||
step_annotation_message_html: "Project: %{project} | Task: %{my_module} | Step: %{step}"
|
||||
result_annotation_title: "%{user} mentioned you in result %{result}."
|
||||
result_comment_annotation_title: "%{user} mentioned you in result %{result} comment."
|
||||
|
|
Loading…
Add table
Reference in a new issue