Fix ProtocolEngine typos for LayoutManager (OHIF-57)

This commit is contained in:
Erik Ziegler 2016-08-11 10:44:05 +02:00
parent 710265af07
commit 373225df3d

View File

@ -31,21 +31,25 @@ function updateProtocolSelect() {
protocolSelect.select2().val(ProtocolEngine.protocol.id).trigger('change'); protocolSelect.select2().val(ProtocolEngine.protocol.id).trigger('change');
} }
Template.protocolEditor.onRendered(function() { Template.protocolEditor.onRendered(() => {
this.timeAgoInterval = Meteor.setInterval(function() { const instance = Template.instance();
instance.timeAgoInterval = Meteor.setInterval(() => {
// Run this every minute // Run this every minute
Session.set('timeAgoVariable', new Date()); Session.set('timeAgoVariable', new Date());
}, 60000); }, 60000);
// Subscribe to the Hanging Protocols Collection // Subscribe to the Hanging Protocols Collection
this.subscribe('hangingprotocols', function() { instance.subscribe('hangingprotocols', () => {
// Update the Protocol select box when the Collection is ready // Update the Protocol select box when the Collection is ready
updateProtocolSelect(); updateProtocolSelect();
}); });
}); });
Template.protocolEditor.onDestroyed(function() { Template.protocolEditor.onDestroyed(() => {
Meteor.clearInterval(this.timeAgoInterval); const instance = Template.instance();
Meteor.clearInterval(instance.timeAgoInterval);
}); });
Template.protocolEditor.helpers({ Template.protocolEditor.helpers({
@ -54,13 +58,14 @@ Template.protocolEditor.helpers({
* *
* @returns {*} The currently active Protocol Model * @returns {*} The currently active Protocol Model
*/ */
activeProtocol: function() { activeProtocol() {
// Whenever the Layout Manager is updated, trigger this helper // Whenever the Layout Manager is updated, trigger this helper
Session.get('LayoutManagerUpdated'); Session.get('LayoutManagerUpdated');
// If no ProtocolEngine, protocol, or stage is defined, stop here // If no ProtocolEngine, protocol, or stage is defined, stop here
if (!ProtocolEngine || if (!ProtocolEngine ||
!ProtocolEngine.protocol || !ProtocolEngine.protocol ||
!ProtocolEngine.LayoutManager ||
ProtocolEngine.stage === undefined) { ProtocolEngine.stage === undefined) {
return; return;
} }
@ -89,14 +94,14 @@ Template.protocolEditor.helpers({
* *
* @returns {*} The current Protocol's active Stage model * @returns {*} The current Protocol's active Stage model
*/ */
activeStage: function() { activeStage() {
// Whenever the Layout Manager is updated, trigger this helper // Whenever the Layout Manager is updated, trigger this helper
Session.get('LayoutManagerUpdated'); Session.get('LayoutManagerUpdated');
// If no ProtocolEngine, protocol, or stage is defined, stop here // If no ProtocolEngine, protocol, or stage is defined, stop here
if (!ProtocolEngine || if (!ProtocolEngine ||
!ProtocolEngine.protocol || !ProtocolEngine.protocol ||
!ProtocolEngine.layoutManager || !ProtocolEngine.LayoutManager ||
ProtocolEngine.stage === undefined) { ProtocolEngine.stage === undefined) {
return; return;
} }
@ -110,8 +115,8 @@ Template.protocolEditor.helpers({
// Update active Stage's layout template and properties based on the displayed // Update active Stage's layout template and properties based on the displayed
// layout properties. This is used to update the Stage Model when the user modifies // layout properties. This is used to update the Stage Model when the user modifies
// the layout in the viewer // the layout in the viewer
stage.viewportStructure.layoutTemplateName = ProtocolEngine.layoutManager.layoutTemplateName; stage.viewportStructure.layoutTemplateName = ProtocolEngine.LayoutManager.layoutTemplateName;
stage.viewportStructure.properties = ProtocolEngine.layoutManager.layoutProps; stage.viewportStructure.properties = ProtocolEngine.LayoutManager.layoutProps;
// If there is a discrepancy between the Stage's number of viewports and the // If there is a discrepancy between the Stage's number of viewports and the
// the number of required viewports given the properties above, rectify it // the number of required viewports given the properties above, rectify it
@ -146,8 +151,9 @@ Template.protocolEditor.helpers({
// Return the current Stage model for the active Protocol // Return the current Stage model for the active Protocol
return ProtocolEngine.getCurrentStageModel(); return ProtocolEngine.getCurrentStageModel();
}, },
activeViewportUndefined: function() { activeViewportUndefined() {
return (Session.get('activeViewport') === undefined); const viewportIndex = Session.get('activeViewport');
return (viewportIndex === undefined);
} }
}); });
@ -155,7 +161,7 @@ Template.protocolEditor.events({
/** /**
* Creates a new Hanging Protocol and displays it in the Viewer * Creates a new Hanging Protocol and displays it in the Viewer
*/ */
'click #newProtocol': function() { 'click #newProtocol'() {
// Clone the default Protocol // Clone the default Protocol
var protocol = HP.defaultProtocol.createClone(); var protocol = HP.defaultProtocol.createClone();
@ -177,7 +183,7 @@ Template.protocolEditor.events({
/** /**
* Rename the current Protocol * Rename the current Protocol
*/ */
'click #renameProtocol': function() { 'click #renameProtocol'() {
var selectedProtocol = this; var selectedProtocol = this;
if (selectedProtocol.locked) { if (selectedProtocol.locked) {
return; return;
@ -233,7 +239,7 @@ Template.protocolEditor.events({
// Create an HTML5 File Reader // Create an HTML5 File Reader
var reader = new FileReader(); var reader = new FileReader();
reader.onload = function() { reader.onload = () => {
var text = reader.result; var text = reader.result;
// POST the file to our protocol-import Route // POST the file to our protocol-import Route
@ -281,13 +287,13 @@ Template.protocolEditor.events({
* Allow the Protocols / Stage navigation tabs to toggle the * Allow the Protocols / Stage navigation tabs to toggle the
* 'active' class when clicked * 'active' class when clicked
*/ */
'click .navigationButtons a': function() { 'click .navigationButtons a'() {
$(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 HangingProtocols Collection with the latest changes to the current Protocol
*/ */
'click #saveProtocol': function() { 'click #saveProtocol'() {
var selectedProtocol = this; var selectedProtocol = this;
if (selectedProtocol.locked) { if (selectedProtocol.locked) {
return; return;
@ -311,7 +317,7 @@ Template.protocolEditor.events({
/** /**
* Save the current Protocol as a new document in the HangingProtocols Collection * Save the current Protocol as a new document in the HangingProtocols Collection
*/ */
'click #saveAsProtocol': function() { 'click #saveAsProtocol'() {
var selectedProtocol = this; var selectedProtocol = this;
// Define some details for the text entry dialog // Define some details for the text entry dialog
@ -341,7 +347,7 @@ Template.protocolEditor.events({
/** /**
* Export the currently selected Protocol as a JSON file * Export the currently selected Protocol as a JSON file
*/ */
'click #exportJSON': function() { 'click #exportJSON'() {
// Tell the User's Browser to download the JSON file by routing a hidden iframe to our // Tell the User's Browser to download the JSON file by routing a hidden iframe to our
// protocol-export Route. This prevents the tab from changing its current content. // protocol-export Route. This prevents the tab from changing its current content.
var selectedProtocol = this; var selectedProtocol = this;
@ -350,7 +356,7 @@ Template.protocolEditor.events({
/** /**
* Delete the currently selected Protocol * Delete the currently selected Protocol
*/ */
'click #deleteProtocol': function() { 'click #deleteProtocol'() {
var selectedProtocol = this; var selectedProtocol = this;
if (selectedProtocol.locked) { if (selectedProtocol.locked) {
return; return;
@ -361,7 +367,7 @@ Template.protocolEditor.events({
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.'
}; };
showConfirmDialog(function() { showConfirmDialog(() => {
// Send a call to remove the Protocol from the HangingProtocols Collection on the server // Send a call to remove the Protocol from the HangingProtocols Collection on the server
Meteor.call('removeHangingProtocol', selectedProtocol._id); Meteor.call('removeHangingProtocol', selectedProtocol._id);