Browse Source

feat(gui-v2): column type autocomplete

pull/2828/head
Wing-Kam Wong 2 years ago
parent
commit
381dd6714d
  1. 36
      packages/nc-gui-v2/components/template/Editor.vue

36
packages/nc-gui-v2/components/template/Editor.vue

@ -1,9 +1,9 @@
<script setup lang="ts"> <script setup lang="ts">
import { useToast } from 'vue-toastification' import { useToast } from 'vue-toastification'
import type { ColumnType, TableType } from 'nocodb-sdk' import type { ColumnType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk' import { isVirtualCol, UITypes } from 'nocodb-sdk'
import type { SizeType } from 'ant-design-vue/es/config-provider' import type { SizeType } from 'ant-design-vue/es/config-provider'
import { computed, onMounted, provide, watch } from '#imports' import { computed, onMounted } from '#imports'
import MdiTableIcon from '~icons/mdi/table' import MdiTableIcon from '~icons/mdi/table'
import MdiStringIcon from '~icons/mdi/alpha-a' import MdiStringIcon from '~icons/mdi/alpha-a'
import MdiLongTextIcon from '~icons/mdi/text' import MdiLongTextIcon from '~icons/mdi/text'
@ -18,6 +18,10 @@ interface Props {
importData: any[] importData: any[]
} }
interface Option {
value: string
}
const { quickImportType, projectTemplate, importData } = defineProps<Props>() const { quickImportType, projectTemplate, importData } = defineProps<Props>()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
@ -31,6 +35,24 @@ const loading = ref(false)
const buttonSize = ref<SizeType>('middle') const buttonSize = ref<SizeType>('middle')
const toast = useToast() const toast = useToast()
const uiTypeOptions = ref<Option[]>(
(Object.keys(UITypes) as Array<keyof typeof UITypes>)
.filter(
(x: any) =>
!isVirtualCol(x) &&
![UITypes.ForeignKey, UITypes.ID, UITypes.CreateTime, UITypes.LastModifiedTime, UITypes.Barcode, UITypes.Button].includes(
x,
),
)
.map((x: string) => ({
value: x,
})),
)
const filterOption = (input: string, option: Option) => {
return option.value.toUpperCase().indexOf(input.toUpperCase()) >= 0
}
const tableColumns = [ const tableColumns = [
{ {
name: 'Column Name', name: 'Column Name',
@ -301,8 +323,12 @@ const importTemplate = async () => {
/> />
</template> </template>
<template v-else-if="column.key === 'column_type'"> <template v-else-if="column.key === 'column_type'">
<!-- TODO: render uidt dropdown--> <a-auto-complete
{{ record.uidt }} v-model:value="record.uidt"
:options="uiTypeOptions"
:filter-option="filterOption"
style="width: 200px"
/>
</template> </template>
<template v-else-if="column.key === 'select_option'"> <template v-else-if="column.key === 'select_option'">

Loading…
Cancel
Save