From 094f526d70aad8355e98e6d41df8e38dfdc2cbac Mon Sep 17 00:00:00 2001 From: Bruno Alves de Faria Date: Wed, 16 Nov 2016 10:03:44 -0200 Subject: [PATCH] LT-306: Fixing defaulted study on quick switch --- .../studyTimepointBrowser.js | 25 +++++++++++++++---- .../studyTimepointStudy.html | 2 +- .../studyTimepointStudy.js | 12 +++++++-- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/Packages/ohif-viewerbase/client/components/viewer/studyTimepointBrowser/studyTimepointBrowser.js b/Packages/ohif-viewerbase/client/components/viewer/studyTimepointBrowser/studyTimepointBrowser.js index 1948ca6f0..ca02b2412 100644 --- a/Packages/ohif-viewerbase/client/components/viewer/studyTimepointBrowser/studyTimepointBrowser.js +++ b/Packages/ohif-viewerbase/client/components/viewer/studyTimepointBrowser/studyTimepointBrowser.js @@ -47,6 +47,7 @@ Template.studyTimepointBrowser.onCreated(() => { Template.studyTimepointBrowser.onRendered(() => { const instance = Template.instance(); + // Collapse all timepoints but first when timepoint view type changes instance.autorun(() => { // Runs this computation every time the timepointViewType is changed const type = instance.timepointViewType.get(); @@ -59,22 +60,36 @@ Template.studyTimepointBrowser.onRendered(() => { } }); + // Expand only the timepoints with loaded studies in viewports let lastStudy; + let activeStudiesUids = []; + + // Wait for rerendering and set the timepoint as active + instance.refreshActiveStudies = () => Tracker.afterFlush(() => { + _.each(activeStudiesUids, studyInstanceUid => { + instance.$(`.studyTimepointStudy[data-uid='${studyInstanceUid}']`).addClass('active'); + }); + // Show only first timepoint expanded for key timepoints + instance.$('.timepointEntry:first').addClass('active'); + }); + instance.autorun(() => { // Runs this computation every time the curenty study is changed const currentStudy = instance.data.currentStudy && instance.data.currentStudy.get(); + // Stop here if there's no current study set + if (!currentStudy) { + return; + } + // Check if the study really changed and update the last study if (currentStudy !== lastStudy) { instance.showAdditionalTimepoints.set(false); lastStudy = currentStudy; + activeStudiesUids = [currentStudy.studyInstanceUid]; } - // Wait for rerendering and set the timepoint as active - Tracker.afterFlush(() => { - // Show only first timepoint expanded for key timepoints - instance.$('.timepointEntry:first').addClass('active'); - }); + instance.refreshActiveStudies(); }); }); diff --git a/Packages/ohif-viewerbase/client/components/viewer/studyTimepointBrowser/studyTimepointStudy.html b/Packages/ohif-viewerbase/client/components/viewer/studyTimepointBrowser/studyTimepointStudy.html index f75ab3c12..7eb5e834c 100644 --- a/Packages/ohif-viewerbase/client/components/viewer/studyTimepointBrowser/studyTimepointStudy.html +++ b/Packages/ohif-viewerbase/client/components/viewer/studyTimepointBrowser/studyTimepointStudy.html @@ -1,6 +1,6 @@