Browse Source

🐛 Bug: default value not applied if value was modified before submitting link shared form

Co-authored-by: gitstart <gitstart@gitstart.com>
Co-authored-by: sheldon-welinga <sheldonwelinga@gmail.com>
Co-authored-by: gitstart_bot <gitstart_bot@users.noreply.github.com>
pull/6472/head
gitstart 1 year ago
parent
commit
9c519987b1
  1. 21
      packages/nc-gui/composables/useSharedFormViewStore.ts
  2. 17
      packages/nc-gui/helpers/parsers/parserHelpers.ts

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

@ -12,6 +12,7 @@ import type {
} from 'nocodb-sdk'
import { ErrorMessages, RelationTypes, UITypes, isLinksOrLTAR, isVirtualCol } from 'nocodb-sdk'
import { isString } from '@vue/shared'
import { filterNullOrUndefinedObjectProperties } from '~/helpers/parsers/parserHelpers'
import {
SharedViewPasswordInj,
computed,
@ -198,18 +199,16 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
}
}
await api.public.dataCreate(
sharedView.value!.uuid!,
{
data,
...attachment,
},
{
headers: {
'xc-password': password.value,
},
const filtedData = filterNullOrUndefinedObjectProperties({
data,
...attachment,
})
await api.public.dataCreate(sharedView.value!.uuid!, filtedData, {
headers: {
'xc-password': password.value,
},
)
})
submitted.value = true
progress.value = false

17
packages/nc-gui/helpers/parsers/parserHelpers.ts

@ -175,3 +175,20 @@ export const getColumnUIDTAndMetas = (colData: [], defaultType: string) => {
// TODO(import): date / datetime
return colProps
}
export const filterNullOrUndefinedObjectProperties = <T extends Record<string, any>>(obj: T): T => {
return Object.keys(obj).reduce((result, propName) => {
const value = obj[propName]
if (value !== null && value !== undefined) {
if (!Array.isArray(value) && typeof value === 'object') {
// Recursively filter nested objects
result[propName] = filterNullOrUndefinedObjectProperties(value)
} else {
result[propName] = value
}
}
return result
}, {} as Record<string, any>) as T
}

Loading…
Cancel
Save