2016-09-29 17:25:04 +02:00
|
|
|
import { Template } from 'meteor/templating';
|
|
|
|
|
import { Session } from 'meteor/session';
|
|
|
|
|
|
2016-10-01 18:58:21 +02:00
|
|
|
const studylistContentId = 'studylistTab';
|
2016-08-04 10:42:34 +02:00
|
|
|
let lastContentId;
|
|
|
|
|
|
2016-07-23 20:11:01 +02:00
|
|
|
// 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);
|
2016-07-23 20:11:01 +02:00
|
|
|
} else {
|
2016-08-04 10:42:34 +02:00
|
|
|
switchToTab(lastContentId);
|
2016-07-23 20:11:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Template.ohifViewer.helpers({
|
|
|
|
|
studyListToggleText() {
|
|
|
|
|
const contentId = Session.get('activeContentId');
|
2016-08-04 10:42:34 +02:00
|
|
|
Session.get('ViewerData');
|
2016-07-23 20:11:01 +02:00
|
|
|
|
|
|
|
|
// 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) {
|
2016-07-23 20:11:01 +02:00
|
|
|
return 'Back to viewer';
|
|
|
|
|
} else {
|
2016-08-04 10:42:34 +02:00
|
|
|
lastContentId = contentId;
|
2016-07-23 20:11:01 +02:00
|
|
|
return 'Study list';
|
|
|
|
|
}
|
|
|
|
|
},
|
2016-09-29 17:25:04 +02:00
|
|
|
|
2016-07-23 20:11:01 +02:00
|
|
|
onStudyList() {
|
2016-10-01 18:58:21 +02:00
|
|
|
return (Session.get('activeContentId') === 'studylistTab');
|
2016-07-23 20:11:01 +02:00
|
|
|
}
|
|
|
|
|
});
|