ohif-viewer/OHIFViewer/client/components/ohifViewer/ohifViewer.js

50 lines
1.3 KiB
JavaScript
Raw Normal View History

import { Template } from 'meteor/templating';
import { Session } from 'meteor/session';
2016-10-01 18:58:21 +02:00
const studylistContentId = 'studylistTab';
let lastContentId;
// Define the ViewerData global object
// If there is currently any Session data for this object,
// use this to repopulate the variable
Template.ohifViewer.onCreated(() => {
ViewerData = Session.get('ViewerData') || {};
});
Template.ohifViewer.events({
'click .js-toggle-studyList'() {
const contentId = Session.get('activeContentId');
2016-10-01 18:58:21 +02:00
if (contentId !== studylistContentId) {
switchToTab(studylistContentId);
} else {
switchToTab(lastContentId);
}
}
});
Template.ohifViewer.helpers({
studyListToggleText() {
const contentId = Session.get('activeContentId');
Session.get('ViewerData');
// If the Viewer has not been opened yet, 'Back to viewer' should
// not be displayed
const viewerContentExists = !!Object.keys(ViewerData).length;
if (!viewerContentExists) {
return;
}
2016-10-01 18:58:21 +02:00
if (contentId === studylistContentId) {
return 'Back to viewer';
} else {
lastContentId = contentId;
return 'Study list';
}
},
onStudyList() {
2016-10-01 18:58:21 +02:00
return (Session.get('activeContentId') === 'studylistTab');
}
});