- Do not attempt to get studies metadata if ViewerData already has studies property and use it to view studies in tab (for cases when a tab is opened with metadata externally)

- Add showStudyListTab helper whether to show StudyListTab in worklist template - it is shown by default (it is not shown only if "data.showStudyListTab" is set to false when rendering worklist template)
This commit is contained in:
Evren Ozkan 2016-06-16 18:36:38 -04:00
parent 7c64341284
commit 5a680261c7
3 changed files with 92 additions and 64 deletions

View File

@ -1,18 +1,22 @@
<template name="worklist"> <template name="worklist">
<ul class="nav noselect" role="tablist" id="tablist"> <ul class="nav noselect" role="tablist" id="tablist">
{{#if showStudyListTab }}
<li role="presentation" class="tabTitle active"> <li role="presentation" class="tabTitle active">
<a data-target="#worklistTab" role="tab" data-toggle="tab">Study List</a> <a data-target="#worklistTab" role="tab" data-toggle="tab">Study List</a>
</li> </li>
{{/if}}
{{#each worklistTabs }} {{#each worklistTabs }}
{{>tabTitle }} {{>tabTitle }}
{{/each }} {{/each }}
</ul> </ul>
<div id="worklistTabs" class="tab-content"> <div id="worklistTabs" class="tab-content">
{{#if showStudyListTab }}
<div role="tabpanel" class="tab-pane active" id="worklistTab"> <div role="tabpanel" class="tab-pane active" id="worklistTab">
<div class="worklistContainer"> <div class="worklistContainer">
{{> worklistResult }} {{> worklistResult }}
</div> </div>
</div> </div>
{{/if}}
{{#each worklistTabs }} {{#each worklistTabs }}
{{>tabContent }} {{>tabContent }}
{{/each }} {{/each }}

View File

@ -43,6 +43,20 @@ Template.worklist.helpers({
*/ */
worklistTabs: function() { worklistTabs: function() {
return WorklistTabs.find(); return WorklistTabs.find();
},
showStudyListTab: function() {
// StudyListTab is shown by default
const instance = Template.instance();
if (!instance.data) {
return true;
}
var showStudyListTab = instance.data.showStudyListTab;
if (showStudyListTab === undefined) {
return true;
}
return showStudyListTab;
} }
}); });

View File

@ -47,12 +47,24 @@ switchToTab = function(contentId) {
return; return;
} }
var studies = ViewerData[contentId].studies;
if (studies) {
// ViewerData already has the meta data (in cases when worklist is launched externally)
viewStudiesInTab(contentId, studies);
} else {
// Use the stored ViewerData global object to retrieve the studyInstanceUid // Use the stored ViewerData global object to retrieve the studyInstanceUid
// related to this tab // related to this tab
var studyInstanceUids = ViewerData[contentId].studyInstanceUids; var studyInstanceUids = ViewerData[contentId].studyInstanceUids;
// Attempt to retrieve the meta data (it might be cached) // Attempt to retrieve the meta data (it might be cached)
getStudiesMetadata(studyInstanceUids, function(studies) { getStudiesMetadata(studyInstanceUids, function(studies) {
viewStudiesInTab(contentId, studies);
});
}
};
function viewStudiesInTab(contentId, studies) {
// Tab closed while study data was being retrieved, stop here // Tab closed while study data was being retrieved, stop here
if (!ViewerData[contentId]) { if (!ViewerData[contentId]) {
log.warn('Tab closed while study data was being retrieved'); log.warn('Tab closed while study data was being retrieved');
@ -69,7 +81,6 @@ switchToTab = function(contentId) {
data.studies = ViewerData[contentId].studies; data.studies = ViewerData[contentId].studies;
} }
// Add additional metadata to our study from the worklist // Add additional metadata to our study from the worklist
data.studies.forEach(function(study) { data.studies.forEach(function(study) {
var worklistStudy = WorklistStudies.findOne({ var worklistStudy = WorklistStudies.findOne({
@ -114,5 +125,4 @@ switchToTab = function(contentId) {
// Prevent overscroll on mobile devices // Prevent overscroll on mobile devices
document.body.style.position = 'fixed'; document.body.style.position = 'fixed';
} }
}); }
};