Browse Source

fix(nc-gui): json cell value visibility issue (#8991)

pull/8995/head
Ramesh Mane 5 months ago committed by GitHub
parent
commit
debaa7b463
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 37
      packages/nc-gui/components/cell/Json.vue

37
packages/nc-gui/components/cell/Json.vue

@ -54,16 +54,6 @@ const localValue = computed<ModelValueType>({
},
})
const clear = () => {
error.value = undefined
isExpanded.value = false
editEnabled.value = false
localValue.value = vModel.value
}
const formatJson = (json: string) => {
try {
return JSON.stringify(JSON.parse(json))
@ -73,21 +63,30 @@ const formatJson = (json: string) => {
}
}
const onSave = () => {
function setLocalValue(val: any) {
try {
localValue.value = formatValue(val) === null ? null : typeof val === 'string' ? JSON.stringify(JSON.parse(val), null, 2) : val
} catch (e) {
localValue.value = formatValue(val) === null ? null : val
}
}
const clear = () => {
error.value = undefined
isExpanded.value = false
editEnabled.value = false
vModel.value = formatValue(localValue.value) === null ? null : formatJson(localValue.value as string)
setLocalValue(vModel.value)
}
const setLocalValue = (val: any) => {
try {
localValue.value =
formatValue(localValue.value) === null ? null : typeof val === 'string' ? JSON.stringify(JSON.parse(val), null, 2) : val
} catch (e) {
localValue.value = formatValue(localValue.value) === null ? null : val
}
const onSave = () => {
isExpanded.value = false
editEnabled.value = false
vModel.value = formatValue(localValue.value) === null ? null : formatJson(localValue.value as string)
}
watch(

Loading…
Cancel
Save