Browse Source

refactor(gui): reset value in finally block

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5189/head
Pranav C 2 years ago
parent
commit
06f03c5315
  1. 26
      packages/nc-gui/components/dlg/TableCreate.vue
  2. 3
      packages/nc-gui/pages/index/index/create.vue

26
packages/nc-gui/components/dlg/TableCreate.vue

@ -1,5 +1,16 @@
<script setup lang="ts">
import { Form, computed, nextTick, onMounted, ref, useProject, useTable, useTabs, useVModel, validateTableName } from '#imports'
import {
Form,
computed,
nextTick,
onMounted,
ref,
useProject,
useTable,
useTabs,
useVModel,
validateTableName,
} from '#imports'
import { TabType } from '~/lib'
const props = defineProps<{
@ -84,12 +95,13 @@ const _createTable = async () => {
try {
creating.value = true
await validate()
await createTable()
} catch (e: any) {
e.errorFields.map((f: Record<string, any>) => message.error(f.errors.join(',')))
if (e.errorFields.length) return
} finally {
creating.value = false
}
await createTable()
creating.value = false
}
onMounted(() => {
@ -114,8 +126,9 @@ onMounted(() => {
<a-button key="back" size="large" @click="dialogShow = false">{{ $t('general.cancel') }}</a-button>
<a-button key="submit" size="large" type="primary" :loading="creating" @click="_createTable">{{
$t('general.submit')
}}</a-button>
$t('general.submit')
}}
</a-button>
</template>
<div class="pl-10 pr-10 pt-5">
@ -151,7 +164,8 @@ onMounted(() => {
<div v-if="!project.prefix" class="mb-2">{{ $t('msg.info.tableNameInDb') }}</div>
<a-form-item v-if="!project.prefix" v-bind="validateInfos.table_name">
<a-input v-model:value="table.table_name" size="large" hide-details :placeholder="$t('msg.info.tableNameInDb')" />
<a-input v-model:value="table.table_name" size="large" hide-details
:placeholder="$t('msg.info.tableNameInDb')" />
</a-form-item>
<div>

3
packages/nc-gui/pages/index/index/create.vue

@ -51,8 +51,9 @@ const createProject = async () => {
await navigateTo(`/nc/${result.id}`)
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))
} finally {
creating.value = false
}
creating.value = false
}
const input: VNodeRef = ref<typeof Input>()

Loading…
Cancel
Save