LT-275: Creating measure flow component common section

This commit is contained in:
Bruno Alves de Faria committed 2016-08-03 11:13:48 -03:00
1 parent 9a8eaff560
commit bbb7dad905
60 files changed
+391 -156

No files matched your search

@@ -0,0 +1,93 @@
<template name="selectTree">
{{#group (extend this
class=(concat
'select-tree '
(valueIf this.root '' 'select-tree-root ')
this.class
)
mixins=(concat 'selectTree ' this.mixins)
)}}
{{>UI.contentBlock}}
<div class="tree-content">
{{#let currentNode=this.currentNode.get}}
{{#if (and (not this.root) (ne this.search false))}}
{{>inputText
label=this.label
labelClass='tree-search'
placeholder=(choose this.searchPlaceholder 'Search')
}}
{{/if}}
<div class="tree-options {{#if currentNode}}collapsed{{/if}}">
{{#if this.root}}
{{>selectTreeBreadcrumb component=this.component}}
{{/if}}
<div class="tree-inputs">
{{#each item in (reactive this.items)}}
{{>inputRadio
class=this.radioClass
name=this.key
value=item.value
label=item.label
labelClass=(valueIf (isArray item.items) 'tree-node' 'tree-leaf')
checked=(eq item.value (reactive this.value))
}}
{{/each}}
</div>
{{#if (and currentNode (isArray currentNode.items))}}
{{>selectTree (clone this
items=currentNode.items
root=(choose this.root this.component)
class='select-tree-node'
)}}
{{/if}}
</div>
{{/let}}
</div>
{{#unless this.root}}
{{>selectTreeCommon this}}
{{/unless}}
{{/group}}
</template>
<template name="selectTreeCommon">
<div class="select-tree-common">
<div class="content">
<h5 class="title">Common</h5>
</div>
</div>
</template>
<template name="selectTreeBreadcrumb">
<div class="tree-breadcrumb clearfix">
{{>selectTreeBreadcrumbParent
component=this.component.parent
index=1
}}
{{#let currentNode=this.component.parent.templateInstance.data.currentNode.get}}
<span class="tree-current-node">{{currentNode.label}}</span>
{{/let}}
</div>
</template>
<template name="selectTreeBreadcrumbParent">
{{#let parent=this.component.parent}}
{{#let parentNode=(reactive parent.templateInstance.data.currentNode)}}
{{#if parentNode}}
{{>selectTreeBreadcrumbParent
component=parent
index=(sum this.index 1)
}}
{{/if}}
<span class="path-link">
<a href="#" class="tree-back" data-index="{{this.index}}">
{{#if parentNode}}
<span>{{parentNode.label}}</span>
{{else}}
<i class="fa fa-fast-backward"></i>
{{/if}}
</a>
{{#if parentNode}}<span>/</span>{{/if}}
</span>
{{/let}}
{{/let}}
</template>
@@ -4,16 +4,20 @@ import { _ } from 'meteor/underscore';
import { $ } from 'meteor/jquery';
// TODO: use npm dependency
import transition from 'meteor/ohif:core/lib/third-party/transition-to-from-auto';
import transition from 'meteor/ohif:core/client/lib/third-party/transition-to-from-auto';
Template.selectTree.onRendered(() => {
const instance = Template.instance();
const component = instance.$('.select-tree:first').data('component');
const rootComponent = instance.data.root || component;
const rootInstance = rootComponent.templateInstance;
const $treeRoot = rootInstance.$('.select-tree-root:first').first();
instance.component = component;
// Start the component transitions
$treeRoot.addClass('started');
// Update the component's viewport height
instance.updateHeight = () => {
const height = rootInstance.$('.tree-options:last').data('height');
@@ -28,18 +32,9 @@ Template.selectTree.onRendered(() => {
// Put the component in selected state
instance.setSelected = (flag) => {
const $treeRoot = rootInstance.$('.select-tree-root:first').first();
const $firstChild = $treeRoot.children().first();
if (flag) {
const search = rootInstance.$('.tree-search').outerHeight() | 0;
const leaf = $treeRoot.find('.tree-leaf.active').position().top;
const martinTop = search + leaf;
// $firstChild.css('margin-top', -martinTop);
// $treeRoot.css('margin-top', martinTop).addClass('selected');
$treeRoot.addClass('selected');
} else {
// $treeRoot.removeClass('selected').css('margin-top', '');
// $firstChild.css('margin-top', '');
$treeRoot.removeClass('selected');
}
};
@@ -60,7 +55,7 @@ Template.selectTree.onRendered(() => {
});
});
const selector = '.select-tree:first>.tree-options>.tree-breadcrumb .path-link';
const selector = '.select-tree:first>.tree-content>.tree-options>.tree-breadcrumb .path-link';
instance.$(selector).css('width', 0).each((index, element) => {
transition({
element: element,
@@ -72,7 +67,12 @@ Template.selectTree.onRendered(() => {
});
Template.selectTree.events({
'change .select-tree:first>.tree-options>.tree-inputs>label>input'(event, instance) {
'click .select-tree-root'(event, instance) {
// Detect the first interaction with the component and do the animation
$(event.currentTarget).addClass('interacted');
},
'change .select-tree:first>.tree-content>.tree-options>.tree-inputs>label>input'(event, instance) {
const component = instance.component;
const $target = $(event.target);
const $label = $target.closest('label');
@@ -111,7 +111,7 @@ Template.selectTree.events({
}
},
'click .select-tree:first>.tree-options>.tree-breadcrumb .tree-back'(event, instance) {
'click .select-tree:first>.tree-content>.tree-options>.tree-breadcrumb .tree-back'(event, instance) {
const rootComponent = instance.data.root || instance.component;
const rootInstance = rootComponent.templateInstance;
File renamed without changes.
+6
View File
@@ -0,0 +1,6 @@
import './lib';
import './components';
import './helpers';
import './ui';
import './routes.js';
File renamed without changes.
@@ -1,2 +1,3 @@
import './blaze.js';
import './string.js';
import './user.js';
File renamed without changes.
+32
View File
@@ -0,0 +1,32 @@
import { OHIF } from 'meteor/ohif:core';
OHIF.user = {};
// Throw error if there is no user logged in
OHIF.user.validate = () => {
if (!Meteor.userId()) {
throw new Meteor.Error('not-authorized');
}
};
// Get the persistent data by key
OHIF.user.getData = key => {
// Check if there is an user logged in
OHIF.user.validate();
// Get the user persistent data
const data = Meteor.user().profile.persistent;
if (data) {
return data[key];
}
};
// Store the persistent data by giving a key and a value to store
OHIF.user.setData = (key, value) => {
// Check if there is an user logged in
OHIF.user.validate();
// Call the update method on server-side
Meteor.call('userDataSet', key, value);
};
+5
View File
@@ -0,0 +1,5 @@
import { Router } from 'meteor/clinical:router';
Router.route('/playground', function() {
this.render('componentPlayground');
});
File renamed without changes.
@@ -1,80 +0,0 @@
<template name="selectTree">
{{#group (extend this
class=(concat
'select-tree '
(valueIf this.root '' 'select-tree-root ')
this.class
)
mixins=(concat 'selectTree ' this.mixins)
)}}
{{>UI.contentBlock}}
{{#let currentNode=this.currentNode.get}}
{{#if (and (not this.root) (ne this.search false))}}
{{>inputText
label=this.label
labelClass='tree-search'
placeholder=(choose this.searchPlaceholder 'Search')
}}
{{/if}}
<div class="tree-options {{#if currentNode}}collapsed{{/if}}">
{{#if this.root}}
{{>selectTreeBreadcrumb component=this.component}}
{{/if}}
<div class="tree-inputs">
{{#each item in (reactive this.items)}}
{{>inputRadio
class=this.radioClass
name=this.key
value=item.value
label=item.label
labelClass=(valueIf (isArray item.items) 'tree-node' 'tree-leaf')
checked=(eq item.value (reactive this.value))
}}
{{/each}}
</div>
{{#if (and currentNode (isArray currentNode.items))}}
{{>selectTree (clone this
items=currentNode.items
root=(choose this.root this.component)
class='select-tree-node'
)}}
{{/if}}
</div>
{{/let}}
{{/group}}
</template>
<template name="selectTreeBreadcrumb">
<div class="tree-breadcrumb clearfix">
{{>selectTreeBreadcrumbParent
component=this.component.parent
index=1
}}
{{#let currentNode=this.component.parent.templateInstance.data.currentNode.get}}
<span class="tree-current-node">{{currentNode.label}}</span>
{{/let}}
</div>
</template>
<template name="selectTreeBreadcrumbParent">
{{#let parent=this.component.parent}}
{{#let parentNode=(reactive parent.templateInstance.data.currentNode)}}
{{#if parentNode}}
{{>selectTreeBreadcrumbParent
component=parent
index=(sum this.index 1)
}}
{{/if}}
<span class="path-link">
<a href="#" class="tree-back" data-index="{{this.index}}">
{{#if parentNode}}
<span>{{parentNode.label}}</span>
{{else}}
<i class="fa fa-fast-backward"></i>
{{/if}}
</a>
{{#if parentNode}}<span>/</span>{{/if}}
</span>
{{/let}}
{{/let}}
</template>
+9 -10
View File
@@ -1,13 +1,12 @@
export { OHIF } from './ohif.js';
/*
* Defines the base OHIF object
*/
import { Meteor } from 'meteor/meteor';
import { Router } from 'meteor/clinical:router';
const OHIF = {};
import './lib';
import './components';
import './helpers';
import './ui';
// Expose the OHIF object to the client if it is on development mode
if (Meteor.isDevelopment && Meteor.isClient) {
window.OHIF = OHIF;
}
Router.route('/playground', function() {
this.render('componentPlayground');
});
export { OHIF };
-11
View File
@@ -1,11 +0,0 @@
/*
* Defines the base OHIF object
*/
const OHIF = {};
if (Meteor.isDevelopment) {
window.OHIF = OHIF;
}
export { OHIF };
+9 -2
View File
@@ -23,8 +23,15 @@ Package.onUse(function(api) {
// UI Styles
api.addFiles([
'ui/resizable/resizable.styl'
'client/ui/resizable/resizable.styl'
], 'client');
api.mainModule('main.js', 'client');
api.mainModule('main.js', ['client', 'server']);
// Client imports and routes
api.addFiles('client/index.js', 'client');
// Server imports and methods
api.addFiles('server/index.js', 'server');
});
+2
View File
@@ -0,0 +1,2 @@
import './mongo.js';
import './user.js';
+26
View File
@@ -0,0 +1,26 @@
import { OHIF } from 'meteor/ohif:core';
import { Meteor } from 'meteor/meteor';
// Mongo data manipulation utilities
class MongoUtils {
// Check if there is an user logged in
static validateUser() {
// Throw error if there is no user logged in
if (!Meteor.userId()) {
throw new Meteor.Error('not-authorized');
}
}
// Generic callback to MongoDB write operations
static writeCallback(error, affected) {
// Throw error if it was not possible to complete the write operation
if (error) {
throw new Meteor.Error('data-write', error);
}
}
}
// Expose the class in the OHIF object
OHIF.MongoUtils = MongoUtils;
+54
View File
@@ -0,0 +1,54 @@
import { OHIF } from 'meteor/ohif:core';
import { Meteor } from 'meteor/meteor';
// Manipulate user's persistent data
class UserData {
// Get the persistent data by key
static get(key) {
// Check if there is an user logged in
OHIF.MongoUtils.validateUser();
// Get the user's profile data
const profileData = Meteor.user().profile;
// Return the data if it is set
if (profileData.persistent) {
return profileData.persistent[key];
}
}
// Store the persistent data by giving a key and a value to store
static set(key, value) {
// Check if there is an user logged in
OHIF.MongoUtils.validateUser();
// Build the query to update only the current user's data
var query = {
_id: Meteor.userId()
};
// Build the path to the persistent data with the given key
const persistentPath = `profile.persistent.${key}`;
// Build the data to be updated
var data = {
$set: {
[persistentPath]: value
}
};
// Update the user's profile data with the persistent information
Accounts.users.update(query, data, OHIF.MongoUtils.writeCallback);
}
}
// Register the methods
Meteor.methods({
userDataGet: key => UserData.get(key),
userDataSet: (key, value) => UserData.set(key, value)
});
// Expose the class in the OHIF object
OHIF.UserData = UserData;