Add measurements to strains page

This commit is contained in:
Matthew Dillon 2015-09-09 11:40:32 -07:00
parent 137ba20bd9
commit 3b3f8cc691
5 changed files with 72 additions and 1 deletions

View file

@ -0,0 +1 @@
{{loading-panel}}

View file

@ -0,0 +1,25 @@
import Ember from 'ember';
export default Ember.Component.extend({
measurementsPresent: function() {
return this.get('model.measurements.length') > 0;
}.property('model.measurements'),
measurementsTable: function() {
let measurements = this.get('model.measurements');
let table = [];
measurements.forEach((measurement) => {
let row = {};
row['measurement'] = measurement;
row['characteristic'] = this.store.peekRecord('characteristic', measurement.get('characteristic.id'));
table.push(row);
});
table.sort((a, b) => {
let a_sort = a['characteristic'] && a['characteristic'].get('sortOrder');
let b_sort = b['characteristic'] && b['characteristic'].get('sortOrder');
return a_sort - b_sort;
});
return table;
}.property(),
});

View file

@ -0,0 +1 @@
{{loading-panel}}

View file

@ -0,0 +1,30 @@
{{#if measurementsPresent}}
<table class="flakes-table">
<thead>
<tr>
<th>Characteristic</th>
<th>Value</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
{{#each measurementsTable as |row|}}
<tr>
<td>
{{#link-to 'protected.characteristics.show' row.characteristic.id}}
{{{row.characteristic.characteristicName}}}
{{/link-to}}
</td>
<td>
{{row.measurement.value}}
</td>
<td>
{{row.measurement.notes}}
</td>
</tr>
{{/each}}
</tbody>
</table>
{{else}}
No measurements on record.
{{/if}}

View file

@ -59,12 +59,26 @@
<dl class="span-1">
<dt>Notes</dt>
<dd>
{{#if model.notes}}
{{{model.notes}}}
{{else}}
No notes.
{{/if}}
</dd>
</dl>
</div>
{{! ROW 5 }}
<div class="grid-1 gutter-20">
<dl class="span-1">
<dt>Characteristics</dt>
<dd>
{{protected/strains/show/measurements-table model=model}}
</dd>
</dl>
</div>
{{! ROW 6 }}
<div class="grid-3 gutter-20">
<dl class="span-1">
<dt>Record Created</dt>