misc: deps cleanup + form validation fixes

This commit is contained in:
Nick
2019-09-15 23:20:40 -04:00
parent 1717f7a8d3
commit 309de5bc17
32 changed files with 761 additions and 1193 deletions

View File

@@ -23,11 +23,6 @@
prepend-icon='mdi-at'
v-model='email'
label='Email Address'
v-validate='{ required: true, email: true, min: 2, max: 255 }',
data-vv-name='email',
data-vv-as='Email Address',
data-vv-scope='newUser',
:error-messages='errors.collect(`newUser.email`)'
key='newUserEmail'
persistent-hint
ref='emailInput'
@@ -41,11 +36,6 @@
:label='mustChangePwd ? `Temporary Password` : `Password`'
counter='255'
@click:append='generatePwd'
v-validate='{ required: true, min: 6, max: 255 }',
data-vv-name='password',
data-vv-as='Password',
data-vv-scope='newUser',
:error-messages='errors.collect(`newUser.password`)'
key='newUserPassword'
persistent-hint
)
@@ -54,11 +44,6 @@
prepend-icon='mdi-account-outline'
v-model='name'
label='Name'
v-validate='{ required: true, min: 2, max: 255 }',
data-vv-name='name',
data-vv-as='Name',
data-vv-scope='newUser',
:error-messages='errors.collect(`newUser.name`)'
:hint='provider === `local` ? `Can be changed by the user.` : `May be overwritten by the provider during login.`'
key='newUserName'
persistent-hint
@@ -94,16 +79,17 @@
v-card-chin
v-spacer
v-btn(text, @click='isShown = false') Cancel
v-btn.px-3(depressed, color='primary', @click='newUser(false)', :disabled='errors.any(`newUser`)')
v-btn.px-3(depressed, color='primary', @click='newUser(false)')
v-icon(left) mdi-chevron-right
span Create
v-btn.px-3(depressed, color='primary', @click='newUser(true)', :disabled='errors.any(`newUser`)')
v-btn.px-3(depressed, color='primary', @click='newUser(true)')
v-icon(left) mdi-chevron-double-right
span Create and Close
</template>
<script>
import _ from 'lodash'
import validate from 'validate.js'
import createUserMutation from 'gql/admin/users/users-mutation-create.gql'
import providersQuery from 'gql/admin/users/users-query-strategies.gql'
@@ -138,20 +124,54 @@ export default {
watch: {
value(newValue, oldValue) {
if (newValue) {
this.$validator.reset()
this.$nextTick(() => {
this.$refs.emailInput.focus()
})
}
},
provider(newValue, oldValue) {
this.$validator.reset()
}
},
methods: {
async newUser(close = false) {
const validationSuccess = await this.$validator.validateAll('newUser')
if (!validationSuccess) {
let rules = {
email: {
presence: {
allowEmpty: false
},
email: true
},
name: {
presence: {
allowEmpty: false
},
length: {
minimum: 2,
maximum: 255
}
}
}
if (this.provider === `local`) {
rules.password = {
presence: {
allowEmpty: false
},
length: {
minimum: 6,
maximum: 255
}
}
}
const validationResults = validate({
email: this.email,
password: this.password,
name: this.name
}, rules, { format: 'flat' })
if (validationResults) {
this.$store.commit('showNotification', {
style: 'red',
message: validationResults[0],
icon: 'alert'
})
return
}
@@ -192,7 +212,7 @@ export default {
this.$store.commit('showNotification', {
style: 'red',
message: _.get(resp, 'data.users.create.responseResult.message', 'An unexpected error occured.'),
icon: 'warning'
icon: 'alert'
})
}
} catch (err) {