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