1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-30 23:30:02 +00:00
bramw_baserow/web-frontend/modules/database/components/form/BlankDatabaseForm.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

92 lines
1.9 KiB
Vue
Raw Normal View History

<template>
<form @submit.prevent="submit">
<FormGroup :error="fieldHasErrors('name')" required small-label>
<template #label>
<i class="iconoir-text"></i>
{{ $t('applicationForm.nameLabel') }}
</template>
<FormInput
ref="name"
2025-02-17 13:17:35 +00:00
v-model="v$.values.name.$model"
:error="fieldHasErrors('name')"
type="text"
size="large"
:placeholder="$t('applicationForm.namePlaceholder')"
@focus.once="$event.target.select()"
2025-03-04 17:47:13 +00:00
@blur="v$.values.name.$touch"
></FormInput>
<template #error>
2025-02-17 13:17:35 +00:00
{{ v$.values.name.$errors[0]?.$message }}
</template>
</FormGroup>
<div class="actions">
<div class="align-right">
2024-04-15 11:29:17 +00:00
<Button
type="primary"
size="large"
:loading="loading"
:disabled="loading"
>
{{ $t('action.add') }}
{{ databaseApplicationType.getName() | lowercase }}
2024-04-15 11:29:17 +00:00
</Button>
</div>
</div>
</form>
</template>
<script>
2025-02-17 13:17:35 +00:00
import { useVuelidate } from '@vuelidate/core'
import form from '@baserow/modules/core/mixins/form'
2025-02-17 13:17:35 +00:00
import { required, helpers } from '@vuelidate/validators'
export default {
name: 'BlankDatabaseForm',
mixins: [form],
props: {
defaultName: {
type: String,
required: false,
default: '',
},
loading: {
type: Boolean,
required: true,
},
},
2025-02-17 13:17:35 +00:00
setup() {
return { v$: useVuelidate({ $lazy: true }) }
},
data() {
return {
values: {
name: this.defaultName,
},
}
},
computed: {
databaseApplicationType() {
return this.$registry.get('application', 'database')
},
},
mounted() {
this.$refs.name.focus()
},
2025-02-17 13:17:35 +00:00
validations() {
return {
values: {
name: {
required: helpers.withMessage(
this.$t('error.requiredField'),
required
),
},
},
}
},
}
</script>