Rough measurements search (WIP)

This commit is contained in:
Matthew Dillon 2015-06-09 14:32:15 -08:00
parent 1976b49608
commit c70dd933c5
8 changed files with 166 additions and 47 deletions

View file

@ -1,5 +1,4 @@
import DS from 'ember-data';
import Ember from 'ember';
export default DS.Model.extend({
strain: DS.belongsTo('strain', { async: true }),
@ -15,34 +14,28 @@ export default DS.Model.extend({
updatedAt: DS.attr('date'),
createdBy: DS.attr('number'),
updatedBy: DS.attr('number'),
computedType: Ember.computed('textMeasurementType', 'txtValue', 'numValue', function() {
if (this.get('textMeasurementType') && !this.get('txtValue') && !this.get('numValue')) {
return 'Fixed-text';
} else if (!this.get('textMeasurementType') && this.get('txtValue') && !this.get('numValue')) {
return 'Free-text';
} else if (!this.get('textMeasurementType') && !this.get('txtValue') && this.get('numValue')) {
return 'Numerical';
} else {
return "error";
// computedType: Ember.computed('textMeasurementType', 'txtValue', 'numValue', function() {
// if (this.get('textMeasurementType')) {
// return 'Fixed-text';
// }
// if (this.get('txtValue')) {
// return 'Free-text';
// }
// if (this.get('numValue')) {
// return 'Numerical';
// }
// return "error";
// }),
value: function() {
if (this.get('textMeasurementType')) {
return this.get('textMeasurementType');
}
}),
computedValue: Ember.computed('textMeasurementType', 'txtValue', 'numValue', function() {
var val;
if (this.get('computedType') === 'Fixed-text') {
val = this.get('textMeasurementType');
} else if (this.get('computedType') === 'Free-text') {
val = this.get('txtValue');
} else if (this.get('computedType') === 'Numerical') {
val = this.get('numValue');
if (this.get('confidenceInterval')) {
val = val + ' ± ' + this.get('confidenceInterval');
}
} else {
val = "error";
if (this.get('txtValue')) {
return this.get('txtValue');
}
if (this.get('unitType')) {
val = val + ' ' + this.get('unitType');
if (this.get('numValue')) {
return this.get('numValue');
}
return val;
})
return "error";
}.property('textMeasurementType', 'txtValue', 'numValue'),
});

View file

@ -17,7 +17,7 @@ export default DS.Model.extend({
updatedBy: DS.attr('number'),
deletedBy: DS.attr('number'),
totalMeasurements: DS.attr('number'),
fullName: Ember.computed('speciesName', 'strainName', function() {
return this.get('speciesName') + ' (' + this.get('strainName') + ')';
fullName: Ember.computed('species.speciesName', 'strainName', function() {
return this.get('species.speciesName') + ' (strain ' + this.get('strainName') + ')';
})
});