From a038608afa3936eb9ce08c03469760b3d7ba49cb Mon Sep 17 00:00:00 2001 From: Pranav C Date: Wed, 17 Aug 2022 02:21:47 +0530 Subject: [PATCH] feat(gui-v2): bring additional features - show blank form - custom message alert Signed-off-by: Pranav C --- .../nc-gui-v2/components/shared-view/Form.vue | 2 +- .../composables/useSharedFormViewStore.ts | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui-v2/components/shared-view/Form.vue b/packages/nc-gui-v2/components/shared-view/Form.vue index d9cb2b6c9b..35deded74a 100644 --- a/packages/nc-gui-v2/components/shared-view/Form.vue +++ b/packages/nc-gui-v2/components/shared-view/Form.vue @@ -39,7 +39,7 @@ function isRequired(_columnObj: Record, required = false) { New form will be loaded after {{ secondsRemain }} seconds

- Submit Another Form + Submit Another Form
diff --git a/packages/nc-gui-v2/composables/useSharedFormViewStore.ts b/packages/nc-gui-v2/composables/useSharedFormViewStore.ts index 9519e2870a..9b00ba034f 100644 --- a/packages/nc-gui-v2/composables/useSharedFormViewStore.ts +++ b/packages/nc-gui-v2/composables/useSharedFormViewStore.ts @@ -1,6 +1,7 @@ import useVuelidate from '@vuelidate/core' import { minLength, required } from '@vuelidate/validators' import { message } from 'ant-design-vue' +import { formatMessages } from 'esbuild' import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk' import { ErrorMessages, RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk' import { extractSdkResponseErrorMsg } from '~/utils' @@ -12,7 +13,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState(() => const showPasswordModal = ref(false) const submitted = ref(false) const password = ref(null) - const secondsRemain = ref(null) + const secondsRemain = ref(0) // todo: type const sharedView = ref() @@ -135,6 +136,10 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState(() => submitted.value = true progress.value = false + + additionalState.value = {} + formState.value = {} + await message.success(sharedView.value.success_msg || 'Saved successfully.') } catch (e: any) { console.log(e) @@ -144,6 +149,19 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState(() => progress.value = false } + /** reset form if show_blank_form is true */ + watch(submitted, (nextVal:boolean) =>{ + if (nextVal && sharedView.value.show_blank_form) { + secondsRemain.value = 5; + const intvl = setInterval(() => { + if (--secondsRemain.value < 0) { + submitted.value = false; + clearInterval(intvl); + } + }, 1000); + } + }) + return { sharedView, loadSharedView, @@ -158,6 +176,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState(() => notFound, password, submitted, + secondsRemain } }, 'expanded-form-store')