Advertisement
Guest User

Untitled

a guest
Jun 9th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. <template>
  2. <v-dialog v-model="show" max-width="500px" lazy>
  3. <transparent-card>
  4. <v-card-title primary-title>
  5. <h2 slot="title">Create Account</h2>
  6. </v-card-title>
  7. <v-card-text>
  8. <v-text-field @input="$v.$touch()" :rules="[usernameError]" v-model="username" label="Username"></v-text-field>
  9. <v-text-field @input="$v.$touch()" :rules="[emailError]" v-model="email" label="Email"></v-text-field>
  10. <v-text-field @input="$v.$touch()" v-model="password" label="Password" type="password"></v-text-field>
  11. <v-text-field @input="$v.$touch()" v-model="repeatPassword" label="Repeat Password"
  12. type="password"></v-text-field>
  13. <div class="text-xs-right">
  14. <v-btn flat color="primary" small>Have account? Sign In!</v-btn>
  15. </div>
  16. </v-card-text>
  17. <v-card-actions class="d-flex">
  18. <v-btn flat @click.stop="show = false">Cancel</v-btn>
  19. <v-btn :disabled="$v.$invalid" color="primary">Sign In</v-btn>
  20. </v-card-actions>
  21. </transparent-card>
  22. </v-dialog>
  23. </template>
  24.  
  25. <script lang="ts">
  26. import Vue from 'vue';
  27. import { required, email, sameAs } from 'vuelidate/lib/validators';
  28. import TransparentCard from '@/components/TransparentCard.vue';
  29. import { validationMessage } from '../../utils';
  30.  
  31. export default Vue.extend({
  32. components: {
  33. TransparentCard
  34. },
  35. props: {
  36. open: {
  37. type: Boolean
  38. }
  39. },
  40. data() {
  41. return {
  42. username: '',
  43. email: '',
  44. password: '',
  45. repeatPassword: ''
  46. };
  47. },
  48. computed: {
  49. show: {
  50. get(): boolean {
  51. return this.open;
  52. },
  53. set(value: boolean) {
  54. if (!value) {
  55. this.$emit('close');
  56. this.resetForm();
  57. }
  58. }
  59. }
  60. },
  61. methods: {
  62. resetForm() {
  63. this.username = '';
  64. this.email = '';
  65. this.password = '';
  66. this.repeatPassword = '';
  67.  
  68. this.$v.$reset();
  69. },
  70. usernameError() {
  71. return validationMessage(this.$v.username);
  72. },
  73. emailError() {
  74. return validationMessage(this.$v.email);
  75. }
  76. },
  77. validations: {
  78. username: { required },
  79. email: { required, email }
  80. }
  81. });
  82. </script>
  83.  
  84. <style lang="scss" scoped>
  85. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement