parent
							
								
									e1abc5e4cb
								
							
						
					
					
						commit
						f41f4caccd
					
				
					 17 changed files with 221 additions and 77 deletions
				
			
		|  | @ -1,5 +1,6 @@ | |||
| import Ember from 'ember'; | ||||
| import Changeset from 'ember-changeset'; | ||||
| import lookupValidator from 'ember-changeset-validations'; | ||||
| 
 | ||||
| const { Component } = Ember; | ||||
| 
 | ||||
|  | @ -7,6 +8,7 @@ export default Component.extend({ | |||
|   init() { | ||||
|     this._super(...arguments); | ||||
|     const model = this.get('model'); | ||||
|     this.set('changeset', new Changeset(model)); | ||||
|     const validations = this.get('validations'); | ||||
|     this.set('changeset', new Changeset(model, lookupValidator(validations), validations)); | ||||
|   }, | ||||
| }); | ||||
|  |  | |||
							
								
								
									
										14
									
								
								app/components/validated-field.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								app/components/validated-field.js
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| import Ember from 'ember'; | ||||
| 
 | ||||
| const { Component, computed, get, isEmpty } = Ember; | ||||
| 
 | ||||
| export default Component.extend({ | ||||
|   classNames: ['form-group'], | ||||
|   classNameBindings: ['isValid::has-error'], | ||||
| 
 | ||||
|   isValid: computed('changeset.error', 'property', function() { | ||||
|     const changeset = this.get('changeset'); | ||||
|     const property = this.get('property'); | ||||
|     return isEmpty(get(changeset, `error.${property}`)); | ||||
|   }), | ||||
| }); | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 GitHub
							GitHub