[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

@@ -1,4 +1,5 @@
import { Template } from 'meteor/templating';
import { OHIF } from 'meteor/ohif:core';
Template.studyTimepoint.onCreated(() => {
const instance = Template.instance();
@@ -39,9 +40,12 @@ Template.studyTimepoint.events({
// Defines where will be the studies searched
let $studiesTarget = instance.$('.studyTimepoint');
// @TypeSafeStudies
debugger;
if (changed.isQuickSwitch) {
// Changes the current quick switch study
const study = ViewerStudies.findOne({
const study = OHIF.viewer.Studies.findBy({
studyInstanceUid: changed.studyInstanceUid
});
instance.data.currentStudy.set(study);
@@ -2,7 +2,7 @@ import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { _ } from 'meteor/underscore';
import { OHIF } from 'meteor/ohif:core';
import { OHIFError } from '../../../lib/classes/OHIFError';
Template.studyTimepointBrowser.onCreated(() => {
@@ -21,8 +21,11 @@ Template.studyTimepointBrowser.onCreated(() => {
// Get the studies for a specific timepoint
instance.getStudies = timepoint => {
// @TypeSafeStudies
debugger;
if (!timepoint) {
return ViewerStudies.find().fetch();
return OHIF.viewer.Studies.all();
}
return timepoint.studyInstanceUids.map(studyInstanceUid => {
@@ -31,7 +34,7 @@ Template.studyTimepointBrowser.onCreated(() => {
studyInstanceUid: studyInstanceUid
};
const loadedStudy = ViewerStudies.findOne(query);
const loadedStudy = OHIF.viewer.Studies.findBy(query);
if (loadedStudy) {
return loadedStudy;
}
@@ -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() {