Final adjustments to routing behaviors
This commit is contained in:
1 parent
9ccebb76bd
commit
e12fb0de35
24 files changed
+226
-362
No files matched your search
@@ -1,46 +1,65 @@
|
||||
import { Template } from 'meteor/templating';
|
||||
import { Session } from 'meteor/session';
|
||||
import { Router } from 'meteor/iron:router';
|
||||
import { ReactiveVar } from 'meteor/reactive-var';
|
||||
import { OHIF } from 'meteor/ohif:core';
|
||||
|
||||
const studylistContentId = 'studylistTab';
|
||||
let lastContentId;
|
||||
Template.ohifViewer.onCreated(() => {
|
||||
const instance = Template.instance();
|
||||
instance.headerClasses = new ReactiveVar('');
|
||||
|
||||
// Define the OHIF.viewer.data global object
|
||||
OHIF.viewer.data = instance.data.viewerData || {};
|
||||
|
||||
OHIF.header.dropdown.setItems([{
|
||||
action: () => OHIF.ui.showDialog('serverInformationModal'),
|
||||
text: 'Server Information',
|
||||
icon: 'fa fa-server fa-lg',
|
||||
separatorAfter: true
|
||||
}, {
|
||||
action: () => $('#aboutModal').show(),
|
||||
text: 'About',
|
||||
icon: 'fa fa-info'
|
||||
}]);
|
||||
|
||||
instance.autorun(() => {
|
||||
const currentRoute = Router.current();
|
||||
if (!currentRoute) return;
|
||||
const routeName = currentRoute.route.getName();
|
||||
const isViewer = routeName.indexOf('viewer') === 0;
|
||||
|
||||
// Add or remove the strech class from body
|
||||
$(document.body)[isViewer ? 'addClass' : 'removeClass']('stretch');
|
||||
|
||||
// Set the header on its bigger version if the viewer is not opened
|
||||
instance.headerClasses.set(isViewer ? '' : 'header-big');
|
||||
|
||||
// Set the viewer open state on session
|
||||
Session.set('ViewerOpened', isViewer);
|
||||
});
|
||||
});
|
||||
|
||||
Template.ohifViewer.events({
|
||||
'click .js-toggle-studyList'() {
|
||||
const contentId = Session.get('activeContentId');
|
||||
'click .js-toggle-studyList'(event, instance) {
|
||||
event.preventDefault();
|
||||
const isViewer = Session.get('ViewerOpened');
|
||||
|
||||
if (contentId !== studylistContentId) {
|
||||
switchToTab(studylistContentId);
|
||||
if (isViewer) {
|
||||
Router.go('studylist');
|
||||
} else {
|
||||
switchToTab(lastContentId);
|
||||
const { studyInstanceUids } = OHIF.viewer.data;
|
||||
Router.go('viewerStudies', { studyInstanceUids });
|
||||
}
|
||||
},
|
||||
|
||||
'click #serverInformation'() {
|
||||
OHIF.ui.showDialog('serverInformationModal');
|
||||
}
|
||||
});
|
||||
|
||||
Template.ohifViewer.helpers({
|
||||
studyListToggleText() {
|
||||
const contentId = Session.get('activeContentId');
|
||||
const isViewer = Session.get('ViewerOpened');
|
||||
|
||||
// If the Viewer has not been opened yet, 'Back to viewer' should
|
||||
// not be displayed
|
||||
const viewerContentExists = !!Object.keys(OHIF.viewer.data).length;
|
||||
if (!viewerContentExists) {
|
||||
return;
|
||||
}
|
||||
// Return empty if viewer was not opened yet
|
||||
if (!OHIF.viewer.data.studyInstanceUids) return;
|
||||
|
||||
if (contentId === studylistContentId) {
|
||||
return 'Back to viewer';
|
||||
} else {
|
||||
lastContentId = contentId;
|
||||
return 'Study list';
|
||||
}
|
||||
},
|
||||
|
||||
onStudyList() {
|
||||
return (Session.get('activeContentId') === 'studylistTab');
|
||||
return isViewer ? 'Study list' : 'Back to viewer';
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user