form-row.js 753 B

12345678910111213141516171819202122232425262728293031
  1. import Ember from 'ember';
  2. export default Ember.Component.extend({
  3. classNames: 'form-group',
  4. classNameBindings: [
  5. 'hasFeedback:has-feedback',
  6. 'hasSuccess:has-success',
  7. 'hasError:has-error'
  8. ],
  9. hasFeedback: function() {
  10. return this.get('validation') !== null;
  11. }.property('validation'),
  12. hasSuccess: function() {
  13. return this.get('hasFeedback') && !this.get('hasError');
  14. }.property('hasFeedback', 'hasError'),
  15. hasError: function() {
  16. return this.get('hasFeedback') && this.get('errors');
  17. }.property('hasFeedback', 'errors'),
  18. errors: function() {
  19. if (this.get('hasFeedback')) {
  20. return this.get('validation.' + this.get('name')) || null;
  21. }
  22. return null;
  23. }.property('validation', 'name')
  24. });