Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. import Em from 'ember';
  2.  
  3. const birthdayRE = /\d{4}-\d{2}-\d{2}/;
  4.  
  5. export default Em.Component.extend({
  6.  
  7. classNames: ['col-md-12', 'section-post-comment'],
  8. title: 'Sign-up',
  9.  
  10. /**
  11. * Because components are singletons, we should re-create the field values any
  12. * time that the form is re-inserted on the page
  13. */
  14. willInsertElement() {
  15. this._super(...arguments);
  16. Em.run.once(() => {
  17. this.set('formValues', Em.Object.create({
  18. email: '',
  19. username: '',
  20. firstName: '',
  21. lastName: '',
  22. birthday: '',
  23. gender: 'unspecified',
  24. // These are just the field values.
  25. createPassword: '',
  26. confirmPassword: ''
  27. }));
  28. });
  29. },
  30.  
  31.  
  32. /**
  33. * Computed property which reflects whether the form has been completely filled out.
  34. * //TODO: Better validation would be nice. IE: Email
  35. */
  36. submitIsDisabled: Em.computed('formValues.createPassword', 'formValues.confirmPassword', 'formValues.username',
  37. 'formValues.firstName', 'formValues.lastName', 'formValues.email',
  38. function() {
  39.  
  40. if (!this.get('formValues.username') || this.get('formValues.username.length') < 4) {
  41. return true;
  42. }
  43. if (this.get('formValues.confirmPassword') !== this.get('formValues.createPassword') || this.get('formValues.confirmPassword') < 4 ) {
  44. return true;
  45. }
  46.  
  47. }),
  48.  
  49.  
  50. /**
  51. * Send submitted form data out to handler.
  52. * Triggered from action fired on submit.
  53. *
  54. * @returns {void}
  55. * @private
  56. */
  57. _sendSubmitForm() {
  58. // Send the formValues out to be handled by external container.
  59. this.sendAction('handleSubmitForm', this.get('formValues'));
  60. },
  61.  
  62.  
  63. actions: {
  64. onSubmitForm() {
  65. this._sendSubmitForm(...arguments);
  66. }
  67. }
  68. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement