Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. Login({
  2. mixin: {
  3. emailSvc: "email",
  4. userSvc: "user"
  5. },
  6. hovering: false,
  7. username: ViewModel.property.string.notBlank
  8. .invalidMessage(`Unique username is required`)
  9. .validatingMessage(`Checking if username is available`)
  10. .validateAsync((value, done) => {
  11. this.userSvc.checkUsername(value, done);
  12. }),
  13. email: ViewModel.property.string
  14. .validate(value => this.emailSvc.validEmail(value))
  15. .invalidMessage(`Valid email is required`),
  16. password: ViewModel.property.string
  17. .min(8)
  18. .invalidMessage(`Password must be at least 8 characters long`),
  19. createAccount() {
  20. if (this.valid()) {
  21. this.userSvc.createAccount(
  22. this.username(),
  23. this.email(),
  24. this.password()
  25. );
  26. }
  27. },
  28. render() {
  29. <div class="ui centered grid">
  30. <div class="column">
  31. <div class="ui form segment">
  32. {/* .field.required + error class if validating the username asynchronously
  33. or it's invalid and hovering over the button */}
  34. <div class="field required">
  35. <label>Username</label>
  36. {/* .icon + loading class if validating the username asynchronously */}
  37. <div class="ui icon input">
  38. <input type="text" placeholder="Username" />
  39. <i class="user icon" />
  40. </div>
  41. </div>
  42.  
  43. {/* .field.required + error class if it's invalid and hovering over the button */}
  44. <div class="field required">
  45. <label>Email</label>
  46. <div class="ui icon input">
  47. <input type="email" placeholder="Email" />
  48. <i class="mail icon" />
  49. </div>
  50. </div>
  51.  
  52. {/* .field.required + error class if it's invalid and hovering over the button */}
  53. <div class="field required">
  54. <label>Password</label>
  55. <div class="ui icon input">
  56. <input type="password" />
  57. <i class="lock icon" />
  58. </div>
  59. </div>
  60.  
  61. {/*
  62. Sign up button calls createAccount when clicked.
  63. Has class 'primary' if the form is in a valid state.
  64. Has classes 'basic red' if hovering over the button and the form is invalid.
  65. */}
  66. <div class="ui button">Sign Up</div>
  67. </div>
  68.  
  69. {/* Only show .red.segment if the form is in an invalid state */}
  70. <div class="ui red segment">
  71. <ul class="ui list">
  72. {/* Repeat the li element for each error in the form */}
  73. <li>Error Message</li>
  74. </ul>
  75. </div>
  76. </div>
  77. </div>;
  78. }
  79. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement