Translate texts, first step, and fix database call and handling

This commit is contained in:
Wolfgang Huß 2021-03-16 17:32:01 +01:00
parent f3aa5afa81
commit b6fb98acdc
6 changed files with 104 additions and 40 deletions

View File

@ -2,8 +2,14 @@
<div class="Sliders"> <div class="Sliders">
<slot :name="'header'" /> <slot :name="'header'" />
<ds-heading v-if="sliderData.sliders[sliderIndex].title" size="h3"> <ds-heading
{{ sliderData.sliders[sliderIndex].title }} v-if="
sliderData.sliders[sliderIndex].titleIdent &&
$t(sliderData.sliders[sliderIndex].titleIdent).length > 0
"
size="h3"
>
{{ $t(sliderData.sliders[sliderIndex].titleIdent) }}
</ds-heading> </ds-heading>
<slot :name="sliderData.sliders[sliderIndex].name" /> <slot :name="sliderData.sliders[sliderIndex].name" />
@ -38,7 +44,7 @@
:disabled="!sliderData.sliders[sliderIndex].validated" :disabled="!sliderData.sliders[sliderIndex].validated"
@click="onNextClick" @click="onNextClick"
> >
{{ sliderData.sliders[sliderIndex].button.title }} {{ $t(sliderData.sliders[sliderIndex].button.titleIdent) }}
</base-button> </base-button>
</ds-flex-item> </ds-flex-item>
</ds-flex> </ds-flex>

View File

