mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
3.1 KiB
85 lines
3.1 KiB
2 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import type { UITypes } from 'nocodb-sdk'
|
||
2 years ago
|
import { computed } from '#imports'
|
||
2 years ago
|
|
||
2 years ago
|
interface Props {
|
||
|
value: Record<string, any>
|
||
|
}
|
||
|
|
||
|
const props = defineProps<Props>()
|
||
|
const emit = defineEmits(['update:value'])
|
||
|
const vModel = useVModel(props, 'value', emit)
|
||
|
|
||
|
const { sqlUi } = useProject()
|
||
|
|
||
|
const { onAlter, onDataTypeChange, validateInfos } = useColumnCreateStoreOrThrow()
|
||
2 years ago
|
|
||
2 years ago
|
// todo: 2nd argument of `getDataTypeListForUiType` is missing!
|
||
2 years ago
|
const dataTypes = computed(() => sqlUi?.value?.getDataTypeListForUiType(vModel.value as { uidt: UITypes }, '' as any))
|
||
2 years ago
|
|
||
|
// to avoid type error with checkbox
|
||
2 years ago
|
vModel.value.rqd = !!vModel.value.rqd
|
||
|
vModel.value.pk = !!vModel.value.pk
|
||
|
vModel.value.un = !!vModel.value.un
|
||
|
vModel.value.ai = !!vModel.value.ai
|
||
|
vModel.value.au = !!vModel.value.au
|
||
2 years ago
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<div class="p-4 border-[2px] radius-1 border-grey w-full flex flex-col gap-2">
|
||
2 years ago
|
<div class="flex justify-between w-full gap-1">
|
||
2 years ago
|
<a-form-item label="NN">
|
||
2 years ago
|
<a-checkbox
|
||
2 years ago
|
v-model:checked="vModel.rqd"
|
||
|
:disabled="vModel.pk || !sqlUi.columnEditable(vModel)"
|
||
2 years ago
|
class="nc-column-checkbox-NN"
|
||
2 years ago
|
@change="onAlter"
|
||
|
/>
|
||
2 years ago
|
</a-form-item>
|
||
|
<a-form-item label="PK">
|
||
2 years ago
|
<a-checkbox
|
||
2 years ago
|
v-model:checked="vModel.pk"
|
||
|
:disabled="!sqlUi.columnEditable(vModel)"
|
||
2 years ago
|
class="nc-column-checkbox-PK"
|
||
2 years ago
|
@change="onAlter"
|
||
|
/>
|
||
2 years ago
|
</a-form-item>
|
||
|
<a-form-item label="AI">
|
||
2 years ago
|
<a-checkbox
|
||
2 years ago
|
v-model:checked="vModel.ai"
|
||
|
:disabled="sqlUi.colPropUNDisabled(vModel) || !sqlUi.columnEditable(vModel)"
|
||
2 years ago
|
class="nc-column-checkbox-AI"
|
||
2 years ago
|
@change="onAlter"
|
||
|
/>
|
||
2 years ago
|
</a-form-item>
|
||
2 years ago
|
<a-form-item label="UN" :disabled="sqlUi.colPropUNDisabled(vModel) || !sqlUi.columnEditable(vModel)" @change="onAlter">
|
||
|
<a-checkbox v-model:checked="vModel.un" class="nc-column-checkbox-UN" />
|
||
2 years ago
|
</a-form-item>
|
||
2 years ago
|
<a-form-item label="AU" :disabled="sqlUi.colPropAuDisabled(vModel) || !sqlUi.columnEditable(vModel)" @change="onAlter">
|
||
|
<a-checkbox v-model:checked="vModel.au" class="nc-column-checkbox-AU" />
|
||
2 years ago
|
</a-form-item>
|
||
|
</div>
|
||
2 years ago
|
<a-form-item :label="$t('labels.databaseType')" v-bind="validateInfos.dt">
|
||
2 years ago
|
<a-select v-model:value="vModel.dt" @change="onDataTypeChange">
|
||
2 years ago
|
<a-select-option v-for="type in dataTypes" :key="type" :value="type">
|
||
2 years ago
|
{{ type }}
|
||
2 years ago
|
</a-select-option>
|
||
|
</a-select>
|
||
2 years ago
|
</a-form-item>
|
||
2 years ago
|
<a-form-item :label="$t('labels.lengthValue')">
|
||
|
<a-input
|
||
2 years ago
|
v-model:value="vModel.dtxp"
|
||
|
:disabled="sqlUi.getDefaultLengthIsDisabled(vModel.dt) || !sqlUi.columnEditable(vModel)"
|
||
2 years ago
|
@input="onAlter"
|
||
|
/>
|
||
2 years ago
|
</a-form-item>
|
||
2 years ago
|
<a-form-item v-if="sqlUi.showScale(vModel)" label="Scale">
|
||
|
<a-input v-model="vModel.dtxs" :disabled="!sqlUi.columnEditable(vModel)" @input="onAlter" />
|
||
2 years ago
|
</a-form-item>
|
||
2 years ago
|
<a-form-item :label="$t('placeholder.defaultValue')">
|
||
2 years ago
|
<a-textarea v-model:value="vModel.cdf" auto-size @input="onAlter(2, true)" />
|
||
|
<span class="text-gray-400 text-xs">{{ sqlUi.getDefaultValueForDatatype(vModel.dt) }}</span>
|
||
2 years ago
|
</a-form-item>
|
||
2 years ago
|
</div>
|
||
|
</template>
|