Stop loading chars in measurements-table

This commit is contained in:
Matthew Dillon 2015-11-10 15:49:55 -07:00
parent fbfbdf19d1
commit ba15af411e
8 changed files with 9 additions and 10 deletions

View file

@ -12,6 +12,7 @@ export default Route.extend(ElevatedAccess, {
return Ember.RSVP.hash({ return Ember.RSVP.hash({
strain: this.store.findRecord('strain', params.strain_id), strain: this.store.findRecord('strain', params.strain_id),
species: this.store.findAll('species'), // Need for dropdown species: this.store.findAll('species'), // Need for dropdown
characteristics: this.store.findAll('characteristic'), // Need for dropdown
}); });
}, },
@ -26,6 +27,7 @@ export default Route.extend(ElevatedAccess, {
setupController: function(controller, models) { setupController: function(controller, models) {
controller.set('model', models.strain); controller.set('model', models.strain);
controller.set('speciesList', models.species); controller.set('speciesList', models.species);
controller.set('allCharacteristics', models.characteristics);
}, },
actions: { actions: {

View file

@ -3,6 +3,7 @@
strain=model strain=model
speciesList=speciesList speciesList=speciesList
add-characteristic=(action "addCharacteristic") add-characteristic=(action "addCharacteristic")
allCharacteristics=allCharacteristics
on-save=(action "save") on-save=(action "save")
on-cancel=(action "cancel") on-cancel=(action "cancel")
}} }}

View file

@ -20,8 +20,6 @@ export default Component.extend({
actions: { actions: {
edit: function() { edit: function() {
// The parent table fetches all of the characteristics ahead of time
this.set('characteristics', this.store.peekAll('characteristic'));
this.toggleProperty('isEditing'); this.toggleProperty('isEditing');
}, },

View file

@ -4,7 +4,7 @@
{{ {{
select-2 select-2
multiple=false multiple=false
content=characteristics content=allCharacteristics
value=row.characteristic value=row.characteristic
optionLabelPath="characteristicName" optionLabelPath="characteristicName"
}} }}

View file

@ -9,6 +9,8 @@ export default Component.extend({
allCharacteristics: null, allCharacteristics: null,
canEdit: false, canEdit: false,
canAdd: false, canAdd: false,
// Actions
"add-characteristic": null, "add-characteristic": null,
// Properties // Properties
@ -20,13 +22,6 @@ export default Component.extend({
return this.get('strain.measurements.length') > 0; return this.get('strain.measurements.length') > 0;
}), }),
// TODO: remove this
// fetchCharacteristics: function() {
// if (this.get('canEdit')) {
// this.store.findAll('characteristic');
// }
// }.on('didInsertElement'),
actions: { actions: {
addCharacteristic: function() { addCharacteristic: function() {
const newChar = this.attrs['add-characteristic'](); const newChar = this.attrs['add-characteristic']();

View file

@ -43,6 +43,7 @@
{{ {{
protected/strains/measurements-table-row protected/strains/measurements-table-row
row=measurement row=measurement
allCharacteristics=allCharacteristics
canEdit=canEdit canEdit=canEdit
}} }}
{{/each}} {{/each}}

View file

@ -9,6 +9,7 @@ export default Component.extend(SetupMetaData, {
isNew: null, isNew: null,
isDirty: false, isDirty: false,
speciesList: null, speciesList: null,
allCharacteristics: null,
// Actions // Actions
"on-save": null, "on-save": null,

View file

@ -54,6 +54,7 @@
protected/strains/measurements-table protected/strains/measurements-table
strain=strain strain=strain
add-characteristic=(action "addCharacteristic") add-characteristic=(action "addCharacteristic")
allCharacteristics=allCharacteristics
canEdit=strain.canEdit canEdit=strain.canEdit
canAdd=metaData.canAdd canAdd=metaData.canAdd
}} }}