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" class="ph-no-capture"
:paneType="paneType" :paneType="paneType"
:editMode="editMode" :editMode="editMode"
:currentOutputIndex="currentOutputIndex"
:sessioId="sessionId" :sessioId="sessionId"
:node="node" :node="node"
:inputData="inputData" :inputData="inputData"

View file

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