Creating ohif-studies package to deal with studies browsing

This commit is contained in:
Bruno Alves de Faria committed 2017-10-25 22:09:08 -02:00
1 parent 956e6da0b3
commit 0b51a53976
28 files changed
+323 -83

No files matched your search

@@ -0,0 +1,5 @@
import './list.html';
import './list.js';
import './item.html';
import './item.js';
import './item.styl';
@@ -0,0 +1,21 @@
<template name="studyBrowserItem">
<div class="study-browser-item {{this.settings.studyItemClass}} {{#if isActive}}active{{/if}} {{#if isLoading}}loading{{/if}}" data-uid="{{this.studyInformation.studyInstanceUid}}">
<div class="study-item">
{{#if isLoading}}
{{>loadingText}}
{{/if}}
<div class="study-item-box">
<div class="study-modality">
<div class="study-modality-text" style="{{modalityStyle}}">{{instance.modalities}}</div>
</div>
<div class="study-text">
<div class="study-date">{{formatDA this.studyInformation.date 'D-MMM-YYYY'}}</div>
<div class="study-description">{{this.studyInformation.description}}</div>
</div>
</div>
</div>
{{#if this.settings.studyTemplate}}
{{>Template.dynamic template=this.settings.studyTemplate data=(clone this)}}
{{/if}}
</div>
</template>
@@ -0,0 +1,43 @@
import { Template } from 'meteor/templating';
import { $ } from 'meteor/jquery';
Template.studyBrowserItem.onCreated(() => {
const instance = Template.instance();
const modality = instance.data.studyInformation.modality || 'UN';
instance.modalities = modality.replace(/\\/g, ' ');
});
Template.studyBrowserItem.events({
'click .study-browser-item'(event, instance) {
const element = event.currentTarget;
const $element = $(element);
$element.trigger('ohif.studies.study.click', instance.data.studyInformation);
const { settings, studyInformation } = instance.data;
if (settings && typeof settings.studyClickCallback) {
settings.studyClickCallback(studyInformation, element);
}
}
});
Template.studyBrowserItem.helpers({
modalityStyle() {
// Responsively styles the Modality Acronyms for studies
// with more than one modality
const instance = Template.instance();
const numModalities = instance.modalities.split(/\s/g).length;
if (numModalities === 1) {
// If we have only one modality, it should take up the whole div.
return 'font-size: 1em';
} else if (numModalities === 2) {
// If we have two, let them sit side-by-side
return 'font-size: 0.75em';
} else {
// If we have more than two modalities, change the line height to display multiple rows,
// depending on the number of modalities we need to display.
const lineHeight = Math.ceil(numModalities / 2) * 1.2;
return 'line-height: ' + lineHeight + 'em';
}
}
});
@@ -0,0 +1,132 @@
@require '{ohif:design}/app'
$boxBorderColor = transparent
$boxHoverBackgroundColor = #14191E
$boxHoverBorderColor = #2d4660
$boxActiveBorderColor = #131D29
$boxWidth = 50px
$borderThickness = 2px
$boxBorderRadius = 8px
$nestingMargin = 6px
$spacerX = 7px
$spacerY = 12px
.study-browser-item
position: relative
// required transformation to make inner fixed elements relative to this one
transform(scale(1))
.loadingTextDiv
padding: 25px
border-radius: 12px
position: absolute
opacity: 0
z-index: 100
background-color: $boxHoverBackgroundColor
pointer-events: none
margin: 0
&.loading
.loadingTextDiv
height: 100%
left: 0
opacity: 0.75
right: 16px
.study-item-box
opacity: 0.2
&.active
.study-item-box
.study-modality
theme('color', '$primaryBackgroundColor')
&
&:before
&:after
theme('background-color', '$activeColor')
border-color: $boxActiveBorderColor
&:not(.active) .studyTimepointThumbnails
max-height: 0 !important
.studyTimepointThumbnails
overflow: hidden
transition($sidebarTransition)
.study-item-box
border: 1px solid $boxBorderColor
border-radius: 12px
cursor: pointer
padding: $spacerY $spacerX ($spacerY - 1)
position: relative
transition($sidebarTransition)
z-index: 1
&:hover
background-color: $boxHoverBackgroundColor
border-color: $boxHoverBorderColor
&.additional
theme('color', '$textSecondaryColor')
&.additional
theme('color', '$textPrimaryColor')
font-size: 16px
font-weight: normal
height: 91px
line-height: 91px
padding: 0
text-align: center
.study-text
font-size: 13px
left: ($spacerX * 3) + $boxWidth + ($nestingMargin * 3)
line-height: 14px
position: absolute
right: $spacerX
top: $spacerY
.study-date
margin-top: 8px
theme('color', '$textSecondaryColor')
.study-description
margin-top: 8px
theme('color', '$textPrimaryColor')
.study-modality
theme('color', '$textSecondaryColor')
font-size: 20px
line-height: $boxWidth
margin-left: $nestingMargin * 2
margin-top: $nestingMargin * 2
position: relative
.study-modality-text
text-align: center
text-transform: uppercase
height: 100%
&
&:before
&:after
theme('border', '%s solid $primaryBackgroundColor' % $borderThickness)
theme('background-color', '$boxBackgroundColor')
border-radius: $boxBorderRadius
height: $boxWidth + ($borderThickness * 2)
transition($sidebarTransition)
width: $boxWidth + ($borderThickness * 2)
&:before
&:after
display: block
content: ''
position: absolute
&:before
top: -($borderThickness + $nestingMargin)
left: -($borderThickness + $nestingMargin)
z-index: -1
&:after
top: -($borderThickness + ($nestingMargin * 2))
left: -($borderThickness + ($nestingMargin * 2))
z-index: -2
@@ -0,0 +1,7 @@
<template name="studyBrowserList">
<div class="study-browser-list {{this.settings.studyListClass}}">
{{#each studyInformation in studiesInformation}}
{{>studyBrowserItem (clone this studyInformation=studyInformation)}}
{{/each}}
</div>
</template>
Whitespace-only changes.