From dd8b3caf656bdd43fef38d5701ac873e061dd69e Mon Sep 17 00:00:00 2001 From: Anton Ignatov Date: Mon, 15 Apr 2019 11:35:30 +0200 Subject: [PATCH] Fix duplicate activtiy issue and fix link to inventory --- .../javascripts/my_modules/protocols.js.erb | 52 ------------------- app/helpers/global_activities_helper.rb | 12 ++++- .../global_activities/_activity.html.erb | 8 ++- .../references/_experiment.html.erb | 2 +- .../references/_my_module.html.erb | 12 ++++- .../references/_project.html.erb | 2 +- .../references/_protocol.html.erb | 4 +- .../references/_report.html.erb | 2 +- .../references/_repository.html.erb | 2 +- .../references/_result.html.erb | 2 +- config/locales/global_activities/en.yml | 2 +- 11 files changed, 36 insertions(+), 64 deletions(-) diff --git a/app/assets/javascripts/my_modules/protocols.js.erb b/app/assets/javascripts/my_modules/protocols.js.erb index 4dd5ea523..551d42e22 100644 --- a/app/assets/javascripts/my_modules/protocols.js.erb +++ b/app/assets/javascripts/my_modules/protocols.js.erb @@ -9,7 +9,6 @@ var selectedRow = null; * Initializes page */ function init() { - bindEditDueDateAjax(); initEditDescription(); initCopyToRepository(); initLinkUpdate(); @@ -60,57 +59,6 @@ function initEditDescription() { }); } -function bindEditDueDateAjax() { - var editDueDateModal = null; - var editDueDateModalBody = null; - var editDueDateModalTitle = null; - var editDueDateModalSubmitBtn = null; - - editDueDateModal = $("#manage-module-due-date-modal"); - editDueDateModalBody = editDueDateModal.find(".modal-body"); - editDueDateModalTitle = editDueDateModal.find("#manage-module-due-date-modal-label"); - editDueDateModalSubmitBtn = editDueDateModal.find("[data-action='submit']"); - - $(".due-date-link") - .on("ajax:success", function(ev, data, status) { - var dueDateLink = $(".task-due-date"); - - // Load contents - editDueDateModalBody.html(data.html); - editDueDateModalTitle.text(data.title); - - // Add listener to form inside modal - editDueDateModalBody.find("form") - .on("ajax:success", function(ev2, data2, status2) { - // Update module's due date - dueDateLink.html(data2.module_header_due_date_label); - - // Close modal - editDueDateModal.modal("hide"); - }) - .on("ajax:error", function(ev2, data2, status2) { - // Display errors if needed - $(this).renderFormErrors("my_module", data2.responseJSON); - }); - - // Open modal - editDueDateModal.modal("show"); - }) - .on("ajax:error", function(ev, data, status) { - // TODO - }); - - editDueDateModalSubmitBtn.on("click", function() { - // Submit the form inside the modal - editDueDateModalBody.find("form").submit(); - }); - - editDueDateModal.on("hidden.bs.modal", function() { - editDueDateModalBody.find("form").off("ajax:success ajax:error"); - editDueDateModalBody.html(""); - }); -} - function initCopyToRepository() { var link = $("[data-action='copy-to-repository']"); var modal = $("#copy-to-repository-modal"); diff --git a/app/helpers/global_activities_helper.rb b/app/helpers/global_activities_helper.rb index 4205620c7..e3cf23049 100644 --- a/app/helpers/global_activities_helper.rb +++ b/app/helpers/global_activities_helper.rb @@ -47,9 +47,11 @@ module GlobalActivitiesHelper path = repository_path(obj) when RepositoryRow return current_value unless obj.repository + path = repository_path(obj.repository) when RepositoryColumn return current_value unless obj.repository + path = repository_path(obj.repository) when Project path = obj.archived? ? projects_path : project_path(obj) @@ -60,7 +62,15 @@ module GlobalActivitiesHelper when MyModule return current_value unless obj.navigable? - path = obj.archived? ? module_archive_experiment_path(obj.experiment) : protocols_my_module_path(obj) + path = if obj.archived? + module_archive_experiment_path(obj.experiment) + else + path = if %w(assign_repository_record unassign_repository_record).include? activity.type_of + repository_my_module_path(obj, activity.values['message_items']['repository']['id']) + else + protocols_my_module_path(obj) + end + end when Protocol if obj.in_repository? path = protocols_path diff --git a/app/views/global_activities/_activity.html.erb b/app/views/global_activities/_activity.html.erb index 7a6132626..bd79ab0c8 100644 --- a/app/views/global_activities/_activity.html.erb +++ b/app/views/global_activities/_activity.html.erb @@ -13,7 +13,13 @@