Bladeren bron

node title number on copied iteration node (#23004)

tags/1.7.1
znn 3 maanden geleden
bovenliggende
commit
e0fe158f0b
No account linked to committer's email address

+ 9
- 1
web/app/components/workflow/nodes/iteration/use-interactions.ts Bestand weergeven

import { useStoreApi } from 'reactflow' import { useStoreApi } from 'reactflow'
import type { import type {
BlockEnum, BlockEnum,
ChildNodeTypeCount,
Node, Node,
} from '../../types' } from '../../types'
import { import {
const nodes = getNodes() const nodes = getNodes()
const childrenNodes = nodes.filter(n => n.parentId === nodeId && n.type !== CUSTOM_ITERATION_START_NODE) const childrenNodes = nodes.filter(n => n.parentId === nodeId && n.type !== CUSTOM_ITERATION_START_NODE)
const newIdMapping = { ...idMapping } const newIdMapping = { ...idMapping }
const childNodeTypeCount: ChildNodeTypeCount = {}


const copyChildren = childrenNodes.map((child, index) => { const copyChildren = childrenNodes.map((child, index) => {
const childNodeType = child.data.type as BlockEnum const childNodeType = child.data.type as BlockEnum
const nodesWithSameType = nodes.filter(node => node.data.type === childNodeType) const nodesWithSameType = nodes.filter(node => node.data.type === childNodeType)

if(!childNodeTypeCount[childNodeType])
childNodeTypeCount[childNodeType] = nodesWithSameType.length + 1
else
childNodeTypeCount[childNodeType] = childNodeTypeCount[childNodeType] + 1

const { newNode } = generateNewNode({ const { newNode } = generateNewNode({
type: getNodeCustomTypeByNodeDataType(childNodeType), type: getNodeCustomTypeByNodeDataType(childNodeType),
data: { data: {
_isBundled: false, _isBundled: false,
_connectedSourceHandleIds: [], _connectedSourceHandleIds: [],
_connectedTargetHandleIds: [], _connectedTargetHandleIds: [],
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${childNodeType}`)} ${nodesWithSameType.length + 1}` : t(`workflow.blocks.${childNodeType}`),
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${childNodeType}`)} ${childNodeTypeCount[childNodeType]}` : t(`workflow.blocks.${childNodeType}`),
iteration_id: newNodeId, iteration_id: newNodeId,
}, },
position: child.position, position: child.position,

+ 4
- 0
web/app/components/workflow/types.ts Bestand weergeven

edit = 'edit', edit = 'edit',
delete = 'delete', delete = 'delete',
} }

export interface ChildNodeTypeCount {
[key: string]: number;
}

Laden…
Annuleren
Opslaan