Roughing in ember-can: placeholders for strain mod
This commit is contained in:
		
							parent
							
								
									b337ca0ee4
								
							
						
					
					
						commit
						ce40ef6071
					
				
					 7 changed files with 53 additions and 0 deletions
				
			
		
							
								
								
									
										17
									
								
								app/abilities/strain.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								app/abilities/strain.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,17 @@ | ||||||
|  | import { Ability } from 'ember-can'; | ||||||
|  | 
 | ||||||
|  | export default Ability.extend({ | ||||||
|  |   // Only admins and writers can create a new strain
 | ||||||
|  |   canAdd: function() { | ||||||
|  |     let role = this.get('session.currentUser.role'); | ||||||
|  |     return (role === 'W') || (role === 'A'); | ||||||
|  |   }.property('session.currentUser.role'), | ||||||
|  | 
 | ||||||
|  |   // Only admins and the person who created can edit
 | ||||||
|  |   canEdit: function() { | ||||||
|  |     let role = this.get('session.currentUser.role'); | ||||||
|  |     let id = this.get('session.currentUser.id'); | ||||||
|  |     let author = this.get('model.author'); | ||||||
|  |     return (role === 'W' && (+id === author)) || (role === 'A'); | ||||||
|  |   }.property('session.currentUser.role', 'session.currentUser.id', 'model.author') | ||||||
|  | }); | ||||||
|  | @ -13,6 +13,7 @@ export default DS.Model.extend({ | ||||||
|   createdAt: DS.attr('date'), |   createdAt: DS.attr('date'), | ||||||
|   updatedAt: DS.attr('date'), |   updatedAt: DS.attr('date'), | ||||||
|   deletedAt: DS.attr('date'), |   deletedAt: DS.attr('date'), | ||||||
|  |   author: DS.attr('number'), | ||||||
|   totalMeasurements: DS.attr('number'), |   totalMeasurements: DS.attr('number'), | ||||||
|   fullName: Ember.computed('speciesName', 'strainName', function() { |   fullName: Ember.computed('speciesName', 'strainName', function() { | ||||||
|     return this.get('speciesName') + ' (' + this.get('strainName') + ')'; |     return this.get('speciesName') + ' (' + this.get('strainName') + ')'; | ||||||
|  |  | ||||||
|  | @ -1,6 +1,11 @@ | ||||||
| <h2>{{genus-name}} Strains</h2> | <h2>{{genus-name}} Strains</h2> | ||||||
| <h3>Total strains: {{controller.length}}</h3> | <h3>Total strains: {{controller.length}}</h3> | ||||||
| 
 | 
 | ||||||
|  | {{#if (can "add strain")}} | ||||||
|  |   {{! Does nothing ATM }} | ||||||
|  |   <a class="button-gray smaller">Add Strain</a> | ||||||
|  | {{/if}} | ||||||
|  | 
 | ||||||
| <table class="flakes-table"> | <table class="flakes-table"> | ||||||
|   <thead> |   <thead> | ||||||
|     <tr> |     <tr> | ||||||
|  |  | ||||||
|  | @ -51,9 +51,19 @@ | ||||||
|         </dl> |         </dl> | ||||||
|         <dl class="span-1"></dl> |         <dl class="span-1"></dl> | ||||||
|       </div> |       </div> | ||||||
|  |       {{#if (can "edit strain" model)}} | ||||||
|  |         {{! ROW 5 }} | ||||||
|  |         <div class="grid-4"> | ||||||
|  |           <div class="span-1"> | ||||||
|  |             {{! Does nothing ATM }} | ||||||
|  |             <a class="button-gray smaller">Edit Strain</a> | ||||||
|  |           </div> | ||||||
|  |         </div> | ||||||
|  |       {{/if}} | ||||||
|     </fieldset> |     </fieldset> | ||||||
|   </div> |   </div> | ||||||
| </div> | </div> | ||||||
|  | 
 | ||||||
| <div class="measurements-container"> | <div class="measurements-container"> | ||||||
|   {{outlet}} |   {{outlet}} | ||||||
| </div> | </div> | ||||||
|  |  | ||||||
|  | @ -42,6 +42,11 @@ module.exports = function(environment) { | ||||||
|       refreshLeeway: 300, |       refreshLeeway: 300, | ||||||
|       timeFactor: 1 |       timeFactor: 1 | ||||||
|     } |     } | ||||||
|  |     ENV['ember-can'] = { | ||||||
|  |       inject: { | ||||||
|  |         session: 'simple-auth-session:main' | ||||||
|  |       } | ||||||
|  |     } | ||||||
|     ENV.apiURL = 'http://127.0.0.1:4200'; |     ENV.apiURL = 'http://127.0.0.1:4200'; | ||||||
|     ENV.contentSecurityPolicy = { |     ENV.contentSecurityPolicy = { | ||||||
|       'default-src': "'none'", |       'default-src': "'none'", | ||||||
|  | @ -72,6 +77,11 @@ module.exports = function(environment) { | ||||||
|       refreshLeeway: 300, |       refreshLeeway: 300, | ||||||
|       timeFactor: 1 |       timeFactor: 1 | ||||||
|     } |     } | ||||||
|  |     ENV['ember-can'] = { | ||||||
|  |       inject: { | ||||||
|  |         session: 'simple-auth-session:main' | ||||||
|  |       } | ||||||
|  |     } | ||||||
|     ENV.apiURL = 'https://bactdb-test.herokuapp.com'; |     ENV.apiURL = 'https://bactdb-test.herokuapp.com'; | ||||||
|     ENV.contentSecurityPolicy = { |     ENV.contentSecurityPolicy = { | ||||||
|       'default-src': "'none'", |       'default-src': "'none'", | ||||||
|  | @ -106,6 +116,11 @@ module.exports = function(environment) { | ||||||
|       refreshLeeway: 300, |       refreshLeeway: 300, | ||||||
|       timeFactor: 1 |       timeFactor: 1 | ||||||
|     } |     } | ||||||
|  |     ENV['ember-can'] = { | ||||||
|  |       inject: { | ||||||
|  |         session: 'simple-auth-session:main' | ||||||
|  |       } | ||||||
|  |     } | ||||||
|     ENV.apiURL = 'https://bactdb.herokuapp.com'; |     ENV.apiURL = 'https://bactdb.herokuapp.com'; | ||||||
|     ENV.contentSecurityPolicy = { |     ENV.contentSecurityPolicy = { | ||||||
|       'default-src': "'none'", |       'default-src': "'none'", | ||||||
|  |  | ||||||
|  | @ -22,6 +22,7 @@ | ||||||
|     "body-parser": "^1.12.2", |     "body-parser": "^1.12.2", | ||||||
|     "broccoli-asset-rev": "^2.0.2", |     "broccoli-asset-rev": "^2.0.2", | ||||||
|     "connect-restreamer": "^1.0.2", |     "connect-restreamer": "^1.0.2", | ||||||
|  |     "ember-can": "^0.4.0", | ||||||
|     "ember-cli": "0.2.2", |     "ember-cli": "0.2.2", | ||||||
|     "ember-cli-app-version": "0.3.3", |     "ember-cli-app-version": "0.3.3", | ||||||
|     "ember-cli-babel": "^4.0.0", |     "ember-cli-babel": "^4.0.0", | ||||||
|  |  | ||||||
|  | @ -16,6 +16,7 @@ module.exports = function(app) { | ||||||
|       createdAt: "0001-01-01T00:00:00Z", |       createdAt: "0001-01-01T00:00:00Z", | ||||||
|       updatedAt: "0001-01-01T00:00:00Z", |       updatedAt: "0001-01-01T00:00:00Z", | ||||||
|       deletedAt: null, |       deletedAt: null, | ||||||
|  |       author: 1, | ||||||
|       totalMeasurements: 5, |       totalMeasurements: 5, | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|  | @ -31,6 +32,7 @@ module.exports = function(app) { | ||||||
|       createdAt: "0001-01-01T00:00:00Z", |       createdAt: "0001-01-01T00:00:00Z", | ||||||
|       updatedAt: "0001-01-01T00:00:00Z", |       updatedAt: "0001-01-01T00:00:00Z", | ||||||
|       deletedAt: null, |       deletedAt: null, | ||||||
|  |       author: 3, | ||||||
|       totalMeasurements: 5, |       totalMeasurements: 5, | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|  | @ -46,6 +48,7 @@ module.exports = function(app) { | ||||||
|       createdAt: "0001-01-01T00:00:00Z", |       createdAt: "0001-01-01T00:00:00Z", | ||||||
|       updatedAt: "0001-01-01T00:00:00Z", |       updatedAt: "0001-01-01T00:00:00Z", | ||||||
|       deletedAt: null, |       deletedAt: null, | ||||||
|  |       author: 1, | ||||||
|       totalMeasurements: 0, |       totalMeasurements: 0, | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|  | @ -61,6 +64,7 @@ module.exports = function(app) { | ||||||
|       createdAt: "0001-01-01T00:00:00Z", |       createdAt: "0001-01-01T00:00:00Z", | ||||||
|       updatedAt: "0001-01-01T00:00:00Z", |       updatedAt: "0001-01-01T00:00:00Z", | ||||||
|       deletedAt: null, |       deletedAt: null, | ||||||
|  |       author: 3, | ||||||
|       totalMeasurements: 0, |       totalMeasurements: 0, | ||||||
|     } |     } | ||||||
|   ]; |   ]; | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 Matthew Dillon
						Matthew Dillon