ENH: Convert sex fields to lookup (#76)
This commit is contained in:
parent
6f01fbf00f
commit
c87bd953d9
10 changed files with 32 additions and 7 deletions
|
@ -3,7 +3,7 @@ branches:
|
|||
only:
|
||||
- master
|
||||
node_js:
|
||||
- "6"
|
||||
- "9"
|
||||
sudo: required
|
||||
dist: trusty
|
||||
addons:
|
||||
|
|
|
@ -22,7 +22,7 @@ export default Component.extend({
|
|||
{ label: 'Species', valuePath: 'species.commonName' },
|
||||
{ label: 'Count', valuePath: 'count' },
|
||||
{ label: 'Count Estimated?', valuePath: 'countEstimated' },
|
||||
{ label: 'Sex', valuePath: 'sex' },
|
||||
{ label: 'Sex', valuePath: 'sex.name' },
|
||||
],
|
||||
|
||||
envMeasColumns: [
|
||||
|
|
|
@ -16,7 +16,8 @@ export default Controller.extend(ValidationMixin, {
|
|||
|
||||
options: computed('projectOptions', 'studyLocationOptions',
|
||||
'collectionTypeOptions', 'collectionMethodOptions',
|
||||
'speciesOptions', 'adfgPermitOptions', function() {
|
||||
'speciesOptions', 'adfgPermitOptions', 'sexOptions',
|
||||
function() {
|
||||
return {
|
||||
projects: this.get('projectOptions'),
|
||||
studyLocations: this.get('studyLocationOptions'),
|
||||
|
@ -24,6 +25,7 @@ export default Controller.extend(ValidationMixin, {
|
|||
collectionMethods: this.get('collectionMethodOptions'),
|
||||
species: this.get('speciesOptions'),
|
||||
adfgPermits: this.get('adfgPermitOptions'),
|
||||
sexes: this.get('sexOptions'),
|
||||
};
|
||||
}),
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ export default Controller.extend(ValidationMixin, {
|
|||
|
||||
options: computed('projectOptions', 'studyLocationOptions',
|
||||
'collectionTypeOptions', 'collectionMethodOptions',
|
||||
'speciesOptions', 'adfgPermitOptions', function() {
|
||||
'speciesOptions', 'adfgPermitOptions', 'sexOptions',
|
||||
function() {
|
||||
return {
|
||||
projects: this.get('projectOptions'),
|
||||
studyLocations: this.get('studyLocationOptions'),
|
||||
|
@ -24,6 +25,7 @@ export default Controller.extend(ValidationMixin, {
|
|||
collectionMethods: this.get('collectionMethodOptions'),
|
||||
species: this.get('speciesOptions'),
|
||||
adfgPermits: this.get('adfgPermitOptions'),
|
||||
sexes: this.get('sexOptions'),
|
||||
};
|
||||
}),
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import DS from 'ember-data';
|
|||
const { Model, attr, belongsTo } = DS;
|
||||
|
||||
export default Model.extend({
|
||||
sex: attr('string'),
|
||||
sex: belongsTo('sex'),
|
||||
count: attr('number'),
|
||||
countEstimated: attr('boolean', { defaultValue: false }),
|
||||
|
||||
|
|
8
app/models/sex.js
Normal file
8
app/models/sex.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import DS from 'ember-data';
|
||||
|
||||
const { Model, attr } = DS;
|
||||
|
||||
export default Model.extend({
|
||||
name: attr('string'),
|
||||
sortOrder: attr('number'),
|
||||
});
|
|
@ -12,6 +12,7 @@ export default Route.extend({
|
|||
collectionMethodOptions: store.findAll('collection-method'),
|
||||
speciesOptions: store.findAll('species'),
|
||||
adfgPermitOptions: store.findAll('adfg-permit'),
|
||||
sexOptions: store.findAll('sex'),
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ export default Route.extend({
|
|||
collectionMethodOptions: store.findAll('collection-method'),
|
||||
speciesOptions: store.findAll('species'),
|
||||
adfgPermitOptions: store.findAll('adfg-permit'),
|
||||
sexOptions: store.findAll('sex'),
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -143,7 +143,15 @@
|
|||
</td>
|
||||
<td class="col-md-3">
|
||||
{{#validated-field property='sex' changeset=cs.changeset}}
|
||||
{{input value=cs.changeset.sex}}
|
||||
{{#power-select
|
||||
options=options.sexes
|
||||
selected=cs.changeset.sex
|
||||
onchange=(action (mut cs.changeset.sex))
|
||||
searchField='name'
|
||||
as |sex|
|
||||
}}
|
||||
{{sex.name}}
|
||||
{{/power-select}}
|
||||
{{/validated-field}}
|
||||
</td>
|
||||
<td class="col-md-2">
|
||||
|
|
|
@ -54,5 +54,8 @@
|
|||
"engines": {
|
||||
"node": "^4.5 || 6.* || >= 7.*"
|
||||
},
|
||||
"private": true
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"npm": "^5.7.1"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue