Add characteristic/measurement to strain

This commit is contained in:
Matthew Dillon 2015-09-29 15:55:34 -07:00
parent 34aa59caf3
commit da27b42f76
6 changed files with 25 additions and 1 deletions

View file

@ -17,6 +17,7 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
setupController: function(controller, models) {
controller.setProperties(models);
controller.set('metaData', this.store.metadataFor('strain'));
},
});

View file

@ -2,6 +2,7 @@
protected/strains/strain-form
strain=strain
species=species
canAdd=metaData.canAdd
save="save"
cancel="cancel"
}}

View file

@ -11,7 +11,19 @@ export default Ember.Component.extend({
}
}.on('didInsertElement'),
sortParams: ['characteristicTypeName', 'sortOrder', 'characteristicName'],
sortParams: ['characteristic.characteristicTypeName', 'characteristic.sortOrder', 'characteristic.characteristicName'],
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);
},
},
});

View file

@ -1,3 +1,11 @@
{{#if canAdd}}
<br>
<button class="button-green smaller" {{action "addCharacteristic"}}>
Add characteristic
</button>
<br><br>
{{/if}}
{{#if measurementsPresent}}
<table class="flakes-table">
<colgroup>

View file

@ -77,6 +77,7 @@
protected/strains/show/measurements-table
model=model
canEdit=false
canAdd=false
}}
</dd>
</dl>

View file

@ -54,6 +54,7 @@
protected/strains/show/measurements-table
model=strain
canEdit=strain.canEdit
canAdd=canAdd
}}
</div>
<br>