Disable the form button with a slot scope

This commit is contained in:
Robert Schäfer 2019-07-08 18:13:24 +02:00
parent 813a6b5c50
commit 90aa1822b5
3 changed files with 80 additions and 102 deletions

View File

@ -3,10 +3,8 @@
v-model="formData" v-model="formData"
:schema="formSchema" :schema="formSchema"
@submit="handleSubmit" @submit="handleSubmit"
@input="handleInput"
@input-valid="handleInputValid"
> >
<template> <template slot-scope="{ errors }">
<ds-input <ds-input
id="oldPassword" id="oldPassword"
model="oldPassword" model="oldPassword"
@ -30,7 +28,7 @@
/> />
<password-strength :password="formData.newPassword" /> <password-strength :password="formData.newPassword" />
<ds-space margin-top="base"> <ds-space margin-top="base">
<ds-button :loading="loading" :disabled="disabled" primary> <ds-button :loading="loading" :disabled="errors" primary>
{{ $t('settings.security.change-password.button') }} {{ $t('settings.security.change-password.button') }}
</ds-button> </ds-button>
</ds-space> </ds-space>
@ -81,12 +79,6 @@ export default {
} }
}, },
methods: { methods: {
async handleInput(data) {
this.disabled = true
},
async handleInputValid(data) {
this.disabled = false
},
async handleSubmit(data) { async handleSubmit(data) {
this.loading = true this.loading = true
const mutation = gql` const mutation = gql`

View File

@ -1,16 +1,14 @@
<template> <template>
<ds-card class="verify-code"> <ds-card class="verify-code">
<ds-space margin="large"> <ds-space margin="large">
<template>
<ds-form <ds-form
v-if="!changePasswordResult" v-if="!changePasswordResult"
v-model="formData" v-model="formData"
:schema="formSchema" :schema="formSchema"
@submit="handleSubmitPassword" @submit="handleSubmitPassword"
@input="handleInput"
@input-valid="handleInputValid"
class="change-password" class="change-password"
> >
<template slot-scope="{ errors }">
<ds-input <ds-input
id="newPassword" id="newPassword"
model="newPassword" model="newPassword"
@ -27,10 +25,11 @@
/> />
<password-strength :password="formData.newPassword" /> <password-strength :password="formData.newPassword" />
<ds-space margin-top="base"> <ds-space margin-top="base">
<ds-button :loading="$apollo.loading" :disabled="disabled" primary> <ds-button :loading="$apollo.loading" :disabled="errors" primary>
{{ $t('settings.security.change-password.button') }} {{ $t('settings.security.change-password.button') }}
</ds-button> </ds-button>
</ds-space> </ds-space>
</template>
</ds-form> </ds-form>
<ds-text v-else> <ds-text v-else>
<template v-if="changePasswordResult === 'success'"> <template v-if="changePasswordResult === 'success'">
@ -48,7 +47,6 @@
<a href="mailto:support@human-connection.org">support@human-connection.org</a> <a href="mailto:support@human-connection.org">support@human-connection.org</a>
</template> </template>
</ds-text> </ds-text>
</template>
</ds-space> </ds-space>
</ds-card> </ds-card>
</template> </template>
@ -95,12 +93,6 @@ export default {
} }
}, },
methods: { methods: {
async handleInput() {
this.disabled = true
},
async handleInputValid() {
this.disabled = false
},
async handleSubmitPassword() { async handleSubmitPassword() {
const mutation = gql` const mutation = gql`
mutation($code: String!, $email: String!, $newPassword: String!) { mutation($code: String!, $email: String!, $newPassword: String!) {

View File

@ -10,12 +10,11 @@
<ds-form <ds-form
v-else v-else
class="create-user-account" class="create-user-account"
@input="handleInput"
@input-valid="handleInputValid"
v-model="formData" v-model="formData"
:schema="formSchema" :schema="formSchema"
@submit="submit" @submit="submit"
> >
<template slot-scope="{ errors }">
<ds-card :header="$t('registration.create-user-account.title')"> <ds-card :header="$t('registration.create-user-account.title')">
<ds-input <ds-input
id="name" id="name"
@ -58,13 +57,14 @@
icon="check" icon="check"
type="submit" type="submit"
:loading="$apollo.loading" :loading="$apollo.loading"
:disabled="disabled" :disabled="errors"
primary primary
> >
{{ $t('actions.save') }} {{ $t('actions.save') }}
</ds-button> </ds-button>
</template> </template>
</ds-card> </ds-card>
</template>
</ds-form> </ds-form>
</template> </template>
@ -131,12 +131,6 @@ export default {
email: { type: String, required: true }, email: { type: String, required: true },
}, },
methods: { methods: {
async handleInput() {
this.disabled = true
},
async handleInputValid() {
this.disabled = false
},
async submit() { async submit() {
const { name, password, about } = this.formData const { name, password, about } = this.formData
const { email, nonce } = this const { email, nonce } = this