From e3561690f141dc47910eb701544c4b8198c05ddb Mon Sep 17 00:00:00 2001 From: Evren Ozkan Date: Thu, 5 Jan 2017 13:06:17 -0500 Subject: [PATCH] Fix minor bugs with hanging protocols --- .../ohif-hanging-protocols/both/schema.js | 37 ------------------- .../protocolEditor/protocolEditor.js | 21 +++++------ 2 files changed, 9 insertions(+), 49 deletions(-) diff --git a/Packages/ohif-hanging-protocols/both/schema.js b/Packages/ohif-hanging-protocols/both/schema.js index 06c301ab9..9de98cf99 100644 --- a/Packages/ohif-hanging-protocols/both/schema.js +++ b/Packages/ohif-hanging-protocols/both/schema.js @@ -173,10 +173,6 @@ HP.Protocol = class Protocol { /** * Creates a clone of the current Protocol with a new name * - * Note! This method absolutely cannot be renamed 'clone', because - * Minimongo's insert method uses 'clone' internally and this - * somehow causes very bizarre behaviour - * * @param name * @returns {Protocol|*} */ @@ -196,9 +192,6 @@ HP.Protocol = class Protocol { clonedProtocol.name = name; } - // Remove any MongoDB ID the current protocol may have had - delete clonedProtocol._id; - // Unlock the clone clonedProtocol.locked = false; @@ -206,36 +199,6 @@ HP.Protocol = class Protocol { return clonedProtocol; } - /** - * Add a Role to the Set of Roles that have access - * to this Protocol - * - * @param role - */ - addAvailableTo(role) { - // Add the role's MongoDB _id to the availableTo Set - this.availableTo.add(role._id); - - // Update the modifiedDate and User that last - // modified this Protocol - this.protocolWasModified(); - } - - /** - * Add a Role to the Set of Roles that have access - * to this Protocol - * - * @param role - */ - addEditableBy(role) { - // Add the role's MongoDB _id to the editableBy Set - this.editableBy.add(role._id); - - // Update the modifiedDate and User that last - // modified this Protocol - this.protocolWasModified(); - } - /** * Adds a Stage to this Protocol's display set sequence * diff --git a/Packages/ohif-hanging-protocols/client/components/protocolEditor/protocolEditor.js b/Packages/ohif-hanging-protocols/client/components/protocolEditor/protocolEditor.js index 37179125a..e95020a42 100644 --- a/Packages/ohif-hanging-protocols/client/components/protocolEditor/protocolEditor.js +++ b/Packages/ohif-hanging-protocols/client/components/protocolEditor/protocolEditor.js @@ -10,9 +10,11 @@ function updateProtocolSelect() { // to create an array with the protocols that includes // a property labelled 'text', so that Select2 has something // to display - var protocols = HP.ProtocolStore.getProtocol().map(function(protocol) { - protocol.text = protocol.name; - return protocol; + var protocolsSelect2Data = HP.ProtocolStore.getProtocol().map(function(protocol) { + return { + id: protocol.id, + text: protocol.name + }; }); // Select the Protocol select DOM element @@ -24,7 +26,7 @@ function updateProtocolSelect() { // Initialize the select element with Select2 using the // array of protocols protocolSelect.select2({ - data: protocols + data: protocolsSelect2Data }); // Update the ProtocolSelector to display the current active Protocol @@ -72,14 +74,6 @@ Template.protocolEditor.helpers({ // Update the Protocol Select box updateProtocolSelect(); - // Find the protocol in the database - var protocolInDatabase = HP.ProtocolStore.getProtocol(ProtocolEngine.protocol.id); - - // Give the current Protocol an _id property from the Database - if (protocolInDatabase) { - ProtocolEngine.protocol._id = protocolInDatabase._id; - } - // Make sure that the number of referenced priors is correct ProtocolEngine.protocol.updateNumberOfPriorsReferenced(); @@ -303,6 +297,9 @@ Template.protocolEditor.events({ // Update the name with the entered text selectedProtocol.name = value; + // Unlock the protocol + selectedProtocol.locked = false; + // Update the Protocol's modifiedDate and modifiedBy User details selectedProtocol.protocolWasModified();