Step one, move up to pod root

This commit is contained in:
Matthew Dillon 2015-11-10 14:35:17 -07:00
parent fa5b741e35
commit 48cd1f4f39
8 changed files with 3 additions and 4 deletions

View file

@ -0,0 +1,49 @@
import Ember from 'ember';
const { Component } = Ember;
export default Component.extend({
measurementsPresent: function() {
return this.get('model.measurements.length') > 0;
}.property('model.measurements'),
fetchCharacteristics: function() {
if (this.get('canEdit')) {
this.store.findAll('characteristic');
}
}.on('didInsertElement'),
sortParams: ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName'],
sortAsc: true,
paramsChanged: false,
sortedMeasurements: Ember.computed.sort('model.measurements', 'sortParams'),
actions: {
addCharacteristic: function() {
const c = this.store.createRecord('characteristic', {
sortOrder: -999
});
const m = this.store.createRecord('measurement', {
characteristic: c
});
this.get('model.measurements').addObject(m);
},
changeSortParam: function(col) {
let sort = this.get('sortAsc') ? 'asc' : 'desc';
let sortCol = `${col}:${sort}`;
this.set('sortParams', [sortCol]);
this.set('paramsChanged', true);
this.toggleProperty('sortAsc');
return false;
},
resetSortParam: function() {
this.set('sortParams', ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName']);
this.set('paramsChanged', false);
this.set('sortAsc', true);
return false;
},
},
});

View file

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

View file

@ -0,0 +1,53 @@
{{#if canAdd}}
<br>
<button class="button-green smaller" {{action "addCharacteristic"}}>
Add characteristic
</button>
<br><br>
{{/if}}
{{#if measurementsPresent}}
{{#if paramsChanged}}
<button class="button-gray smaller" {{action 'resetSortParam'}}>
Reset sort
</button>
{{/if}}
<table class="flakes-table">
<colgroup>
{{#if canEdit}}
<col span="1" style="width:10%">
<col span="1" style="width:30%">
<col span="1" style="width:20%">
<col span="1" style="width:20%">
<col span="1" style="width:20%">
{{else}}
<col span="1" style="width:10%">
<col span="1" style="width:30%">
<col span="1" style="width:30%">
<col span="1" style="width:30%">
{{/if}}
</colgroup>
<thead>
<tr>
<th {{action "changeSortParam" "characteristic.characteristicTypeName"}} class="click">Type</th>
<th {{action "changeSortParam" "characteristic.characteristicName"}} class="click">Characteristic</th>
<th {{action "changeSortParam" "value"}} class="click">Value</th>
<th {{action "changeSortParam" "notes"}} class="click">Notes</th>
{{#if canEdit}}
<th>Edit</th>
{{/if}}
</tr>
</thead>
<tbody>
{{#each sortedMeasurements as |measurement|}}
{{
protected/strains/measurements-table-row
row=measurement
canEdit=canEdit
}}
{{/each}}
</tbody>
</table>
{{else}}
No measurements on record.
{{/if}}