2023-04-13 16:57:15 +00:00
|
|
|
<template>
|
|
|
|
<form @submit.prevent="submit">
|
2024-07-05 09:35:08 +00:00
|
|
|
<FormGroup
|
|
|
|
small-label
|
|
|
|
required
|
|
|
|
:label="$t('customDomainForm.domainNameLabel')"
|
2025-02-17 13:17:35 +00:00
|
|
|
:error-message="getFirstErrorMessage('domain_name') || serverErrorMessage"
|
2024-07-05 09:35:08 +00:00
|
|
|
>
|
|
|
|
<FormInput
|
2025-03-18 10:51:03 +00:00
|
|
|
ref="domainName"
|
2025-02-17 13:17:35 +00:00
|
|
|
v-model="v$.values.domain_name.$model"
|
2024-07-05 09:35:08 +00:00
|
|
|
size="large"
|
2025-02-17 13:17:35 +00:00
|
|
|
@input="handleInput"
|
|
|
|
@blur="v$.values.domain_name.$touch"
|
2023-04-13 16:57:15 +00:00
|
|
|
/>
|
2024-07-05 09:35:08 +00:00
|
|
|
</FormGroup>
|
2023-04-13 16:57:15 +00:00
|
|
|
</form>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2025-02-17 13:17:35 +00:00
|
|
|
import { useVuelidate } from '@vuelidate/core'
|
|
|
|
import { required, maxLength, helpers } from '@vuelidate/validators'
|
2023-09-18 08:29:09 +00:00
|
|
|
import domainForm from '@baserow/modules/builder/mixins/domainForm'
|
2023-04-13 16:57:15 +00:00
|
|
|
|
|
|
|
export default {
|
2023-09-18 08:29:09 +00:00
|
|
|
name: 'CustomDomainForm',
|
|
|
|
mixins: [domainForm],
|
2025-02-17 13:17:35 +00:00
|
|
|
setup() {
|
|
|
|
return { v$: useVuelidate() }
|
|
|
|
},
|
2023-04-13 16:57:15 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
values: {
|
|
|
|
domain_name: '',
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
2025-02-17 13:17:35 +00:00
|
|
|
computed: {
|
|
|
|
serverErrorMessage() {
|
|
|
|
return this.serverErrors.domain_name
|
|
|
|
? this.serverErrors.domain_name.code === 'invalid'
|
|
|
|
? this.$t('domainForm.invalidDomain')
|
|
|
|
: this.serverErrors.domain_name.code === 'unique'
|
|
|
|
? this.$t('domainForm.notUniqueDomain')
|
|
|
|
: ''
|
|
|
|
: ''
|
|
|
|
},
|
|
|
|
},
|
2025-03-18 10:51:03 +00:00
|
|
|
mounted() {
|
|
|
|
this.$refs.domainName.focus()
|
|
|
|
},
|
2025-02-17 13:17:35 +00:00
|
|
|
methods: {
|
|
|
|
handleInput() {
|
|
|
|
this.serverErrors.domain_name = null
|
|
|
|
this.v$.values.domain_name.$touch()
|
|
|
|
this.$emit('error', this.v$.$error)
|
|
|
|
},
|
|
|
|
},
|
2023-04-13 16:57:15 +00:00
|
|
|
validations() {
|
|
|
|
return {
|
|
|
|
values: {
|
|
|
|
domain_name: {
|
2025-02-17 13:17:35 +00:00
|
|
|
required: helpers.withMessage(
|
|
|
|
this.$t('error.requiredField'),
|
|
|
|
required
|
|
|
|
),
|
|
|
|
maxLength: helpers.withMessage(
|
|
|
|
this.$t('error.maxLength', { max: 255 }),
|
|
|
|
maxLength(255)
|
|
|
|
),
|
2023-04-13 16:57:15 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|