diff --git a/app/controllers/concerns/steps_actions.rb b/app/controllers/concerns/steps_actions.rb index a8de5ca0b..ea260e2dd 100644 --- a/app/controllers/concerns/steps_actions.rb +++ b/app/controllers/concerns/steps_actions.rb @@ -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, diff --git a/app/controllers/step_elements/texts_controller.rb b/app/controllers/step_elements/texts_controller.rb index b33bad5b2..06ebe2293 100644 --- a/app/controllers/step_elements/texts_controller.rb +++ b/app/controllers/step_elements/texts_controller.rb @@ -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 diff --git a/config/locales/en.yml b/config/locales/en.yml index ea90f2033..db5e7df7b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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}."