Created
December 26, 2014 21:09
-
-
Save davidwallacejackson/1004b423d0eea7bada83 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import FormInput from './form-input'; | |
| var displayValuePath = 'name'; | |
| export default FormInput.extend({ | |
| valid: function() { | |
| // Values in 'selection' are always promise proxies for models. By this | |
| // point, they should *always* be resolved, so _data should have a model in | |
| // it (or null). | |
| var selection = this.get('selection'); | |
| if (selection && selection._data) { | |
| return true; | |
| } | |
| return false; | |
| }.property('selection'), | |
| selection: function() { | |
| var value = this.get('value'); | |
| return this.get('content').findBy(displayValuePath, value); | |
| }.property('value', 'content'), | |
| meaninglessProperty: function() { | |
| return true; | |
| }.property('value') | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| export default Ember.TextField.extend({ | |
| classNameBindings: ['error'], | |
| /** | |
| * Whether the field is currently in an error state. | |
| */ | |
| error: function() { | |
| if (this.get('required')) { | |
| return !this.get('valid'); | |
| } | |
| return true; | |
| }.property('valid'), | |
| required: true, | |
| /** | |
| * Whether the current value of the field is valid. By default, any truthy | |
| * value is valid. Doesn't take 'required' into account. | |
| */ | |
| valid: function() { | |
| if (this.get('value')) { | |
| return true; | |
| } | |
| return false; | |
| }.property('value') | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment