bugFix(issue163) Save button not appearing and saved measurements not getting drawn in canvas (#196)
This commit is contained in:
parent
5785d19ee1
commit
b8506b5dae
@ -7,6 +7,12 @@
|
|||||||
|
|
||||||
{{>toolbarSectionTools toolbarButtons=toolbarButtons}}
|
{{>toolbarSectionTools toolbarButtons=toolbarButtons}}
|
||||||
|
|
||||||
|
<div class="pull-right m-t-1 rm-x-1">
|
||||||
|
{{#form (extend api=instance.api)}}
|
||||||
|
{{#button class='btn p-x-2' action='save' disabled=(isFinishDisabled)}}Save{{/button}}
|
||||||
|
{{/form}}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="toggleMeasurements" class="pull-right m-t-1 rm-x-1">
|
<div id="toggleMeasurements" class="pull-right m-t-1 rm-x-1">
|
||||||
{{>roundedButtonGroup rightSidebarToggleButtonData}}
|
{{>roundedButtonGroup rightSidebarToggleButtonData}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,9 +1,21 @@
|
|||||||
import { Template } from 'meteor/templating';
|
import { Template } from 'meteor/templating';
|
||||||
import { Session } from 'meteor/session';
|
import { Session } from 'meteor/session';
|
||||||
|
import { Tracker } from 'meteor/tracker';
|
||||||
import { OHIF } from 'meteor/ohif:core';
|
import { OHIF } from 'meteor/ohif:core';
|
||||||
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
import { Viewerbase } from 'meteor/ohif:viewerbase';
|
||||||
|
|
||||||
Template.toolbarSection.helpers({
|
Template.toolbarSection.helpers({
|
||||||
|
isFinishDisabled() {
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
|
||||||
leftSidebarToggleButtonData() {
|
leftSidebarToggleButtonData() {
|
||||||
const instance = Template.instance();
|
const instance = Template.instance();
|
||||||
return {
|
return {
|
||||||
@ -235,6 +247,46 @@ Template.toolbarSection.events({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Template.toolbarSection.onCreated( function() {
|
||||||
|
const instance = Template.instance();
|
||||||
|
|
||||||
|
instance.path = 'viewer.studyViewer.measurements';
|
||||||
|
instance.saveObserver = new Tracker.Dependency();
|
||||||
|
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', Object.assign({ class: 'themed' }, data));
|
||||||
|
};
|
||||||
|
|
||||||
|
const promise = instance.data.measurementApi.storeMeasurements();
|
||||||
|
promise.then(successHandler).catch(errorHandler);
|
||||||
|
OHIF.ui.showDialog('dialogLoading', {
|
||||||
|
promise,
|
||||||
|
text: 'Saving measurement data'
|
||||||
|
});
|
||||||
|
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
instance.unsavedChangesHandler = () => {
|
||||||
|
const isNotDisabled = !instance.$('.js-finish-case').hasClass('disabled');
|
||||||
|
if (isNotDisabled && instance.progressPercent.get() === 100) {
|
||||||
|
instance.api.save();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Attach handler for unsaved changes dialog...
|
||||||
|
OHIF.ui.unsavedChanges.attachHandler(instance.path, 'save', instance.unsavedChangesHandler);
|
||||||
|
});
|
||||||
|
|
||||||
Template.toolbarSection.onRendered(function() {
|
Template.toolbarSection.onRendered(function() {
|
||||||
// Set disabled/enabled tool buttons that are set in toolManager
|
// Set disabled/enabled tool buttons that are set in toolManager
|
||||||
const states = Viewerbase.toolManager.getToolDefaultStates();
|
const states = Viewerbase.toolManager.getToolDefaultStates();
|
||||||
@ -259,3 +311,9 @@ Template.toolbarSection.onRendered(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Template.caseProgress.onDestroyed(() => {
|
||||||
|
const instance = Template.instance();
|
||||||
|
// Remove unsaved changes handler after this view has been destroyed...
|
||||||
|
OHIF.ui.unsavedChanges.removeHandler(instance.path, 'save', instance.unsavedChangesHandler);
|
||||||
|
});
|
||||||
|
|||||||
@ -21,3 +21,7 @@
|
|||||||
min-width: 30px
|
min-width: 30px
|
||||||
theme('stroke', '$defaultColor')
|
theme('stroke', '$defaultColor')
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
||||||
|
.saveMeasurements
|
||||||
|
display: inline-block
|
||||||
|
margin-left: 22px
|
||||||
|
|||||||
@ -8,7 +8,7 @@ OHIF.measurements.syncMeasurementAndToolData = measurement => {
|
|||||||
|
|
||||||
// Stop here if the metadata for the measurement's study is not loaded yet
|
// Stop here if the metadata for the measurement's study is not loaded yet
|
||||||
const { studyInstanceUid } = measurement;
|
const { studyInstanceUid } = measurement;
|
||||||
const metadata = OHIF.viewer.StudyMetadataList.findBy({ studyInstanceUid });
|
const metadata = OHIF.viewer.StudyMetadataList.findBy({ "studyInstanceUID": studyInstanceUid });
|
||||||
if (!metadata) return;
|
if (!metadata) return;
|
||||||
|
|
||||||
// Iterate each child tool if the current tool has children
|
// Iterate each child tool if the current tool has children
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user