fix(save-measurements): Prevent users from saving by hotkey when saving is disabled
This commit is contained in:
parent
303c94c3b0
commit
63a9fdab62
@ -14,6 +14,7 @@ import './getTimepointName';
|
||||
import './getToolConfiguration';
|
||||
import './hangingProtocolCustomizations';
|
||||
import './isNewLesionsMeasurement';
|
||||
import './isSaveDisabled';
|
||||
import './MeasurementHandlers';
|
||||
import './MeasurementManager';
|
||||
import './navigateOverLesions';
|
||||
|
||||
24
Packages/ohif-measurements/client/lib/isSaveDisabled.js
Normal file
24
Packages/ohif-measurements/client/lib/isSaveDisabled.js
Normal file
@ -0,0 +1,24 @@
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
OHIF.measurements.isSaveDisabled = timepointId => {
|
||||
const basePath = `viewer.studyViewer.measurements.${timepointId}`;
|
||||
|
||||
// Get the timepoint object
|
||||
const timepoint = OHIF.viewer.timepointApi.timepoints.findOne({ timepointId });
|
||||
|
||||
// Check if the timepoint is locked
|
||||
let isLocked = (timepoint && timepoint.isLocked);
|
||||
if (typeof isLocked === 'undefined') {
|
||||
isLocked = true;
|
||||
}
|
||||
|
||||
// Check if the given timepoint suffered changes
|
||||
const hasChanges = OHIF.ui.unsavedChanges.probe(basePath) !== 0;
|
||||
|
||||
// Check if the given timepoint has nonconformities
|
||||
const nonconformities = OHIF.viewer.conformanceCriteria.nonconformities.get();
|
||||
const hasNonconformities = nonconformities && !!nonconformities.length;
|
||||
|
||||
// Prevent saving if timepoint is locked, has no changes or has nonconformities
|
||||
return isLocked || !hasChanges || hasNonconformities;
|
||||
};
|
||||
@ -4,12 +4,10 @@ OHIF.measurements.saveMeasurements = (measurementApi, timepointId) => {
|
||||
const { unsavedChanges, notifications, showDialog } = OHIF.ui;
|
||||
const basePath = `viewer.studyViewer.measurements.${timepointId}`;
|
||||
|
||||
// Stop here if there are nonconformities in the timepoints
|
||||
const nonconformities = OHIF.viewer.conformanceCriteria.nonconformities.get();
|
||||
if (nonconformities.length) return;
|
||||
|
||||
// Stop here if there were no changes to the timepoint
|
||||
if (unsavedChanges.probe(basePath) === 0) return;
|
||||
// Prevent saving if it's disabled
|
||||
if (OHIF.measurements.isSaveDisabled(timepointId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear unsaved changes state and display success message
|
||||
const successHandler = () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user