Remove some subscription / reactivity / caching bugs and the unnecessary PatientLocations collection

This commit is contained in:
Erik Ziegler committed 2016-02-10 16:38:49 +01:00
1 parent 7d42456f57
commit 9cde04bcfe
43 files changed
+321 -234

No files matched your search

+5 -3
View File
@@ -1,16 +1,18 @@
<template name="viewer">
{{#if Template.subscriptionsReady}}
<div id="viewer">
{{>confirmDeleteDialog}}
{{>lesionLocationDialog}}
{{>nonTargetLesionDialog}}
{{>nonTargetResponseDialog}}
{{>timepointTextDialog}}
{{ >conformanceCheckFeedback }}
{{>conformanceCheckFeedback}}
{{>hidingPanel}}
<div id="viewportAndLesionTable">
{{>viewerMain }}
{{>lesionTable }}
</div>
</div>
{{else}}
{{>loadingText}}
{{/if}}
</template>
+19 -7
View File
@@ -1,9 +1,14 @@
Session.setDefault('activeViewport', false);
ViewerStudies = new Meteor.Collection(null);
ViewerStudies._debugName = 'ViewerStudies';
Template.viewer.onCreated(function() {
// Attach the Window resize listener
$(window).on('resize', handleResize);
ValidationErrors.remove({});
var self = this;
var firstMeasurementsActivated = false;
var contentId = this.data.contentId;
@@ -97,10 +102,11 @@ Template.viewer.onCreated(function() {
Session.set('activeViewport', ViewerData[contentId].activeViewport || false);
// Set lesion tool buttons as disabled if pixel spacing is not available for active element
this.autorun(pixelSpacingAutorunCheck);
self.autorun(pixelSpacingAutorunCheck);
// Update the ViewerStudies collection with the loaded studies
ViewerStudies = new Meteor.Collection(null);
ViewerStudies.remove({});
this.data.studies.forEach(function(study) {
study.selected = true;
ViewerStudies.insert(study);
@@ -110,11 +116,17 @@ Template.viewer.onCreated(function() {
Session.set('patientId', patientId);
self.autorun(function() {
var patientId = Session.get('patientId');
self.subscribe('singlePatientTimepoints', patientId);
self.subscribe('singlePatientMeasurements', patientId);
var dataContext = Template.currentData();
self.subscribe('singlePatientAssociatedStudies', dataContext.studies[0].patientId);
self.subscribe('singlePatientTimepoints', dataContext.studies[0].patientId);
self.subscribe('singlePatientMeasurements', dataContext.studies[0].patientId);
var subscriptionsReady = self.subscriptionsReady();
console.log('autorun viewer.js. Ready: ' + subscriptionsReady);
if (subscriptionsReady) {
TrialResponseCriteria.validateAllDelayed();
if (self.subscriptionsReady()) {
ViewerStudies.find().observe({
added: function(study) {
// Find the relevant timepoint given the newly added study
@@ -128,7 +140,7 @@ Template.viewer.onCreated(function() {
log.warn('Study added to Viewer has not been associated!');
return;
}
// Update the added document with its related timepointId
ViewerStudies.update(study._id, {
$set: {
+68
View File
@@ -0,0 +1,68 @@
Meteor.startup(function() {
var debug = false;
if (debug === true) {
// http://www.meteorpedia.com/read/Debugging_Reactivity
Meteor.autorun(function(computation) {
computation.onInvalidate(function() {
console.trace();
});
});
var wrappedFind = Meteor.Collection.prototype.find;
Meteor.Collection.prototype.find = function() {
var cursor = wrappedFind.apply(this, arguments);
var collectionName = this._name || this._debugName;
/*cursor.observeChanges({
added: function(id, fields) {
console.log(collectionName, 'added', id, fields);
},
changed: function(id, fields) {
console.log(collectionName, 'changed', id, fields);
},
movedBefore: function(id, before) {
console.log(collectionName, 'movedBefore', id, before);
},
removed: function(id) {
console.log(collectionName, 'removed', id);
}
});*/
cursor.observe({
added: function(data) {
console.log(collectionName, 'added', data);
},
changed: function(data) {
console.log(collectionName, 'changed', data);
},
removed: function(data) {
console.log(collectionName, 'removed', data);
}
});
return cursor;
};
function logRenders() {
Object.keys(Template).forEach(function(name) {
if (name.indexOf('_') > -1) {
return;
}
var template = Template[name];
var oldRender = template.rendered;
var counter = 0;
template.rendered = function() {
console.log(name, 'render count: ', ++counter);
oldRender && oldRender.apply(this, arguments);
};
});
}
logRenders();
}
});