Cleaning up measurement edit
This commit is contained in:
parent
40f2b789e4
commit
4b6a776b63
6 changed files with 29 additions and 42 deletions
|
@ -5,21 +5,13 @@ export default Ember.Component.extend({
|
|||
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(),
|
||||
fetchCharacteristics: function() {
|
||||
if (this.get('canEdit')) {
|
||||
this.store.findAll('characteristic');
|
||||
}
|
||||
}.on('didInsertElement'),
|
||||
|
||||
sortParams: ['characteristicTypeName', 'sortOrder', 'characteristicName'],
|
||||
sortedMeasurements: Ember.computed.sort('model.measurements', 'sortParams'),
|
||||
|
||||
});
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each measurementsTable as |row|}}
|
||||
{{#each sortedMeasurements as |measurement|}}
|
||||
{{
|
||||
protected/strains/show/measurements-table-row
|
||||
row=row
|
||||
row=measurement
|
||||
canEdit=canEdit
|
||||
}}
|
||||
{{/each}}
|
||||
|
|
Reference in a new issue