LT-290 Disable Lesion Tracker tool buttons if the opened study is not associated

- Fix the bug with temp lesion when the study is not associated
This commit is contained in:
Evren Ozkan 2016-11-03 14:20:11 -04:00 committed by Erik Ziegler
parent 7fa242d0aa
commit 5cbf08ea4f
5 changed files with 54 additions and 9 deletions

View File

@ -28,7 +28,7 @@
</div>
<div class="buttonLabel">HUD</div>
</div>
<div class="toolbarSectionButton pull-right rp-x-1 m-t-1 rm-r-1" data-toggle="modal" data-target="#optionsModal">
<div id="toggleTrial" class="toolbarSectionButton pull-right rp-x-1 m-t-1 rm-r-1">
<div class="svgContainer">
<svg>
<use xlink:href="/packages/ohif_viewerbase/assets/icons.svg#icon-trial-info"></use>

View File

@ -145,8 +145,25 @@ Template.toolbarSection.helpers({
Template.toolbarSection.events({
'click #toggleHUD'() {
const $this = $(event.currentTarget).find('#toggleHUD');
// Stop here if the tool is disabled
if ($this.hasClass('disabled')) {
return;
}
const state = Session.get('measurementTableHudOpen');
Session.set('measurementTableHudOpen', !state);
},
'click #toggleTrial'() {
const $this = $(event.currentTarget).find('#toggleHUD');
// Stop here if the tool is disabled
if ($this.hasClass('disabled')) {
return;
}
$('#optionsModal').modal();
}
});
@ -154,15 +171,15 @@ Template.toolbarSection.onRendered(function() {
// Set disabled/enabled tool buttons that are set in toolManager
const states = toolManager.getToolDefaultStates();
const disabledToolButtons = states.disabledToolButtons;
const allToolbarButtons = $('#toolbar').find('button');
const allToolbarButtons = $('.toolbarSection').find('.toolbarSectionButton');
if (disabledToolButtons && disabledToolButtons.length > 0) {
for (var i = 0; i < allToolbarButtons.length; i++) {
const toolbarButton = allToolbarButtons[i];
$(toolbarButton).prop('disabled', false);
$(toolbarButton).removeClass('disabled');
const index = disabledToolButtons.indexOf($(toolbarButton).attr('id'));
if (index !== -1) {
$(toolbarButton).prop('disabled', true);
$(toolbarButton).addClass('disabled');
}
}
}

View File

@ -81,6 +81,14 @@ Template.viewer.onCreated(() => {
if (prior) {
instance.data.measurementApi.priorTimepointId = prior.timepointId;
}
if (instance.data.currentTimepointId) {
// Enable Lesion Tracker Tools if the opened study is associated
OHIF.lesiontracker.toggleLesionTrackerToolsButtons(true);
} else {
// Disable Lesion Tracker Tools if the opened study is not associated
OHIF.lesiontracker.toggleLesionTrackerToolsButtons(false);
}
});
Template.viewer.helpers({

View File

@ -41,3 +41,21 @@ OHIF.lesiontracker.toggleLesionTrackerTools = () => {
toolsShown = true;
}
};
OHIF.lesiontracker.toggleLesionTrackerToolsButtons = (isEnabled) => {
const toolStates = previousStates || toolManager.getToolDefaultStates();
if (isEnabled) {
toolStates.disabledToolButtons = [];
} else {
toolStates.disabledToolButtons = [ 'bidirectional', 'nonTarget', 'crTool', 'unTool', 'exTool', 'toggleHUD', 'toggleTrial', 'toolbarSectionEntry' ];
}
// Reload the updated previous or default states
toolManager.setToolDefaultStates(toolStates);
// Reset the active tool if disabled
if (!isEnabled) {
toolManager.setActiveTool();
}
};

View File

@ -53,12 +53,14 @@ class MeasurementHandlers {
const timepointApi = instance.data.timepointApi;
if (timepointApi) {
const timepoint = timepointApi.study(studyInstanceUid)[0];
const timepointId = timepoint.timepointId;
measurement.timepointId = timepointId;
measurement.measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, Collection, timepointApi);
if (timepoint) {
const timepointId = timepoint.timepointId;
measurement.timepointId = timepointId;
measurement.measurementNumber = OHIF.measurements.MeasurementManager.getNewMeasurementNumber(timepointId, Collection, timepointApi);
// TODO: Fix this
measurement.measurementNumberAbsolute = measurement.measurementNumber;
// TODO: Fix this
measurement.measurementNumberAbsolute = measurement.measurementNumber;
}
} else {
const numCurrentMeasurementsInStudy = Collection.find({
studyInstanceUid: study.studyInstanceUid