From 86b5925800310ddc7666db6ebf4f9f87200bf58c Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Mon, 8 Aug 2022 19:59:04 +0800 Subject: [PATCH] feat(gui-v2): page after submission --- .../nc-gui-v2/components/smartsheet/Form.vue | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui-v2/components/smartsheet/Form.vue b/packages/nc-gui-v2/components/smartsheet/Form.vue index 3ca77c6218..49d1508ccc 100644 --- a/packages/nc-gui-v2/components/smartsheet/Form.vue +++ b/packages/nc-gui-v2/components/smartsheet/Form.vue @@ -27,6 +27,8 @@ const { isUIAllowed } = useUIPermission() const formState = reactive({}) +const secondsRemain = ref(0) + const isEditable = isUIAllowed('editFormView' as Permission) const meta = inject(MetaInj) @@ -71,6 +73,8 @@ const showColumnDropdown = ref(false) const drag = ref(false) +const submitted = ref(false) + const activeRow = ref('') const formView = ref({}) @@ -93,6 +97,7 @@ async function submitForm() { } insertRow(formState) + submitted.value = true } function isDbRequired(column: Record) { @@ -203,6 +208,12 @@ async function checkSMTPStatus() {} function setFormData() { const col = (formColumnData as Record)?.value + formViewData.value = { + ...formViewData.value, + submit_another_form: !!(formViewData?.value?.submit_another_form ?? 0), + show_blank_form: !!(formViewData?.value?.show_blank_form ?? 0), + } + localColumns.value = col .filter((f: Record) => f.show && f.uidt !== UITypes.Rollup && f.uidt !== UITypes.Lookup) .sort((a: Record, b: Record) => a.order - b.order) @@ -239,6 +250,18 @@ const updateColMeta = useDebounceFn(async (col: Record) => { } }, 250) +watch(submitted, (v) => { + if (v && formViewData?.value?.show_blank_form) { + secondsRemain.value = 5 + const intvl = setInterval(() => { + if (--secondsRemain.value < 0) { + submitted.value = false + clearInterval(intvl) + } + }, 1000) + } +}) + onClickOutside(draggableRef, () => { activeRow.value = '' }) @@ -254,7 +277,26 @@ onMounted(async () => {