diff --git a/packages/nc-gui-v2/components/dlg/TableCreate.vue b/packages/nc-gui-v2/components/dlg/TableCreate.vue index 2efc128b65..b3a7aeadc2 100644 --- a/packages/nc-gui-v2/components/dlg/TableCreate.vue +++ b/packages/nc-gui-v2/components/dlg/TableCreate.vue @@ -7,6 +7,11 @@ const { modelValue } = defineProps<{ modelValue?: boolean }>() const emit = defineEmits(['update:modelValue']) +const idTypes = [ + { value: 'AI', text: 'Auto increment number' }, + { value: 'AG', text: 'Auto generated string' }, +] + const dialogShow = computed({ get() { return modelValue @@ -32,91 +37,11 @@ const validateDuplicate = (v: string) => { return (tables?.value || []).every((t) => t.table_name.toLowerCase() !== (v || '').toLowerCase()) || 'Duplicate table name' } +const inputEl = ref() + onMounted(() => { generateUniqueTitle() }) - -/* import { validateTableName } from '~/helpers' - -export default { - name: 'DlgTableCreate', - props: ['value'], - data() { - return { - isAdvanceOptVisible: false, - table: { - name: '', - columns: ['id', 'title', 'created_at', 'updated_at'], - }, - isIdToggleAllowed: false, - valid: false, - idType: 'AI', - idTypes: [ - { value: 'AI', text: 'Auto increment number' }, - { value: 'AG', text: 'Auto generated string' }, - ], - } - }, - computed: { - dialogShow: { - get() { - return this.value - }, - set(v) { - this.$emit('input', v) - }, - }, - projectPrefix() { - return this.$store.getters['project/GtrProjectPrefix'] - }, - tables() { - return this.$store.state.project.tables || [] - }, - }, - watch: { - 'table.alias': function (alias) { - this.$set(this.table, 'name', `${this.projectPrefix || ''}${alias}`) - }, - }, - created() { - this.populateDefaultTitle() - }, - mounted() { - setTimeout(() => { - const el = this.$refs.input.$el - el.querySelector('input').focus() - el.querySelector('input').select() - }, 100) - }, - - methods: { - populateDefaultTitle() { - let c = 1 - while (this.tables.some((t) => t.title === `Sheet${c}`)) { - c++ - } - this.$set(this.table, 'alias', `Sheet${c}`) - }, - validateTableName(v) { - return validateTableName(v, this.$store.getters['project/GtrProjectIsGraphql']) - }, - validateDuplicateAlias(v) { - return (this.tables || []).every((t) => t.title !== (v || '')) || 'Duplicate table alias' - }, - validateLedingOrTrailingWhiteSpace(v) { - return !/^\s+|\s+$/.test(v) || 'Leading or trailing whitespace not allowed in table name' - }, - validateDuplicate(v) { - return (this.tables || []).every((t) => t.table_name.toLowerCase() !== (v || '').toLowerCase()) || 'Duplicate table name' - }, - onCreateBtnClick() { - this.$emit('create', { - ...this.table, - columns: this.table.columns.map((c) => (c === 'id' && this.idType === 'AG' ? 'id_ag' : c)), - }) - }, - }, -} */