diff --git a/app/pods/protected/strains/measurements-table-row/template.hbs b/app/pods/protected/strains/measurements-table-row/template.hbs index 3e3fd4d..7a51e78 100644 --- a/app/pods/protected/strains/measurements-table-row/template.hbs +++ b/app/pods/protected/strains/measurements-table-row/template.hbs @@ -1,5 +1,7 @@ {{#if isEditing}} - <td></td> + <td> + {{{characteristic.characteristicTypeName}}} + </td> <td> <select onchange={{action "characteristicDidChange" value="target.value"}}> {{#each allCharacteristics as |characteristicChoice|}} diff --git a/app/pods/protected/strains/strain-form/component.js b/app/pods/protected/strains/strain-form/component.js index 006a62b..3931156 100644 --- a/app/pods/protected/strains/strain-form/component.js +++ b/app/pods/protected/strains/strain-form/component.js @@ -35,10 +35,29 @@ export default Component.extend(SetupMetaData, { notes: null, measurements: [], + // Dropdown menu + characteristics: [], + sortParams: ['characteristicTypeName', 'sortOrder', 'characteristicName'], + sortedCharacteristics: sort('characteristics', 'sortParams'), + setupCharacteristics: Ember.on('init', function() { + const tempArray = this._resetArray(this.get('allCharacteristics')); + this.set('characteristics', tempArray); + }), + resetOnInit: Ember.on('init', function() { this._resetProperties(); }), + _resetArray: function(arr) { + let tempArray = []; + arr.forEach((val) => { + if (!val.get('isNew')) { + tempArray.push(val); + } + }); + return tempArray; + }, + _resetProperties: function() { // Still some coupling going on here because of adding strain to measurement this.get('measurements').forEach((val) => { @@ -52,12 +71,7 @@ export default Component.extend(SetupMetaData, { this.get('propertiesList').forEach((field) => { const valueInStrain = this.get('strain').get(field); if (field === 'measurements') { - let tempArray = []; - valueInStrain.forEach((val) => { - if (!val.get('isNew')) { - tempArray.push(val); - } - }); + const tempArray = this._resetArray(valueInStrain); this.set(field, tempArray); } else { this.set(field, valueInStrain); diff --git a/app/pods/protected/strains/strain-form/template.hbs b/app/pods/protected/strains/strain-form/template.hbs index d1b1fb8..2ed0b5f 100644 --- a/app/pods/protected/strains/strain-form/template.hbs +++ b/app/pods/protected/strains/strain-form/template.hbs @@ -63,7 +63,7 @@ protected/strains/measurements-table measurements=measurements add-characteristic=(action "addCharacteristic") - allCharacteristics=allCharacteristics + allCharacteristics=sortedCharacteristics save-measurement=(action "saveMeasurement") delete-measurement=(action "deleteMeasurement") canEdit=strain.canEdit