From 2320409510d381e04b12d04c95d86529c3cfcba1 Mon Sep 17 00:00:00 2001 From: Isaac Hodes Date: Mon, 16 Feb 2015 18:53:40 -0500 Subject: [PATCH] Tidy, address CR --- cycledash/static/js/runs.js | 72 ++++++++++++++++++++++++++--------- cycledash/templates/runs.html | 2 +- 2 files changed, 54 insertions(+), 20 deletions(-) diff --git a/cycledash/static/js/runs.js b/cycledash/static/js/runs.js index a900d9c..5686440 100644 --- a/cycledash/static/js/runs.js +++ b/cycledash/static/js/runs.js @@ -12,13 +12,18 @@ var NO_FILTER = '----'; var RunsPage = React.createClass({ propTypes: { runs: React.PropTypes.arrayOf(React.PropTypes.object).isRequired, - runKeyVals: React.PropTypes.object.isRequired + runDescriptionTitleKeys: React.PropTypes.object.isRequired }, getInitialState: function() { return {selectedRunId: null, projectFilter: null}; }, filteredRuns: function() { - return this.props.runs.filter(run => (this.state.projectFilter === null) || this.state.projectFilter.match(run.project_name) ); + return this.props.runs.filter(run => { + var filter = this.state.projectFilter, + noFilter = filter === null, + matches = filter && filter.match(run.project_name); + return noFilter || matches; + }); }, handleClickRun: function(runId) { return () => { @@ -31,12 +36,20 @@ var RunsPage = React.createClass({ }, render: function() { var projectNames = _.unique(_.pluck(this.props.runs, 'project_name')); - var projects = projectNames.map(name => ); + var projects = projectNames.map(name => { + return ( + + ); + }); var runs = this.filteredRuns(); var rows = runs.map((run) => { - var rows = []; + var rows = []; if (run.id === this.state.selectedRunId) { - rows.push(); + rows.push(); } return rows; }); @@ -66,7 +79,7 @@ var RunsPage = React.createClass({ } }); -var RunRow = React.createClass({ +var Run = React.createClass({ propTypes: { run: React.PropTypes.object.isRequired, handleClick: React.PropTypes.func.isRequired @@ -82,21 +95,21 @@ var RunRow = React.createClass({ { run.caller_name } { run.dataset_name } { run.created_at } - - + + ); } }); -var RowValues = React.createClass({ +var RunDescription = React.createClass({ propTypes: { run: React.PropTypes.object.isRequired, - runKeyVals: React.PropTypes.object.isRequired + runDescriptionTitleKeys: React.PropTypes.object.isRequired }, render: function() { var run = this.props.run, - descriptions = _.reduce(this.props.runKeyVals, function(acc, key, title) { + descriptions = _.reduce(this.props.runDescriptionTitleKeys, function(acc, key, title) { if (run[key]) { acc.push(
{ title }
); acc.push(
{ run[key] }
); @@ -115,23 +128,43 @@ var RowValues = React.createClass({ } }); -var RowLabels = React.createClass({ +var RunLabels = React.createClass({ propTypes: { run: React.PropTypes.object.isRequired }, render: function() { - var run = this.props.run; + var run = this.props.run, + labels = []; + if (run.validation_vcf) { + labels.push( + validation + ); + } + if (run.tumor_bam_uri) { + labels.push( + tumor + ); + } + if (run.normal_bam_uri) { + labels.push( + normal + ); + } return ( - { run.validation_vcf ? validation : null } - { run.tumor_bam_uri ? tumor : null } - { run.normal_bam_uri ? normal : null } + {labels} ); } }); -var RowComments = React.createClass({ +var RunComments = React.createClass({ propTypes: { run: React.PropTypes.object.isRequired }, @@ -190,8 +223,9 @@ function extractError(response) { } -window.renderRunPage = function(el, runs, runKeyVals) { - React.render(, el); +window.renderRunPage = function(el, runs, runDescriptionTitleKeys) { + React.render(, el); d3.select('#show-submit') .on('click', function() { diff --git a/cycledash/templates/runs.html b/cycledash/templates/runs.html index b8f0498..87be64a 100644 --- a/cycledash/templates/runs.html +++ b/cycledash/templates/runs.html @@ -25,6 +25,6 @@

Last {{ last_comments|length}} Comments:

{% endblock %}