2015-10-23 14:08:51 +02:00
|
|
|
|
ViewerData = Session.get('ViewerData') || {};
|
|
|
|
|
|
|
2015-10-15 15:05:41 +02:00
|
|
|
|
Template.worklist.helpers({
|
|
|
|
|
|
'tabs': function() {
|
2015-10-20 15:45:27 +02:00
|
|
|
|
console.log('Updating tabs');
|
|
|
|
|
|
return tabs.find();
|
|
|
|
|
|
}
|
2015-10-15 15:05:41 +02:00
|
|
|
|
});
|
2015-10-13 14:14:50 +02:00
|
|
|
|
|
|
|
|
|
|
Template.worklist.events({
|
2015-10-15 15:05:41 +02:00
|
|
|
|
'click a[data-toggle="tab"]': function(e) {
|
2015-10-23 14:08:51 +02:00
|
|
|
|
var contentId = $(e.currentTarget).data('target').replace("#", "");
|
2015-10-20 15:45:27 +02:00
|
|
|
|
switchToTab(contentId);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
switchToTab = function(contentId) {
|
2015-10-23 14:08:51 +02:00
|
|
|
|
var data = ViewerData[contentId];
|
2015-10-20 15:45:27 +02:00
|
|
|
|
|
|
|
|
|
|
console.log("Switching to tab: " + contentId);
|
2015-10-29 13:50:28 +01:00
|
|
|
|
|
|
|
|
|
|
// Set active tab
|
|
|
|
|
|
Session.set("activeContentId", contentId);
|
|
|
|
|
|
|
2015-10-23 14:08:51 +02:00
|
|
|
|
$('.tabTitle a[data-target="#' + contentId + '"]').tab('show');
|
2015-10-20 15:45:27 +02:00
|
|
|
|
|
|
|
|
|
|
$("#viewer").remove();
|
|
|
|
|
|
|
2015-10-23 14:08:51 +02:00
|
|
|
|
var container = $('.tab-content').find("#" + contentId).get(0);
|
2015-10-20 15:45:27 +02:00
|
|
|
|
if (!container) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-10-23 14:08:51 +02:00
|
|
|
|
if (contentId === 'worklistTab') {
|
2015-10-20 15:45:27 +02:00
|
|
|
|
console.log('Switching to worklist');
|
|
|
|
|
|
document.body.style.overflow = null;
|
|
|
|
|
|
document.body.style.height = null;
|
|
|
|
|
|
document.body.style.minWidth = null;
|
|
|
|
|
|
document.body.style.position = null;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
UI.renderWithData(Template.viewer, data, container);
|
|
|
|
|
|
var imageViewer = $("#viewer");
|
|
|
|
|
|
if (imageViewer) {
|
|
|
|
|
|
document.body.style.overflow = "hidden";
|
|
|
|
|
|
document.body.style.height = '100%';
|
|
|
|
|
|
document.body.style.width = '100%';
|
|
|
|
|
|
document.body.style.minWidth = 0;
|
|
|
|
|
|
document.body.style.position = 'fixed'; // Prevent overscroll on mobile devices
|
2015-10-13 14:14:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-10-20 15:45:27 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Template.worklist.onRendered(function() {
|
|
|
|
|
|
this.autorun(function() {
|
2015-10-23 14:08:51 +02:00
|
|
|
|
var data = Session.get('OpenNewTabEvent');
|
|
|
|
|
|
|
|
|
|
|
|
// If we have no new tab data, stop here
|
|
|
|
|
|
// (e.g. if we are rendering the worklist)
|
|
|
|
|
|
if (!data) {
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var contentId = data.contentid;
|
|
|
|
|
|
if (ViewerData.hasOwnProperty(contentId)) {
|
|
|
|
|
|
console.warn('Contentid already exists?');
|
|
|
|
|
|
return;
|
2015-10-20 15:45:27 +02:00
|
|
|
|
}
|
2015-10-23 14:08:51 +02:00
|
|
|
|
|
|
|
|
|
|
// Update the viewer data object
|
|
|
|
|
|
ViewerData[contentId] = {
|
|
|
|
|
|
contentId: contentId,
|
|
|
|
|
|
studies: data.studies,
|
|
|
|
|
|
title: data.title
|
|
|
|
|
|
};
|
|
|
|
|
|
Session.set('ViewerData', ViewerData);
|
|
|
|
|
|
|
2015-10-29 13:50:28 +01:00
|
|
|
|
|
2015-10-23 14:08:51 +02:00
|
|
|
|
switchToTab(contentId);
|
2015-10-20 15:45:27 +02:00
|
|
|
|
});
|
2015-10-13 14:14:50 +02:00
|
|
|
|
});
|