2021-01-06 20:23:15 +00:00
|
|
|
<template>
|
|
|
|
<div class="control__elements">
|
2021-10-04 15:54:29 +00:00
|
|
|
<FieldSelectOptionsDropdown
|
2021-01-06 20:23:15 +00:00
|
|
|
:value="valueId"
|
2022-09-13 08:24:13 +00:00
|
|
|
:options="singleSelectOptions"
|
2022-08-31 09:37:27 +00:00
|
|
|
:allow-create-option="allowCreateOptions"
|
2021-04-08 14:30:26 +00:00
|
|
|
:disabled="readOnly"
|
2024-10-14 08:47:26 +00:00
|
|
|
:error="touched && !valid"
|
|
|
|
size="large"
|
2021-01-06 20:23:15 +00:00
|
|
|
@input="updateValue($event, value)"
|
|
|
|
@create-option="createOption($event)"
|
2021-07-11 18:02:37 +00:00
|
|
|
@hide="touch()"
|
2021-10-04 15:54:29 +00:00
|
|
|
></FieldSelectOptionsDropdown>
|
2021-07-11 18:02:37 +00:00
|
|
|
<div v-show="touched && !valid" class="error">
|
|
|
|
{{ error }}
|
|
|
|
</div>
|
2021-01-06 20:23:15 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import rowEditField from '@baserow/modules/database/mixins/rowEditField'
|
|
|
|
import singleSelectField from '@baserow/modules/database/mixins/singleSelectField'
|
2022-09-06 15:32:12 +00:00
|
|
|
import FieldSelectOptionsDropdown from '@baserow/modules/database/components/field/FieldSelectOptionsDropdown'
|
2021-01-06 20:23:15 +00:00
|
|
|
|
|
|
|
export default {
|
2021-10-04 15:54:29 +00:00
|
|
|
name: 'RowEditFieldSingleSelect',
|
2022-09-06 15:32:12 +00:00
|
|
|
components: { FieldSelectOptionsDropdown },
|
|
|
|
mixins: [rowEditField, singleSelectField],
|
2022-04-20 14:03:12 +01:00
|
|
|
props: {
|
|
|
|
allowCreateOptions: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true,
|
|
|
|
required: false,
|
|
|
|
},
|
|
|
|
},
|
2022-09-13 08:24:13 +00:00
|
|
|
computed: {
|
|
|
|
singleSelectOptions() {
|
|
|
|
if (this.field.select_options) {
|
|
|
|
return this.field.select_options
|
|
|
|
} else if (this.value) {
|
|
|
|
return [this.value]
|
|
|
|
} else {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2021-01-06 20:23:15 +00:00
|
|
|
}
|
|
|
|
</script>
|