mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-22 23:03:00 +08:00
Add protocol activity group for protocol step sequence assets [SCI-9087] (#6078)
This commit is contained in:
parent
db4aa53f72
commit
c80e99bdbc
3 changed files with 40 additions and 23 deletions
|
@ -19,24 +19,24 @@ class GeneSequenceAssetsController < ApplicationController
|
|||
def edit
|
||||
@file_url = rails_representation_url(@asset.file)
|
||||
@file_name = @asset.render_file_name
|
||||
log_activity(:protocol_sequence_asset_edit_started)
|
||||
log_activity('sequence_asset_edit_started')
|
||||
render :edit, layout: false
|
||||
end
|
||||
|
||||
def create
|
||||
save_asset!
|
||||
log_activity(:protocol_sequence_asset_added)
|
||||
log_activity('sequence_asset_added')
|
||||
head :ok
|
||||
end
|
||||
|
||||
def update
|
||||
save_asset!
|
||||
log_activity(:protocol_sequence_asset_edit_finished)
|
||||
log_activity('sequence_asset_edit_finished')
|
||||
head :ok
|
||||
end
|
||||
|
||||
def destroy
|
||||
log_activity(:protocol_sequence_asset_deleted)
|
||||
log_activity('sequence_asset_deleted')
|
||||
head :ok
|
||||
end
|
||||
|
||||
|
@ -141,25 +141,34 @@ class GeneSequenceAssetsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def log_activity(type_of, message_items = {})
|
||||
def log_activity(type_of, project = nil, message_items = {})
|
||||
return unless @parent.is_a?(Step)
|
||||
|
||||
my_module = @parent.my_module
|
||||
default_items = {
|
||||
protocol: @protocol.id,
|
||||
my_module: my_module&.id,
|
||||
protocol: @parent.protocol.id,
|
||||
step: @parent.id,
|
||||
asset_name: { id: @asset.id, value_for: 'file_name' },
|
||||
step_position: { id: @parent.id, value_for: 'position_plus_one' }
|
||||
}
|
||||
|
||||
if my_module
|
||||
project = my_module.project
|
||||
default_items[:my_module] = my_module.id
|
||||
type_of = "task_#{type_of}".to_sym
|
||||
else
|
||||
type_of = "protocol_#{type_of}".to_sym
|
||||
end
|
||||
|
||||
message_items = default_items.merge(message_items)
|
||||
|
||||
Activities::CreateActivityService
|
||||
.call(activity_type: type_of,
|
||||
owner: current_user,
|
||||
team: @protocol.team,
|
||||
project: my_module&.project,
|
||||
subject: @protocol,
|
||||
message_items: message_items)
|
||||
Activities::CreateActivityService.call(
|
||||
activity_type: type_of,
|
||||
owner: current_user,
|
||||
team: @parent.protocol.team,
|
||||
subject: @parent.protocol,
|
||||
message_items: message_items,
|
||||
project: project
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -449,10 +449,14 @@ class Extends
|
|||
task_link_sharing_enabled: 246,
|
||||
task_link_sharing_disabled: 247,
|
||||
shared_task_message_edited: 248,
|
||||
protocol_sequence_asset_added: 249,
|
||||
protocol_sequence_asset_edit_started: 250,
|
||||
protocol_sequence_asset_edit_finished: 251,
|
||||
protocol_sequence_asset_deleted: 252
|
||||
task_sequence_asset_added: 249,
|
||||
task_sequence_asset_edit_started: 250,
|
||||
task_sequence_asset_edit_finished: 251,
|
||||
task_sequence_asset_deleted: 252,
|
||||
protocol_sequence_asset_added: 253,
|
||||
protocol_sequence_asset_edit_started: 254,
|
||||
protocol_sequence_asset_edit_finished: 255,
|
||||
protocol_sequence_asset_deleted: 256
|
||||
}
|
||||
|
||||
ACTIVITY_GROUPS = {
|
||||
|
@ -469,7 +473,7 @@ class Extends
|
|||
78, 96, 107, 113, 114, *133..136, 180, 181, 182],
|
||||
protocol_repository: [80, 103, 89, 87, 79, 90, 91, 88, 85, 86, 84, 81, 82,
|
||||
83, 101, 112, 123, 125, 117, 119, 129, 131, 170, 173, 179, 187, 186,
|
||||
190, 191, *204..215, 220, 221, 223, 227, 228, 229, *230..235, *237..240],
|
||||
190, 191, *204..215, 220, 221, 223, 227, 228, 229, *230..235, *237..240, *253..256],
|
||||
team: [92, 94, 93, 97, 104, 244, 245],
|
||||
label_templates: [*216..219]
|
||||
}
|
||||
|
|
|
@ -273,10 +273,14 @@ en:
|
|||
task_link_sharing_enabled_html: "%{user} enabled link sharing for task %{my_module}."
|
||||
task_link_sharing_disabled_html: "%{user} disabled link sharing for task %{my_module}."
|
||||
shared_task_message_edited_html: "%{user} edited message for shared task %{my_module}."
|
||||
protocol_sequence_asset_added_html: "%{user} created sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> on task <strong>%{my_module}</strong>."
|
||||
protocol_sequence_asset_edit_started_html: "%{user} edited sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> on task <strong>%{my_module}</strong>: editing started."
|
||||
protocol_sequence_asset_edit_finished_html: "%{user} edited sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> on task <strong>%{my_module}</strong>: editing finished."
|
||||
protocol_sequence_asset_deleted_html: "%{user} deleted sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> on task <strong>%{my_module}</strong>."
|
||||
task_sequence_asset_added_html: "%{user} created sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> on task <strong>%{my_module}</strong>."
|
||||
task_sequence_asset_edit_started_html: "%{user} edited sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> on task <strong>%{my_module}</strong>: editing started."
|
||||
task_sequence_asset_edit_finished_html: "%{user} edited sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> on task <strong>%{my_module}</strong>: editing finished."
|
||||
task_sequence_asset_deleted_html: "%{user} deleted sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> on task <strong>%{my_module}</strong>."
|
||||
protocol_sequence_asset_added_html: "%{user} created sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> in Protocol repository."
|
||||
protocol_sequence_asset_edit_started_html: "%{user} edited sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> in Protocol repository: editing started."
|
||||
protocol_sequence_asset_edit_finished_html: "%{user} edited sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> in Protocol repository: editing finished."
|
||||
protocol_sequence_asset_deleted_html: "%{user} deleted sequence <strong>%{asset_name}</strong> on protocol’s step <strong>%{step_position}</strong> <strong>%{step}</strong> in Protocol repository."
|
||||
activity_name:
|
||||
create_project: "Project created"
|
||||
rename_project: "Project renamed"
|
||||
|
|
Loading…
Reference in a new issue