ENH: Collection environment measurement (#65)
This commit is contained in:
parent
56f8796eaf
commit
39f4789a61
10 changed files with 103 additions and 4 deletions
|
@ -26,4 +26,11 @@ export default Component.extend({
|
||||||
{ label: 'Count Estimated?', valuePath: 'countEstimated' },
|
{ label: 'Count Estimated?', valuePath: 'countEstimated' },
|
||||||
{ label: 'Sex', valuePath: 'sex' },
|
{ label: 'Sex', valuePath: 'sex' },
|
||||||
],
|
],
|
||||||
|
|
||||||
|
envMeasColumns: [
|
||||||
|
{ label: 'Date Measured', valuePath: 'dateMeasured', },
|
||||||
|
{ label: 'Time Measured', valuePath: 'timeMeasured', },
|
||||||
|
{ label: 'Water Temp (deg C)', valuePath: 'waterTempC', },
|
||||||
|
{ label: 'Air Temp (deg C)', valuePath: 'airTempC', },
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import CollectionValidations from 'ccdb-web/validations/collection';
|
import CollectionValidations from 'ccdb-web/validations/collection';
|
||||||
import CollectionSpeciesValidations from 'ccdb-web/validations/collection-species';
|
import CollectionSpeciesValidations from 'ccdb-web/validations/collection-species';
|
||||||
|
import CollectionMeasurementValidations from 'ccdb-web/validations/collection-measurement';
|
||||||
import DatasheetValidations from 'ccdb-web/validations/datasheet';
|
import DatasheetValidations from 'ccdb-web/validations/datasheet';
|
||||||
import ValidationMixin from 'ccdb-web/mixins/validation';
|
import ValidationMixin from 'ccdb-web/mixins/validation';
|
||||||
|
|
||||||
|
@ -10,8 +11,9 @@ export default Controller.extend(ValidationMixin, {
|
||||||
CollectionValidations,
|
CollectionValidations,
|
||||||
CollectionSpeciesValidations,
|
CollectionSpeciesValidations,
|
||||||
DatasheetValidations,
|
DatasheetValidations,
|
||||||
|
CollectionMeasurementValidations,
|
||||||
|
|
||||||
hasMany: ['collectionSpecies', 'datasheets'],
|
hasMany: ['collectionSpecies', 'datasheets', 'envMeasurements'],
|
||||||
|
|
||||||
options: computed('projectOptions', 'studyLocationOptions',
|
options: computed('projectOptions', 'studyLocationOptions',
|
||||||
'collectionTypeOptions', 'collectionMethodOptions',
|
'collectionTypeOptions', 'collectionMethodOptions',
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import CollectionValidations from 'ccdb-web/validations/collection';
|
import CollectionValidations from 'ccdb-web/validations/collection';
|
||||||
import CollectionSpeciesValidations from 'ccdb-web/validations/collection-species';
|
import CollectionSpeciesValidations from 'ccdb-web/validations/collection-species';
|
||||||
|
import CollectionMeasurementValidations from 'ccdb-web/validations/collection-measurement';
|
||||||
import DatasheetValidations from 'ccdb-web/validations/datasheet';
|
import DatasheetValidations from 'ccdb-web/validations/datasheet';
|
||||||
import ValidationMixin from 'ccdb-web/mixins/validation';
|
import ValidationMixin from 'ccdb-web/mixins/validation';
|
||||||
|
|
||||||
|
@ -10,8 +11,9 @@ export default Controller.extend(ValidationMixin, {
|
||||||
CollectionValidations,
|
CollectionValidations,
|
||||||
CollectionSpeciesValidations,
|
CollectionSpeciesValidations,
|
||||||
DatasheetValidations,
|
DatasheetValidations,
|
||||||
|
CollectionMeasurementValidations,
|
||||||
|
|
||||||
hasMany: ['collectionSpecies', 'datasheets'],
|
hasMany: ['collectionSpecies', 'datasheets', 'envMeasurements'],
|
||||||
|
|
||||||
options: computed('projectOptions', 'studyLocationOptions',
|
options: computed('projectOptions', 'studyLocationOptions',
|
||||||
'collectionTypeOptions', 'collectionMethodOptions',
|
'collectionTypeOptions', 'collectionMethodOptions',
|
||||||
|
|
12
app/models/collection-measurement.js
Normal file
12
app/models/collection-measurement.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import DS from 'ember-data';
|
||||||
|
|
||||||
|
const { Model, attr, belongsTo } = DS;
|
||||||
|
|
||||||
|
export default Model.extend({
|
||||||
|
dateMeasured: attr('string'),
|
||||||
|
timeMeasured: attr('string'),
|
||||||
|
waterTempC: attr('number'),
|
||||||
|
airTempC: attr('number'),
|
||||||
|
|
||||||
|
collection: belongsTo('collection'),
|
||||||
|
});
|
|
@ -21,6 +21,7 @@ export default Model.extend({
|
||||||
|
|
||||||
collectionSpecies: hasMany('collection-species'),
|
collectionSpecies: hasMany('collection-species'),
|
||||||
datasheets: hasMany('datasheet-attachment'),
|
datasheets: hasMany('datasheet-attachment'),
|
||||||
|
envMeasurements: hasMany('collection-measurement'),
|
||||||
|
|
||||||
// computed
|
// computed
|
||||||
species: computed.mapBy('collectionSpecies', 'species'),
|
species: computed.mapBy('collectionSpecies', 'species'),
|
||||||
|
|
|
@ -6,7 +6,7 @@ export default Route.extend({
|
||||||
model(params) {
|
model(params) {
|
||||||
return RSVP.all([
|
return RSVP.all([
|
||||||
this.get('store').findRecord('collection', params.collection_id, {
|
this.get('store').findRecord('collection', params.collection_id, {
|
||||||
include: 'collection-species,datasheets',
|
include: 'collection-species,datasheets,env-measurements',
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
validations=(hash
|
validations=(hash
|
||||||
collection=CollectionValidations
|
collection=CollectionValidations
|
||||||
collectionSpecies=CollectionSpeciesValidations
|
collectionSpecies=CollectionSpeciesValidations
|
||||||
datasheet=DatasheetValidations)
|
datasheet=DatasheetValidations
|
||||||
|
envMeasurements=CollectionMeasurementValidations)
|
||||||
options=options
|
options=options
|
||||||
hasMany=hasMany
|
hasMany=hasMany
|
||||||
onSave=(action 'onSave')
|
onSave=(action 'onSave')
|
||||||
|
|
|
@ -155,6 +155,54 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<table class="table">
|
||||||
|
<caption>
|
||||||
|
Environmental Measurements
|
||||||
|
{{action-button isSuccess=true isXSmall=true label='+' onClick=(action 'addHasMany' 'collection-measurement' 'envMeasurements')}}
|
||||||
|
</caption>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="col-md-3">Date Measured</th>
|
||||||
|
<th class="col-md-3">Time Measured</th>
|
||||||
|
<th class="col-md-3">Water Temperature (deg C)</th>
|
||||||
|
<th class="col-md-3">Air Temperature (deg C)</th>
|
||||||
|
<th class="col-md-1">Delete</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{{#each changesets.hasMany.envMeasurements as |cm|}}
|
||||||
|
<tr class="form">
|
||||||
|
<td class="col-md-3">
|
||||||
|
{{#validated-field property='dateMeasured' changeset=cm.changeset}}
|
||||||
|
{{input value=cm.changeset.dateMeasured type='date' class='form-control'}}
|
||||||
|
{{/validated-field}}
|
||||||
|
</td>
|
||||||
|
<td class="col-md-3">
|
||||||
|
{{#validated-field property='timeMeasured' changeset=cm.changeset}}
|
||||||
|
{{input value=cm.changeset.timeMeasured type='time' class='form-control'}}
|
||||||
|
{{/validated-field}}
|
||||||
|
</td>
|
||||||
|
<td class="col-md-3">
|
||||||
|
{{#validated-field property='waterTempC' changeset=cm.changeset}}
|
||||||
|
{{input value=cm.changeset.waterTempC class='form-control'}}
|
||||||
|
{{/validated-field}}
|
||||||
|
</td>
|
||||||
|
<td class="col-md-3">
|
||||||
|
{{#validated-field property='airTempC' changeset=cm.changeset}}
|
||||||
|
{{input value=cm.changeset.airTempC class='form-control'}}
|
||||||
|
{{/validated-field}}
|
||||||
|
</td>
|
||||||
|
<td class="col-md-2">
|
||||||
|
{{action-button isDanger=true isXSmall=true label='X' onClick=(action 'deleteHasMany' cm 'envMeasurements')}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{/each}}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<form enctype="multipart/form-data">
|
<form enctype="multipart/form-data">
|
||||||
|
|
|
@ -33,6 +33,20 @@
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<h3>Environmental Measurements</h3>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
{{#ccdb-table model=model.[0].envMeasurements columns=envMeasColumns as |c|}}
|
||||||
|
{{#c.grid as |g|}}
|
||||||
|
{{g.head}}
|
||||||
|
{{g.body}}
|
||||||
|
{{/c.grid}}
|
||||||
|
{{/ccdb-table}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
<h3>Notes</h3>
|
<h3>Notes</h3>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
|
12
app/validations/collection-measurement.js
Normal file
12
app/validations/collection-measurement.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import {
|
||||||
|
validatePresence,
|
||||||
|
validateNumber,
|
||||||
|
} from 'ember-changeset-validations/validators';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
dateMeasured: validatePresence(true),
|
||||||
|
timeMeasured: validatePresence(true),
|
||||||
|
waterTemp: validateNumber({ allowBlank: true, integer: false, positive: false }),
|
||||||
|
airTemp: validateNumber({ allowBlank: true, integer: false, positive: false }),
|
||||||
|
collection: validatePresence(true),
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue