Typescript Terminato! Funziona!
This commit is contained in:
@@ -5,24 +5,26 @@ import { complexity, registered } from '@/validation'
|
||||
|
||||
export type TSignup = { signup: ISignupOptions, validationGroup: string[] }
|
||||
|
||||
export const validations: ValidationRuleset<TSignup> = {
|
||||
export const validations = {
|
||||
signup: {
|
||||
confirmPassword: {
|
||||
repeatPassword: {
|
||||
required,
|
||||
sameAsPassword: sameAs('password')
|
||||
},
|
||||
displayName: {
|
||||
required,
|
||||
minLength: minLength(2)
|
||||
},
|
||||
password: {
|
||||
required,
|
||||
complexity
|
||||
},
|
||||
userName: {
|
||||
username: {
|
||||
required,
|
||||
email,
|
||||
registered
|
||||
},
|
||||
email: {
|
||||
required,
|
||||
email
|
||||
},
|
||||
terms: {
|
||||
required
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,43 @@
|
||||
import { Component, Vue, Prop } from 'vue-property-decorator'
|
||||
import Vue from 'vue'
|
||||
import { Component, Prop, Watch } from 'vue-property-decorator'
|
||||
import { UserModule } from '@/store/modules/user'
|
||||
import { ErroriMongoDb } from '@/store/modules/user'
|
||||
|
||||
import { validationMixin } from 'vuelidate'
|
||||
import { required, minValue } from 'vuelidate/lib/validators'
|
||||
import { required, email, numeric, maxLength, maxValue, minValue, sameAs, minLength } from 'vuelidate/lib/validators'
|
||||
import { ISignupOptions, IUserState } from '@/model'
|
||||
import { validations, TSignup } from './signup-validate'
|
||||
|
||||
import { validationMixin } from 'vuelidate'
|
||||
|
||||
import './signup.scss'
|
||||
import { complexity, registered } from '@/validation'
|
||||
|
||||
// import {Loading, QSpinnerFacebook, QSpinnerGears} from 'quasar'
|
||||
|
||||
@Component({
|
||||
mixins: [validationMixin],
|
||||
name: 'Signup',
|
||||
validations: validations
|
||||
})
|
||||
|
||||
export default class Signup extends Vue {
|
||||
public $v
|
||||
public $q
|
||||
$t: any
|
||||
|
||||
duplicate_email: boolean = false
|
||||
duplicate_username: boolean = false
|
||||
user: ISignupOptions = {
|
||||
|
||||
public signup: ISignupOptions = {
|
||||
email: process.env.TEST_EMAIL,
|
||||
username: process.env.TEST_USERNAME || '',
|
||||
password: process.env.TEST_PASSWORD,
|
||||
repeatPassword: process.env.TEST_PASSWORD
|
||||
repeatPassword: process.env.TEST_PASSWORD,
|
||||
terms: true
|
||||
}
|
||||
terms = true
|
||||
|
||||
$v: any
|
||||
$t: any
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
}
|
||||
|
||||
created() {
|
||||
|
||||
this.$v.$reset()
|
||||
}
|
||||
|
||||
mounted() {
|
||||
@@ -47,7 +48,7 @@ export default class Signup extends Vue {
|
||||
|
||||
get allowSubmit() {
|
||||
|
||||
let error = this.$v.signup.$error || this.$v.signup.$invalid
|
||||
let error = this.$v.$error || this.$v.$invalid
|
||||
return !error
|
||||
}
|
||||
|
||||
@@ -95,7 +96,7 @@ export default class Signup extends Vue {
|
||||
this.$q.notify(msg)
|
||||
}
|
||||
|
||||
errorMsg(cosa: string, item: any) {
|
||||
public errorMsg(cosa: string, item: any) {
|
||||
try {
|
||||
if (!item.$error) return ''
|
||||
if (item.$params.email && !item.email) return this.$t('reg.err.email')
|
||||
@@ -137,40 +138,38 @@ export default class Signup extends Vue {
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
|
||||
|
||||
submit() {
|
||||
this.$v.user.$touch()
|
||||
this.$v.signup.$touch()
|
||||
|
||||
this.duplicate_email = false
|
||||
this.duplicate_username = false
|
||||
|
||||
if (!this.user.terms) {
|
||||
if (!this.signup.terms) {
|
||||
this.showNotif(this.$t('reg.err.terms'))
|
||||
return
|
||||
}
|
||||
|
||||
if (this.v.user.$error) {
|
||||
if (this.$v.signup.$error) {
|
||||
this.showNotif(this.$t('reg.err.errore_generico'))
|
||||
return
|
||||
}
|
||||
|
||||
this.$q.loading.show({ message: this.$t('reg.incorso') })
|
||||
|
||||
console.log(this.user)
|
||||
UserModule.signup(this.user)
|
||||
console.log(this.signup)
|
||||
UserModule.signup(this.signup)
|
||||
.then((riscode) => {
|
||||
this.checkErrors(riscode)
|
||||
this.$q.loading.hide()
|
||||
}).catch(error => {
|
||||
console.log("ERROR = " + error)
|
||||
console.log('ERROR = ' + error)
|
||||
this.$q.loading.hide()
|
||||
})
|
||||
|
||||
|
||||
// ...
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,80 +10,73 @@
|
||||
<!--Prova URL : {{env('PROVA_PAOLO')}}-->
|
||||
|
||||
<q-field
|
||||
:error="$v.user.email.$error"
|
||||
error-label="`${errorMsg('username', $v.user.username)}`"
|
||||
:error="$v.signup.email.$error"
|
||||
:error-label="`${errorMsg('email', $v.signup.email)}`"
|
||||
>
|
||||
<q-input
|
||||
v-model="user.email"
|
||||
v-validate="'required|email|truthy'"
|
||||
:value="user.email"
|
||||
@change="val => { user.email = val }"
|
||||
v-model="signup.email"
|
||||
@change="val => { signup.email = val }"
|
||||
:before="[{icon: 'mail', handler () {}}]"
|
||||
@blur="$v.user.email.touch"
|
||||
:error="$v.user.email.$error"
|
||||
:float-label="$t('reg.email')"
|
||||
/>
|
||||
@blur="$v.signup.email.$touch"
|
||||
:error="$v.signup.email.$error"
|
||||
:float-label="$t('reg.email')"></q-input>
|
||||
</q-field>
|
||||
|
||||
<!--
|
||||
|
||||
<q-field
|
||||
:error="v.user.username.$error"
|
||||
:error-label="`${errorMsg('username', v.user.username)}`"
|
||||
:error="$v.signup.username.$error"
|
||||
:error-label="`${errorMsg('username', $v.signup.username)}`"
|
||||
>
|
||||
<q-input
|
||||
:value="user.username"
|
||||
@change="val => { user.username = val }"
|
||||
v-model="signup.username"
|
||||
@change="val => { signup.username = val }"
|
||||
:before="[{icon: 'person', handler () {}}]"
|
||||
@blur="v.user.username.$touch"
|
||||
:error="v.user.username.$error"
|
||||
:float-label="$t('reg.username')"
|
||||
/>
|
||||
@blur="$v.signup.username.$touch"
|
||||
:error="$v.signup.username.$error"
|
||||
:float-label="$t('reg.username')"></q-input>
|
||||
</q-field>
|
||||
|
||||
|
||||
<q-field
|
||||
:error="v.user.password.$error"
|
||||
:error-label="`${errorMsg('password', v.user.password)}`"
|
||||
:error="$v.signup.password.$error"
|
||||
:error-label="`${errorMsg('password', $v.signup.password)}`"
|
||||
>
|
||||
<q-input
|
||||
v-model="user.password"
|
||||
v-model="signup.password"
|
||||
:before="[{icon: 'vpn_key', handler () {}}]"
|
||||
@blur="v.user.password.$touch"
|
||||
:error="v.user.password.$error"
|
||||
:float-label="$t('reg.password')"
|
||||
/>
|
||||
@blur="$v.signup.password.$touch"
|
||||
:error="$v.signup.password.$error"
|
||||
:float-label="$t('reg.password')"></q-input>
|
||||
</q-field>
|
||||
|
||||
<q-field
|
||||
:error="v.user.repeatPassword.$error"
|
||||
:error-label="`${errorMsg('repeatpassword', v.user.repeatPassword)}`"
|
||||
:error="$v.signup.repeatPassword.$error"
|
||||
:error-label="`${errorMsg('repeatpassword', $v.signup.repeatPassword)}`"
|
||||
>
|
||||
<q-input
|
||||
v-model="user.repeatPassword"
|
||||
v-model="signup.repeatPassword"
|
||||
:before="[{icon: 'vpn_key', handler () {}}]"
|
||||
@blur="v.user.repeatPassword.$touch"
|
||||
:error="v.user.repeatPassword.$error"
|
||||
:float-label="$t('reg.repeatPassword')"
|
||||
/>
|
||||
@blur="$v.signup.repeatPassword.$touch"
|
||||
:error="$v.signup.repeatPassword.$error"
|
||||
:float-label="$t('reg.repeatPassword')"></q-input>
|
||||
</q-field>
|
||||
|
||||
<q-field
|
||||
:error="v.user.terms.$error"
|
||||
:error-label="`${errorMsg('terms', v.user.terms)}`"
|
||||
:error="$v.signup.terms.$error"
|
||||
:error-label="`${errorMsg('terms', $v.signup.terms)}`"
|
||||
>
|
||||
|
||||
<q-checkbox
|
||||
v-model="user.terms"
|
||||
v-model="signup.terms"
|
||||
:before="[{icon: 'vpn_key', handler () {}}]"
|
||||
color="secondary"
|
||||
@blur="v.user.terms.$touch"
|
||||
:error="v.user.terms.$error"
|
||||
@blur="$v.signup.terms.$touch"
|
||||
:error="$v.signup.terms.$error"
|
||||
:float-label="$t('reg.terms')"
|
||||
:label="$t('reg.terms')"
|
||||
/>
|
||||
:label="$t('reg.terms')"></q-checkbox>
|
||||
</q-field>
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user