1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-04-09 07:07:49 +00:00
bramw_baserow/web-frontend/modules/database/components/form/BlankDatabaseForm.vue
2023-11-15 05:25:06 +00:00

77 lines
1.7 KiB
Vue

<template>
<form @submit.prevent="submit">
<FormElement :error="fieldHasErrors('name')" class="control">
<label class="control__label">
<i class="iconoira-text"></i>
{{ $t('applicationForm.nameLabel') }}
</label>
<div class="control__elements">
<input
ref="name"
v-model="values.name"
:class="{ 'input--error': fieldHasErrors('name') }"
type="text"
class="input"
@focus.once="$event.target.select()"
@blur="$v.values.name.$touch()"
/>
<div v-if="fieldHasErrors('name')" class="error">
{{ $t('error.requiredField') }}
</div>
</div>
</FormElement>
<div class="actions">
<div class="align-right">
<button
class="button button--large"
:class="{ 'button--loading': loading }"
:disabled="loading"
>
{{ $t('action.add') }}
{{ databaseApplicationType.getName() | lowercase }}
</button>
</div>
</div>
</form>
</template>
<script>
import form from '@baserow/modules/core/mixins/form'
import { required } from 'vuelidate/lib/validators'
export default {
name: 'BlankDatabaseForm',
mixins: [form],
props: {
defaultName: {
type: String,
required: false,
default: '',
},
loading: {
type: Boolean,
required: true,
},
},
data() {
return {
values: {
name: this.defaultName,
},
}
},
computed: {
databaseApplicationType() {
return this.$registry.get('application', 'database')
},
},
mounted() {
this.$refs.name.focus()
},
validations: {
values: {
name: { required },
},
},
}
</script>