fix: entry editor may lose field value
This commit is contained in:
parent
827ca1f2e7
commit
f9abba37d2
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, defineEmits, defineProps, nextTick, reactive, ref, watch } from 'vue'
|
import { computed, defineEmits, defineProps, nextTick, reactive, ref, watchEffect } from 'vue'
|
||||||
import { useThemeVars } from 'naive-ui'
|
import { useThemeVars } from 'naive-ui'
|
||||||
import Save from '@/components/icons/Save.vue'
|
import Save from '@/components/icons/Save.vue'
|
||||||
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
|
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
|
||||||
|
@ -13,8 +13,12 @@ import Pin from '@/components/icons/Pin.vue'
|
||||||
import OffScreen from '@/components/icons/OffScreen.vue'
|
import OffScreen from '@/components/icons/OffScreen.vue'
|
||||||
import ContentEditor from '@/components/content_value/ContentEditor.vue'
|
import ContentEditor from '@/components/content_value/ContentEditor.vue'
|
||||||
import usePreferencesStore from 'stores/preferences.js'
|
import usePreferencesStore from 'stores/preferences.js'
|
||||||
|
import { toString } from 'lodash'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
show: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
field: {
|
field: {
|
||||||
type: [String, Number],
|
type: [String, Number],
|
||||||
},
|
},
|
||||||
|
@ -54,15 +58,17 @@ const emit = defineEmits([
|
||||||
'close',
|
'close',
|
||||||
])
|
])
|
||||||
|
|
||||||
watch(
|
watchEffect(
|
||||||
() => props.value,
|
() => {
|
||||||
(val) => {
|
if (props.show && props.value != null) {
|
||||||
if (val != null) {
|
|
||||||
onFormatChanged()
|
onFormatChanged()
|
||||||
} else {
|
} else {
|
||||||
viewAs.value = ''
|
viewAs.value = ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
flush: 'post',
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
@ -84,7 +90,7 @@ const displayValue = computed(() => {
|
||||||
})
|
})
|
||||||
const editingContent = ref('')
|
const editingContent = ref('')
|
||||||
const enableSave = computed(() => {
|
const enableSave = computed(() => {
|
||||||
return editingContent.value !== viewAs.value
|
return toString(props.field) !== viewAs.field || editingContent.value !== viewAs.value
|
||||||
})
|
})
|
||||||
|
|
||||||
const viewLanguage = computed(() => {
|
const viewLanguage = computed(() => {
|
||||||
|
@ -150,7 +156,7 @@ const onSave = () => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="entry-editor flex-box-v">
|
<div v-show="show" class="entry-editor flex-box-v">
|
||||||
<n-card :title="$t('interface.edit_row')" autofocus size="small" style="height: 100%">
|
<n-card :title="$t('interface.edit_row')" autofocus size="small" style="height: 100%">
|
||||||
<div class="editor-content flex-box-v" style="height: 100%">
|
<div class="editor-content flex-box-v" style="height: 100%">
|
||||||
<!-- field -->
|
<!-- field -->
|
||||||
|
|
|
@ -402,6 +402,7 @@ defineExpose({
|
||||||
:field="currentEditRow.key"
|
:field="currentEditRow.key"
|
||||||
:field-label="$t('common.field')"
|
:field-label="$t('common.field')"
|
||||||
:format="currentEditRow.format"
|
:format="currentEditRow.format"
|
||||||
|
:show="inEdit"
|
||||||
:value="currentEditRow.value"
|
:value="currentEditRow.value"
|
||||||
:value-label="$t('common.value')"
|
:value-label="$t('common.value')"
|
||||||
class="flex-item-expand"
|
class="flex-item-expand"
|
||||||
|
|
|
@ -379,6 +379,7 @@ defineExpose({
|
||||||
:field-label="$t('common.index')"
|
:field-label="$t('common.index')"
|
||||||
:field-readonly="true"
|
:field-readonly="true"
|
||||||
:format="currentEditRow.format"
|
:format="currentEditRow.format"
|
||||||
|
:show="inEdit"
|
||||||
:value="currentEditRow.value"
|
:value="currentEditRow.value"
|
||||||
:value-label="$t('common.value')"
|
:value-label="$t('common.value')"
|
||||||
class="flex-item-expand"
|
class="flex-item-expand"
|
||||||
|
|
|
@ -376,6 +376,7 @@ defineExpose({
|
||||||
:field-label="$t('common.index')"
|
:field-label="$t('common.index')"
|
||||||
:field-readonly="true"
|
:field-readonly="true"
|
||||||
:format="currentEditRow.format"
|
:format="currentEditRow.format"
|
||||||
|
:show="inEdit"
|
||||||
:value="currentEditRow.value"
|
:value="currentEditRow.value"
|
||||||
:value-label="$t('common.value')"
|
:value-label="$t('common.value')"
|
||||||
class="flex-item-expand"
|
class="flex-item-expand"
|
||||||
|
|
|
@ -411,6 +411,7 @@ defineExpose({
|
||||||
:field="currentEditRow.score"
|
:field="currentEditRow.score"
|
||||||
:field-label="$t('common.score')"
|
:field-label="$t('common.score')"
|
||||||
:format="currentEditRow.format"
|
:format="currentEditRow.format"
|
||||||
|
:show="inEdit"
|
||||||
:value="currentEditRow.value"
|
:value="currentEditRow.value"
|
||||||
:value-label="$t('common.value')"
|
:value-label="$t('common.value')"
|
||||||
class="flex-item-expand"
|
class="flex-item-expand"
|
||||||
|
|
|
@ -15,7 +15,7 @@ export const typesShortName = {
|
||||||
STRING: 'S',
|
STRING: 'S',
|
||||||
HASH: 'H',
|
HASH: 'H',
|
||||||
LIST: 'L',
|
LIST: 'L',
|
||||||
SET: 'S',
|
SET: 'E',
|
||||||
ZSET: 'Z',
|
ZSET: 'Z',
|
||||||
STREAM: 'X',
|
STREAM: 'X',
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue