Browse Source

fix(nc-gui): prefill form decode query param issue

pull/9720/head
Ramesh Mane 1 month ago
parent
commit
d1478fbd30
  1. 19
      packages/nc-gui/composables/useSharedFormViewStore.ts

19
packages/nc-gui/composables/useSharedFormViewStore.ts

@ -441,13 +441,25 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
async function handlePreFillForm() {
if (Object.keys(route.query || {}).length) {
// Decode both query parameter keys and values if values are present
const decodedQuery = Object.fromEntries(
Object.entries(route.query).map(([key, value]) => [
decodeURIComponent(key),
value
? Array.isArray(value)
? value.map((qp) => decodeURIComponent(qp as string)?.trim())
: decodeURIComponent(value as string)?.trim()
: value,
]),
)
columns.value = await Promise.all(
(columns.value || []).map(async (c) => {
const queryParam = route.query[c.title as string] || route.query[encodeURIComponent(c.title as string)]
const decodedQueryParam = decodedQuery[c.title as string]
if (
!c.title ||
!queryParam ||
!decodedQueryParam ||
isSystemColumn(c) ||
(isVirtualCol(c) && !isLinksOrLTAR(c)) ||
(!sharedViewMeta.value.preFillEnabled && !isVirtualCol(c) && !isLinksOrLTAR(c)) ||
@ -456,9 +468,6 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
) {
return c
}
const decodedQueryParam = Array.isArray(queryParam)
? queryParam.map((qp) => decodeURIComponent(qp as string).trim())
: decodeURIComponent(queryParam as string).trim()
const preFillValue = await getPreFillValue(c, decodedQueryParam)
if (preFillValue !== undefined) {

Loading…
Cancel
Save