Merging hanging-protocol changes from master to nucleus-parity branch

This commit is contained in:
Emanuel F. Oliveira 2017-01-25 19:36:41 -02:00
parent acb64c4246
commit ed66a38654
6 changed files with 199 additions and 192 deletions

View File

@ -107,7 +107,7 @@ Template.protocolEditor.helpers({
} }
// Retrieve the Stage Model for the current Protocol's active Stage // Retrieve the Stage Model for the current Protocol's active Stage
const stage = ProtocolEngine.getCurrentStageModel(); var stage = ProtocolEngine.getCurrentStageModel();
if (!stage) { if (!stage) {
return; return;
} }
@ -123,14 +123,14 @@ Template.protocolEditor.helpers({
// by removing or adding Viewports to the stage // by removing or adding Viewports to the stage
// //
// First, calculate the difference, if any exists // First, calculate the difference, if any exists
const difference = stage.viewportStructure.getNumViewports() - stage.viewports.length; var difference = stage.viewportStructure.getNumViewports() - stage.viewports.length;
if (difference < 0) { if (difference < 0) {
// Make the viewport difference into a positive value // Make the viewport difference into a positive value
const absDifference = Math.abs(difference); var absDifference = Math.abs(difference);
// If there are more Viewports defined than necessary, remove the extraneous Viewports // If there are more Viewports defined than necessary, remove the extraneous Viewports
const position = stage.viewports.length - absDifference; var position = stage.viewports.length - absDifference;
// Splice extra viewports from the Stage's viewports array // Splice extra viewports from the Stage's viewports array
stage.viewports.splice(position, absDifference); stage.viewports.splice(position, absDifference);
@ -139,9 +139,9 @@ Template.protocolEditor.helpers({
// required amount // required amount
// Count up until the difference in number of Viewports // Count up until the difference in number of Viewports
for (let i = 0; i < difference; i++) { for (var i = 0; i < difference; i++) {
// Instantiate a new Viewport Model // Instantiate a new Viewport Model
const viewport = new HP.Viewport(); var viewport = new HP.Viewport();
// Add new Viewports to the Stage's viewports array // Add new Viewports to the Stage's viewports array
stage.viewports.push(viewport); stage.viewports.push(viewport);
@ -163,7 +163,7 @@ Template.protocolEditor.events({
*/ */
'click #newProtocol'() { 'click #newProtocol'() {
// Clone the default Protocol // Clone the default Protocol
const protocol = HP.defaultProtocol.createClone(); var protocol = HP.defaultProtocol.createClone();
// Change the Protocol name to state that it is New, and give it a timestamp // Change the Protocol name to state that it is New, and give it a timestamp
protocol.name = 'New (created ' + moment().format('h:mm:ss a') + ')'; protocol.name = 'New (created ' + moment().format('h:mm:ss a') + ')';
@ -184,19 +184,19 @@ Template.protocolEditor.events({
* Rename the current Protocol * Rename the current Protocol
*/ */
'click #renameProtocol'() { 'click #renameProtocol'() {
const selectedProtocol = this; var selectedProtocol = this;
if (selectedProtocol.locked) { if (selectedProtocol.locked) {
return; return;
} }
// Define some details for the text entry dialog // Define some details for the text entry dialog
const title = 'Rename Protocol'; var title = 'Rename Protocol';
const instructions = 'Enter a new name'; var instructions = 'Enter a new name';
const currentValue = selectedProtocol.name; var currentValue = selectedProtocol.name;
// Open the text entry dialog with the details above // Open the text entry dialog with the details above
// and fire the callback function when finished. // and fire the callback function when finished.
openTextEntryDialog(title, instructions, currentValue, value => { openTextEntryDialog(title, instructions, currentValue, function(value) {
// Update the name with the entered text // Update the name with the entered text
selectedProtocol.name = value; selectedProtocol.name = value;
@ -220,17 +220,17 @@ Template.protocolEditor.events({
* *
* @param event The Change event for the input * @param event The Change event for the input
*/ */
'change .btn-file :file'(event) { 'change .btn-file :file': function(event) {
// http://www.abeautifulsite.net/whipping-file-inputs-into-shape-with-bootstrap-3/ // http://www.abeautifulsite.net/whipping-file-inputs-into-shape-with-bootstrap-3/
// Find the Input in the DOM // Find the Input in the DOM
const input = $(event.currentTarget); var input = $(event.currentTarget);
// Get the number of selected files // Get the number of selected files
const numFiles = input.get(0).files ? input.get(0).files.length : 1; var numFiles = input.get(0).files ? input.get(0).files.length : 1;
// Get the label of the file // Get the label of the file
const label = input.val().replace(/\\/g, '/').replace(/.*\//, ''); var label = input.val().replace(/\\/g, '/').replace(/.*\//, '');
// Trigger our custom event with the number of files and label // Trigger our custom event with the number of files and label
input.trigger('fileselect', [numFiles, label]); input.trigger('fileselect', [numFiles, label]);
@ -240,15 +240,15 @@ Template.protocolEditor.events({
* *
* @param event The custom fileselect event * @param event The custom fileselect event
*/ */
'fileselect .btn-file :file'(event) { 'fileselect .btn-file :file': function(event) {
// Retreieve the FileList // Retreieve the FileList
const files = event.target.files; var files = event.target.files;
// Create an HTML5 File Reader // Create an HTML5 File Reader
const reader = new FileReader(); var reader = new FileReader();
reader.onload = () => { reader.onload = () => {
const protocolToImport = JSON.parse(reader.result); var protocolToImport = JSON.parse(reader.result);
// Insert the protocol // Insert the protocol
HP.ProtocolStore.addProtocol(protocolToImport); HP.ProtocolStore.addProtocol(protocolToImport);
@ -266,14 +266,12 @@ Template.protocolEditor.events({
* *
* @param event The select2:select event * @param event The select2:select event
*/ */
'select2:select #protocolSelect'(event) { 'select2:select #protocolSelect': function(event) {
// Retrieve the protocolId // Retrieve the protocolId
const protocolId = event.params.data.id; var protocolId = event.params.data.id;
// Retrieve the Protocol from the HangingProtocols Collection // Retrieve the protocol from the protocol store
const selectedProtocol = HangingProtocols.findOne({ var selectedProtocol = HP.ProtocolStore.getProtocol(protocolId);
id: protocolId
});
// If it doesn't exist, stop here // If it doesn't exist, stop here
if (!selectedProtocol) { if (!selectedProtocol) {
@ -291,85 +289,92 @@ Template.protocolEditor.events({
$(this).addClass('active').siblings().removeClass('active'); $(this).addClass('active').siblings().removeClass('active');
}, },
/** /**
* Update the HangingProtocols Collection with the latest changes to the current Protocol * Update the protocol with the latest changes to the current Protocol
*/ */
'click #saveProtocol'() { 'click #saveProtocol'() {
const selectedProtocol = this; var selectedProtocol = this;
if (selectedProtocol.locked) { if (selectedProtocol.locked) {
return; return;
} }
// Store the ID for the update call
const id = selectedProtocol._id;
// Remove the MongoDB _id property so that we can
// simplify the $set value
delete selectedProtocol._id;
// Update the Protocol's modifiedDate and modifiedBy User details // Update the Protocol's modifiedDate and modifiedBy User details
selectedProtocol.protocolWasModified(); selectedProtocol.protocolWasModified();
// Update the current Protocol in the database with the latest changes // Update the current Protocol in the database with the latest changes
HangingProtocols.update(id, { HP.ProtocolStore.updateProtocol(selectedProtocol.id, selectedProtocol);
$set: selectedProtocol
});
}, },
/** /**
* Save the current Protocol as a new document in the HangingProtocols Collection * Save the current Protocol as a new document
*/ */
'click #saveAsProtocol'() { 'click #saveAsProtocol'() {
const selectedProtocol = this; var selectedProtocol = this;
// Clone the selected Protocol
var protocol = selectedProtocol.createClone();
// Define some details for the text entry dialog // Define some details for the text entry dialog
const title = 'Save Protocol As'; var title = 'Save Protocol As';
const instructions = 'Enter a new name'; var instructions = 'Enter a new name';
const currentValue = selectedProtocol.name; var currentValue = protocol.name;
// Open the text entry dialog with the details above // Open the text entry dialog with the details above
// and fire the callback function when finished. // and fire the callback function when finished.
openTextEntryDialog(title, instructions, currentValue, value => { openTextEntryDialog(title, instructions, currentValue, function(value) {
// Erase the MongoDB _id
delete selectedProtocol._id;
// Create a new ID for the protocol // Create a new ID for the protocol
selectedProtocol.id = Random.id(); protocol.id = Random.id();
// Update the name with the entered text // Update the name with the entered text
selectedProtocol.name = value; protocol.name = value;
// Unlock the protocol
protocol.locked = false;
// Update the Protocol's modifiedDate and modifiedBy User details // Update the Protocol's modifiedDate and modifiedBy User details
selectedProtocol.protocolWasModified(); protocol.protocolWasModified();
// Insert the new Protocol // Insert the new Protocol
HangingProtocols.insert(selectedProtocol); HP.ProtocolStore.addProtocol(protocol);
// Activate the new Protocol using the ProtocolEngine
ProtocolEngine.setHangingProtocol(protocol);
// Update the protocol selector to display the new Protocols
updateProtocolSelect();
}); });
}, },
/** /**
* Export the currently selected Protocol as a JSON file * Export the currently selected Protocol as a JSON file
*/ */
'click #exportJSON'() { 'click #exportJSON'() {
// Tell the User's Browser to download the JSON file by routing a hidden iframe to our var selectedProtocol = this;
// protocol-export Route. This prevents the tab from changing its current content.
const selectedProtocol = this; var protocolJSON = JSON.stringify(selectedProtocol, null, 2),
document.getElementById('download_iframe').src = '/protocol-export/' + selectedProtocol.id; currentDate = new Date(),
filename = selectedProtocol.name + '-' + (currentDate.getTime().toString()) + '.json',
protocolBlob = new Blob([protocolJSON], { type: 'application/json' });
var downloadElement = document.getElementById('downloadElement');
downloadElement.href = URL.createObjectURL(protocolBlob);
downloadElement.download = filename;
downloadElement.click();
}, },
/** /**
* Delete the currently selected Protocol * Delete the currently selected Protocol
*/ */
'click #deleteProtocol'() { 'click #deleteProtocol'() {
const selectedProtocol = this; var selectedProtocol = this;
if (selectedProtocol.locked) { if (selectedProtocol.locked) {
return; return;
} }
const options = { var options = {
title: 'Delete Protocol', title: 'Delete Protocol',
text: 'Are you sure you would like to remove this Protocol? This cannot be reversed.' text: 'Are you sure you would like to remove this Protocol? This cannot be reversed.'
}; };
OHIF.viewerbase.showConfirmDialog(() => { OHIF.viewerbase.showConfirmDialog(() => {
// Send a call to remove the Protocol from the HangingProtocols Collection on the server // Remove the Protocol
Meteor.call('removeHangingProtocol', selectedProtocol._id); HP.ProtocolStore.removeProtocol(selectedProtocol.id);
// Reset the ProtocolEngine to the next best match // Reset the ProtocolEngine to the next best match
ProtocolEngine.reset(); ProtocolEngine.reset();

View File

@ -17,7 +17,7 @@ const keys = {
* *
* @param dialog The DOM element of the dialog to close * @param dialog The DOM element of the dialog to close
*/ */
const closeHandler = dialog => { function closeHandler(dialog) {
// Hide the lesion dialog // Hide the lesion dialog
$(dialog).css('display', 'none'); $(dialog).css('display', 'none');
@ -26,7 +26,7 @@ const closeHandler = dialog => {
// Restore the focus to the active viewport // Restore the focus to the active viewport
Viewerbase.setFocusToActiveViewport(); Viewerbase.setFocusToActiveViewport();
}; }
/** /**
* Displays and updates the UI of the Rule Entry Dialog given a new set of * Displays and updates the UI of the Rule Entry Dialog given a new set of
@ -39,10 +39,10 @@ const closeHandler = dialog => {
*/ */
openRuleEntryDialog = function(attributes, level, rule) { openRuleEntryDialog = function(attributes, level, rule) {
// Get the lesion location dialog // Get the lesion location dialog
const dialog = $('.ruleEntryDialog'); var dialog = $('.ruleEntryDialog');
// Clear any input that is still on the page // Clear any input that is still on the page
const currentValueInput = dialog.find('input.currentValue'); var currentValueInput = dialog.find('input.currentValue');
currentValueInput.val(''); currentValueInput.val('');
// Store the Dialog DOM data, rule level and rule in the template data // Store the Dialog DOM data, rule level and rule in the template data
@ -51,7 +51,7 @@ openRuleEntryDialog = function(attributes, level, rule) {
Template.ruleEntryDialog.rule = rule; Template.ruleEntryDialog.rule = rule;
// Initialize the Select2 search box for the attribute list // Initialize the Select2 search box for the attribute list
const attributeSelect = dialog.find('.attributes'); var attributeSelect = dialog.find('.attributes');
attributeSelect.html('').select2({ attributeSelect.html('').select2({
data: attributes, data: attributes,
placeholder: 'Select an attribute', placeholder: 'Select an attribute',
@ -70,15 +70,15 @@ openRuleEntryDialog = function(attributes, level, rule) {
// If a rule has been provided, use its constraint to find the relevant Comparator // If a rule has been provided, use its constraint to find the relevant Comparator
if (rule && rule.constraint) { if (rule && rule.constraint) {
const validator = Object.keys(rule.constraint)[0]; var validator = Object.keys(rule.constraint)[0];
const validatorOption = Object.keys(rule.constraint[validator])[0]; var validatorOption = Object.keys(rule.constraint[validator])[0];
const comparator = Comparators.findOne({ var comparator = Comparators.findOne({
validator: validator, validator: validator,
validatorOption: validatorOption validatorOption: validatorOption
}); });
// Set the current value input based on the rule constraint // Set the current value input based on the rule constraint
const currentValue = rule.constraint[validator][validatorOption]; var currentValue = rule.constraint[validator][validatorOption];
currentValueInput.val(currentValue); currentValueInput.val(currentValue);
} }
@ -93,10 +93,10 @@ openRuleEntryDialog = function(attributes, level, rule) {
dialog.css('display', 'block'); dialog.css('display', 'block');
// Show the backdrop // Show the backdrop
Blaze.render(Template.removableBackdrop, document.body); UI.render(Template.removableBackdrop, document.body);
// Make sure the context menu is closed when the user clicks away // Make sure the context menu is closed when the user clicks away
$('.removableBackdrop').one('mousedown touchstart', () => { $('.removableBackdrop').one('mousedown touchstart', function() {
closeHandler(dialog); closeHandler(dialog);
}); });
}; };
@ -106,23 +106,23 @@ openRuleEntryDialog = function(attributes, level, rule) {
*/ */
function getActiveViewportImageId() { function getActiveViewportImageId() {
// Retrieve the active viewport index from the Session // Retrieve the active viewport index from the Session
const activeViewport = Session.get('activeViewport'); var activeViewport = Session.get('activeViewport');
if (activeViewport === undefined) { if (activeViewport === undefined) {
return; return;
} }
// Obtain the list of all Viewports on the page // Obtain the list of all Viewports on the page
const viewports = $('.imageViewerViewport'); var viewports = $('.imageViewerViewport');
// Retrieve the active viewport element // Retrieve the active viewport element
const element = viewports.get(activeViewport); var element = viewports.get(activeViewport);
if (!element) { if (!element) {
return; return;
} }
// Obtain the enabled element from Cornerstone // Obtain the enabled element from Cornerstone
try { try {
const enabledElement = cornerstone.getEnabledElement(element); var enabledElement = cornerstone.getEnabledElement(element);
if (!enabledElement) { if (!enabledElement) {
return; return;
} }
@ -143,6 +143,10 @@ function getAbstractPriorValue(imageId) {
sort: [ ['studyDate', 'desc'] ] sort: [ ['studyDate', 'desc'] ]
}); });
if (!currentStudy) {
return;
}
const priorStudy = cornerstoneTools.metaData.get('study', imageId); const priorStudy = cornerstoneTools.metaData.get('study', imageId);
if (!priorStudy) { if (!priorStudy) {
return; return;
@ -180,7 +184,7 @@ function getAbstractPriorValue(imageId) {
*/ */
function getCurrentAttributeValue(attribute, level) { function getCurrentAttributeValue(attribute, level) {
// Retrieve the active viewport's imageId. If none exists, stop here // Retrieve the active viewport's imageId. If none exists, stop here
const imageId = getActiveViewportImageId(); var imageId = getActiveViewportImageId();
if (!imageId) { if (!imageId) {
return; return;
} }
@ -197,7 +201,7 @@ function getCurrentAttributeValue(attribute, level) {
// Retrieve the metadata values for the specified level from // Retrieve the metadata values for the specified level from
// the Cornerstone Tools metaData provider // the Cornerstone Tools metaData provider
const metadata = cornerstoneTools.metaData.get(level, imageId); var metadata = cornerstoneTools.metaData.get(level, imageId);
if (metadata[attribute] === undefined) { if (metadata[attribute] === undefined) {
return HP.attributeDefaults[attribute]; return HP.attributeDefaults[attribute];
@ -208,7 +212,7 @@ function getCurrentAttributeValue(attribute, level) {
Template.ruleEntryDialog.onCreated(function() { Template.ruleEntryDialog.onCreated(function() {
// Define the ReactiveVars that will be used to link aspects of the UI // Define the ReactiveVars that will be used to link aspects of the UI
const template = this; var template = this;
// Note: currentValue's initial value must be a string so the template renders properly // Note: currentValue's initial value must be a string so the template renders properly
template.currentValue = new ReactiveVar(''); template.currentValue = new ReactiveVar('');
template.attribute = new ReactiveVar(); template.attribute = new ReactiveVar();
@ -217,12 +221,12 @@ Template.ruleEntryDialog.onCreated(function() {
Template.ruleEntryDialog.onRendered(function() { Template.ruleEntryDialog.onRendered(function() {
// Initialize the Comparators Select2 box // Initialize the Comparators Select2 box
const template = Template.instance(); var template = Template.instance();
template.$('.comparators').select2(); template.$('.comparators').select2();
// Get the default Comparator from the Select2 box and use it to // Get the default Comparator from the Select2 box and use it to
// initialize the comparatorId ReactiveVar // initialize the comparatorId ReactiveVar
const comparatorId = template.$('.comparators').val(); var comparatorId = template.$('.comparators').val();
template.comparatorId.set(comparatorId); template.comparatorId.set(comparatorId);
const dialog = template.$('.ruleEntryDialog'); const dialog = template.$('.ruleEntryDialog');
@ -233,7 +237,7 @@ Template.ruleEntryDialog.helpers({
/** /**
* Returns the Comparators Collection to the Template with reactive rerendering * Returns the Comparators Collection to the Template with reactive rerendering
*/ */
comparators() { comparators: function() {
return Comparators.find(); return Comparators.find();
}, },
/** /**
@ -241,7 +245,7 @@ Template.ruleEntryDialog.helpers({
* *
* @returns {*} Attribute value for the active image * @returns {*} Attribute value for the active image
*/ */
currentValue() { currentValue: function() {
return Template.instance().currentValue.get(); return Template.instance().currentValue.get();
} }
}); });
@ -253,15 +257,15 @@ Template.ruleEntryDialog.events({
* @param event the Click event * @param event the Click event
* @param template The template context * @param template The template context
*/ */
'click #save'(event, template) { 'click #save': function(event, template) {
// Retrieve the input properties to the template // Retrieve the input properties to the template
const dialog = Template.ruleEntryDialog.dialog; var dialog = Template.ruleEntryDialog.dialog;
const level = Template.ruleEntryDialog.level; var level = Template.ruleEntryDialog.level;
// Retrieve the current values for the attribute value and comparatorId // Retrieve the current values for the attribute value and comparatorId
const attribute = template.attribute.get(); var attribute = template.attribute.get();
const comparatorId = template.comparatorId.get(); var comparatorId = template.comparatorId.get();
const currentValue = template.currentValue.get(); var currentValue = template.currentValue.get();
// If currentValue input is undefined, prevent saving this rule // If currentValue input is undefined, prevent saving this rule
if (currentValue === undefined) { if (currentValue === undefined) {
@ -269,14 +273,14 @@ Template.ruleEntryDialog.events({
} }
// Check if we are editing a rule or creating a new one // Check if we are editing a rule or creating a new one
let rule; var rule;
if (Template.ruleEntryDialog.rule) { if (Template.ruleEntryDialog.rule) {
// If we are editing a rule, change the rule data // If we are editing a rule, change the rule data
rule = Template.ruleEntryDialog.rule; rule = Template.ruleEntryDialog.rule;
} else { } else {
// If we are creating a rule, obtain the active Viewport model // If we are creating a rule, obtain the active Viewport model
// from the Protocol and Stage // from the Protocol and Stage
const viewport = getActiveViewportModel(); var viewport = getActiveViewportModel();
// Create a rule depending on the level property of this dialog // Create a rule depending on the level property of this dialog
switch (level) { switch (level) {
@ -300,12 +304,12 @@ Template.ruleEntryDialog.events({
} }
// Find the Comparator from the Comparators Collection given its ID // Find the Comparator from the Comparators Collection given its ID
const comparator = Comparators.findOne({ var comparator = Comparators.findOne({
id: comparatorId id: comparatorId
}); });
// Create a new constraint to add to the rule // Create a new constraint to add to the rule
const constraint = {}; var constraint = {};
constraint[comparator.validator] = {}; constraint[comparator.validator] = {};
constraint[comparator.validator][comparator.validatorOption] = currentValue; constraint[comparator.validator][comparator.validatorOption] = currentValue;
@ -314,7 +318,7 @@ Template.ruleEntryDialog.events({
rule.constraint = constraint; rule.constraint = constraint;
// Instruct the Protocol Engine to update the Layout Manager with new data // Instruct the Protocol Engine to update the Layout Manager with new data
const viewportIndex = Session.get('activeViewport'); var viewportIndex = Session.get('activeViewport');
ProtocolEngine.updateViewports(viewportIndex); ProtocolEngine.updateViewports(viewportIndex);
// Close the dialog // Close the dialog
@ -323,8 +327,8 @@ Template.ruleEntryDialog.events({
/** /**
* Allow the user to click the Cancel button to close the dialog * Allow the user to click the Cancel button to close the dialog
*/ */
'click #cancel'() { 'click #cancel': function() {
const dialog = Template.ruleEntryDialog.dialog; var dialog = Template.ruleEntryDialog.dialog;
closeHandler(dialog); closeHandler(dialog);
}, },
/** /**
@ -333,8 +337,8 @@ Template.ruleEntryDialog.events({
* @param event The Keydown event details * @param event The Keydown event details
* @returns {boolean} Return false to prevent bubbling of the event * @returns {boolean} Return false to prevent bubbling of the event
*/ */
'keydown .ruleEntryDialog'(event) { 'keydown .ruleEntryDialog': function(event) {
const dialog = Template.ruleEntryDialog.dialog; var dialog = Template.ruleEntryDialog.dialog;
// If Esc key is pressed, close the dialog // If Esc key is pressed, close the dialog
if (event.which === keys.ESC) { if (event.which === keys.ESC) {
@ -348,9 +352,9 @@ Template.ruleEntryDialog.events({
* @param event The Change event for the select box * @param event The Change event for the select box
* @param template The current template context * @param template The current template context
*/ */
'change select.attributes'(event, template) { 'change select.attributes': function(event, template) {
// Obtain the user-specified attribute to test against // Obtain the user-specified attribute to test against
const attribute = $(event.currentTarget).val(); var attribute = $(event.currentTarget).val();
// Store it in the ReactiveVar // Store it in the ReactiveVar
template.attribute.set(attribute); template.attribute.set(attribute);
@ -359,10 +363,10 @@ Template.ruleEntryDialog.events({
Template.ruleEntryDialog.selectedAttribute = attribute; Template.ruleEntryDialog.selectedAttribute = attribute;
// Get the level of this dialog // Get the level of this dialog
const level = Template.ruleEntryDialog.level; var level = Template.ruleEntryDialog.level;
// Retrieve the current value of the attribute for the active viewport model // Retrieve the current value of the attribute for the active viewport model
const value = getCurrentAttributeValue(attribute, level); var value = getCurrentAttributeValue(attribute, level);
// Update the ReactiveVar with the user-specified value // Update the ReactiveVar with the user-specified value
template.currentValue.set(value); template.currentValue.set(value);
@ -373,12 +377,12 @@ Template.ruleEntryDialog.events({
* @param event The Change event for the input * @param event The Change event for the input
* @param template The current template context * @param template The current template context
*/ */
'change input.currentValue'(event, template) { 'change input.currentValue': function(event, template) {
// Get the DOM element representing the input box // Get the DOM element representing the input box
const input = $(event.currentTarget); var input = $(event.currentTarget);
// Get the current value of the input // Get the current value of the input
let value = input.val(); var value = input.val();
// If the input is of type 'number', parse it as a Float // If the input is of type 'number', parse it as a Float
if (input.attr('type') === 'number') { if (input.attr('type') === 'number') {
@ -394,9 +398,9 @@ Template.ruleEntryDialog.events({
* @param event The Change event for the select box * @param event The Change event for the select box
* @param template The current template context * @param template The current template context
*/ */
'change select.comparators'(event, template) { 'change select.comparators': function(event, template) {
// Get the current value of the select box // Get the current value of the select box
const comparatorId = $(event.currentTarget).val(); var comparatorId = $(event.currentTarget).val();
// Update the ReactiveVar with the value of the Comparators select box // Update the ReactiveVar with the value of the Comparators select box
template.comparatorId.set(comparatorId); template.comparatorId.set(comparatorId);

View File

@ -16,7 +16,7 @@ const keys = {
* *
* @param dialog The DOM element of the dialog to close * @param dialog The DOM element of the dialog to close
*/ */
const closeHandler = dialog => { function closeHandler(dialog) {
// Hide the lesion dialog // Hide the lesion dialog
$(dialog).css('display', 'none'); $(dialog).css('display', 'none');
@ -25,7 +25,7 @@ const closeHandler = dialog => {
// Restore the focus to the active viewport // Restore the focus to the active viewport
Viewerbase.setFocusToActiveViewport(); Viewerbase.setFocusToActiveViewport();
}; }
/** /**
* Displays and updates the UI of the Setting Entry Dialog given an * Displays and updates the UI of the Setting Entry Dialog given an
@ -35,40 +35,40 @@ const closeHandler = dialog => {
*/ */
openSettingEntryDialog = function(settingObject) { openSettingEntryDialog = function(settingObject) {
// Get the lesion location dialog // Get the lesion location dialog
const dialog = $('.settingEntryDialog'); var dialog = $('.settingEntryDialog');
// Store the Dialog DOM data, setting level and setting in the template data // Store the Dialog DOM data, setting level and setting in the template data
Template.settingEntryDialog.dialog = dialog; Template.settingEntryDialog.dialog = dialog;
Template.settingEntryDialog.settingObject = settingObject; Template.settingEntryDialog.settingObject = settingObject;
// Initialize the Select2 search box for the attribute list // Initialize the Select2 search box for the attribute list
const settings = Object.keys(HP.displaySettings); var settings = Object.keys(HP.displaySettings);
settings.concat(Object.keys(HP.CustomViewportSettings)); settings.concat(Object.keys(HP.CustomViewportSettings));
const displaySettingsOptions = Object.keys(HP.displaySettings).map(key => { var displaySettingsOptions = Object.keys(HP.displaySettings).map(key => {
return { return {
id: key, id: key,
text: HP.displaySettings[key].text text: HP.displaySettings[key].text
}; };
}); });
const customSettingsOptions = Object.keys(HP.CustomViewportSettings).map(key => { var customSettingsOptions = Object.keys(HP.CustomViewportSettings).map(key => {
return { return {
id: key, id: key,
text: HP.CustomViewportSettings[key].text text: HP.CustomViewportSettings[key].text
}; };
}); });
const settingsOptions = displaySettingsOptions.concat(customSettingsOptions); var settingsOptions = displaySettingsOptions.concat(customSettingsOptions);
const settingSelect = dialog.find('.settings'); var settingSelect = dialog.find('.settings');
settingSelect.html('').select2({ settingSelect.html('').select2({
data: settingsOptions, data: settingsOptions,
placeholder: 'Select a setting', placeholder: 'Select a setting',
allowClear: true allowClear: true
}); });
let settingDetails = { var settingDetails = {
options: [] options: []
}; };
@ -78,7 +78,7 @@ openSettingEntryDialog = function(settingObject) {
settingDetails = HP.CustomViewportSettings[settingObject.id]; settingDetails = HP.CustomViewportSettings[settingObject.id];
} }
const valueSelect = dialog.find('.currentValue'); var valueSelect = dialog.find('.currentValue');
valueSelect.html('').select2({ valueSelect.html('').select2({
data: settingDetails.options, data: settingDetails.options,
placeholder: 'Select a value', placeholder: 'Select a value',
@ -107,14 +107,14 @@ openSettingEntryDialog = function(settingObject) {
Blaze.render(Template.removableBackdrop, document.body); Blaze.render(Template.removableBackdrop, document.body);
// Make sure the context menu is closed when the user clicks away // Make sure the context menu is closed when the user clicks away
$('.removableBackdrop').one('mousedown touchstart', () => { $('.removableBackdrop').one('mousedown touchstart', function() {
closeHandler(dialog); closeHandler(dialog);
}); });
}; };
Template.settingEntryDialog.onCreated(function() { Template.settingEntryDialog.onCreated(function() {
// Define the ReactiveVars that will be used to link aspects of the UI // Define the ReactiveVars that will be used to link aspects of the UI
const template = this; var template = this;
// Note: currentValue's initial value must be a string so the template renders properly // Note: currentValue's initial value must be a string so the template renders properly
template.currentValue = new ReactiveVar(''); template.currentValue = new ReactiveVar('');
@ -134,29 +134,29 @@ Template.settingEntryDialog.events({
* @param event the Click event * @param event the Click event
* @param template The template context * @param template The template context
*/ */
'click #save'(event, template) { 'click #save': function(event, template) {
// Retrieve the input properties to the template // Retrieve the input properties to the template
const dialog = Template.settingEntryDialog.dialog; var dialog = Template.settingEntryDialog.dialog;
// Retrieve the current values for the id and current value // Retrieve the current values for the id and current value
const setting = template.setting.get(); var setting = template.setting.get();
const currentValue = template.currentValue.get(); var currentValue = template.currentValue.get();
// If currentValue input is undefined, prevent saving this setting // If currentValue input is undefined, prevent saving this setting
if (currentValue === undefined) { if (currentValue === undefined) {
return; return;
} }
const viewportSetting = { var viewportSetting = {
id: setting, id: setting,
value: currentValue value: currentValue
}; };
// Obtain the active Viewport model from the Protocol and Stage // Obtain the active Viewport model from the Protocol and Stage
const viewport = getActiveViewportModel(); var viewport = getActiveViewportModel();
// Remove any old rules if the ID has been changes // Remove any old rules if the ID has been changes
const originalSettingObject = Template.settingEntryDialog.settingObject; var originalSettingObject = Template.settingEntryDialog.settingObject;
if (originalSettingObject && originalSettingObject.id) { if (originalSettingObject && originalSettingObject.id) {
delete viewport.viewportSettings[originalSettingObject.id]; delete viewport.viewportSettings[originalSettingObject.id];
} }
@ -165,7 +165,7 @@ Template.settingEntryDialog.events({
viewport.viewportSettings[viewportSetting.id] = viewportSetting.value; viewport.viewportSettings[viewportSetting.id] = viewportSetting.value;
// Instruct the Protocol Engine to update the Layout Manager with new data // Instruct the Protocol Engine to update the Layout Manager with new data
const viewportIndex = Session.get('activeViewport'); var viewportIndex = Session.get('activeViewport');
ProtocolEngine.updateViewports(viewportIndex); ProtocolEngine.updateViewports(viewportIndex);
// Close the dialog // Close the dialog
@ -174,8 +174,8 @@ Template.settingEntryDialog.events({
/** /**
* Allow the user to click the Cancel button to close the dialog * Allow the user to click the Cancel button to close the dialog
*/ */
'click #cancel'() { 'click #cancel': function() {
const dialog = Template.settingEntryDialog.dialog; var dialog = Template.settingEntryDialog.dialog;
closeHandler(dialog); closeHandler(dialog);
}, },
/** /**
@ -184,8 +184,8 @@ Template.settingEntryDialog.events({
* @param event The Keydown event details * @param event The Keydown event details
* @returns {boolean} Return false to prevent bubbling of the event * @returns {boolean} Return false to prevent bubbling of the event
*/ */
'keydown .settingEntryDialog'(event) { 'keydown .settingEntryDialog': function(event) {
const dialog = Template.settingEntryDialog.dialog; var dialog = Template.settingEntryDialog.dialog;
// If Esc key is pressed, close the dialog // If Esc key is pressed, close the dialog
if (event.which === keys.ESC) { if (event.which === keys.ESC) {
@ -199,15 +199,15 @@ Template.settingEntryDialog.events({
* @param event The Change event for the select box * @param event The Change event for the select box
* @param template The current template context * @param template The current template context
*/ */
'change select.settings'(event, template) { 'change select.settings': function(event, template) {
// Obtain the user-specified attribute to test against // Obtain the user-specified attribute to test against
const settingId = $(event.currentTarget).val(); var settingId = $(event.currentTarget).val();
// Store it in the ReactiveVar // Store it in the ReactiveVar
template.setting.set(settingId); template.setting.set(settingId);
// Retrieve the current value from the attribute // Retrieve the current value from the attribute
let settingDetails = { var settingDetails = {
options: [] options: []
}; };
if (settingId && HP.displaySettings[settingId]) { if (settingId && HP.displaySettings[settingId]) {
@ -216,8 +216,8 @@ Template.settingEntryDialog.events({
settingDetails = HP.CustomViewportSettings[settingId]; settingDetails = HP.CustomViewportSettings[settingId];
} }
const dialog = Template.settingEntryDialog.dialog; var dialog = Template.settingEntryDialog.dialog;
const valueSelect = dialog.find('.currentValue'); var valueSelect = dialog.find('.currentValue');
valueSelect.html('').select2({ valueSelect.html('').select2({
data: settingDetails.options, data: settingDetails.options,
placeholder: 'Select a value', placeholder: 'Select a value',
@ -236,9 +236,9 @@ Template.settingEntryDialog.events({
* @param event The Change event for the input * @param event The Change event for the input
* @param template The current template context * @param template The current template context
*/ */
'change select.currentValue'(event, template) { 'change select.currentValue': function(event, template) {
// Get the current value of the select box // Get the current value of the select box
const value = $(event.currentTarget).val(); var value = $(event.currentTarget).val();
// Update the ReactiveVar with the user-specified value // Update the ReactiveVar with the user-specified value
template.currentValue.set(value); template.currentValue.set(value);

View File

@ -10,7 +10,7 @@ import 'meteor/ohif:viewerbase';
* so we can swap stages more easily * so we can swap stages more easily
*/ */
Array.prototype.move = function(oldIndex, newIndex) { Array.prototype.move = function(oldIndex, newIndex) {
const value = this[oldIndex]; var value = this[oldIndex];
newIndex = Math.max(0, newIndex); newIndex = Math.max(0, newIndex);
newIndex = Math.min(this.length, newIndex); newIndex = Math.min(this.length, newIndex);
@ -29,13 +29,13 @@ Array.prototype.move = function(oldIndex, newIndex) {
* @returns {number} The index of the specified stage within the Protocol, * @returns {number} The index of the specified stage within the Protocol,
* or undefined if it is not present. * or undefined if it is not present.
*/ */
const getStageIndex = (protocol, id) => { function getStageIndex(protocol, id) {
let stageIndex; var stageIndex;
if (!protocol || !protocol.stages) { if (!protocol || !protocol.stages) {
return; return;
} }
protocol.stages.forEach((stage, index) => { protocol.stages.forEach(function(stage, index) {
if (stage.id === id) { if (stage.id === id) {
stageIndex = index; stageIndex = index;
return false; return false;
@ -43,7 +43,7 @@ const getStageIndex = (protocol, id) => {
}); });
return stageIndex; return stageIndex;
}; }
Template.stageSortable.helpers({ Template.stageSortable.helpers({
/** /**
@ -51,7 +51,7 @@ Template.stageSortable.helpers({
* *
* @returns {boolean} Whether or not the stage is currently being displayed * @returns {boolean} Whether or not the stage is currently being displayed
*/ */
isActiveStage() { isActiveStage: function() {
// Rerun this function every time the layout manager has been updated // Rerun this function every time the layout manager has been updated
Session.get('LayoutManagerUpdated'); Session.get('LayoutManagerUpdated');
@ -60,7 +60,7 @@ Template.stageSortable.helpers({
return; return;
} }
const currentStage = ProtocolEngine.getCurrentStageModel(); var currentStage = ProtocolEngine.getCurrentStageModel();
if (!currentStage) { if (!currentStage) {
return false; return false;
} }
@ -73,8 +73,8 @@ Template.stageSortable.helpers({
* *
* @returns {number|*} * @returns {number|*}
*/ */
stageLabel() { stageLabel: function() {
const stage = this; var stage = this;
// If no Protocol Engine has been defined yet, stop here to prevent errors // If no Protocol Engine has been defined yet, stop here to prevent errors
if (!ProtocolEngine) { if (!ProtocolEngine) {
@ -82,10 +82,10 @@ Template.stageSortable.helpers({
} }
// Retrieve the last saved copy of the current protocol // Retrieve the last saved copy of the current protocol
const lastSavedCopy = HangingProtocols.findOne(ProtocolEngine.protocol._id); var lastSavedCopy = HP.ProtocolStore.getProtocol(ProtocolEngine.protocol.id);
// Try to find the index of this stage in the previously saved copy // Try to find the index of this stage in the previously saved copy
let stageIndex = getStageIndex(lastSavedCopy, stage.id); var stageIndex = getStageIndex(lastSavedCopy, stage.id);
// If the stage is new, and therefore wasn't present in the last save, // If the stage is new, and therefore wasn't present in the last save,
// retrieve it's index in the array of new stage ids and use that for // retrieve it's index in the array of new stage ids and use that for
@ -95,11 +95,11 @@ Template.stageSortable.helpers({
Session.get('timeAgoVariable'); Session.get('timeAgoVariable');
// Find the index of the stage in the array of newly created stage IDs // Find the index of the stage in the array of newly created stage IDs
const newStageNumber = ProtocolEngine.newStageIds.indexOf(stage.id) + 1; var newStageNumber = ProtocolEngine.newStageIds.indexOf(stage.id) + 1;
// Use Moment.js to format the createdDate of this stage relative to the // Use Moment.js to format the createdDate of this stage relative to the
// current time // current time
const dateCreatedFromNow = moment(stage.createdDate).fromNow(); var dateCreatedFromNow = moment(stage.createdDate).fromNow();
// Return the label for the new stage, // Return the label for the new stage,
// e.g. "New Stage 1 (created a few seconds ago)" // e.g. "New Stage 1 (created a few seconds ago)"
@ -115,7 +115,7 @@ Template.stageSortable.helpers({
* *
* @returns {boolean} Whether or not a later stage exists * @returns {boolean} Whether or not a later stage exists
*/ */
isNextAvailable() { isNextAvailable: function() {
// Run this helper whenever the ProtocolEngine / LayoutManager has changed // Run this helper whenever the ProtocolEngine / LayoutManager has changed
Session.get('LayoutManagerUpdated'); Session.get('LayoutManagerUpdated');
@ -132,7 +132,7 @@ Template.stageSortable.helpers({
* *
* @returns {boolean} Whether or not an earlier stage exists * @returns {boolean} Whether or not an earlier stage exists
*/ */
isPreviousAvailable() { isPreviousAvailable: function() {
// Run this helper whenever the ProtocolEngine / LayoutManager has changed // Run this helper whenever the ProtocolEngine / LayoutManager has changed
Session.get('LayoutManagerUpdated'); Session.get('LayoutManagerUpdated');
@ -150,9 +150,9 @@ Template.stageSortable.events({
/** /**
* Displays a stage when its title is clicked * Displays a stage when its title is clicked
*/ */
'click .sortable-item span'() { 'click .sortable-item span': function() {
// Retrieve the index of this stage in the display set sequences // Retrieve the index of this stage in the display set sequences
const stageIndex = getStageIndex(ProtocolEngine.protocol, this.id); var stageIndex = getStageIndex(ProtocolEngine.protocol, this.id);
// Display the selected stage // Display the selected stage
ProtocolEngine.setCurrentProtocolStage(stageIndex); ProtocolEngine.setCurrentProtocolStage(stageIndex);
@ -161,12 +161,12 @@ Template.stageSortable.events({
* Creates a new stage and adds it to the currently loaded Protocol at * Creates a new stage and adds it to the currently loaded Protocol at
* the end of the display set sequence * the end of the display set sequence
*/ */
'click #addStage'() { 'click #addStage': function() {
// Retrieve the model describing the current stage // Retrieve the model describing the current stage
const stage = ProtocolEngine.getCurrentStageModel(); var stage = ProtocolEngine.getCurrentStageModel();
// Clone this stage to create a new stage // Clone this stage to create a new stage
const newStage = stage.createClone(); var newStage = stage.createClone();
// Remove the stage's name if it has one // Remove the stage's name if it has one
delete newStage.name; delete newStage.name;
@ -178,7 +178,7 @@ Template.stageSortable.events({
ProtocolEngine.newStageIds.push(newStage.id); ProtocolEngine.newStageIds.push(newStage.id);
// Calculate the index of the last stage in the display set sequence // Calculate the index of the last stage in the display set sequence
const stageIndex = ProtocolEngine.protocol.stages.length - 1; var stageIndex = ProtocolEngine.protocol.stages.length - 1;
// Switch to the last stage in the display set sequence // Switch to the last stage in the display set sequence
ProtocolEngine.setCurrentProtocolStage(stageIndex); ProtocolEngine.setCurrentProtocolStage(stageIndex);
@ -188,22 +188,22 @@ Template.stageSortable.events({
* the stages array. If it is the currently active stage, the current stage is * the stages array. If it is the currently active stage, the current stage is
* set to one stage earlier in the display set sequence. * set to one stage earlier in the display set sequence.
*/ */
'click .deleteStage'() { 'click .deleteStage': function() {
// If this is the only stage in the Protocol, stop here // If this is the only stage in the Protocol, stop here
if (ProtocolEngine.protocol.stages.length === 1) { if (ProtocolEngine.protocol.stages.length === 1) {
return; return;
} }
const stageId = this.id; var stageId = this.id;
const options = { var options = {
title: 'Remove Protocol Stage', title: 'Remove Protocol Stage',
text: 'Are you sure you would like to remove this Protocol Stage? This cannot be reversed.' text: 'Are you sure you would like to remove this Protocol Stage? This cannot be reversed.'
}; };
OHIF.viewerbase.showConfirmDialog(() => { showConfirmDialog(function() {
// Retrieve the index of this stage in the display set sequences // Retrieve the index of this stage in the display set sequences
const stageIndex = getStageIndex(ProtocolEngine.protocol, stageId); var stageIndex = getStageIndex(ProtocolEngine.protocol, stageId);
// Remove it from the display set sequence // Remove it from the display set sequence
ProtocolEngine.protocol.stages.splice(stageIndex, 1); ProtocolEngine.protocol.stages.splice(stageIndex, 1);
@ -211,7 +211,7 @@ Template.stageSortable.events({
// If we have removed the currently active stage, switch to the one before it // If we have removed the currently active stage, switch to the one before it
if (ProtocolEngine.stage === stageIndex) { if (ProtocolEngine.stage === stageIndex) {
// Make sure we don't try to switch to a stage index below zero // Make sure we don't try to switch to a stage index below zero
const newStageIndex = Math.max(stageIndex - 1, 0); var newStageIndex = Math.max(stageIndex - 1, 0);
// Display the new stage // Display the new stage
ProtocolEngine.setCurrentProtocolStage(newStageIndex); ProtocolEngine.setCurrentProtocolStage(newStageIndex);
@ -222,10 +222,10 @@ Template.stageSortable.events({
}, options); }, options);
}, },
'click .moveStageUp'() { 'click .moveStageUp': function() {
// Get the old and new indices following a 'sort' event // Get the old and new indices following a 'sort' event
const oldIndex = ProtocolEngine.stage; var oldIndex = ProtocolEngine.stage;
const newIndex = Math.max(ProtocolEngine.stage - 1, 0); var newIndex = Math.max(ProtocolEngine.stage - 1, 0);
if (oldIndex === newIndex) { if (oldIndex === newIndex) {
return; return;
@ -242,10 +242,10 @@ Template.stageSortable.events({
// Update the Session variable to the UI re-renders // Update the Session variable to the UI re-renders
Session.set('LayoutManagerUpdated', Random.id()); Session.set('LayoutManagerUpdated', Random.id());
}, },
'click .moveStageDown'() { 'click .moveStageDown': function() {
// Get the old and new indices following a 'sort' event // Get the old and new indices following a 'sort' event
const oldIndex = ProtocolEngine.stage; var oldIndex = ProtocolEngine.stage;
const newIndex = Math.min(ProtocolEngine.stage + 1, ProtocolEngine.protocol.stages.length - 1); var newIndex = Math.min(ProtocolEngine.stage + 1, ProtocolEngine.protocol.stages.length - 1);
if (oldIndex === newIndex) { if (oldIndex === newIndex) {
return; return;

View File

@ -15,7 +15,7 @@ const keys = {
* *
* @param dialog The DOM element of the dialog to close * @param dialog The DOM element of the dialog to close
*/ */
const closeHandler = dialog => { function closeHandler(dialog) {
// Hide the lesion dialog // Hide the lesion dialog
$(dialog).css('display', 'none'); $(dialog).css('display', 'none');
@ -24,7 +24,7 @@ const closeHandler = dialog => {
// Restore the focus to the active viewport // Restore the focus to the active viewport
Viewerbase.setFocusToActiveViewport(); Viewerbase.setFocusToActiveViewport();
}; }
/** /**
* Displays and updates the UI of the Text Entry Dialog given a new title, * Displays and updates the UI of the Text Entry Dialog given a new title,
@ -36,10 +36,10 @@ const closeHandler = dialog => {
*/ */
openTextEntryDialog = function(title, instructions, currentValue, doneCallback) { openTextEntryDialog = function(title, instructions, currentValue, doneCallback) {
// Get the lesion location dialog // Get the lesion location dialog
const dialog = $('.textEntryDialog'); var dialog = $('.textEntryDialog');
// Clear any input that is still on the page // Clear any input that is still on the page
const currentValueInput = dialog.find('input.currentValue'); var currentValueInput = dialog.find('input.currentValue');
currentValueInput.val(currentValue); currentValueInput.val(currentValue);
// Store the Dialog DOM data, rule level and rule in the template data // Store the Dialog DOM data, rule level and rule in the template data
@ -55,10 +55,10 @@ openTextEntryDialog = function(title, instructions, currentValue, doneCallback)
dialog.css('display', 'block'); dialog.css('display', 'block');
// Show the backdrop // Show the backdrop
Blaze.render(Template.removableBackdrop, document.body); UI.render(Template.removableBackdrop, document.body);
// Make sure the context menu is closed when the user clicks away // Make sure the context menu is closed when the user clicks away
$('.removableBackdrop').one('mousedown touchstart', () => { $('.removableBackdrop').one('mousedown touchstart', function() {
closeHandler(dialog); closeHandler(dialog);
}); });
}; };
@ -74,17 +74,17 @@ Template.textEntryDialog.events({
* Save the user-specified text * Save the user-specified text
* *
*/ */
'click .save'() { 'click .save': function() {
// Retrieve the input properties to the template // Retrieve the input properties to the template
const dialog = Template.textEntryDialog.dialog; var dialog = Template.textEntryDialog.dialog;
const currentValue = dialog.find('input.currentValue').val(); var currentValue = dialog.find('input.currentValue').val();
// If currentValue input is undefined, prevent saving this rule // If currentValue input is undefined, prevent saving this rule
if (currentValue === undefined) { if (currentValue === undefined) {
return; return;
} }
const doneCallback = Template.textEntryDialog.doneCallback; var doneCallback = Template.textEntryDialog.doneCallback;
if (doneCallback) { if (doneCallback) {
doneCallback(currentValue); doneCallback(currentValue);
} }
@ -95,7 +95,7 @@ Template.textEntryDialog.events({
/** /**
* Allow the user to click the Cancel button to close the dialog * Allow the user to click the Cancel button to close the dialog
*/ */
'click .cancel'() { 'click .cancel': function() {
closeHandler(Template.textEntryDialog.dialog); closeHandler(Template.textEntryDialog.dialog);
}, },
/** /**
@ -104,22 +104,22 @@ Template.textEntryDialog.events({
* @param event The Keydown event details * @param event The Keydown event details
* @returns {boolean} Return false to prevent bubbling of the event * @returns {boolean} Return false to prevent bubbling of the event
*/ */
'keydown .textEntryDialog'(event) { 'keydown .textEntryDialog': function(event) {
const dialog = Template.textEntryDialog.dialog; var dialog = Template.textEntryDialog.dialog;
// If Esc key is pressed, close the dialog // If Esc key is pressed, close the dialog
if (event.which === keys.ESC) { if (event.which === keys.ESC) {
closeHandler(dialog); closeHandler(dialog);
return false; return false;
} else if (event.which === keys.ENTER) { } else if (event.which === keys.ENTER) {
const currentValue = dialog.find('input.currentValue').val(); var currentValue = dialog.find('input.currentValue').val();
// If currentValue input is undefined, prevent saving this rule // If currentValue input is undefined, prevent saving this rule
if (currentValue === undefined) { if (currentValue === undefined) {
return; return;
} }
const doneCallback = Template.textEntryDialog.doneCallback; var doneCallback = Template.textEntryDialog.doneCallback;
if (doneCallback) { if (doneCallback) {
doneCallback(currentValue); doneCallback(currentValue);
} }
@ -134,9 +134,9 @@ Template.textEntryDialog.events({
* @param event The Change event for the input * @param event The Change event for the input
* @param template The current template context * @param template The current template context
*/ */
'change input.currentValue'(event, template) { 'change input.currentValue': function(event, template) {
// Get the DOM element representing the input box // Get the DOM element representing the input box
const input = $(event.currentTarget); var input = $(event.currentTarget);
// Update the template data with the current value // Update the template data with the current value
Template.textEntryDialog.currentValue = input.val(); Template.textEntryDialog.currentValue = input.val();

View File

@ -196,7 +196,7 @@ HP.ProtocolEngine = class ProtocolEngine {
findMatchByStudy(study) { findMatchByStudy(study) {
var matched = []; var matched = [];
HangingProtocols.find().forEach(protocol => { HP.ProtocolStore.getProtocol().forEach(protocol => {
// Clone the protocol's protocolMatchingRules array // Clone the protocol's protocolMatchingRules array
// We clone it so that we don't accidentally add the // We clone it so that we don't accidentally add the
// numberOfPriorsReferenced rule to the Protocol itself. // numberOfPriorsReferenced rule to the Protocol itself.
@ -225,9 +225,7 @@ HP.ProtocolEngine = class ProtocolEngine {
}); });
if (!matched.length) { if (!matched.length) {
var defaultProtocol = HangingProtocols.findOne({ var defaultProtocol = HP.ProtocolStore.getProtocol('defaultProtocol');
id: 'defaultProtocol'
});
return [{ return [{
score: 1, score: 1,
@ -422,7 +420,7 @@ HP.ProtocolEngine = class ProtocolEngine {
// TODO: Add relative Date / time // TODO: Add relative Date / time
}); });
this.studies.forEach(study => { this.studies.forEach(function(study) {
const studyMatchDetails = HP.match(study, studyMatchingRules); const studyMatchDetails = HP.match(study, studyMatchingRules);
if ((studyMatchingRules.length && !studyMatchDetails.score) || if ((studyMatchingRules.length && !studyMatchDetails.score) ||
studyMatchDetails.score < highestStudyMatchingScore) { studyMatchDetails.score < highestStudyMatchingScore) {
@ -440,7 +438,7 @@ HP.ProtocolEngine = class ProtocolEngine {
highestSeriesMatchingScore = seriesMatchDetails.score; highestSeriesMatchingScore = seriesMatchDetails.score;
series.instances.forEach((instance, index) => { series.instances.forEach(function(instance, index) {
// This tests to make sure there is actually image data in this instance // This tests to make sure there is actually image data in this instance
// TODO: Change this when we add PDF and MPEG support // TODO: Change this when we add PDF and MPEG support
// See https://ohiforg.atlassian.net/browse/LT-227 // See https://ohiforg.atlassian.net/browse/LT-227