[WIP] Moving ViewerStudies collection to TypeSafeCollection implementation + Fixing sorting bug in findAllBy method in TypeSafeCollection

This commit is contained in:
Emanuel F. Oliveira committed 2017-01-29 22:11:17 -02:00
1 parent a4e7aa86ab
commit d25141f336
18 files changed
+143 -77

No files matched your search

@@ -3,6 +3,7 @@ import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { _ } from 'meteor/underscore';
import { $ } from 'meteor/jquery';
import { OHIF } from 'meteor/ohif:core';
import { sortingManager } from '../../../lib/sortingManager';
Template.studyTimepointStudy.onCreated(() => {
@@ -97,10 +98,12 @@ Template.studyTimepointStudy.events({
const isQuickSwitch = !_.isUndefined(instance.data.viewportIndex);
// @TypeSafeStudies
debugger;
// Check if the study already has series data,
// and if not, retrieve it.
if (!studyData.seriesList) {
const alreadyLoaded = ViewerStudies.findOne({ _id });
const alreadyLoaded = OHIF.viewer.Studies.findBy({ studyInstanceUid });
if (!alreadyLoaded) {
const $studies = instance.getStudyElement(true);
@@ -108,12 +111,10 @@ Template.studyTimepointStudy.events({
getStudyMetadata(studyInstanceUid, study => {
study.displaySets = sortingManager.getDisplaySets(study);
instance.data.study = study;
ViewerStudies.insert(study, () => {
// To make sure studies are rendered in the DOM
// use minimongo insert callback
$studies.trigger('loadEnded');
instance.select(isQuickSwitch);
});
OHIF.viewer.Studies.insert(study);
// make sure studies are rendered in the DOM
$studies.trigger('loadEnded');
instance.select(isQuickSwitch);
});
} else {
studyData.seriesList = alreadyLoaded.seriesList;
@@ -126,9 +127,11 @@ Template.studyTimepointStudy.events({
Template.studyTimepointStudy.helpers({
isLoading() {
// @TypeSafeStudies
debugger;
const instance = Template.instance();
const studyData = instance.data.study;
const alreadyLoaded = ViewerStudies.findOne({ _id: studyData._id });
const alreadyLoaded = OHIF.viewer.Studies.findBy({ studyInstanceUid: studyData.studyInstanceUid });
return instance.loading.get() && !alreadyLoaded;
},
modalities() {