ohif-viewer/LesionTracker/client/components/toolbarSection/toolbarSection.js
Evren Ozkan 5cbf08ea4f 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
2016-11-15 08:24:30 +01:00

187 lines
5.9 KiB
JavaScript

import { OHIF } from 'meteor/ohif:core';
Template.toolbarSection.helpers({
// Returns true if the view shall be split in two viewports
splitView() {
// Run this computation every time the viewports are updated
Session.get('LayoutManagerUpdated');
// Stops here if layout manager is not defined yet
if (!window.layoutManager) {
return;
}
return window.layoutManager.viewportData.length > 1;
},
leftSidebarToggleButtonData() {
const instance = Template.instance();
return {
toggleable: true,
key: 'leftSidebar',
value: instance.data.state,
options: [{
value: 'studies',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-studies',
svgWidth: 15,
svgHeight: 13,
bottomLabel: 'Studies'
}]
};
},
rightSidebarToggleButtonData() {
const instance = Template.instance();
return {
toggleable: true,
key: 'rightSidebar',
value: instance.data.state,
options: [{
value: 'measurements',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-measurements-lesions',
svgWidth: 18,
svgHeight: 10,
bottomLabel: 'Measurements'
}]
};
},
toolbarButtons() {
// Check if the measure tools shall be disabled
const isToolDisabled = false; //!Template.instance().data.timepointApi;
const buttonData = [];
buttonData.push({
id: 'zoom',
title: 'Zoom',
classes: 'imageViewerTool',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-zoom'
});
buttonData.push({
id: 'wwwc',
title: 'Levels',
classes: 'imageViewerTool',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-levels'
});
buttonData.push({
id: 'pan',
title: 'Pan',
classes: 'imageViewerTool',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-pan'
});
/*
TODO: design the link functionality
Commenting this out until we build this tool
buttonData.push({
id: 'link',
title: 'Link',
classes: 'imageViewerCommand toolbarSectionButton',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-link'
});*/
buttonData.push({
id: 'bidirectional',
title: 'Target',
classes: 'imageViewerTool rm-l-3',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-measure-target',
disabled: isToolDisabled
});
buttonData.push({
id: 'nonTarget',
title: 'Non-Target',
classes: 'imageViewerTool toolbarSectionButton',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-measure-non-target',
disabled: isToolDisabled
});
buttonData.push({
id: 'length',
title: 'Temp',
classes: 'imageViewerTool toolbarSectionButton',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-measure-temp'
});
return buttonData;
},
extraToolbarButtons() {
// Check if the measure tools shall be disabled
const isToolDisabled = false; //!Template.instance().data.timepointApi.currentTimepointId;
const buttonData = [];
// TODO: Get real icons for CR / UN / EX
buttonData.push({
id: 'crTool',
title: 'CR Tool',
classes: 'imageViewerTool toolbarSectionButton',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-measure-temp',
disabled: isToolDisabled
});
buttonData.push({
id: 'unTool',
title: 'UN Tool',
classes: 'imageViewerTool toolbarSectionButton',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-measure-temp',
disabled: isToolDisabled
});
buttonData.push({
id: 'exTool',
title: 'EX Tool',
classes: 'imageViewerTool toolbarSectionButton',
svgLink: '/packages/ohif_viewerbase/assets/icons.svg#icon-tools-measure-temp',
disabled: isToolDisabled
});
return buttonData;
}
});
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();
}
});
Template.toolbarSection.onRendered(function() {
// Set disabled/enabled tool buttons that are set in toolManager
const states = toolManager.getToolDefaultStates();
const disabledToolButtons = states.disabledToolButtons;
const allToolbarButtons = $('.toolbarSection').find('.toolbarSectionButton');
if (disabledToolButtons && disabledToolButtons.length > 0) {
for (var i = 0; i < allToolbarButtons.length; i++) {
const toolbarButton = allToolbarButtons[i];
$(toolbarButton).removeClass('disabled');
const index = disabledToolButtons.indexOf($(toolbarButton).attr('id'));
if (index !== -1) {
$(toolbarButton).addClass('disabled');
}
}
}
});