Browse Source

fix/gui-v2-json-bug-fix

pull/2946/head
Muhammed Mustafa 2 years ago
parent
commit
f35d7888eb
  1. 19
      packages/nc-gui-v2/components/cell/Json.vue

19
packages/nc-gui-v2/components/cell/Json.vue

@ -22,7 +22,16 @@ let editEnabled = $(inject(EditModeInj))
let vModel = $(useVModel(props, 'modelValue', emits)) let vModel = $(useVModel(props, 'modelValue', emits))
let localValue = $ref<string>('{}') let localValueState = $ref<string | undefined>(undefined)
let localValue = $(
computed<string | undefined>({
get: () => localValueState,
set: (val: undefined | string | Record<string, any>) => {
localValueState = typeof val === 'object' ? JSON.stringify(val) : val
},
}),
)
let error = $ref<string | undefined>(undefined) let error = $ref<string | undefined>(undefined)
let isExpanded = $ref(false) let isExpanded = $ref(false)
@ -31,7 +40,7 @@ const clear = () => {
isExpanded = false isExpanded = false
editEnabled = false editEnabled = false
localValue = JSON.stringify(vModel) localValue = vModel
} }
const onSave = () => { const onSave = () => {
@ -40,13 +49,13 @@ const onSave = () => {
} }
onMounted(() => { onMounted(() => {
localValue = JSON.stringify(vModel) localValue = vModel
}) })
watch( watch(
() => vModel, () => vModel,
(val) => { (val) => {
localValue = JSON.stringify(val) localValue = val
}, },
) )
@ -66,7 +75,7 @@ watch(
() => editEnabled, () => editEnabled,
() => { () => {
isExpanded = false isExpanded = false
localValue = JSON.stringify(vModel) localValue = vModel
}, },
) )
</script> </script>

Loading…
Cancel
Save