@ -37,7 +37,7 @@
<input id="checkbox" type="checkbox" v-model="sendEmailAgain" :checked="sendEmailAgain" /> <input id="checkbox" type="checkbox" v-model="sendEmailAgain" :checked="sendEmailAgain" />
<label for="checkbox0"> <label for="checkbox0">
<!-- Wolle {{ $t('termsAndConditions.termsAndConditionsConfirmed') }} --> <!-- Wolle {{ $t('termsAndConditions.termsAndConditionsConfirmed') }} -->
{{ 'Send e-mail again' }} {{ $t('components.email.form.sendEmailAgain') }}
</label> </label>
</ds-text> </ds-text>
</ds-form> </ds-form>
@ -157,16 +157,16 @@ export default {
buttonValues() { buttonValues() {
return { return {
sliderSettings: { sliderSettings: {
buttonTitle: this.sliderData.collectedInputData.emailSend buttonTitleIdent: this.sliderData.collectedInputData.emailSend
? this.sendEmailAgain ? this.sendEmailAgain
? 'Resend e-mail' ? 'components.email.buttonTitleResend'
: 'Skip resend' : 'components.email.buttonTitleSkipResend'
: 'Send e-mail', // Wolle : 'components.email.buttonTitleSend',
buttonIcon: this.sliderData.collectedInputData.emailSend buttonIcon: this.sliderData.collectedInputData.emailSend
? this.sendEmailAgain ? this.sendEmailAgain
? 'envelope' ? 'envelope'
: 'arrow-right' : 'arrow-right'
: 'envelope', // Wolle : 'envelope',
}, },
} }
}, },
@ -191,7 +191,7 @@ export default {
if (this.sendEmailAgain || !this.isVariablesRequested(variables)) { if (this.sendEmailAgain || !this.isVariablesRequested(variables)) {
try { try {
const response = await this.$apollo.mutate({ SignupMutation, variables }) // e-mail is send in emailMiddleware of backend const response = await this.$apollo.mutate({ mutation: SignupMutation, variables }) // e-mail is send in emailMiddleware of backend
this.sliderData.setSliderValuesCallback(null, { this.sliderData.setSliderValuesCallback(null, {
sliderData: { request: { variables }, response: response.data }, sliderData: { request: { variables }, response: response.data },
}) })
@ -202,11 +202,11 @@ export default {
}) })
this.setButtonValues() this.setButtonValues()
const { email: respnseEmail } = this.sliderData.sliders[ const { email: responseEmail } = this.sliderData.sliders[
this.sliderIndex this.sliderIndex
].data.response.Signup ].data.response.Signup
this.$toast.success( this.$toast.success(
this.$t('components.registration.email.form.success', { email: respnseEmail }), this.$t('components.registration.email.form.success', { email: responseEmail }),
) )
} }
return true return true

View File

@ -8,9 +8,23 @@
@input-valid="handleInputValid" @input-valid="handleInputValid"
> >
<ds-text> <ds-text>
<!-- Wolle {{ $t('components.enter-nonce.form.description') }} --> {{ $t('components.enter-nonce.form.yourEmail') }}
Your e-mail address: <b
<b>{{ this.sliderData.collectedInputData.email }}</b> v-if="sliderData.collectedInputData.email && sliderData.collectedInputData.email.length > 0"
>
{{ sliderData.collectedInputData.email }}
</b>
<b v-else class="warning">{{ $t('components.enter-nonce.form.yourEmailWarningUndef') }}</b>
<b
v-if="
sliderData.collectedInputData.email &&
sliderData.collectedInputData.email.length > 0 &&
!isEmailFormat
"
class="warning"
>
{{ $t('components.enter-nonce.form.yourEmailWarningFormat') }}
</b>
</ds-text> </ds-text>
<ds-input <ds-input
:placeholder="$t('components.enter-nonce.form.nonce')" :placeholder="$t('components.enter-nonce.form.nonce')"
@ -28,6 +42,7 @@
<script> <script>
import gql from 'graphql-tag' import gql from 'graphql-tag'
import { isEmail } from 'validator'
export const verifyNonceQuery = gql` export const verifyNonceQuery = gql`
query($email: String!, $nonce: String!) { query($email: String!, $nonce: String!) {
@ -54,6 +69,7 @@ export default {
message: this.$t('components.enter-nonce.form.validations.length'), message: this.$t('components.enter-nonce.form.validations.length'),
}, },
}, },
dbRequestInProgress: false,
} }
}, },
mounted: function () { mounted: function () {
@ -77,6 +93,9 @@ export default {
validInput() { validInput() {
return this.formData.nonce.length === 5 return this.formData.nonce.length === 5
}, },
isEmailFormat() {
return isEmail(this.sliderData.collectedInputData.email)
},
}, },
methods: { methods: {
async sendValidation() { async sendValidation() {
@ -110,9 +129,13 @@ export default {
const { email, nonce } = this.sliderData.collectedInputData const { email, nonce } = this.sliderData.collectedInputData
const variables = { email, nonce } const variables = { email, nonce }
if (!this.isVariablesRequested(variables)) { if (!this.isVariablesRequested(variables) && !this.dbRequestInProgress) {
try { try {
this.dbRequestInProgress = true
console.log('handleSubmitVerify !!! variables: ', variables)
const response = await this.$apollo.query({ query: verifyNonceQuery, variables }) const response = await this.$apollo.query({ query: verifyNonceQuery, variables })
console.log('handleSubmitVerify !!! response: ', response)
this.sliderData.setSliderValuesCallback(null, { this.sliderData.setSliderValuesCallback(null, {
sliderData: { request: { variables }, response: response.data }, sliderData: { request: { variables }, response: response.data },
}) })
@ -132,6 +155,8 @@ export default {
const { message } = err const { message } = err
this.$toast.error(message) this.$toast.error(message)
} finally {
this.dbRequestInProgress = false
} }
} }
}, },
@ -147,5 +172,9 @@ export default {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
margin: $space-large 0 $space-xxx-small 0; margin: $space-large 0 $space-xxx-small 0;
.warning {
color: $text-color-warning;
}
} }
</style> </style>

View File

@ -78,12 +78,11 @@ export default {
const slidersPortfolio = { const slidersPortfolio = {
noPublicRegistration: { noPublicRegistration: {
name: 'no-public-registration', name: 'no-public-registration',
// title: this.$t('components.registration.create-user-account.title'), titleIdent: 'No Public Registration', // Wolle
title: 'No Public Registration', // Wolle
validated: false, validated: false,
data: { request: null, response: null }, data: { request: null, response: null },
button: { button: {
title: this.$t('site.back-to-login'), // Wolle titleIdent: this.$t('site.back-to-login'), // Wolle
icon: 'arrow-right', icon: 'arrow-right',
callback: this.buttonCallback, callback: this.buttonCallback,
sliderCallback: null, // optional set by slot sliderCallback: null, // optional set by slot
@ -91,12 +90,11 @@ export default {
}, },
enterInvite: { enterInvite: {
name: 'enter-invite', name: 'enter-invite',
// title: this.$t('components.registration.create-user-account.title'), titleIdent: 'components.registration.invite-code.title',
title: 'Invitation', // Wolle
validated: false, validated: false,
data: { request: null, response: { isValidInviteCode: false } }, data: { request: null, response: { isValidInviteCode: false } },
button: { button: {
title: 'Next', // Wolle titleIdent: 'components.registration.invite-code.buttonTitle',
icon: 'arrow-right', icon: 'arrow-right',
callback: this.buttonCallback, callback: this.buttonCallback,
sliderCallback: null, // optional set by slot sliderCallback: null, // optional set by slot
@ -104,11 +102,11 @@ export default {
}, },
enterEmail: { enterEmail: {
name: 'enter-email', name: 'enter-email',
title: 'E-Mail', // Wolle titleIdent: 'components.registration.email.title',
validated: false, validated: false,
data: { request: null, response: null }, data: { request: null, response: null },
button: { button: {
title: '', // set by slider component titleIdent: '', // set by slider component
icon: '', // set by slider component icon: '', // set by slider component
callback: this.buttonCallback, callback: this.buttonCallback,
sliderCallback: null, // optional set by slot sliderCallback: null, // optional set by slot
@ -116,11 +114,11 @@ export default {
}, },
enterNonce: { enterNonce: {
name: 'enter-nonce', name: 'enter-nonce',
title: 'E-Mail Confirmation', // Wolle titleIdent: 'components.registration.email-nonce.title',
validated: false, validated: false,
data: { request: null, response: { VerifyNonce: false } }, data: { request: null, response: { VerifyNonce: false } },
button: { button: {
title: 'Confirm', // Wolle titleIdent: 'components.registration.email-nonce.buttonTitle',
icon: 'arrow-right', icon: 'arrow-right',
callback: this.buttonCallback, callback: this.buttonCallback,
sliderCallback: null, // optional set by slot sliderCallback: null, // optional set by slot
@ -128,12 +126,11 @@ export default {
}, },
createUserAccount: { createUserAccount: {
name: 'create-user-account', name: 'create-user-account',
title: this.$t('components.registration.create-user-account.title'), titleIdent: this.$t('components.registration.create-user-account.title'),
validated: false, validated: false,
data: { request: null, response: null }, data: { request: null, response: null },
button: { button: {
// title: this.$t('actions.save'), // Wolle titleIdent: 'Create', // Wolle
title: 'Create', // Wolle
icon: 'check', icon: 'check',
callback: this.buttonCallback, callback: this.buttonCallback,
sliderCallback: null, // optional set by slot sliderCallback: null, // optional set by slot
@ -226,9 +223,9 @@ export default {
} }
} }
if (sliderSettings) { if (sliderSettings) {
const { buttonTitle, buttonIcon, buttonSliderCallback } = sliderSettings const { buttonTitleIdent, buttonIcon, buttonSliderCallback } = sliderSettings
if (buttonTitle) { if (buttonTitleIdent) {
this.sliderData.sliders[this.sliderIndex].button.title = buttonTitle this.sliderData.sliders[this.sliderIndex].button.titleIdent = buttonTitleIdent
} }
if (buttonIcon) { if (buttonIcon) {
this.sliderData.sliders[this.sliderIndex].button.icon = buttonIcon this.sliderData.sliders[this.sliderIndex].button.icon = buttonIcon

View File

@ -120,6 +120,14 @@
"versus": "Versus" "versus": "Versus"
}, },
"components": { "components": {
"email": {
"buttonTitleResend": "Erneut senden",
"buttonTitleSend": "Sende E-Mail",
"buttonTitleSkipResend": "Nicht senden",
"form": {
"sendEmailAgain": "E-Mail erneut senden"
}
},
"enter-invite": { "enter-invite": {
"form": { "form": {
"description": "Gib den Einladungs-Code ein, den du bekommen hast.", "description": "Gib den Einladungs-Code ein, den du bekommen hast.",
@ -137,7 +145,10 @@
"nonce": "Code eingeben", "nonce": "Code eingeben",
"validations": { "validations": {
"length": "muss genau 6 Buchstaben lang sein" "length": "muss genau 6 Buchstaben lang sein"
} },
"yourEmail": "Deine E-Mail-Adresse:",
"yourEmailWarningFormat": "⚠️ E-Mail hat ein ungültiges Format!",
"yourEmailWarningUndef": "⚠️ Keine E-Mail definiert!"
} }
}, },
"password-reset": { "password-reset": {
@ -165,17 +176,22 @@
"email": { "email": {
"form": { "form": {
"success": "Verifikations-E-Mail gesendet an <b>{email}</b>!" "success": "Verifikations-E-Mail gesendet an <b>{email}</b>!"
} },
"title": "E-Mail"
}, },
"email-nonce": { "email-nonce": {
"buttonTitle": "Bestätigen",
"form": { "form": {
"success": "Gültiger Bestätigungs-Code <b>{nonce}</b> für E-Mail <b>{email}</b>!" "success": "Gültiger Bestätigungs-Code <b>{nonce}</b> für E-Mail <b>{email}</b>!"
} },
"title": "E-Mail Bestätigung"
}, },
"invite-code": { "invite-code": {
"buttonTitle": "Weiter",
"form": { "form": {
"success": "Gültiger Einladungs-Code <b>{inviteCode}</b>!" "success": "Gültiger Einladungs-Code <b>{inviteCode}</b>!"
} },
"title": "Einladung"
}, },
"signup": { "signup": {
"form": { "form": {

View File

@ -120,6 +120,14 @@
"versus": "Versus" "versus": "Versus"
}, },
"components": { "components": {
"email": {
"buttonTitleResend": "Resend e-mail",
"buttonTitleSend": "Send e-mail",
"buttonTitleSkipResend": "Skip resend",
"form": {
"sendEmailAgain": "Send e-mail again"
}
},
"enter-invite": { "enter-invite": {
"form": { "form": {
"description": "Enter the invitation code you received.", "description": "Enter the invitation code you received.",
@ -137,7 +145,10 @@
"nonce": "Enter your code", "nonce": "Enter your code",
"validations": { "validations": {
"length": "must be 6 characters long" "length": "must be 6 characters long"
} },
"yourEmail": "Your e-mail address:",
"yourEmailWarningFormat": "⚠️ E-mail has wrong format!",
"yourEmailWarningUndef": "⚠️ No e-mail defined!"
} }
}, },
"password-reset": { "password-reset": {
@ -165,17 +176,22 @@
"email": { "email": {
"form": { "form": {
"success": "Verification e-mail send to <b>{email}</b>!" "success": "Verification e-mail send to <b>{email}</b>!"
} },
"title": "E-Mail"
}, },
"email-nonce": { "email-nonce": {
"buttonTitle": "Confirm",
"form": { "form": {
"success": "Valid verification code <b>{nonce}</b> for e-mail <b>{email}</b>!" "success": "Valid verification code <b>{nonce}</b> for e-mail <b>{email}</b>!"
} },
"title": "E-Mail Confirmation"
}, },
"invite-code": { "invite-code": {
"buttonTitle": "Next",
"form": { "form": {
"success": "Valid invite code <b>{inviteCode}</b>!" "success": "Valid invite code <b>{inviteCode}</b>!"
} },
"title": "Invitation"
}, },
"signup": { "signup": {
"form": { "form": {