feat(editor): Add mapping support for data paths (#5191)

* feat: add data path flag

* chore: update types

* feat: use path for data

* feat: add support for multiple values

* fix: handle if not prev node

* fix: update node

* fix: handle multi part path

* feat: add support for multiple vals for field

* feat: add support for table transforms

* feat: use dot notation

* feat: fix bug where brackets removed

* fix: handle dots, fix unit tests

* test: update snapshot

* test: fix tests

* test: add test for edge case
This commit is contained in:
Mutasem Aldmour
2023-01-30 14:42:08 +03:00
committed by GitHub
parent 5b9c650e55
commit 6092f6c41e
14 changed files with 679 additions and 66 deletions

View File

@@ -79,6 +79,7 @@ import { externalHooks } from '@/mixins/externalHooks';
import { mapStores } from 'pinia';
import { useNDVStore } from '@/stores/ndv';
import MappingPill from './MappingPill.vue';
import { getMappedExpression } from '@/utils/mappingUtils';
const runDataJsonActions = () => import('@/components/RunDataJsonActions.vue');
@@ -169,11 +170,13 @@ export default mixins(externalHooks).extend({
return shorten(el.dataset.name || '', 16, 2);
},
getJsonParameterPath(path: string): string {
const convertedPath = convertPath(path);
return `{{ ${convertedPath.replace(
/^(\["?\d"?])/,
this.distanceFromActive === 1 ? '$json' : `$node["${this.node!.name}"].json`,
)} }}`;
const subPath = path.replace(/^(\["?\d"?])/, ''); // remove item position
return getMappedExpression({
nodeName: this.node.name,
distanceFromActive: this.distanceFromActive,
path: subPath,
});
},
onDragStart(el: HTMLElement) {
if (el && el.dataset.path) {