mirror of
https://github.com/directus/directus.git
synced 2026-01-23 07:17:55 -05:00
Use dropdown for boolean default value
This commit is contained in:
@@ -292,7 +292,7 @@ export class FieldsService {
|
||||
column = table[field.type](field.field);
|
||||
}
|
||||
|
||||
if (field.schema.default_value) {
|
||||
if (field.schema.default_value !== undefined) {
|
||||
if (
|
||||
typeof field.schema.default_value === 'string' &&
|
||||
field.schema.default_value.toLowerCase() === 'now()'
|
||||
|
||||
@@ -77,13 +77,16 @@ function validateFilter(filter: Query['filter']) {
|
||||
}
|
||||
|
||||
function validateFilterPrimitive(value: any, key: string) {
|
||||
if ((typeof value === 'string' || typeof value === 'number') === false) {
|
||||
if (
|
||||
(typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') ===
|
||||
false
|
||||
) {
|
||||
throw new InvalidQueryException(
|
||||
`The filter value for "${key}" has to be a string or a number`
|
||||
);
|
||||
}
|
||||
|
||||
if (Number.isNaN(value)) {
|
||||
if (typeof value === 'number' && Number.isNaN(value)) {
|
||||
throw new InvalidQueryException(`The filter value for "${key}" is not a valid number`);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,9 @@
|
||||
:disabled="item.disabled"
|
||||
@click="multiple ? null : $emit('input', item.value)"
|
||||
>
|
||||
<v-list-item-icon v-if="multiple === false && allowOther === false && itemIcon !== null && item.icon">
|
||||
<v-list-item-icon
|
||||
v-if="multiple === false && allowOther === false && itemIcon !== null && item.icon"
|
||||
>
|
||||
<v-icon :name="item.icon" />
|
||||
</v-list-item-icon>
|
||||
<v-list-item-content>
|
||||
@@ -119,8 +121,8 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, PropType, computed, toRefs, Ref } from '@vue/composition-api';
|
||||
import i18n from '@/lang';
|
||||
import { useCustomSelection, useCustomSelectionMultiple } from '@/composables/use-custom-selection';
|
||||
import i18n from '../../lang';
|
||||
import { useCustomSelection, useCustomSelectionMultiple } from '../../composables/use-custom-selection';
|
||||
|
||||
type Item = {
|
||||
text: string;
|
||||
@@ -150,7 +152,7 @@ export default defineComponent({
|
||||
default: null,
|
||||
},
|
||||
value: {
|
||||
type: [Array, String, Number] as PropType<InputValue>,
|
||||
type: [Array, String, Number, Boolean] as PropType<InputValue>,
|
||||
default: null,
|
||||
},
|
||||
multiple: {
|
||||
|
||||
@@ -110,12 +110,24 @@
|
||||
v-model="defaultValue"
|
||||
:placeholder="$t('add_a_default_value')"
|
||||
/>
|
||||
<v-checkbox
|
||||
<v-select
|
||||
v-else-if="fieldData.type === 'boolean'"
|
||||
class="monospace"
|
||||
v-model="defaultValue"
|
||||
:label="defaultValue ? $t('true') : $t('false')"
|
||||
block
|
||||
:items="[
|
||||
{
|
||||
text: 'true',
|
||||
value: true,
|
||||
},
|
||||
{
|
||||
text: 'false',
|
||||
value: false,
|
||||
},
|
||||
{
|
||||
text: 'NULL',
|
||||
value: null,
|
||||
},
|
||||
]"
|
||||
/>
|
||||
<v-input
|
||||
v-else
|
||||
@@ -141,9 +153,9 @@
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, computed } from '@vue/composition-api';
|
||||
import useSync from '@/composables/use-sync';
|
||||
import { types } from '@/types';
|
||||
import i18n from '@/lang';
|
||||
import useSync from '../../../../../../composables/use-sync';
|
||||
import { types } from '../../../../../../types';
|
||||
import i18n from '../../../../../../lang';
|
||||
import { state } from '../store';
|
||||
|
||||
export const fieldTypes = [
|
||||
@@ -403,6 +415,7 @@ export default defineComponent({
|
||||
|
||||
.monospace {
|
||||
--v-input-font-family: var(--family-monospace);
|
||||
--v-select-font-family: var(--family-monospace);
|
||||
}
|
||||
|
||||
.required {
|
||||
|
||||
Reference in New Issue
Block a user