mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-27 18:52:07 +08:00
add notification for previous task has been completed
This commit is contained in:
parent
a2896031ab
commit
ac8b1769be
2 changed files with 30 additions and 0 deletions
|
@ -2,6 +2,8 @@ class MyModulesController < ApplicationController
|
||||||
include SampleActions
|
include SampleActions
|
||||||
include TeamsHelper
|
include TeamsHelper
|
||||||
include InputSanitizeHelper
|
include InputSanitizeHelper
|
||||||
|
include Rails.application.routes.url_helpers
|
||||||
|
include ActionView::Helpers::UrlHelper
|
||||||
|
|
||||||
before_action :load_vars,
|
before_action :load_vars,
|
||||||
only: %I[show update destroy description due_date protocols
|
only: %I[show update destroy description due_date protocols
|
||||||
|
@ -564,6 +566,32 @@ class MyModulesController < ApplicationController
|
||||||
message: message,
|
message: message,
|
||||||
type_of: completed ? :complete_task : :uncomplete_task
|
type_of: completed ? :complete_task : :uncomplete_task
|
||||||
)
|
)
|
||||||
|
start_work_on_next_task_notification
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_work_on_next_task_notification
|
||||||
|
if @my_module.completed?
|
||||||
|
title = t('notifications.start_work_on_next_task',
|
||||||
|
user: current_user.full_name,
|
||||||
|
module: @my_module.name)
|
||||||
|
message = t('notifications.start_work_on_next_task_message',
|
||||||
|
project: link_to(@project.name, project_url(@project)),
|
||||||
|
experiment: link_to(@experiment.name,
|
||||||
|
canvas_experiment_url(@experiment)),
|
||||||
|
my_module: link_to(@my_module.name,
|
||||||
|
protocols_my_module_url(@my_module)))
|
||||||
|
notification = Notification.create(
|
||||||
|
type_of: :recent_changes,
|
||||||
|
title: sanitize_input(title, %w(strong a)),
|
||||||
|
message: sanitize_input(message, %w(strong a)),
|
||||||
|
generator_user_id: current_user.id
|
||||||
|
)
|
||||||
|
# create notification for all users on the next modules in the workflow
|
||||||
|
@my_module.my_modules.map(&:users).flatten.uniq.each do |target_user|
|
||||||
|
next if target_user == current_user
|
||||||
|
UserNotification.create(notification: notification, user: target_user)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_vars
|
def load_vars
|
||||||
|
|
|
@ -1771,6 +1771,8 @@ en:
|
||||||
assign_user_to_team: "<i>%{assigned_user}</i> was added as %{role} to team <strong>%{team}</strong> by <i>%{assigned_by_user}</i>."
|
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>."
|
unassign_user_from_team: "<i>%{unassigned_user}</i> was removed from team <strong>%{team}</strong> by <i>%{unassigned_by_user}</i>."
|
||||||
task_completed: "%{user} completed task %{module}. %{date} | Project: %{project} | Experiment: %{experiment}"
|
task_completed: "%{user} completed task %{module}. %{date} | Project: %{project} | Experiment: %{experiment}"
|
||||||
|
start_work_on_next_task: "<i>%{user}</i> has completed the task <strong>%{module}</strong>. You can now start working on the next task in the workflow."
|
||||||
|
start_work_on_next_task_message: "Project: %{project} | Experiment: %{experiment} | Task: %{my_module}"
|
||||||
|
|
||||||
assets:
|
assets:
|
||||||
head_title:
|
head_title:
|
||||||
|
|
Loading…
Reference in a new issue