parent
93d70d3c95
commit
bfae4422f4
8 changed files with 78 additions and 17 deletions
12
app/models/collection-species.js
Normal file
12
app/models/collection-species.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import DS from 'ember-data';
|
||||
|
||||
const { Model, attr, belongsTo } = DS;
|
||||
|
||||
export default Model.extend({
|
||||
sex: attr('string'),
|
||||
count: attr('number'),
|
||||
countEstimated: attr('boolean'),
|
||||
|
||||
collection: belongsTo('collection'),
|
||||
species: belongsTo('species'),
|
||||
});
|
|
@ -2,7 +2,7 @@ import Ember from 'ember';
|
|||
import DS from 'ember-data';
|
||||
|
||||
const { computed } = Ember;
|
||||
const { Model, attr, belongsTo } = DS;
|
||||
const { Model, attr, belongsTo, hasMany } = DS;
|
||||
|
||||
export const schema = {
|
||||
displayName: attr('string'),
|
||||
|
@ -12,11 +12,23 @@ export const schema = {
|
|||
collectionEndDate: attr('string-null-to-empty'),
|
||||
collectionEndTime: attr('string-null-to-empty'),
|
||||
|
||||
project: belongsTo('project'),
|
||||
studyLocation: belongsTo('study-location'),
|
||||
collectionMethod: belongsTo('collection-method'),
|
||||
collectionType: belongsTo('collection-type'),
|
||||
adfgPermit: belongsTo('adfg-permit'),
|
||||
project: belongsTo('project'),
|
||||
studyLocation: belongsTo('study-location'),
|
||||
collectionMethod: belongsTo('collection-method'),
|
||||
collectionType: belongsTo('collection-type'),
|
||||
adfgPermit: belongsTo('adfg-permit'),
|
||||
|
||||
collectionSpecies: hasMany('collection-species', { async: false }),
|
||||
|
||||
species: computed.mapBy('collectionSpecies', 'species'),
|
||||
speciesNames: computed.mapBy('species', 'commonName'),
|
||||
counts: computed.mapBy('collectionSpecies', 'count'),
|
||||
speciesAndCounts: computed('speciesNames', 'counts', function() {
|
||||
const speciesNames = this.get('speciesNames');
|
||||
let counts = this.get('counts');
|
||||
counts = counts.map(c => c !== null ? c : 'No Count');
|
||||
return speciesNames.map((n, i) => `${n} (${counts[i]})`).join(', ');
|
||||
}),
|
||||
};
|
||||
|
||||
export default Model.extend(Object.assign({}, schema, {
|
||||
|
|
11
app/models/species.js
Normal file
11
app/models/species.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
import DS from 'ember-data';
|
||||
|
||||
const { Model, attr } = DS;
|
||||
|
||||
export default Model.extend({
|
||||
commonName: attr('string'),
|
||||
genus: attr('string'),
|
||||
species: attr('string'),
|
||||
parasite: attr('boolean'),
|
||||
sortOrder: attr('number'),
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue