Skip to content

Commit 2ec27c1

Browse files
committed
feat(frontend): add typed row editing with JSON editor support
1 parent f9af70e commit 2ec27c1

8 files changed

Lines changed: 612 additions & 2046 deletions

File tree

frontend/src/components/results/ResultViewerDocument.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NButton, NIcon } from 'naive-ui'
33
import { computed } from 'vue'
44
import { useRowEditorModal } from '@/composables/useRowEditorModal'
55
import { Pencil, Trash } from '@/lib/icons'
6+
import { buildEditorFieldsFromValue } from '@/lib/rowEditor'
67
import JsonNode from './JsonNode.vue'
78
import RowEditorModal from './RowEditorModal.vue'
89
@@ -47,6 +48,8 @@ const {
4748
editorRow: editorDoc,
4849
editorFilter,
4950
editorSource,
51+
editorFields,
52+
editorFocusField,
5053
openEditor,
5154
closeEditor,
5255
performMutation,
@@ -79,14 +82,14 @@ const docs = computed(() => {
7982
class="doc-row"
8083
>
8184
<div v-if="showEdit || showDelete" class="flex justify-end gap-2 mb-1">
82-
<NButton v-if="showEdit" size="small" tertiary title="Edit document" @click.stop.prevent="openEditor('update', doc)">
85+
<NButton v-if="showEdit" size="small" tertiary title="Edit document" @click.stop.prevent="openEditor('update', doc, '', '', buildEditorFieldsFromValue(doc))">
8386
<template #icon>
8487
<NIcon :size="16">
8588
<Pencil />
8689
</NIcon>
8790
</template>
8891
</NButton>
89-
<NButton v-if="showDelete" size="small" tertiary title="Delete document" @click.stop.prevent="openEditor('delete', doc)">
92+
<NButton v-if="showDelete" size="small" tertiary title="Delete document" @click.stop.prevent="openEditor('delete', doc, '', '', buildEditorFieldsFromValue(doc))">
9093
<template #icon>
9194
<NIcon :size="16">
9295
<Trash />
@@ -104,6 +107,8 @@ const docs = computed(() => {
104107
v-model:show="showEditor"
105108
:operation="editorOperation"
106109
:row="editorDoc"
110+
:fields="editorFields"
111+
:focus-field="editorFocusField"
107112
:filter="editorFilter"
108113
:source="editorSource"
109114
@submit="handleMutation"

frontend/src/components/results/ResultViewerKeyValue.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NButton, NIcon } from 'naive-ui'
33
import { computed, defineEmits } from 'vue'
44
import { useRowEditorModal } from '@/composables/useRowEditorModal'
55
import { Pencil, Trash } from '@/lib/icons'
6+
import { buildEditorFieldsFromValue } from '@/lib/rowEditor'
67
import RowEditorModal from './RowEditorModal.vue'
78
89
const props = defineProps({
@@ -47,13 +48,15 @@ const {
4748
editorRow,
4849
editorFilter,
4950
editorSource,
51+
editorFields,
52+
editorFocusField,
5053
openEditor: _openEditor,
5154
closeEditor,
5255
performMutation,
5356
} = useRowEditorModal()
5457
5558
function openEditor(op, row) {
56-
_openEditor(op, { ...row })
59+
_openEditor(op, { ...row }, '', '', buildEditorFieldsFromValue(row))
5760
}
5861
5962
async function handleMutation(params) {
@@ -91,6 +94,8 @@ async function handleMutation(params) {
9194
v-model:show="showEditor"
9295
:operation="editorOperation"
9396
:row="editorRow"
97+
:fields="editorFields"
98+
:focus-field="editorFocusField"
9499
:filter="editorFilter"
95100
:source="editorSource"
96101
@submit="handleMutation"

0 commit comments

Comments
 (0)