From 548cdf945778dfd4f7975e00282b8d7466a0cef7 Mon Sep 17 00:00:00 2001 From: sboursen-scinote Date: Fri, 24 Feb 2023 16:23:23 +0100 Subject: [PATCH] Open protocol versions modal when actions-toolbar button is clicked [sb_SCI-7991] --- app/assets/javascripts/protocols/index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/protocols/index.js b/app/assets/javascripts/protocols/index.js index a4b36fb79..595e97353 100644 --- a/app/assets/javascripts/protocols/index.js +++ b/app/assets/javascripts/protocols/index.js @@ -23,7 +23,6 @@ var ProtocolsIndex = (function() { var archivedOnToFilter; var protocolsViewSearch; - /** * Initializes page */ @@ -419,6 +418,23 @@ var ProtocolsIndex = (function() { e.stopPropagation(); e.preventDefault(); }); + + $(protocolsContainer).on('click', '#protocolVersions', function(e) { + const url = `protocols/${rowsSelected[0]}/versions_modal`; + $.get(url, function(data) { + $(protocolsContainer).append($.parseHTML(data.html)); + $(versionsModal).modal('show'); + inlineEditing.init(); + $(versionsModal).find('[data-toggle="tooltip"]').tooltip(); + + // Remove modal when it gets closed + $(versionsModal).on('hidden.bs.modal', function() { + $(versionsModal).remove(); + }); + }); + e.stopPropagation(); + e.preventDefault(); + }); } function initdeleteDraftModal() {