fix(editor): JSON view values can be mapped like keys (#4702)

* fix(editor): JSON view values can be mapped like keys, resolving to the same expression

* fix(editor): JSON view list item draggable pill name
This commit is contained in:
Csaba Tuncsik 2022-12-01 09:33:34 +01:00 committed by GitHub
parent 430cc65a4e
commit 6d4e959884
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 6 deletions

View file

@ -239,7 +239,6 @@
class="ph-no-capture"
:paneType="paneType"
:editMode="editMode"
:currentOutputIndex="currentOutputIndex"
:sessioId="sessionId"
:node="node"
:inputData="inputData"

View file

@ -16,7 +16,6 @@
:disabled="!mappingEnabled"
@dragstart="onDragStart"
@dragend="onDragEnd"
ref="draggable"
>
<template #preview="{ canDrop, el }">
<div :class="[$style.dragPill, canDrop ? $style.droppablePill : $style.defaultPill]">
@ -47,7 +46,19 @@
>"{{ node.key }}"</span>
</template>
<template #nodeValue="{ node }">
<span>{{ getContent(node.content) }}</span>
<span v-if="isNaN(node.index)">{{ getContent(node.content) }}</span>
<span
v-else
data-target="mappable"
:data-value="getJsonParameterPath(node.path)"
:data-name="getListItemName(node.path)"
:data-path="node.path"
:data-depth="node.level"
:class="{
[$style.mappable]: mappingEnabled,
[$style.dragged]: draggingPath === node.path,
}"
>{{ getContent(node.content) }}</span>
</template>
</vue-json-pretty>
</template>
@ -81,9 +92,6 @@ export default mixins(externalHooks).extend({
editMode: {
type: Object as () => { enabled?: boolean; value?: string; },
},
currentOutputIndex: {
type: Number,
},
sessionId: {
type: String,
},
@ -197,6 +205,9 @@ export default mixins(externalHooks).extend({
getContent(value: unknown): string {
return isString(value) ? `"${ value }"` : JSON.stringify(value);
},
getListItemName(path: string): string {
return path.replace(/^(\["?\d"?]\.?)/g, '');
},
},
});
</script>