Browse Source

feat(gui-v2): bring additional features

- show blank form
- custom message alert

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3188/head
Pranav C 2 years ago
parent
commit
a038608afa
  1. 2
      packages/nc-gui-v2/components/shared-view/Form.vue
  2. 21
      packages/nc-gui-v2/composables/useSharedFormViewStore.ts

2
packages/nc-gui-v2/components/shared-view/Form.vue

@ -39,7 +39,7 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
New form will be loaded after {{ secondsRemain }} seconds New form will be loaded after {{ secondsRemain }} seconds
</p> </p>
<div v-if="sharedView.submit_another_form" class="text-center"> <div v-if="sharedView.submit_another_form" class="text-center">
<a-btn color="primary" @click="submitted = false"> Submit Another Form</a-btn> <a-button color="primary" @click="submitted = false"> Submit Another Form</a-button>
</div> </div>
</div> </div>
</div> </div>

21
packages/nc-gui-v2/composables/useSharedFormViewStore.ts

@ -1,6 +1,7 @@
import useVuelidate from '@vuelidate/core' import useVuelidate from '@vuelidate/core'
import { minLength, required } from '@vuelidate/validators' import { minLength, required } from '@vuelidate/validators'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { formatMessages } from 'esbuild'
import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk' import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
import { ErrorMessages, RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk' import { ErrorMessages, RelationTypes, UITypes, isVirtualCol } from 'nocodb-sdk'
import { extractSdkResponseErrorMsg } from '~/utils' import { extractSdkResponseErrorMsg } from '~/utils'
@ -12,7 +13,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState(() =>
const showPasswordModal = ref(false) const showPasswordModal = ref(false)
const submitted = ref(false) const submitted = ref(false)
const password = ref(null) const password = ref(null)
const secondsRemain = ref(null) const secondsRemain = ref(0)
// todo: type // todo: type
const sharedView = ref<any>() const sharedView = ref<any>()
@ -135,6 +136,10 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState(() =>
submitted.value = true submitted.value = true
progress.value = false progress.value = false
additionalState.value = {}
formState.value = {}
await message.success(sharedView.value.success_msg || 'Saved successfully.') await message.success(sharedView.value.success_msg || 'Saved successfully.')
} catch (e: any) { } catch (e: any) {
console.log(e) console.log(e)
@ -144,6 +149,19 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState(() =>
progress.value = false 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 { return {
sharedView, sharedView,
loadSharedView, loadSharedView,
@ -158,6 +176,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState(() =>
notFound, notFound,
password, password,
submitted, submitted,
secondsRemain
} }
}, 'expanded-form-store') }, 'expanded-form-store')

Loading…
Cancel
Save