mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-10 07:05:57 +08:00
Add protocol actions to protocol templates [SCI-11758]
This commit is contained in:
parent
55b0b37239
commit
3b2fd65c0b
5 changed files with 41 additions and 23 deletions
|
@ -294,17 +294,17 @@ class StepsController < ApplicationController
|
|||
step.duplicate(@protocol, current_user, original_protocol: selected_protocol)
|
||||
end
|
||||
|
||||
Activities::CreateActivityService
|
||||
.call(activity_type: :task_steps_loaded_from_template,
|
||||
owner: current_user,
|
||||
subject: @protocol.my_module,
|
||||
team: @protocol.team,
|
||||
project: @protocol.my_module.project,
|
||||
message_items: {
|
||||
protocol: selected_protocol.id,
|
||||
my_module: @protocol.my_module.id,
|
||||
count: steps.count
|
||||
})
|
||||
message_items = {
|
||||
protocol: selected_protocol.id,
|
||||
count: steps.count
|
||||
}
|
||||
|
||||
if @protocol.in_module?
|
||||
message_items[:my_module] = @protocol.my_module.id
|
||||
log_activity(:task_steps_loaded_from_template, @my_module.experiment.project, message_items)
|
||||
else
|
||||
log_activity(:protocol_steps_loaded_from_template, nil, message_items)
|
||||
end
|
||||
|
||||
render json: steps, each_serializer: StepSerializer, user: current_user
|
||||
end
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<ProtocolOptions
|
||||
v-if="protocol.attributes && protocol.attributes.urls"
|
||||
:protocol="protocol"
|
||||
:inRepository="inRepository"
|
||||
@protocol:delete_steps="deleteSteps"
|
||||
@protocol:add_protocol_steps="addSteps"
|
||||
:canDeleteSteps="steps.length > 0 && urls.delete_steps_url !== null"
|
||||
|
@ -129,7 +130,7 @@
|
|||
</div>
|
||||
<div :class="inRepository ? 'protocol-section protocol-steps-section protocol-information' : ''">
|
||||
<div v-if="inRepository" id="protocol-steps" class="protocol-section-header">
|
||||
<div class="protocol-steps-container">
|
||||
<div class="protocol-steps-container w-full flex flex-row items-center justify-between">
|
||||
<a class="protocol-section-caret" role="button" data-toggle="collapse" href="#protocol-steps-container" aria-expanded="false" aria-controls="protocol-steps-container">
|
||||
<i class="sn-icon sn-icon-right"></i>
|
||||
<span id="protocolStepsLabel" class="protocol-section-title" data-e2e="e2e-TX-protocol-templateSteps-title">
|
||||
|
@ -138,6 +139,14 @@
|
|||
</h2>
|
||||
</span>
|
||||
</a>
|
||||
<ProtocolOptions
|
||||
v-if="protocol.attributes && protocol.attributes.urls"
|
||||
:protocol="protocol"
|
||||
:inRepository="inRepository"
|
||||
@protocol:delete_steps="deleteSteps"
|
||||
@protocol:add_protocol_steps="addSteps"
|
||||
:canDeleteSteps="steps.length > 0 && urls.delete_steps_url !== null"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sci-divider my-4" v-if="!inRepository"></div>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
class="dropdown-menu dropdown-menu-right rounded !p-2.5 sn-shadow-menu-sm"
|
||||
aria-labelledby="dropdownProtocolOptions"
|
||||
>
|
||||
<li v-if="protocol.attributes.urls.load_from_repo_url">
|
||||
<li v-if="protocol.attributes.urls.load_from_repo_url && !inRepository">
|
||||
<a class="!px-3 !py-2.5 hover:!bg-sn-super-light-blue !text-sn-blue"
|
||||
ref="loadProtocol"
|
||||
data-action="load-from-repository"
|
||||
|
@ -36,7 +36,7 @@
|
|||
}}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li v-if="!inRepository">
|
||||
<a class="!px-3 !py-2.5 hover:!bg-sn-super-light-blue !text-sn-blue"
|
||||
data-toggle="modal"
|
||||
data-target="#newProtocolModal"
|
||||
|
@ -48,7 +48,7 @@
|
|||
}}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<li v-if="!inRepository">
|
||||
<a class="!px-3 !py-2.5 hover:!bg-sn-super-light-blue !text-sn-blue"
|
||||
data-turbolinks="false"
|
||||
:href="protocol.attributes.urls.export_url"
|
||||
|
@ -59,7 +59,7 @@
|
|||
}}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li v-if="protocol.attributes.urls.update_protocol_url">
|
||||
<li v-if="protocol.attributes.urls.update_protocol_url && !inRepository">
|
||||
<a class="!px-3 !py-2.5 hover:!bg-sn-super-light-blue !text-sn-blue"
|
||||
ref="updateProtocol"
|
||||
data-action="update-self"
|
||||
|
@ -70,7 +70,7 @@
|
|||
}}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li v-if="protocol.attributes.urls.unlink_url">
|
||||
<li v-if="protocol.attributes.urls.unlink_url && !inRepository">
|
||||
<a class="!px-3 !py-2.5 hover:!bg-sn-super-light-blue !text-sn-blue"
|
||||
ref="unlinkProtocol"
|
||||
data-action="unlink"
|
||||
|
@ -81,7 +81,7 @@
|
|||
}}</span>
|
||||
</a>
|
||||
</li>
|
||||
<li v-if="protocol.attributes.urls.revert_protocol_url">
|
||||
<li v-if="protocol.attributes.urls.revert_protocol_url && !inRepository">
|
||||
<a class="!px-3 !py-2.5 hover:!bg-sn-super-light-blue !text-sn-blue"
|
||||
ref="revertProtocol"
|
||||
data-action="revert"
|
||||
|
@ -131,12 +131,18 @@ export default {
|
|||
canDeleteSteps: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
inRepository: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// Legacy global functions from app/assets/javascripts/my_modules/protocols.js
|
||||
initLoadFromRepository();
|
||||
initLinkUpdate();
|
||||
if (!this.inRepository) {
|
||||
initLoadFromRepository();
|
||||
initLinkUpdate();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
openStepsDeletingModal() {
|
||||
|
|
|
@ -557,7 +557,8 @@ class Extends
|
|||
form_block_duplicated: 356,
|
||||
form_duplicated: 357,
|
||||
form_unpublished: 358,
|
||||
task_steps_loaded_from_template: 359
|
||||
task_steps_loaded_from_template: 359,
|
||||
protocol_steps_loaded_from_template: 360
|
||||
}
|
||||
|
||||
ACTIVITY_GROUPS = {
|
||||
|
@ -575,7 +576,7 @@ class Extends
|
|||
protocol_repository: [80, 103, 89, 87, 79, 90, 91, 88, 85, 86, 84, 81, 82,
|
||||
83, 101, 112, 123, 125, 117, 119, 129, 131, 187, 186,
|
||||
190, 191, *204..215, 220, 223, 227, 228, 229, *230..235,
|
||||
*237..240, *253..256, *279..283, 300, 304, 307, 330, *353..355],
|
||||
*237..240, *253..256, *279..283, 300, 304, 307, 330, *353..355, 360],
|
||||
team: [92, 94, 93, 97, 104, 244, 245],
|
||||
label_templates: [*216..219],
|
||||
storage_locations: [*309..315],
|
||||
|
|
|
@ -373,6 +373,7 @@ en:
|
|||
form_block_duplicated_html: "%{user} duplicated form block %{block_name} in form %{form} in Form templates."
|
||||
form_unpublished_html: "%{user} unpublished form %{form}."
|
||||
task_steps_loaded_from_template_html: "%{user} added %{count} steps from template %{protocol} to task %{my_module}."
|
||||
protocol_steps_loaded_from_template_html: "%{user} added %{count} steps from template %{protocol}."
|
||||
activity_name:
|
||||
create_project: "Project created"
|
||||
rename_project: "Project renamed"
|
||||
|
@ -702,7 +703,8 @@ en:
|
|||
form_duplicated: "Form duplicated"
|
||||
form_block_duplicated: "Form block duplicated"
|
||||
form_unpublished: "Form unpublished"
|
||||
task_steps_loadead_from: "Task step loaded from template"
|
||||
task_steps_loaded_from_template: "Task step loaded from template"
|
||||
protocol_steps_loaded_from_template: "Step loaded from template"
|
||||
activity_group:
|
||||
projects: "Projects"
|
||||
task_results: "Task results"
|
||||
|
|
Loading…
Add table
Reference in a new issue