Browse Source

Merge pull request #6472 from gitstart/NCDBOSS-88

🐛 Bug: default value not applied if value was modified before submitting link shared form
pull/6816/head
Raju Udava 1 year ago committed by GitHub
parent
commit
674ecb80b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      packages/nc-gui/composables/useSharedFormViewStore.ts
  2. 17
      packages/nc-gui/helpers/parsers/parserHelpers.ts

13
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!,
{
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

@ -174,3 +174,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