Browse Source

fix(nc-gui): prefill link issue after clicking clear form btn in form builder

pull/7786/head
Ramesh Mane 9 months ago
parent
commit
b9057d20b7
  1. 6
      packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue
  2. 33
      packages/nc-gui/components/smartsheet/Form.vue

6
packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue

@ -7,8 +7,6 @@ const { view: _view, $api } = useSmartsheetStoreOrThrow()
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
const { getBaseUrl, appInfo } = useGlobal() const { getBaseUrl, appInfo } = useGlobal()
const { t } = useI18n()
const { dashboardUrl } = useDashboard() const { dashboardUrl } = useDashboard()
const viewStore = useViewsStore() const viewStore = useViewsStore()
@ -428,14 +426,14 @@ watchEffect(() => {})
<a-radio-group <a-radio-group
v-if="formPreFill.preFillEnabled" v-if="formPreFill.preFillEnabled"
:value="formPreFill.preFilledMode || ''" :value="formPreFill.preFilledMode"
class="nc-field-layout-list" class="nc-field-layout-list"
data-testid="nc-modal-share-view__preFillMode" data-testid="nc-modal-share-view__preFillMode"
@update:value=" @update:value="
(value) => { (value) => {
formPreFill = { formPreFill = {
...formPreFill, ...formPreFill,
preFilledMode: value || '', preFilledMode: value,
} }
} }
" "

33
packages/nc-gui/components/smartsheet/Form.vue

@ -31,7 +31,6 @@ import {
onClickOutside, onClickOutside,
parseProp, parseProp,
provide, provide,
reactive,
ref, ref,
useDebounceFn, useDebounceFn,
useEventListener, useEventListener,
@ -82,7 +81,7 @@ const { getPossibleAttachmentSrc } = useAttachment()
const formRef = ref() const formRef = ref()
let formState = reactive<Record<string, any>>({}) const formState = ref<Record<string, any>>({})
const secondsRemain = ref(0) const secondsRemain = ref(0)
@ -112,7 +111,7 @@ const { fields, showAll, hideAll } = useViewColumnsOrThrow()
const { state, row } = useProvideSmartsheetRowStore( const { state, row } = useProvideSmartsheetRowStore(
meta, meta,
ref({ ref({
row: formState, row: formState.value,
oldRow: {}, oldRow: {},
rowMeta: { new: true }, rowMeta: { new: true },
}), }),
@ -198,7 +197,7 @@ const updateView = useDebounceFn(
const updatePreFillFormSearchParams = useDebounceFn(() => { const updatePreFillFormSearchParams = useDebounceFn(() => {
if (isLocked.value || !isUIAllowed('dataInsert')) return if (isLocked.value || !isUIAllowed('dataInsert')) return
const preFilledData = { ...formState, ...state.value } const preFilledData = { ...formState.value, ...state.value }
const searchParams = new URLSearchParams() const searchParams = new URLSearchParams()
@ -224,7 +223,7 @@ async function submitForm() {
} }
await insertRow({ await insertRow({
row: { ...formState, ...state.value }, row: { ...formState.value, ...state.value },
oldRow: {}, oldRow: {},
rowMeta: { new: true }, rowMeta: { new: true },
}) })
@ -235,7 +234,7 @@ async function submitForm() {
async function clearForm() { async function clearForm() {
if (isLocked.value || !isUIAllowed('dataInsert')) return if (isLocked.value || !isUIAllowed('dataInsert')) return
formState = reactive<Record<string, any>>({}) formState.value = {}
state.value = {} state.value = {}
await formRef.value?.clearValidate() await formRef.value?.clearValidate()
reloadEventHook.trigger() reloadEventHook.trigger()
@ -592,19 +591,25 @@ watch(view, (nextView) => {
} }
}) })
watch([formState, state.value], async () => { watch(
[formState, state],
async () => {
for (const virtualField in state.value) { for (const virtualField in state.value) {
if (!formState[virtualField]) { formState.value[virtualField] = state.value[virtualField]
formState[virtualField] = state.value[virtualField]
}
} }
updatePreFillFormSearchParams()
try { try {
await formRef.value?.validateFields([...Object.keys(formState)]) await formRef.value?.validateFields([...Object.keys(formState.value)])
} catch (e: any) { } catch (e: any) {
e.errorFields.map((f: Record<string, any>) => console.error(f.errors.join(','))) e.errorFields.map((f: Record<string, any>) => console.error(f.errors.join(',')))
} }
}) },
{
deep: true,
},
)
watch(activeRow, (newValue) => { watch(activeRow, (newValue) => {
if (newValue) { if (newValue) {
@ -624,10 +629,6 @@ watch([focusLabel, activeRow], () => {
} }
}) })
watch([formState, state], () => {
updatePreFillFormSearchParams()
})
useEventListener( useEventListener(
formRef, formRef,
'focusout', 'focusout',

Loading…
Cancel
Save