Rough in characteristics
This commit is contained in:
		
							parent
							
								
									c5cb0ec145
								
							
						
					
					
						commit
						d587f14af4
					
				
					 13 changed files with 187 additions and 0 deletions
				
			
		
							
								
								
									
										5
									
								
								app/controllers/characteristics/index.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								app/controllers/characteristics/index.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,5 @@ | ||||||
|  | import SortableController from '../sortable'; | ||||||
|  | 
 | ||||||
|  | export default SortableController.extend({ | ||||||
|  |   sortBy: 'characteristicName', | ||||||
|  | }); | ||||||
							
								
								
									
										11
									
								
								app/models/characteristic.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								app/models/characteristic.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,11 @@ | ||||||
|  | import DS from 'ember-data'; | ||||||
|  | 
 | ||||||
|  | export default DS.Model.extend({ | ||||||
|  |   characteristicName: DS.attr('string'), | ||||||
|  |   characteristicType: DS.attr('string'), | ||||||
|  |   strains: DS.hasMany('strain'), | ||||||
|  |   measurements: DS.hasMany('measurements'), | ||||||
|  |   createdAt: DS.attr('date'), | ||||||
|  |   updatedAt: DS.attr('date'), | ||||||
|  |   deletedAt: DS.attr('date') | ||||||
|  | }); | ||||||
|  | @ -13,6 +13,7 @@ Router.map(function() { | ||||||
|       this.resource('measurements', function() {}); |       this.resource('measurements', function() {}); | ||||||
|     }); |     }); | ||||||
|   }); |   }); | ||||||
|  |   this.resource('characteristics', function() {}); | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| export default Router; | export default Router; | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								app/routes/characteristics.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								app/routes/characteristics.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,4 @@ | ||||||
|  | import Ember from 'ember'; | ||||||
|  | import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin'; | ||||||
|  | 
 | ||||||
|  | export default Ember.Route.extend(AuthenticatedRouteMixin); | ||||||
							
								
								
									
										7
									
								
								app/routes/characteristics/index.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								app/routes/characteristics/index.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,7 @@ | ||||||
|  | import Ember from 'ember'; | ||||||
|  | 
 | ||||||
