diff --git a/app/components/collection/detail-container.js b/app/components/collection/detail-container.js index e26790e..fdf5d07 100644 --- a/app/components/collection/detail-container.js +++ b/app/components/collection/detail-container.js @@ -8,11 +8,15 @@ export default Component.extend({ columns: [ { label: 'Project', valuePath: 'project.name', }, + { label: 'IACUC', valuePath: 'project.iacucNumber', }, + { label: 'Region', valuePath: 'studyLocation.site.region.name', }, + { label: 'Site', valuePath: 'studyLocation.site.name', }, { label: 'Study Location', valuePath: 'studyLocation.code', }, { label: 'Method', valuePath: 'collectionMethod.code', }, { label: 'Type', valuePath: 'collectionType.name', }, { label: '# of Traps', valuePath: 'numberOfTraps', }, { label: 'Start', valuePath: 'startDateTime', }, { label: 'End', valuePath: 'endDateTime', }, + { label: 'ADFG Permit', valuePath: 'adfgPermit.name', }, ], }); diff --git a/app/components/collection/list-container.js b/app/components/collection/list-container.js index e9cb377..1f5c3a5 100644 --- a/app/components/collection/list-container.js +++ b/app/components/collection/list-container.js @@ -8,6 +8,7 @@ export default Component.extend({ columns: [ { label: 'Project', valuePath: 'project.name', }, + { label: 'IACUC', valuePath: 'project.iacucNumber', }, { label: 'Region', valuePath: 'studyLocation.site.region.name', }, { label: 'Site', valuePath: 'studyLocation.site.name', }, { label: 'Study Location', valuePath: 'studyLocation.code', }, @@ -15,5 +16,6 @@ export default Component.extend({ { label: '# of Traps', valuePath: 'numberOfTraps', }, { label: 'Start', valuePath: 'startDateTime', }, { label: 'End', valuePath: 'endDateTime', }, + { label: 'ADFG Permit', valuePath: 'adfgPermit.name', }, ], }); diff --git a/app/controllers/collections/index.js b/app/controllers/collections/index.js index 48482d2..77a2a93 100644 --- a/app/controllers/collections/index.js +++ b/app/controllers/collections/index.js @@ -6,25 +6,28 @@ const { Controller, computed, get, set } = Ember; export default Controller.extend({ queryParams: ['page', 'project', 'region', 'site', 'study_location', 'collection_method', 'number_of_traps', 'collection_start_date', - 'collection_end_date'], + 'collection_end_date', 'adfg_permit'], page: 1, project: [], region: [], site: [], study_location: [], collection_method: [], + adfg_permit: [], number_of_traps: '', collection_start_date: '', collection_end_date: '', options: computed('projectOptions', 'regionOptions', 'siteOptions', - 'studyLocationOptions', 'collectionMethodOptions', function() { + 'studyLocationOptions', 'collectionMethodOptions', + 'adfgPermitOptions', function() { return { projects: this.get('projectOptions'), regions: this.get('regionOptions'), sites: this.get('siteOptions'), studyLocations: this.get('studyLocationOptions'), collectionMethods: this.get('collectionMethodOptions'), + adfgPermits: this.get('adfgPermitOptions'), }; }), @@ -42,12 +45,21 @@ export default Controller.extend({ createCollection() { this.transitionToRoute('collections.create'); }, + resetFilter() { + set(this, 'page', 1); + ['project', 'region', 'site', 'study_location', 'collection_method', 'adfg_permit'].forEach((field) => { + set(this, field, []); + }); + ['number_of_traps', 'collection_start_date', 'collection_end_date'].forEach((field) => { + set(this, field, ''); + }); + }, changeFilter(filter) { // Need to reset the page so that things don't get weird set(this, 'page', 1); const filterModelFields = ['project', 'region', 'site', 'study_location', - 'collection_method']; + 'collection_method', 'adfg_permit']; filterModelFields.forEach((field) => { let fields = get(filter, field); diff --git a/app/models/adfg-permit.js b/app/models/adfg-permit.js new file mode 100644 index 0000000..de48a20 --- /dev/null +++ b/app/models/adfg-permit.js @@ -0,0 +1,10 @@ +import DS from 'ember-data'; + +const { Model, attr, hasMany } = DS; + +export default Model.extend({ + name: attr('string'), + sortOrder: attr('number'), + + collection: hasMany('collection'), +}); diff --git a/app/models/collection.js b/app/models/collection.js index b869c9e..cd7c707 100644 --- a/app/models/collection.js +++ b/app/models/collection.js @@ -16,6 +16,7 @@ export const schema = { studyLocation: belongsTo('study-location'), collectionMethod: belongsTo('collection-method'), collectionType: belongsTo('collection-type'), + adfgPermit: belongsTo('adfg-permit'), }; export default Model.extend(Object.assign({}, schema, { diff --git a/app/routes/collections/index.js b/app/routes/collections/index.js index ab1eee6..37d72f5 100644 --- a/app/routes/collections/index.js +++ b/app/routes/collections/index.js @@ -14,12 +14,13 @@ export default Route.extend({ number_of_traps: { refreshModel: true }, collection_start_date: { refreshModel: true }, collection_end_date: { refreshModel: true }, + adfg_permit: { refreshModel: true }, }, model(params) { const store = this.get('store'); const opts = { - include: 'project,study-location,study-location.site,site,collection-method', + include: 'project,study-location,study-location.site,site,collection-method,adfg-permit', }; return RSVP.hash({ @@ -28,6 +29,7 @@ export default Route.extend({ siteOptions: store.findAll('site'), studyLocationOptions: store.findAll('study-location'), collectionMethodOptions: store.findAll('collection-method'), + adfgPermitOptions: store.findAll('adfg-permit'), model: store.query('collection', Object.assign(params, opts)), }); }, @@ -53,6 +55,9 @@ export default Route.extend({ let collectionMethod = controller.get('collection_method'); collectionMethod = collectionMethod.map(id => store.peekRecord('collection-method', id)); + let adfgPermit = controller.get('adfg_permit'); + adfgPermit = adfgPermit.map(id => store.peekRecord('adfg-permit', id)); + const numberOfTraps = controller.get('number_of_traps'); const collectionStartDate = controller.get('collection_start_date'); const collectionEndDate = controller.get('collection_end_date'); @@ -66,6 +71,7 @@ export default Route.extend({ number_of_traps: numberOfTraps, collection_start_date: collectionStartDate, collection_end_date: collectionEndDate, + adfg_permit: adfgPermit, } controller.set('filters', filter); }, diff --git a/app/templates/collections/index.hbs b/app/templates/collections/index.hbs index ca47c63..00a52d9 100644 --- a/app/templates/collections/index.hbs +++ b/app/templates/collections/index.hbs @@ -4,6 +4,7 @@ filters=filters options=options changeFilter=(action 'changeFilter') + resetFilter=(action 'resetFilter') changePage=(action 'changePage') onRowClick=(action 'rowClick') createCollection=(action 'createCollection') diff --git a/app/templates/components/collection/list-container.hbs b/app/templates/components/collection/list-container.hbs index 6b7c9c9..5d8f481 100644 --- a/app/templates/components/collection/list-container.hbs +++ b/app/templates/components/collection/list-container.hbs @@ -64,7 +64,7 @@
-
+
{{#power-select-multiple options=options.collectionMethods @@ -76,11 +76,26 @@ {{collectionMethod.name}} {{/power-select-multiple}}
-
+
{{input type="text" class="form-control" value=filters.number_of_traps}}
-
+
+ + {{#power-select-multiple + options=options.adfgPermits + selected=filters.adfg_permit + onchange=(action (mut filters.adfg_permit)) + searchField='name' + as |adfgPermit| + }} + {{adfgPermit.name}} + {{/power-select-multiple}} +
+
+ +
+
{{ pikaday-input @@ -91,7 +106,7 @@ class='form-control' }}
-
+
{{ pikaday-input @@ -106,12 +121,20 @@
- {{ - action-button - isSuccess=true - label='Search' - onClick=(action changeFilter filters) - }} +
+ {{ + action-button + isSuccess=true + label='Search' + onClick=(action changeFilter filters) + }} + {{ + action-button + isWarning=true + label='Reset' + onClick=(action resetFilter) + }} +
diff --git a/tests/unit/models/adfgpermit-test.js b/tests/unit/models/adfgpermit-test.js new file mode 100644 index 0000000..461d7d5 --- /dev/null +++ b/tests/unit/models/adfgpermit-test.js @@ -0,0 +1,12 @@ +import { moduleForModel, test } from 'ember-qunit'; + +moduleForModel('adfg-permit', 'Unit | Model | adfg permit', { + // Specify the other units that are required for this test. + needs: [] +}); + +test('it exists', function(assert) { + let model = this.subject(); + // let store = this.store(); + assert.ok(!!model); +});