From f32512a3d7c43da8166373068a4471a4ee21db08 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 22 Feb 2023 18:52:50 +0530 Subject: [PATCH 1/2] fix(gui): while creating column/project disable button to avoid duplicate api call Signed-off-by: Pranav C --- packages/nc-gui/components/dlg/TableCreate.vue | 8 +++++++- .../nc-gui/components/smartsheet/column/EditOrAdd.vue | 6 +++++- packages/nc-gui/pages/index/index/create.vue | 8 +++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/dlg/TableCreate.vue b/packages/nc-gui/components/dlg/TableCreate.vue index 96cb6cec16..96718e9bba 100644 --- a/packages/nc-gui/components/dlg/TableCreate.vue +++ b/packages/nc-gui/components/dlg/TableCreate.vue @@ -78,14 +78,18 @@ const systemColumnsCheckboxInfo = SYSTEM_COLUMNS.map((c, index) => ({ disabled: index === 0, })) +const creating = ref(false) + const _createTable = async () => { try { + creating.value = true await validate() } catch (e: any) { e.errorFields.map((f: Record) => message.error(f.errors.join(','))) if (e.errorFields.length) return } await createTable() + creating.value = false } onMounted(() => { @@ -109,7 +113,9 @@ onMounted(() => {
diff --git a/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue b/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue index 91004c235b..326acca7cc 100644 --- a/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue +++ b/packages/nc-gui/components/smartsheet/column/EditOrAdd.vue @@ -80,8 +80,12 @@ const reloadMetaAndData = async () => { } } +const saving = ref(false) + async function onSubmit() { + saving.value = true const saved = await addOrUpdate(reloadMetaAndData, props.columnPosition) + saving.value = false if (!saved) return @@ -234,7 +238,7 @@ useEventListener('keydown', (e: KeyboardEvent) => { {{ $t('general.cancel') }} - + {{ $t('general.save') }} diff --git a/packages/nc-gui/pages/index/index/create.vue b/packages/nc-gui/pages/index/index/create.vue index ff6c1ec374..8f65c439ba 100644 --- a/packages/nc-gui/pages/index/index/create.vue +++ b/packages/nc-gui/pages/index/index/create.vue @@ -37,9 +37,13 @@ const formState = reactive({ title: '', }) +const creating = ref(false) + const createProject = async () => { $e('a:project:create:xcdb') try { + creating.value = true + const result = await api.project.create({ title: formState.title, }) @@ -48,6 +52,7 @@ const createProject = async () => { } catch (e: any) { message.error(await extractSdkResponseErrorMsg(e)) } + creating.value = false } const input: VNodeRef = ref() @@ -90,7 +95,8 @@ onMounted(async () => {
-