From 5e647f62d5db92065b7334e3e676e9a1d6d33724 Mon Sep 17 00:00:00 2001 From: zmagod Date: Tue, 16 Aug 2016 09:34:04 +0200 Subject: [PATCH] changed import label [fixes SCI-317] --- .../protocols/import_export/import.js.erb | 20 +++++++++++++++++-- config/locales/en.yml | 3 ++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/protocols/import_export/import.js.erb b/app/assets/javascripts/protocols/import_export/import.js.erb index a2d5b9c11..81eb110bd 100644 --- a/app/assets/javascripts/protocols/import_export/import.js.erb +++ b/app/assets/javascripts/protocols/import_export/import.js.erb @@ -331,12 +331,23 @@ function importProtocolFromFile( function importCurrentProtocol() { // Check for confirmation first - if (importIntoProtocol && !confirm(I18n.t("protocols.import_export.import_modal.import_into_protocol_confirm"))) { + var path = new RegExp("modules"); + var check_linked = $("[data-role='protocol-status-bar']") + .text(); + if( path.test( window.location.href ) && check_linked === '(unlinked)' ){ + console.log("linked"); + confirm_message = I18n.t("protocols.import_export.import_modal.import_to_linked_task"); + } else { + console.log("unlinked"); + confirm_message = I18n.t("protocols.import_export.import_modal.import_into_protocol_confirm"); + } + + if (importIntoProtocol && !confirm(confirm_message)) { importModal.modal("hide"); } else { - var path = new RegExp("modules"); if( path.test( window.location.href ) ){ + animateSpinner(); importSingleProtocol(currentProtocol, false, function(data) { importModal.find("[data-role='preview-container']").html(""); afterImportCallback([data]); @@ -504,6 +515,11 @@ function importProtocolFromFile( }, error: function(ev) { resultCallback(ev.responseJSON); + + var path = new RegExp("modules"); + if( path.test( window.location.href ) ){ + animateSpinner(null, false); + } } }); } diff --git a/config/locales/en.yml b/config/locales/en.yml index e2b4abccf..2b193c401 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1135,7 +1135,8 @@ en: title_import: "Import protocol/s" title_import_into_protocol: "Load protocol from file" import_into_protocol_message: "This will overwrite the current protocol!" - import_into_protocol_confirm: "Are you sure you wish to load protocol from repository? This action will overwrite the current protocol." + import_into_protocol_confirm: "Are you sure you wish to load protocol? This action will overwrite the current protocol." + import_to_linked_task: "Are you sure you wish to load protocol from repository? This action will overwrite the current protocol in the task and un-link it from repository. The current protocol will remain unchanged in repository." name_label: "Protocol name" authors_label: "Authors" description_label: "Description"