Browse Source

chore/removed enter to save for json cells and added formatting after save

pull/2946/head
Muhammed Mustafa 2 years ago
parent
commit
ad7358ccdf
  1. 11
      packages/nc-gui-v2/components/cell/Json.vue
  2. 2
      packages/nc-gui-v2/components/smartsheet/Cell.vue

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

@ -27,7 +27,7 @@ let localValue = $(
computed<string | undefined>({
get: () => localValueState,
set: (val: undefined | string | Record<string, any>) => {
localValueState = typeof val === 'object' ? JSON.stringify(val) : val
localValueState = typeof val === 'object' ? JSON.stringify(val, null, 2) : val
},
}),
)
@ -43,9 +43,18 @@ const clear = () => {
localValue = vModel
}
const formatJson = (json: string) => {
try {
return JSON.stringify(JSON.parse(json), null, 2)
} catch (e) {
return json
}
}
const onSave = () => {
isExpanded = false
editEnabled.value = false
localValue = localValue ? formatJson(localValue) : localValue
vModel = localValue
}

2
packages/nc-gui-v2/components/smartsheet/Cell.vue

@ -92,6 +92,8 @@ const {
} = useColumn(column)
const syncAndNavigate = (dir: NavigateDir) => {
if (isJSON) return
if (changed) {
emit('save')
changed = false

Loading…
Cancel
Save