diff --git a/app/components/collection/detail-container.js b/app/components/collection/detail-container.js index 84afb77..2501e69 100644 --- a/app/components/collection/detail-container.js +++ b/app/components/collection/detail-container.js @@ -26,4 +26,11 @@ export default Component.extend({ { label: 'Count Estimated?', valuePath: 'countEstimated' }, { 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', }, + ], }); diff --git a/app/controllers/collections/create.js b/app/controllers/collections/create.js index c927cc9..5ee4c55 100644 --- a/app/controllers/collections/create.js +++ b/app/controllers/collections/create.js @@ -1,6 +1,7 @@ import Ember from 'ember'; import CollectionValidations from 'ccdb-web/validations/collection'; import CollectionSpeciesValidations from 'ccdb-web/validations/collection-species'; +import CollectionMeasurementValidations from 'ccdb-web/validations/collection-measurement'; import DatasheetValidations from 'ccdb-web/validations/datasheet'; import ValidationMixin from 'ccdb-web/mixins/validation'; @@ -10,8 +11,9 @@ export default Controller.extend(ValidationMixin, { CollectionValidations, CollectionSpeciesValidations, DatasheetValidations, + CollectionMeasurementValidations, - hasMany: ['collectionSpecies', 'datasheets'], + hasMany: ['collectionSpecies', 'datasheets', 'envMeasurements'], options: computed('projectOptions', 'studyLocationOptions', 'collectionTypeOptions', 'collectionMethodOptions', diff --git a/app/controllers/collections/detail/edit.js b/app/controllers/collections/detail/edit.js index 978331a..c74bc84 100644 --- a/app/controllers/collections/detail/edit.js +++ b/app/controllers/collections/detail/edit.js @@ -1,6 +1,7 @@ import Ember from 'ember'; import CollectionValidations from 'ccdb-web/validations/collection'; import CollectionSpeciesValidations from 'ccdb-web/validations/collection-species'; +import CollectionMeasurementValidations from 'ccdb-web/validations/collection-measurement'; import DatasheetValidations from 'ccdb-web/validations/datasheet'; import ValidationMixin from 'ccdb-web/mixins/validation'; @@ -10,8 +11,9 @@ export default Controller.extend(ValidationMixin, { CollectionValidations, CollectionSpeciesValidations, DatasheetValidations, + CollectionMeasurementValidations, - hasMany: ['collectionSpecies', 'datasheets'], + hasMany: ['collectionSpecies', 'datasheets', 'envMeasurements'], options: computed('projectOptions', 'studyLocationOptions', 'collectionTypeOptions', 'collectionMethodOptions', diff --git a/app/models/collection-measurement.js b/app/models/collection-measurement.js new file mode 100644 index 0000000..776fb6f --- /dev/null +++ b/app/models/collection-measurement.js @@ -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'), +}); diff --git a/app/models/collection.js b/app/models/collection.js index e8cc45a..0997f74 100644 --- a/app/models/collection.js +++ b/app/models/collection.js @@ -21,6 +21,7 @@ export default Model.extend({ collectionSpecies: hasMany('collection-species'), datasheets: hasMany('datasheet-attachment'), + envMeasurements: hasMany('collection-measurement'), // computed species: computed.mapBy('collectionSpecies', 'species'), diff --git a/app/routes/collections/detail.js b/app/routes/collections/detail.js index 11517f6..2fb322c 100644 --- a/app/routes/collections/detail.js +++ b/app/routes/collections/detail.js @@ -6,7 +6,7 @@ export default Route.extend({ model(params) { return RSVP.all([ this.get('store').findRecord('collection', params.collection_id, { - include: 'collection-species,datasheets', + include: 'collection-species,datasheets,env-measurements', }) ]); }, diff --git a/app/templates/collections/detail/edit.hbs b/app/templates/collections/detail/edit.hbs index ae0f2b0..4314bd1 100644 --- a/app/templates/collections/detail/edit.hbs +++ b/app/templates/collections/detail/edit.hbs @@ -4,7 +4,8 @@ validations=(hash collection=CollectionValidations collectionSpecies=CollectionSpeciesValidations - datasheet=DatasheetValidations) + datasheet=DatasheetValidations + envMeasurements=CollectionMeasurementValidations) options=options hasMany=hasMany onSave=(action 'onSave') diff --git a/app/templates/components/collection/create-container.hbs b/app/templates/components/collection/create-container.hbs index 9933bfe..c0c9fa0 100644 --- a/app/templates/components/collection/create-container.hbs +++ b/app/templates/components/collection/create-container.hbs @@ -155,6 +155,54 @@ +
+
+ + + + + + + + + + + + + {{#each changesets.hasMany.envMeasurements as |cm|}} + + + + + + + + {{/each}} + +
+ Environmental Measurements + {{action-button isSuccess=true isXSmall=true label='+' onClick=(action 'addHasMany' 'collection-measurement' 'envMeasurements')}} +
Date MeasuredTime MeasuredWater Temperature (deg C)Air Temperature (deg C)Delete
+ {{#validated-field property='dateMeasured' changeset=cm.changeset}} + {{input value=cm.changeset.dateMeasured type='date' class='form-control'}} + {{/validated-field}} + + {{#validated-field property='timeMeasured' changeset=cm.changeset}} + {{input value=cm.changeset.timeMeasured type='time' class='form-control'}} + {{/validated-field}} + + {{#validated-field property='waterTempC' changeset=cm.changeset}} + {{input value=cm.changeset.waterTempC class='form-control'}} + {{/validated-field}} + + {{#validated-field property='airTempC' changeset=cm.changeset}} + {{input value=cm.changeset.airTempC class='form-control'}} + {{/validated-field}} + + {{action-button isDanger=true isXSmall=true label='X' onClick=(action 'deleteHasMany' cm 'envMeasurements')}} +
+
+
diff --git a/app/templates/components/collection/detail-container.hbs b/app/templates/components/collection/detail-container.hbs index 23f66aa..7580a46 100644 --- a/app/templates/components/collection/detail-container.hbs +++ b/app/templates/components/collection/detail-container.hbs @@ -33,6 +33,20 @@
+

Environmental Measurements

+
+
+ {{#ccdb-table model=model.[0].envMeasurements columns=envMeasColumns as |c|}} + {{#c.grid as |g|}} + {{g.head}} + {{g.body}} + {{/c.grid}} + {{/ccdb-table}} +
+
+ +
+

Notes

diff --git a/app/validations/collection-measurement.js b/app/validations/collection-measurement.js new file mode 100644 index 0000000..c2b990a --- /dev/null +++ b/app/validations/collection-measurement.js @@ -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), +}