Finishing case progress and save behavior

This commit is contained in:
Bruno Alves de Faria committed 2018-02-02 09:21:42 -02:00
1 parent abe7691730
commit 45a3cdeaf5
13 files changed
+87 -56

No files matched your search

@@ -0,0 +1,31 @@
import { OHIF } from 'meteor/ohif:core';
OHIF.measurements.saveMeasurements = (measurementApi, timepointId) => {
const { unsavedChanges, notifications, showDialog } = OHIF.ui;
const basePath = `viewer.studyViewer.measurements.${timepointId}`;
// Stop here if there were no changes to the timepoint
if (unsavedChanges.probe(basePath) === 0) return;
// Clear unsaved changes state and display success message
const successHandler = () => {
unsavedChanges.clear(basePath, true);
notifications.success({ text: 'The measurement data was successfully saved' });
};
// Display the error messages
const errorHandler = data => {
showDialog('dialogInfo', Object.assign({ class: 'themed' }, data));
};
// Call the storage method and display a loading overlay
const promise = measurementApi.storeMeasurements(timepointId);
promise.then(successHandler).catch(errorHandler);
showDialog('dialogLoading', {
promise,
text: 'Saving measurement data'
});
// Return the save promise
return promise;
};