form-row.js 735 B

123456789101112131415161718192021222324252627282930
  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 typeof this.get('validation') !== 'undefined';
  11. }.property('validation'),
  12. hasSuccess: function() {
  13. return this.get('validation') === 'ok';
  14. }.property('hasFeedback'),
  15. hasError: function() {
  16. return this.get('hasFeedback') && !this.get('hasSuccess');
  17. }.property('hasFeedback', 'hasSuccess'),
  18. messages: function() {
  19. if (this.get('hasError')) {
  20. return this.get('validation');
  21. } else {
  22. return null;
  23. }
  24. }.property('hasError', 'hasSuccess')
  25. });