Files
baserow/web-frontend/modules/database/mixins/rowEditField.js
716d43a9a8 Nuxt 3 migration (#4342)
Update the nuxt3 version.

Co-authored-by: Jonathan Adeline <jonathan@baserow.io>
Co-authored-by: Bram Wiepjes <bramw@protonmail.com>
Co-authored-by: Cezary <cezary@baserow.io>
Co-authored-by: Tsering Paljor <tsering@baserow.io>
Co-authored-by: Przemyslaw Kukulski <przemyslaw+gh@baserow.io>
Co-authored-by: Bram <bram2w@users.noreply.github.com>
2026-01-22 10:27:19 +01:00

67 lines
1.7 KiB
JavaScript

import baseField from '@baserow/modules/database/mixins/baseField'
/**
* A mixin that can be used by a row edit modal component. It introduces the props that
* will be passed by the RowEditModalField component.
*/
export default {
mixins: [baseField],
emits: ['touched'],
props: {
readOnly: {
type: Boolean,
required: true,
},
/**
* Indicates if the value is required. If so, then an error is added when the
* value is not provided.
*/
required: {
type: Boolean,
required: false,
default: false,
},
/**
* Indicates if the input has been touched by the user. If not touched then the
* error messages are not displayed because that might be confusing for the
* user. By default this is set to true because that's expected in the row
* modal. When using it as a form that is first rendered in an empty state, then
* this value should be false.
*/
touched: {
type: Boolean,
required: false,
default: true,
},
rowIsCreated: {
type: Boolean,
required: false,
default: () => true,
},
},
methods: {
/**
* Extends the getValidationError and add the required error message if this
* field value is required.
*/
getValidationError(value) {
const error = baseField.methods.getValidationError.call(this, value)
if (this.required && error === null) {
const fieldType = this.$registry.get('field', this.field.type)
const empty = fieldType.isEmpty(this.field, value)
if (empty) {
return this.$t('error.requiredField')
}
}
return error
},
touch() {
if (!this.touched) {
this.$emit('touched')
}
},
},
}