mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-08 21:06:24 +08:00
Update export action in protocol repository [SCI-7901]
This commit is contained in:
parent
cb332f163f
commit
a4e622b903
3 changed files with 25 additions and 5 deletions
|
@ -420,13 +420,13 @@ var ProtocolsIndex = (function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function initArchiveMyModules() {
|
function initArchiveProtocols() {
|
||||||
$('.protocols-index').on('click', '#archiveProtocol', function(e) {
|
$('.protocols-index').on('click', '#archiveProtocol', function(e) {
|
||||||
archiveMyModules(e.currentTarget.dataset.url, rowsSelected);
|
archiveProtocols(e.currentTarget.dataset.url, rowsSelected);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function archiveMyModules(url, ids) {
|
function archiveProtocols(url, ids) {
|
||||||
$.post(url, { protocol_ids: ids }, (data) => {
|
$.post(url, { protocol_ids: ids }, (data) => {
|
||||||
HelperModule.flashAlertMsg(data.message, 'success');
|
HelperModule.flashAlertMsg(data.message, 'success');
|
||||||
protocolsDatatable.ajax.reload();
|
protocolsDatatable.ajax.reload();
|
||||||
|
@ -435,6 +435,24 @@ var ProtocolsIndex = (function() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initExportProtocols() {
|
||||||
|
$('.protocols-index').on('click', '#exportProtocol', function(e) {
|
||||||
|
exportProtocols(e.currentTarget.dataset.url, rowsSelected);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function exportProtocols(url, ids) {
|
||||||
|
if (ids.length > 0) {
|
||||||
|
let params = '?protocol_ids[]=' + ids[0];
|
||||||
|
for (let i = 1; i < ids.length; i += 1) {
|
||||||
|
params += '&protocol_ids[]=' + ids[i];
|
||||||
|
}
|
||||||
|
params = encodeURI(params);
|
||||||
|
window.location.href = url + params;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function initLinkedChildrenModal() {
|
function initLinkedChildrenModal() {
|
||||||
// Only do this if the repository is public/private
|
// Only do this if the repository is public/private
|
||||||
if (repositoryType !== 'archive') {
|
if (repositoryType !== 'archive') {
|
||||||
|
@ -951,7 +969,8 @@ var ProtocolsIndex = (function() {
|
||||||
|
|
||||||
init();
|
init();
|
||||||
initManageAccessButton();
|
initManageAccessButton();
|
||||||
initArchiveMyModules();
|
initArchiveProtocols();
|
||||||
|
initExportProtocols();
|
||||||
initdeleteDraftModal();
|
initdeleteDraftModal();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -803,6 +803,7 @@ class ProtocolsController < ApplicationController
|
||||||
|
|
||||||
# Create folder and xml file for each protocol and populate it
|
# Create folder and xml file for each protocol and populate it
|
||||||
@protocols.each do |protocol|
|
@protocols.each do |protocol|
|
||||||
|
protocol = protocol.published_versions.order(version_number: :desc).first || protocol
|
||||||
protocol_dir = get_guid(protocol.id).to_s
|
protocol_dir = get_guid(protocol.id).to_s
|
||||||
ostream.put_next_entry("#{protocol_dir}/eln.xml")
|
ostream.put_next_entry("#{protocol_dir}/eln.xml")
|
||||||
ostream.print(generate_protocol_xml(protocol))
|
ostream.print(generate_protocol_xml(protocol))
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<i class="fas fa-copy"></i>
|
<i class="fas fa-copy"></i>
|
||||||
<span class="button-text"><%= t("protocols.index.action_toolbar.duplicate") %></span>
|
<span class="button-text"><%= t("protocols.index.action_toolbar.duplicate") %></span>
|
||||||
</button>
|
</button>
|
||||||
<button id="moveTask" class="btn btn-light multiple-object-action hidden only-active">
|
<button id="exportProtocol" class="btn btn-light single-object-action hidden only-active" data-url="<%= export_protocols_path %>">
|
||||||
<i class="fas fa-download"></i>
|
<i class="fas fa-download"></i>
|
||||||
<span class="button-text"><%= t("protocols.index.action_toolbar.export") %></span>
|
<span class="button-text"><%= t("protocols.index.action_toolbar.export") %></span>
|
||||||
</button>
|
</button>
|
||||||
|
|
Loading…
Add table
Reference in a new issue