mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-10 13:59:56 +08:00
Updated protocol actions select menu in task [SCI-7820] (#4939)
This commit is contained in:
parent
d66dc98300
commit
9caa5be4c0
3 changed files with 80 additions and 20 deletions
|
@ -36,22 +36,12 @@
|
||||||
@click="saveProtocol"
|
@click="saveProtocol"
|
||||||
:class="{ disabled: !protocol.attributes.urls.save_to_repo_url }"
|
:class="{ disabled: !protocol.attributes.urls.save_to_repo_url }"
|
||||||
>
|
>
|
||||||
<span class="fas fa-check"></span>
|
<span class="fas fa-save"></span>
|
||||||
<span>{{
|
<span>{{
|
||||||
i18n.t("my_modules.protocol.options_dropdown.save_to_repo")
|
i18n.t("my_modules.protocol.options_dropdown.save_to_repo")
|
||||||
}}</span>
|
}}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</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>
|
<li>
|
||||||
<a
|
<a
|
||||||
data-turbolinks="false"
|
data-turbolinks="false"
|
||||||
|
@ -64,6 +54,42 @@
|
||||||
}}</span>
|
}}</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</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">
|
<li v-if="canDeleteSteps">
|
||||||
<a
|
<a
|
||||||
data-turbolinks="false"
|
data-turbolinks="false"
|
||||||
|
@ -108,6 +134,7 @@ export default {
|
||||||
initLoadFromRepository();
|
initLoadFromRepository();
|
||||||
initCopyToRepository();
|
initCopyToRepository();
|
||||||
initImport();
|
initImport();
|
||||||
|
initLinkUpdate();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
openStepsDeletingModal() {
|
openStepsDeletingModal() {
|
||||||
|
@ -128,6 +155,21 @@ export default {
|
||||||
$(this.$refs.saveProtocol).trigger("ajax:success", data);
|
$(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() {
|
deleteSteps() {
|
||||||
this.$emit('protocol:delete_steps')
|
this.$emit('protocol:delete_steps')
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,9 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
load_from_repo_url: load_from_repo_url,
|
load_from_repo_url: load_from_repo_url,
|
||||||
save_to_repo_url: save_to_repo_url,
|
save_to_repo_url: save_to_repo_url,
|
||||||
export_url: export_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,
|
steps_url: steps_url,
|
||||||
reorder_steps_url: reorder_steps_url,
|
reorder_steps_url: reorder_steps_url,
|
||||||
add_step_url: add_step_url,
|
add_step_url: add_step_url,
|
||||||
|
@ -79,12 +81,6 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
copy_to_repository_modal_protocol_path(object, format: :json)
|
copy_to_repository_modal_protocol_path(object, format: :json)
|
||||||
end
|
end
|
||||||
|
|
||||||
def import_url
|
|
||||||
return unless can_manage_protocol_in_module?(object)
|
|
||||||
|
|
||||||
load_from_file_protocol_path(object, format: :json)
|
|
||||||
end
|
|
||||||
|
|
||||||
def export_url
|
def export_url
|
||||||
return unless can_read_protocol_in_module?(object)
|
return unless can_read_protocol_in_module?(object)
|
||||||
|
|
||||||
|
@ -109,6 +105,25 @@ class ProtocolSerializer < ActiveModel::Serializer
|
||||||
protocol_steps_path(protocol_id: object.id)
|
protocol_steps_path(protocol_id: object.id)
|
||||||
end
|
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
|
def update_protocol_name_url
|
||||||
if in_repository && can_manage_protocol_in_repository?(object)
|
if in_repository && can_manage_protocol_in_repository?(object)
|
||||||
name_protocol_path(object)
|
name_protocol_path(object)
|
||||||
|
|
|
@ -984,11 +984,14 @@ en:
|
||||||
protocol:
|
protocol:
|
||||||
title: "Protocol"
|
title: "Protocol"
|
||||||
options_dropdown:
|
options_dropdown:
|
||||||
title: "Protocol options"
|
title: "Protocol actions"
|
||||||
load_from_repo: "Load from templates"
|
load_from_repo: "Load from templates"
|
||||||
import: "Import protocol"
|
import: "Import protocol"
|
||||||
export: "Export 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"
|
delete_steps: "Delete all steps"
|
||||||
description:
|
description:
|
||||||
title: "Edit task %{module} description"
|
title: "Edit task %{module} description"
|
||||||
|
|
Loading…
Add table
Reference in a new issue