-
- {{> worklistSearch }}
- {{> worklistResult }}
-
+
+ -
+ Study List
+
+ {{ #each tabs }}
+ {{ >tabTitle }}
+ {{ /each }}
+
+
+
+
+ {{> worklistSearch }}
+ {{> worklistResult }}
+ {{ #each tabs }}
+ {{ >tabContent }}
+ {{ /each }}
\ No newline at end of file
diff --git a/Packages/worklist/components/worklist.js b/Packages/worklist/components/worklist.js
index da038100e..7d55e56ee 100644
--- a/Packages/worklist/components/worklist.js
+++ b/Packages/worklist/components/worklist.js
@@ -1,110 +1,43 @@
-var contentID = "";
-
-//Generate UUID to create unique tabs
-function generateUUID () {
- var d = new Date().getTime();
- var uuid = 'xxxxxxxx'.replace(/[xy]/g, function(c) {
- var r = (d + Math.random()*8)%8 | 0;
- d = Math.floor(d/8);
- return (c=='x' ? r : (r&0x3|0x8)).toString(8);
- });
- return uuid;
-}
-
-//Remove tab
-function removeTab (uuid) {
- var removedTabIndex = $("#tab"+uuid).index();
- //Remove tab
- $("#tab"+uuid).remove();
- //Remove Content
- $("#content"+uuid).remove();
-
- //TODO:Activate previous tab
-
-}
-
-//Add new tab
-function addNewTab (data) {
- //Make inactive all tabs
- $("#tabs > li").removeClass("active");
- $("#tabs-content > div").removeClass("active");
-
- //Create new li element for tab
- var tabli = document.createElement("li");
- $(tabli).addClass("active");
- $("#tabs").append(tabli);
-
- //a element inside li
- var taba = document.createElement("a");
- var uuid = generateUUID();
- var tabId = "tab"+uuid;
-
-
- //activeTabId provides unique tabs content and encapsulates templates in tabs
- Session.set("activeTabId", tabId);
- console.log(Session.get("activeTabId"));
-
- //Create tab
- taba.setAttribute("data-toggle","tab");
- taba.setAttribute("id",tabId);
- taba.innerHTML = data.patientName;
- tabli.appendChild(taba);
-
- //Create close button
- var btnClose = document.createElement('button');
- $(btnClose).addClass("btnClose");
- btnClose.innerHTML = "x";
- btnClose.onclick = function() { // Note this is a function
- removeTab(uuid);
- };
- taba.appendChild(btnClose);
-
- //Create div content
- var tabContent = document.createElement("div");
- var contentId = "content"+uuid;
- tabContent.setAttribute("id",contentId);
- $(tabContent).css("background-color", "black");
- $(tabContent).addClass("tab-pane");
- $(tabContent).addClass("active");
- $("#tabs-content").append(tabContent);
-
- contentID = contentId;
-}
-
-function insertContent() {
- console.log('Include imageViewer template');
- //Include imageViewer template
- UI.insert( UI.render( Template.viewer ), $( '#'+contentID ).get(0) );
-}
-
-Template.worklist.events({
- 'click ul#tabs>li>a': function (event){
- var tabId = $(event.target).attr("id");
- if ( tabId !== undefined ) {
- //Save activeTabId to load correct study for each tab
- Session.set("activeTabId", tabId);
-
- var splitTabId = tabId.split("tab");
- var contentId = "content"+splitTabId[1];
-
- //Make inactive all tab-pane divs
- $("#tabs-content>div").removeClass("active");
- $("#"+contentId).addClass("active");
- }
- }
+Template.worklist.helpers({
+ 'tabs': function() {
+ var tabData = tabs.find().fetch();
+ return tabData;
+ },
});
-Tracker.autorun(function () {
- var data = Session.get('openNewTabEvent');
- var content = Session.get('showContentInTab');
- if ( data ) {
- addNewTab(data);
- }
+Template.worklist.events({
+ 'click a[data-toggle="tab"]': function(e) {
+ console.log(e.currentTarget);
+ var contentId = $(e.currentTarget).data('target');
+ $(e.currentTarget).tab('show');
- if (content) {
- insertContent();
- }
+ var container = $('.tab-content').find(contentId).get(0);
+ var studies = Session.get('StudiesInTab' + contentId);
+ var data = {
+ studies: studies
+ };
- Session.set('openNewTabEvent', false);
- Session.set('showContentInTab', false);
+ if (contentId === '#worklistTab') {
+ console.log('Switching to worklist');
+ $("#viewer").remove();
+ 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) {
+ $('.navbar-default').css({
+ 'background-color': '#000000',
+ 'border-color': '#101010'
+ });
+ 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
+ }
+ }
+ }
});
\ No newline at end of file
diff --git a/Packages/worklist/components/worklistStudy/worklistStudy.js b/Packages/worklist/components/worklistStudy/worklistStudy.js
index 244c56faa..389460128 100644
--- a/Packages/worklist/components/worklistStudy/worklistStudy.js
+++ b/Packages/worklist/components/worklistStudy/worklistStudy.js
@@ -1,18 +1,5 @@
Template.worklistStudy.events({
'click': function (){
Router.go('viewer', {_id: this.studyInstanceUid});
-
- Session.set('openNewTabEvent', self);
- var studyInstanceUid = this.studyInstanceUid;
- Meteor.call('GetStudyMetadata', studyInstanceUid, function(error, study) {
- //console.log(study);
- sortStudy(study);
-
- var studies = [study];
- Session.set('studies', studies);
- Session.set(activeTabId, studies);
- Session.set('showContentInTab', true);
- self.render('viewer');
- });
}
});
\ No newline at end of file
diff --git a/Packages/worklist/lib/generateUUID.js b/Packages/worklist/lib/generateUUID.js
new file mode 100644
index 000000000..a03d70e59
--- /dev/null
+++ b/Packages/worklist/lib/generateUUID.js
@@ -0,0 +1,10 @@
+//Generate UUID to create unique tabs
+generateUUID = function() {
+ var d = new Date().getTime();
+ var uuid = 'xxxxxxxx'.replace(/[xy]/g, function(c) {
+ var r =(d + Math.random()*8)%8 | 0;
+ d = Math.floor(d/8);
+ return(c=='x' ? r :(r&0x3|0x8)).toString(8);
+ });
+ return uuid;
+};
\ No newline at end of file
diff --git a/Packages/worklist/package.js b/Packages/worklist/package.js
index 267373698..c51c02f2a 100644
--- a/Packages/worklist/package.js
+++ b/Packages/worklist/package.js
@@ -16,6 +16,12 @@ Package.onUse(function (api) {
api.addFiles('components/worklist.js', 'client');
api.addFiles('components/worklist.styl', 'client');
+ api.addFiles('components/tabTitle/tabTitle.html', 'client');
+ api.addFiles('components/tabTitle/tabTitle.js', 'client');
+ api.addFiles('components/tabTitle/tabTitle.styl', 'client');
+
+ api.addFiles('components/tabContent/tabContent.html', 'client');
+
api.addFiles('components/worklistStudy/worklistStudy.html', 'client');
api.addFiles('components/worklistStudy/worklistStudy.js', 'client');
api.addFiles('components/worklistStudy/worklistStudy.styl', 'client');
@@ -27,5 +33,8 @@ Package.onUse(function (api) {
api.addFiles('components/worklistSearch/worklistSearch.html', 'client');
api.addFiles('components/worklistSearch/worklistSearch.js', 'client');
api.addFiles('components/worklistSearch/worklistSearch.styl', 'client');
+
+ api.addFiles('lib/generateUUID.js', 'client');
+ api.export('generateUUID', 'client');
});