Fixing baseline saving on LesionTracker
This commit is contained in:
parent
b4bb44625c
commit
6edd34ea5e
@ -1,6 +1,5 @@
|
||||
import { Blaze } from 'meteor/blaze';
|
||||
import { Template } from 'meteor/templating';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { _ } from 'meteor/underscore';
|
||||
import { $ } from 'meteor/jquery';
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { Tracker } from 'meteor/tracker';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
import { _ } from 'meteor/underscore';
|
||||
|
||||
@ -315,13 +316,24 @@ export const unsavedChanges = {
|
||||
|
||||
rootNode: rootNode,
|
||||
|
||||
observer: new Tracker.Dependency(),
|
||||
|
||||
/**
|
||||
* Register a reactive dependency on every change any path suffers
|
||||
*/
|
||||
depend: function() {
|
||||
return this.observer.depend();
|
||||
},
|
||||
|
||||
/**
|
||||
* Signal an unsaved change for a given namespace.
|
||||
* @param {String} path A string (e.g., "viewer.studyViewer.measurements.targets") that identifies the namespace of the signaled changes.
|
||||
* @return {Boolean} Returns false if the signal could not be saved or the supplied namespace is invalid. Otherwise, true is returned.
|
||||
*/
|
||||
set: function(path) {
|
||||
return rootNode.appendPath(path, 1);
|
||||
const result = rootNode.appendPath(path, 1);
|
||||
this.observer.changed();
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -334,7 +346,9 @@ export const unsavedChanges = {
|
||||
* @return {Boolean} Returns false if the signal could not be removed or the supplied namespace is invalid. Otherwise, true is returned.
|
||||
*/
|
||||
clear: function(path, recursively) {
|
||||
return rootNode.clearPath(path, typeof recursively === UNDEFINED ? true : recursively);
|
||||
const result = rootNode.clearPath(path, typeof recursively === UNDEFINED ? true : recursively);
|
||||
this.observer.changed();
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<template name="caseProgress">
|
||||
<div class="caseProgress">
|
||||
{{#form (extend class='caseProgress' api=instance.api)}}
|
||||
{{#unless progressComplete}}
|
||||
{{>radialProgressBar isLocked=isLocked progressPercent=progressPercent progressText=progressText}}
|
||||
{{/unless}}
|
||||
@ -10,8 +10,8 @@
|
||||
{{/if}}
|
||||
{{#if progressComplete}}
|
||||
<div class="caseProgressStatus">
|
||||
<button class="btn js-finish-case {{valueIf isFinishDisabled 'disabled' ''}}">Save</button>
|
||||
{{#button class='btn' action='save' disabled=(isFinishDisabled)}}Save{{/button}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/form}}
|
||||
</template>
|
||||
|
||||
@ -13,30 +13,32 @@ Template.caseProgress.onCreated(() => {
|
||||
instance.path = 'viewer.studyViewer.measurements';
|
||||
instance.saveObserver = new Tracker.Dependency();
|
||||
|
||||
instance.saveData = () => {
|
||||
// Clear signaled unsaved changes...
|
||||
const successHandler = () => {
|
||||
OHIF.ui.unsavedChanges.clear(`${instance.path}.*`);
|
||||
instance.saveObserver.changed();
|
||||
};
|
||||
instance.api = {
|
||||
save() {
|
||||
// Clear signaled unsaved changes...
|
||||
const successHandler = () => {
|
||||
OHIF.ui.unsavedChanges.clear(`${instance.path}.*`);
|
||||
instance.saveObserver.changed();
|
||||
};
|
||||
|
||||
// Display the error messages
|
||||
const errorHandler = data => OHIF.ui.showDialog('dialogInfo', data);
|
||||
// Display the error messages
|
||||
const errorHandler = data => OHIF.ui.showDialog('dialogInfo', data);
|
||||
|
||||
const promise = instance.data.measurementApi.storeMeasurements();
|
||||
promise.then(successHandler).catch(errorHandler);
|
||||
OHIF.ui.showDialog('dialogLoading', {
|
||||
promise,
|
||||
text: 'Saving measurement data'
|
||||
});
|
||||
const promise = instance.data.measurementApi.storeMeasurements();
|
||||
promise.then(successHandler).catch(errorHandler);
|
||||
OHIF.ui.showDialog('dialogLoading', {
|
||||
promise,
|
||||
text: 'Saving measurement data'
|
||||
});
|
||||
|
||||
return promise;
|
||||
return promise;
|
||||
}
|
||||
};
|
||||
|
||||
instance.unsavedChangesHandler = () => {
|
||||
const isNotDisabled = !instance.$('.js-finish-case').hasClass('disabled');
|
||||
if (isNotDisabled && instance.progressPercent.get() === 100) {
|
||||
instance.saveData();
|
||||
instance.api.save();
|
||||
}
|
||||
};
|
||||
|
||||
@ -171,22 +173,10 @@ Template.caseProgress.helpers({
|
||||
const instance = Template.instance();
|
||||
|
||||
// Run this computation on save or every time any measurement / timepoint suffer changes
|
||||
OHIF.ui.unsavedChanges.depend();
|
||||
instance.saveObserver.depend();
|
||||
Session.get('LayoutManagerUpdated');
|
||||
|
||||
return OHIF.ui.unsavedChanges.probe('viewer.*') === 0;
|
||||
}
|
||||
});
|
||||
|
||||
Template.caseProgress.events({
|
||||
'click .js-finish-case'(event, instance) {
|
||||
const $this = $(event.currentTarget);
|
||||
|
||||
// Stop here if the tool is disabled
|
||||
if ($this.hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
instance.saveData();
|
||||
}
|
||||
});
|
||||
|
||||
@ -88,6 +88,9 @@ Template.measurementTableRow.events({
|
||||
|
||||
// Repaint the images on all viewports without the removed measurements
|
||||
_.each($('.imageViewerViewport'), element => cornerstone.updateImage(element));
|
||||
|
||||
// Notify that viewer suffered changes
|
||||
OHIF.ui.unsavedChanges.set('viewer.studyViewer.measurements.deleted');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@ -52,6 +52,9 @@ OHIF.measurements.toggleLabelButton = options => {
|
||||
});
|
||||
options.measurement.location = location;
|
||||
options.measurement.description = description;
|
||||
|
||||
// Notify that viewer suffered changes
|
||||
OHIF.ui.unsavedChanges.set('viewer.studyViewer.measurements.renamed');
|
||||
}
|
||||
};
|
||||
buttonView = Blaze.renderWithData(Template.measureFlow, data, options.element);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user