LT-249: Implementing behavior for 'comparison' and 'key timepoints' switch

This commit is contained in:
Bruno Alves de Faria 2016-06-27 18:18:42 -03:00 committed by Erik Ziegler
parent ef89c3dfd7
commit 048bb3f050
11 changed files with 136 additions and 93 deletions

View File

@ -4,13 +4,13 @@
{{>studyTimepointBrowser}}
</div>
<div class="mainContent {{#if leftSidebarOpen}}sidebar-left-open{{/if}} {{#if rightSidebarOpen}}sidebar-right-open{{/if}}">
{{>viewerMain }}
{{>viewerMain}}
</div>
<div class="sidebarMenu sidebar-right {{#if lesionSidebarOpen}}sidebar-open{{/if}}">
{{>lesionTable }}
{{>lesionTable}}
</div>
<div class="sidebarMenu sidebar-right {{#if additionalMeasurementsSidebarOpen}}sidebar-open{{/if}}">
{{>additionalMeasurements }}
{{>additionalMeasurements}}
</div>
</div>
</template>

View File

@ -4,10 +4,10 @@
{{>roundedButtonGroup buttonGroupData}}
</div>
<div class="lesionTableTimepointHeaderRow">
{{#each timepoints}}
{{#each timepoints.get}}
{{>lesionTableTimepointHeader}}
{{/each}}
</div>
{{>lesionTableView}}
{{>lesionTableView this}}
</div>
</template>

View File

@ -1,48 +1,37 @@
Template.lesionTable.helpers({
timepoints: function() {
return Timepoints.find({}, {
Template.lesionTable.onCreated(() => {
const instance = Template.instance();
instance.data.lesionTableLayout = new ReactiveVar('comparison');
instance.data.timepoints = new ReactiveVar([]);
instance.autorun(() => {
// Get the current table layout
const tableLayout = instance.data.lesionTableLayout.get();
// Get all the timepoints
const allTimepoints = Timepoints.find({}, {
sort: {
latestDate: 1
latestDate: -1
}
});
},
}).fetch();
buttonGroupData() {
const instance = Template.instance();
return {
value: instance.lesionTableLayout,
options: [{
value: 'comparison',
text: 'Comparison'
}, {
value: 'key',
text: 'Key Timepoints'
}]
};
}
});
// Get the last 2 timepoints
let timepoints = allTimepoints.slice(0, 2);
Template.lesionTable.events({
/**
* Retrieve the lesion id from the DOM data for this row
*/
/*'click table#tblLesion tbody tr': function(e, template) {
var measurementId = $(e.currentTarget).data('measurementid');
activateLesion(measurementId, template.data);
},*/
// Concatenate the baseline if the table layout is for key timepoints
if (tableLayout === 'key' && allTimepoints.length > 2) {
timepoints = timepoints.concat(_.last(allTimepoints));
}
// Return key timepoints
instance.data.timepoints.set(timepoints);
});
});
// Temporary until we have a real window manager with events for series/study changed
Session.setDefault('NewSeriesLoaded', false);
Template.lesionTable.onCreated(function() {
var instance = this;
instance.lesionTableLayout = new ReactiveVar();
instance.lesionTableLayout.set('comparison');
});
Template.lesionTable.onRendered(function() {
Template.lesionTable.onRendered(() => {
// Find the first measurement by Lesion Number
var firstLesion = Measurements.findOne({}, {
sort: {
@ -60,3 +49,33 @@ Template.lesionTable.onRendered(function() {
activateLesion(firstLesion._id, templateData);
}
});
Template.lesionTable.events({
/**
* Retrieve the lesion id from the DOM data for this row
*/
/*'click table#tblLesion tbody tr': function(e, template) {
var measurementId = $(e.currentTarget).data('measurementid');
activateLesion(measurementId, template.data);
},*/
});
Template.lesionTable.helpers({
dataContainer() {
return {};
},
buttonGroupData() {
const instance = Template.instance();
return {
value: instance.data.lesionTableLayout,
options: [{
value: 'comparison',
text: 'Comparison'
}, {
value: 'key',
text: 'Key Timepoints'
}]
};
}
});

View File

@ -2,16 +2,16 @@
<div class="lesionTableRow {{#if descriptionRequired}}warning{{/if}}{{#if responseStatus}}response-status{{/if}}" data-measurementid="{{_id}}">
<div class='lesionRowSidebar'>
<div class="lesionNumber">
{{lesionNumberAbsolute}}
{{rowItem.lesionNumberAbsolute}}
</div>
{{#if descriptionRequired}}
{{#if rowItem.descriptionRequired}}
<div class="warning-icon">
<svg>
<use xlink:href=/packages/lesiontracker/assets/icons.svg#icon-ui-warning></use>
</svg>
</div>
{{/if}}
{{#if responseStatus}}
{{#if rowItem.responseStatus}}
<div class="response-status-icon">
CR
</div>
@ -19,17 +19,17 @@
</div>
<div class="lesionDetails">
<div class='location'>
{{ #if location }}
{{location}}
{{ else }}
{{#if rowItem.location}}
{{rowItem.location}}
{{else}}
(No description)
{{ /if }}
{{/if}}
</div>
<div class="timepointData">
<!--Each time point as a column-->
{{# each timepoints }}
{{> lesionTableTimepointCell}}
{{/ each }}
{{#each timepoints.get}}
{{>lesionTableTimepointCell}}
{{/each}}
</div>
</div>
</div>

View File

@ -1,13 +1,3 @@
Template.lesionTableRow.helpers({
timepoints: function() {
return Timepoints.find({}, {
sort: {
timepointName: 1
}
});
}
});
function doneCallback(measurementData, deleteTool) {
// If a Lesion or Non-Target is removed via a dialog
// opened by the Lesion Table, we should clear the data for

View File

@ -1,11 +1,11 @@
<template name="lesionTableTimepointCell">
{{ #if hasDataAtThisTimepoint }}
<div class="lesionTableTimepointCell" tabindex="1">
{{displayData}}
</div>
{{ else }}
<div class="lesionTableTimepointCell empty">
...
</div>
{{ /if }}
</template>
{{#if hasDataAtThisTimepoint}}
<div class="lesionTableTimepointCell" tabindex="1">
{{displayData}}
</div>
{{else}}
<div class="lesionTableTimepointCell empty">
...
</div>
{{/if}}
</template>

View File

@ -2,14 +2,14 @@ Template.lesionTableTimepointCell.helpers({
hasDataAtThisTimepoint: function() {
// This simple function just checks whether or not timepoint data
// exists for this Measurement at this Timepoint
var lesionData = Template.parentData(1);
var lesionData = Template.parentData(1).rowItem;
return (lesionData &&
lesionData.timepoints &&
lesionData.timepoints[this.timepointId]);
},
displayData: function() {
// Search Measurements by lesion and timepoint
var lesionData = Template.parentData(1);
var lesionData = Template.parentData(1).rowItem;
if (!lesionData ||
!lesionData.timepoints ||
!lesionData.timepoints[this.timepointId]) {
@ -49,7 +49,7 @@ Template.lesionTableTimepointCell.helpers({
},
isBidirectional: function() {
var lesionData = Template.parentData(1);
var lesionData = Template.parentData(1).rowItem;
if (lesionData.toolType === 'bidirectional') {
return true;
}
@ -77,7 +77,7 @@ Template.lesionTableTimepointCell.events({
'dblclick .lesionTableTimepointCell': function() {
log.info('Double clicked on a timepoint cell');
// Search Measurements by lesion and timepoint
var currentMeasurement = Template.parentData(1);
var currentMeasurement = Template.parentData(1).rowItem;
// Create some fake measurement data
var currentTimepointID = this.timepointId;
@ -110,7 +110,7 @@ Template.lesionTableTimepointCell.events({
var keyCode = e.which;
if (keyCode === keys.DELETE ||
(keyCode === keys.D && e.ctrlKey === true)) {
var currentMeasurement = Template.parentData(1);
var currentMeasurement = Template.parentData(1).rowItem;
var currentTimepointID = this.timepointId;
showConfirmDialog(function() {

View File

@ -1,18 +1,18 @@
<template name="lesionTableView">
<div class="lesionTableView scrollArea">
{{ >lesionTableHeaderRow id="target" type="Targets" measurements=targets}}
{{ #each targets }}
{{ >lesionTableRow }}
{{ /each }}
{{>lesionTableHeaderRow id="target" type="Targets" measurements=targets}}
{{#each target in targets}}
{{>lesionTableRow (extend this rowItem=target)}}
{{/each}}
{{ >lesionTableHeaderRow id="nonTarget" type="Non-targets" measurements=nonTargets}}
{{ #each nonTargets }}
{{ >lesionTableRow }}
{{ /each }}
{{>lesionTableHeaderRow id="nonTarget" type="Non-targets" measurements=nonTargets}}
{{#each nonTarget in nonTargets}}
{{>lesionTableRow (extend this rowItem=nonTarget)}}
{{/each}}
{{ >lesionTableHeaderRow id="newLesions" type="New lesions" measurements=newLesions}}
{{ #each nonTargets }}
{{ >lesionTableRow }}
{{ /each }}
{{>lesionTableHeaderRow id="newLesions" type="New lesions" measurements=newLesions}}
{{#each newLesion in newLesions}}
{{>lesionTableRow (extend this rowItem=newLesion)}}
{{/each}}
</div>
</template>
</template>

View File

@ -1,5 +1,5 @@
Template.lesionTableView.helpers({
targets: function () {
targets() {
// All Targets shall be listed first followed by Non-Targets
return Measurements.find({
isTarget: true
@ -9,7 +9,7 @@ Template.lesionTableView.helpers({
}
});
},
nonTargets: function () {
nonTargets() {
// All Targets shall be listed first followed by Non-Targets
return Measurements.find({
isTarget: false
@ -19,7 +19,7 @@ Template.lesionTableView.helpers({
}
});
},
newLesions: function () {
newLesions() {
// All Targets shall be listed first followed by Non-Targets
return Measurements.find({
saved: false
@ -29,4 +29,4 @@ Template.lesionTableView.helpers({
}
});
}
});
});

View File

@ -0,0 +1,33 @@
// Return the current template instance
Template.registerHelper('instance', () => {
return Template.instance();
});
// Create a new object and extends it with the argument objects
Template.registerHelper('extend', (...argsArray) => {
// Create the resulting object
const result = {};
// Extract the Spacebars kw hash
const kwHash = _.last(argsArray).hash;
// Extract the given objects
const objects = _.initial(argsArray);
// Iterate over the given objects
_.each(objects, current => {
// Stop here if the current argument is not an object
if (typeof current !== 'object') {
return;
}
// Extend the resulting object with the current argument object
_.extend(result, current);
});
// Extend the resulting object with the Spacebars kw hash
_.extend(result, kwHash);
// Return the resulting object
return result;
});

View File

@ -175,6 +175,7 @@ Package.onUse(function(api) {
// UI Helpers
api.addFiles([
'lib/helpers/formatDA.js',
'lib/helpers/blaze.js',
'lib/helpers/logical.js',
'lib/helpers/formatJSDate.js',
'lib/helpers/jsDateFromNow.js',