Add new step text notification [SCI-7559]

This commit is contained in:
Anton 2022-12-13 14:47:53 +01:00
parent ff6471ce14
commit 8e1e95b219
3 changed files with 17 additions and 0 deletions

View file

@ -55,6 +55,17 @@ module StepsActions
)
end
def step_text_annotation(step, step_text, old_text = nil)
smart_annotation_notification(
old_text: old_text,
new_text: step_text.text,
title: t('notifications.step_text_title',
user: current_user.full_name,
step: step.name),
message: annotation_message(step)
)
end
def checklist_name_annotation(step, checklist, old_text = nil)
smart_annotation_notification(
old_text: old_text,

View file

@ -2,6 +2,9 @@
module StepElements
class TextsController < BaseController
include ApplicationHelper
include StepsActions
before_action :load_step_text, only: %i(update destroy duplicate)
def create
@ -18,10 +21,12 @@ module StepElements
end
def update
old_text = @step_text.text
ActiveRecord::Base.transaction do
@step_text.update!(step_text_params)
TinyMceAsset.update_images(@step_text, params[:tiny_mce_images], current_user)
log_step_activity(:text_edited, { text_name: @step_text.name })
step_text_annotation(@step, @step_text, old_text)
end
render json: @step_text, serializer: StepTextSerializer, user: current_user

View file

@ -2932,6 +2932,7 @@ en:
step_comment_annotation_title: "%{user} mentioned you in a comment on step %{step}."
step_description_title: "%{user} mentioned you in a description on step %{step}."
checklist_title: "%{user} mentioned you in a checklist on step %{step}."
step_text_title: "%{user} mentioned you in a text on step %{step}."
step_annotation_message_html: "Project: %{project} | Experiment: %{experiment} | Task: %{my_module} | Step: %{step}"
result_annotation_title: "%{user} mentioned you in result %{result}."
result_comment_annotation_title: "%{user} mentioned you in a comment on result %{result}."