Fix minor bugs with hanging protocols

This commit is contained in:
Evren Ozkan 2017-01-05 13:06:17 -05:00
parent 3f8350a79b
commit e3561690f1
2 changed files with 9 additions and 49 deletions

View File

@ -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
*

View File

@ -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();