LT-288: Fixing viewer crash for non associated studies

This commit is contained in:
Bruno Alves de Faria 2016-08-29 09:10:51 -03:00
parent 0eeb05e72b
commit 396f83b449
7 changed files with 88 additions and 38 deletions

View File

@ -26,8 +26,14 @@ class TimepointApi {
}); });
} }
// Return the prior timepoint
prior() { prior() {
const latestDate = this.current().latestDate; const current = this.current();
if (!current) {
return;
}
const latestDate = current.latestDate;
return this.timepoints.findOne({ return this.timepoints.findOne({
latestDate: { latestDate: {
$lt: latestDate $lt: latestDate
@ -41,9 +47,15 @@ class TimepointApi {
// Return only the current and prior Timepoints // Return only the current and prior Timepoints
currentAndPrior() { currentAndPrior() {
let timepoints = [this.current()]; const timepoints = [];
const current = this.current();
if (current) {
timepoints.push(current);
}
const prior = this.prior(); const prior = this.prior();
if (prior) { if (current && prior._id !== current._id) {
timepoints.push(prior); timepoints.push(prior);
} }

View File

@ -7,7 +7,14 @@ Template.caseProgress.onCreated(() => {
instance.progressText = new ReactiveVar(); instance.progressText = new ReactiveVar();
instance.isLocked = new ReactiveVar(); instance.isLocked = new ReactiveVar();
// Get the current timepoint
const current = instance.data.timepointApi.current(); const current = instance.data.timepointApi.current();
// Stop here if no timepoint was found
if (!current) {
return;
}
if (!current.timepointId) { if (!current.timepointId) {
console.warn('Case has no timepointId'); console.warn('Case has no timepointId');
return; return;

View File

@ -1,13 +1,17 @@
<template name="lesionTable"> <template name="lesionTable">
<div id="lesionTableContainer"> <div id="lesionTableContainer">
<div class="lesionTableLayoutChanger viewerRoundedButtonGroup"> {{#if this.timepoints.get.length}}
{{>roundedButtonGroup buttonGroupData}} <div class="lesionTableLayoutChanger viewerRoundedButtonGroup">
</div> {{>roundedButtonGroup buttonGroupData}}
<div class="lesionTableTimepointHeaderRow"> </div>
{{#each this.timepoints.get}} <div class="lesionTableTimepointHeaderRow">
{{>lesionTableTimepointHeader}} {{#each this.timepoints.get}}
{{/each}} {{>lesionTableTimepointHeader}}
</div> {{/each}}
{{>lesionTableView (clone this)}} </div>
{{>lesionTableView (clone this)}}
{{else}}
<h3 class="p-x-1 text-center">No associated timepoint</h3>
{{/if}}
</div> </div>
</template> </template>

View File

@ -16,7 +16,14 @@ Template.lesionTableHeaderRow.onCreated(() => {
const instance = Template.instance(); const instance = Template.instance();
instance.maxNumLesions = new ReactiveVar(); instance.maxNumLesions = new ReactiveVar();
// Get the current timepoint
const current = instance.data.timepointApi.current(); const current = instance.data.timepointApi.current();
// Stop here if no timepoint was found
if (!current) {
return;
}
const timepointType = current.timepointType; const timepointType = current.timepointType;
if (!instance.data.currentTimepointId) { if (!instance.data.currentTimepointId) {

View File

@ -53,7 +53,10 @@ Template.toolbarSection.helpers({
}, },
toolbarButtons() { toolbarButtons() {
var buttonData = []; // Check if the measure tools shall be disabled
const isMesureDisabled = !Template.instance().data.timepointApi.currentTimepointId;
const buttonData = [];
buttonData.push({ buttonData.push({
id: 'zoom', id: 'zoom',
title: 'Zoom', title: 'Zoom',
@ -86,14 +89,16 @@ Template.toolbarSection.helpers({
id: 'bidirectional', id: 'bidirectional',
title: 'Target', title: 'Target',
classes: 'imageViewerTool rm-l-3', classes: 'imageViewerTool rm-l-3',
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-target' svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-target',
disabled: isMesureDisabled
}); });
buttonData.push({ buttonData.push({
id: 'nonTarget', id: 'nonTarget',
title: 'Non-Target', title: 'Non-Target',
classes: 'imageViewerTool toolbarSectionButton', classes: 'imageViewerTool toolbarSectionButton',
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-non-target' svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-non-target',
disabled: isMesureDisabled
}); });
buttonData.push({ buttonData.push({
@ -107,28 +112,33 @@ Template.toolbarSection.helpers({
}, },
extraToolbarButtons() { extraToolbarButtons() {
let buttonData = []; // Check if the measure tools shall be disabled
const isMesureDisabled = !Template.instance().data.timepointApi.currentTimepointId;
const buttonData = [];
// TODO: Get real icons for CR / UN / EX // TODO: Get real icons for CR / UN / EX
buttonData.push({ buttonData.push({
id: 'crTool', id: 'crTool',
title: 'CR Tool', title: 'CR Tool',
classes: 'imageViewerTool toolbarSectionButton', classes: 'imageViewerTool toolbarSectionButton',
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-temp' svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-temp',
disabled: isMesureDisabled
}); });
buttonData.push({ buttonData.push({
id: 'unTool', id: 'unTool',
title: 'UN Tool', title: 'UN Tool',
classes: 'imageViewerTool toolbarSectionButton', classes: 'imageViewerTool toolbarSectionButton',
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-temp' svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-temp',
disabled: isMesureDisabled
}); });
buttonData.push({ buttonData.push({
id: 'exTool', id: 'exTool',
title: 'EX Tool', title: 'EX Tool',
classes: 'imageViewerTool toolbarSectionButton', classes: 'imageViewerTool toolbarSectionButton',
svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-temp' svgLink: '/packages/viewerbase/assets/icons.svg#icon-tools-measure-temp',
disabled: isMesureDisabled
}); });
return buttonData; return buttonData;

View File

@ -1,22 +1,22 @@
<template name="toolbarSectionButton"> <template name="toolbarSectionButton">
{{ #if this.buttonTemplateName }} {{#if this.buttonTemplateName}}
{{> UI.dynamic template=this.buttonTemplateName data=this }} {{>UI.dynamic template=this.buttonTemplateName data=this}}
{{ else }} {{else}}
<div id="{{this.id}}" <div id="{{this.id}}"
class="toolbarSectionButton rp-x-1 {{this.classes}} {{activeClass}}" class="toolbarSectionButton rp-x-1 {{this.classes}} {{activeClass}} {{#if this.disabled}}disabled{{/if}}"
title="{{this.title}}"> title="{{this.title}}">
<div class="svgContainer"> <div class="svgContainer">
{{ #if this.svgLink }} {{#if this.svgLink}}
<svg> <svg>
<use xlink:href={{this.svgLink}}></use> <use xlink:href={{this.svgLink}}></use>
</svg> </svg>
{{ else }} {{else}}
<i class={{iconClasses}}></i> <i class={{iconClasses}}></i>
{{ /if }} {{/if}}
</div>
<div class="buttonLabel">
{{this.title}}
</div>
</div> </div>
<div class="buttonLabel"> {{/if}}
{{this.title}}
</div>
</div>
{{ /if }}
</template> </template>

View File

@ -15,6 +15,11 @@ Template.toolbarSectionButton.helpers({
Template.toolbarSectionButton.events({ Template.toolbarSectionButton.events({
'click .imageViewerTool'(event, instance) { 'click .imageViewerTool'(event, instance) {
// Stop here if the tool is disabled
if ($(event.currentTarget).hasClass('disabled')) {
return;
}
const tool = event.currentTarget.id; const tool = event.currentTarget.id;
const elements = instance.$('.imageViewerViewport'); const elements = instance.$('.imageViewerViewport');
@ -29,6 +34,11 @@ Template.toolbarSectionButton.events({
} }
}, },
'click .imageViewerCommand'(event, instance) { 'click .imageViewerCommand'(event, instance) {
// Stop here if the tool is disabled
if ($(event.currentTarget).hasClass('disabled')) {
return;
}
const command = event.currentTarget.id; const command = event.currentTarget.id;
if (!OHIF.viewer.functionList || !OHIF.viewer.functionList.hasOwnProperty(command)) { if (!OHIF.viewer.functionList || !OHIF.viewer.functionList.hasOwnProperty(command)) {
return; return;