|  | export default Ember.Route.extend({ | ||||||
|  |   model: function() { | ||||||
|  |     return this.store.findAll('characteristic'); | ||||||
|  |   } | ||||||
|  | }); | ||||||
|  | @ -6,6 +6,9 @@ | ||||||
|       {{#link-to 'strains' tagName='li' href=false}} |       {{#link-to 'strains' tagName='li' href=false}} | ||||||
|         {{#link-to 'strains'}}Strains{{/link-to}} |         {{#link-to 'strains'}}Strains{{/link-to}} | ||||||
|       {{/link-to}} |       {{/link-to}} | ||||||
|  |       {{#link-to 'characteristics' tagName='li' href=false}} | ||||||
|  |         {{#link-to 'characteristics'}}Characteristics{{/link-to}} | ||||||
|  |       {{/link-to}} | ||||||
|       {{#link-to 'about' tagName='li' href=false}} |       {{#link-to 'about' tagName='li' href=false}} | ||||||
|         {{#link-to 'about'}}About{{/link-to}} |         {{#link-to 'about'}}About{{/link-to}} | ||||||
|       {{/link-to}} |       {{/link-to}} | ||||||
|  |  | ||||||
							
								
								
									
										1
									
								
								app/templates/characteristics.hbs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								app/templates/characteristics.hbs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1 @@ | ||||||
|  | {{outlet}} | ||||||
							
								
								
									
										19
									
								
								app/templates/characteristics/index.hbs
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								app/templates/characteristics/index.hbs
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,19 @@ | ||||||
|  | <h2>Hymenobacter Characteristics</h2> | ||||||
|  | <h3>Total characteristics: {{controller.length}}</h3> | ||||||
|  | 
 | ||||||
|  | <table class="flakes-table"> | ||||||
|  |   <thead> | ||||||
|  |     <tr> | ||||||
|  |       <th {{action "setSortBy" "characteristicName"}}>Name</th> | ||||||
|  |       <th {{action "setSortBy" "characteristicType"}}>Type</th> | ||||||
|  |     </tr> | ||||||
|  |   </thead> | ||||||
|  |   <tbody> | ||||||
|  |     {{#each characteristic in controller}} | ||||||
|  |       <tr> | ||||||
|  |         <td>{{characteristic.characteristicName}}</td> | ||||||
|  |         <td>{{characteristic.characteristicType}}</td> | ||||||
|  |       </tr> | ||||||
|  |     {{/each}} | ||||||
|  |   </tbody> | ||||||
|  | </table> | ||||||
							
								
								
									
										78
									
								
								server/mocks/characteristics.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								server/mocks/characteristics.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,78 @@ | ||||||
|  | module.exports = function(app) { | ||||||
|  |   var express = require('express'); | ||||||
|  |   var characteristicsRouter = express.Router(); | ||||||
|  | 
 | ||||||
|  |   var CHARACTERISTICS = [ | ||||||
|  |     { | ||||||
|  |       id: 1, | ||||||
|  |       characteristicName: 'α-fucosidase (API ZYM)', | ||||||
|  |       characteristicType: 'Type 1', | ||||||
|  |       strains: [1], | ||||||
|  |       measurements: [1], | ||||||
|  |       createdAt: "0001-01-01T00:00:00Z", | ||||||
|  |       updatedAt: "0001-01-01T00:00:00Z", | ||||||
|  |       deletedAt: null | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       id: 2, | ||||||
|  |       characteristicName: 'α-glucosidase', | ||||||
|  |       characteristicType: 'Type 2', | ||||||
|  |       strains: [1], | ||||||
|  |       measurements: [2], | ||||||
|  |       createdAt: "0001-01-01T00:00:00Z", | ||||||
|  |       updatedAt: "0001-01-01T00:00:00Z", | ||||||
|  |       deletedAt: null | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       id: 3, | ||||||
|  |       characteristicName: 'Chloramphenicol', | ||||||
|  |       characteristicType: 'Type 3', | ||||||
|  |       strains: [1], | ||||||
|  |       measurements: [3], | ||||||
|  |       createdAt: "0001-01-01T00:00:00Z", | ||||||
|  |       updatedAt: "0001-01-01T00:00:00Z", | ||||||
|  |       deletedAt: null | ||||||
|  |     } | ||||||
|  |   ] | ||||||
|  | 
 | ||||||
|  |   characteristicsRouter.get('/', function(req, res) { | ||||||
|  |     var characteristics; | ||||||
|  |     if (req.query.ids) { | ||||||
|  |       characteristics = CHARACTERISTICS.filter(function(c) { | ||||||
|  |         return req.query.ids.indexOf(c.id.toString()) > -1; | ||||||
|  |       }); | ||||||
|  |     } else { | ||||||
|  |       characteristics = CHARACTERISTICS; | ||||||
|  |     } | ||||||
|  |     res.send({ | ||||||
|  |       'characteristics': characteristics | ||||||
|  |     }); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   characteristicsRouter.post('/', function(req, res) { | ||||||
|  |     res.status(201).end(); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   characteristicsRouter.get('/:id', function(req, res) { | ||||||
|  |     var characteristic = CHARACTERISTICS.filter(function(c) { | ||||||
|  |       return c.id == req.params.id; | ||||||
|  |     }); | ||||||
|  |     res.send({ | ||||||
|  |       'characteristic': characteristic | ||||||
|  |     }); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   characteristicsRouter.put('/:id', function(req, res) { | ||||||
|  |     res.send({ | ||||||
|  |       'characteristics': { | ||||||
|  |         id: req.params.id | ||||||
|  |       } | ||||||
|  |     }); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   characteristicsRouter.delete('/:id', function(req, res) { | ||||||
|  |     res.status(204).end(); | ||||||
|  |   }); | ||||||
|  | 
 | ||||||
|  |   app.use('/api/hymenobacter/characteristics', characteristicsRouter); | ||||||
|  | }; | ||||||
							
								
								
									
										15
									
								
								tests/unit/controllers/characteristics/index-test.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								tests/unit/controllers/characteristics/index-test.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | ||||||
|  | import { | ||||||
|  |   moduleFor, | ||||||
|  |   test | ||||||
|  | } from 'ember-qunit'; | ||||||
|  | 
 | ||||||
|  | moduleFor('controller:characteristics/index', { | ||||||
|  |   // Specify the other units that are required for this test.
 | ||||||
|  |   // needs: ['controller:foo']
 | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | // Replace this with your real tests.
 | ||||||
|  | test('it exists', function(assert) { | ||||||
|  |   var controller = this.subject(); | ||||||
|  |   assert.ok(controller); | ||||||
|  | }); | ||||||
							
								
								
									
										15
									
								
								tests/unit/models/characteristic-test.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								tests/unit/models/characteristic-test.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,15 @@ | ||||||
|  | import { | ||||||
|  |   moduleForModel, | ||||||
|  |   test | ||||||
|  | } from 'ember-qunit'; | ||||||
|  | 
 | ||||||
|  | moduleForModel('characteristic', { | ||||||
|  |   // Specify the other units that are required for this test.
 | ||||||
|  |   needs: [] | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('it exists', function(assert) { | ||||||
|  |   var model = this.subject(); | ||||||
|  |   // var store = this.store();
 | ||||||
|  |   assert.ok(!!model); | ||||||
|  | }); | ||||||
							
								
								
									
										14
									
								
								tests/unit/routes/characteristics-test.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								tests/unit/routes/characteristics-test.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | ||||||
|  | import { | ||||||
|  |   moduleFor, | ||||||
|  |   test | ||||||
|  | } from 'ember-qunit'; | ||||||
|  | 
 | ||||||
|  | moduleFor('route:characteristics', { | ||||||
|  |   // Specify the other units that are required for this test.
 | ||||||
|  |   // needs: ['controller:foo']
 | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('it exists', function(assert) { | ||||||
|  |   var route = this.subject(); | ||||||
|  |   assert.ok(route); | ||||||
|  | }); | ||||||
							
								
								
									
										14
									
								
								tests/unit/routes/characteristics/index-test.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								tests/unit/routes/characteristics/index-test.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | ||||||
|  | import { | ||||||
|  |   moduleFor, | ||||||
|  |   test | ||||||
|  | } from 'ember-qunit'; | ||||||
|  | 
 | ||||||
|  | moduleFor('route:characteristics/index', { | ||||||
|  |   // Specify the other units that are required for this test.
 | ||||||
|  |   // needs: ['controller:foo']
 | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | test('it exists', function(assert) { | ||||||
|  |   var route = this.subject(); | ||||||
|  |   assert.ok(route); | ||||||
|  | }); | ||||||
		Reference in a new issue
	
	 Matthew Dillon
						Matthew Dillon