Updated protocol actions select menu in task [SCI-7820] ()

This commit is contained in:
ajugo 2023-02-07 10:39:49 +01:00 committed by GitHub
parent d66dc98300
commit 9caa5be4c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 20 deletions
app
javascript/vue/protocol
serializers
config/locales

View file

@ -36,22 +36,12 @@
@click="saveProtocol"
:class="{ disabled: !protocol.attributes.urls.save_to_repo_url }"
>
<span class="fas fa-check"></span>
<span class="fas fa-save"></span>
<span>{{
i18n.t("my_modules.protocol.options_dropdown.save_to_repo")
}}</span>
</a>
</li>
<li>
<a data-action="load-from-file"
class="btn-open-file"
:data-import-url="protocol.attributes.urls.import_url"
:class="{ disabled: !protocol.attributes.urls.import_url }">
<span class="fas fa-download"></span>
<span>{{ i18n.t("my_modules.protocol.options_dropdown.import") }}</span>
<input type="file" value="" accept=".eln" data-turbolinks="false">
</a>
</li>
<li>
<a
data-turbolinks="false"
@ -64,6 +54,42 @@
}}</span>
</a>
</li>
<li v-if="protocol.attributes.urls.update_protocol_url">
<a
ref="updateProtocol"
data-action="update-self"
@click="updateProtocol"
>
<span class="fas fa-sync-alt"></span>
<span>{{
i18n.t("my_modules.protocol.options_dropdown.update_protocol")
}}</span>
</a>
</li>
<li v-if="protocol.attributes.urls.unlink_url">
<a
ref="unlinkProtocol"
data-action="unlink"
@click="unlinkProtocol"
>
<span class="fas fa-unlink"></span>
<span>{{
i18n.t("my_modules.protocol.options_dropdown.unlink")
}}</span>
</a>
</li>
<li v-if="protocol.attributes.urls.revert_protocol_url">
<a
ref="revertProtocol"
data-action="revert"
@click="revertProtocol"
>
<span class="fas fa-undo"></span>
<span>{{
i18n.t("my_modules.protocol.options_dropdown.revert_protocol")
}}</span>
</a>
</li>
<li v-if="canDeleteSteps">
<a
data-turbolinks="false"
@ -108,6 +134,7 @@ export default {
initLoadFromRepository();
initCopyToRepository();
initImport();
initLinkUpdate();
},
methods: {
openStepsDeletingModal() {
@ -128,6 +155,21 @@ export default {
$(this.$refs.saveProtocol).trigger("ajax:success", data);
});
},
unlinkProtocol() {
$.get(this.protocol.attributes.urls.unlink_url).success((data) => {
$(this.$refs.unlinkProtocol).trigger("ajax:success", data);
});
},
updateProtocol() {
$.get(this.protocol.attributes.urls.update_protocol_url).success((data) => {
$(this.$refs.updateProtocol).trigger("ajax:success", data);
});
},
revertProtocol() {
$.get(this.protocol.attributes.urls.revert_protocol_url).success((data) => {
$(this.$refs.revertProtocol).trigger("ajax:success", data);
});
},
deleteSteps() {
this.$emit('protocol:delete_steps')
}

View file

@ -49,7 +49,9 @@ class ProtocolSerializer < ActiveModel::Serializer
load_from_repo_url: load_from_repo_url,
save_to_repo_url: save_to_repo_url,
export_url: export_url,
import_url: import_url,
unlink_url: unlink_url,
revert_protocol_url: revert_protocol_url,
update_protocol_url: update_protocol_url,
steps_url: steps_url,
reorder_steps_url: reorder_steps_url,
add_step_url: add_step_url,
@ -79,12 +81,6 @@ class ProtocolSerializer < ActiveModel::Serializer
copy_to_repository_modal_protocol_path(object, format: :json)
end
def import_url
return unless can_manage_protocol_in_module?(object)
load_from_file_protocol_path(object, format: :json)
end
def export_url
return unless can_read_protocol_in_module?(object)
@ -109,6 +105,25 @@ class ProtocolSerializer < ActiveModel::Serializer
protocol_steps_path(protocol_id: object.id)
end
def unlink_url
return unless can_manage_protocol_in_module?(object) && object.linked?
unlink_modal_protocol_path(object, format: :json)
end
def revert_protocol_url
return unless can_read_protocol_in_module?(object) && object.linked? && object.newer_than_parent?
revert_modal_protocol_path(object, format: :json)
end
def update_protocol_url
return unless can_read_protocol_in_module?(object) && object.linked? &&
(object.parent_newer? || object.parent_and_self_newer?)
update_from_parent_modal_protocol_path(object, format: :json)
end
def update_protocol_name_url
if in_repository && can_manage_protocol_in_repository?(object)
name_protocol_path(object)

View file

@ -984,11 +984,14 @@ en:
protocol:
title: "Protocol"
options_dropdown:
title: "Protocol options"
title: "Protocol actions"
load_from_repo: "Load from templates"
import: "Import protocol"
export: "Export protocol"
save_to_repo: "Save to templates"
unlink: "Unlink protocol"
revert_protocol: "Revert protocol"
update_protocol: "New version update"
save_to_repo: "Save as new template"
delete_steps: "Delete all steps"
description:
title: "Edit task %{module} description"