From 76902b34aeba35f8315365ca9dbe8c6d747cc808 Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Wed, 19 Mar 2025 13:23:32 +0300 Subject: [PATCH] F: Improve OSS create operations --- rsconcept/backend/apps/oss/views/oss.py | 4 ++-- rsconcept/backend/shared/messages.py | 4 ++++ .../dlg-create-operation.tsx | 2 +- .../frontend/src/features/oss/models/oss-api.ts | 17 ++++++++--------- .../editor-oss-graph/node-context-menu.tsx | 4 ++-- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/rsconcept/backend/apps/oss/views/oss.py b/rsconcept/backend/apps/oss/views/oss.py index 7e55686d..2cfe840e 100644 --- a/rsconcept/backend/apps/oss/views/oss.py +++ b/rsconcept/backend/apps/oss/views/oss.py @@ -200,9 +200,9 @@ class OssViewSet(viewsets.GenericViewSet, generics.ListAPIView, generics.Retriev serializer.is_valid(raise_exception=True) operation: m.Operation = cast(m.Operation, serializer.validated_data['target']) - if operation.operation_type != m.OperationType.INPUT: + if len(operation.getQ_arguments()) > 0: raise serializers.ValidationError({ - 'target': msg.operationNotInput(operation.alias) + 'target': msg.operationHasArguments(operation.alias) }) if operation.result is not None: raise serializers.ValidationError({ diff --git a/rsconcept/backend/shared/messages.py b/rsconcept/backend/shared/messages.py index 6f0bb86e..ed2963c8 100644 --- a/rsconcept/backend/shared/messages.py +++ b/rsconcept/backend/shared/messages.py @@ -34,6 +34,10 @@ def operationNotInput(title: str): return f'Операция не является Загрузкой: {title}' +def operationHasArguments(title: str): + return f'Операция имеет аргументы: {title}' + + def operationResultFromAnotherOSS(): return 'Схема является результатом другой ОСС' diff --git a/rsconcept/frontend/src/features/oss/dialogs/dlg-create-operation/dlg-create-operation.tsx b/rsconcept/frontend/src/features/oss/dialogs/dlg-create-operation/dlg-create-operation.tsx index d3bbe977..dc4984f1 100644 --- a/rsconcept/frontend/src/features/oss/dialogs/dlg-create-operation/dlg-create-operation.tsx +++ b/rsconcept/frontend/src/features/oss/dialogs/dlg-create-operation/dlg-create-operation.tsx @@ -69,7 +69,7 @@ export function DlgCreateOperation() { const isValid = !!alias && !oss.items.some(operation => operation.alias === alias); function onSubmit(data: IOperationCreateDTO) { - const target = calculateInsertPosition(oss, data.item_data.operation_type, data.arguments, positions, { + const target = calculateInsertPosition(oss, data.arguments, positions, { x: defaultX, y: defaultY }); diff --git a/rsconcept/frontend/src/features/oss/models/oss-api.ts b/rsconcept/frontend/src/features/oss/models/oss-api.ts index f9499899..0700b9fd 100644 --- a/rsconcept/frontend/src/features/oss/models/oss-api.ts +++ b/rsconcept/frontend/src/features/oss/models/oss-api.ts @@ -23,7 +23,7 @@ import { infoMsg } from '@/utils/labels'; import { TextMatcher } from '@/utils/utils'; import { Graph } from '../../../models/graph'; -import { type IOperationPosition, OperationType } from '../backend/types'; +import { type IOperationPosition } from '../backend/types'; import { describeSubstitutionError } from '../labels'; import { type IOperation, type IOperationSchema, SubstitutionErrorType } from './oss'; @@ -493,7 +493,6 @@ export function getRelocateCandidates( */ export function calculateInsertPosition( oss: IOperationSchema, - operationType: OperationType, argumentsOps: number[], positions: IOperationPosition[], defaultPosition: Position2D @@ -503,15 +502,15 @@ export function calculateInsertPosition( return result; } - if (operationType === OperationType.INPUT || argumentsOps.length === 0) { - let inputsNodes = positions.filter(pos => - oss.items.find(operation => operation.operation_type === OperationType.INPUT && operation.id === pos.id) + if (argumentsOps.length === 0) { + let inputsPositions = positions.filter(pos => + oss.items.find(operation => operation.arguments.length === 0 && operation.id === pos.id) ); - if (inputsNodes.length > 0) { - inputsNodes = positions; + if (inputsPositions.length === 0) { + inputsPositions = positions; } - const maxX = Math.max(...inputsNodes.map(node => node.position_x)); - const minY = Math.min(...inputsNodes.map(node => node.position_y)); + const maxX = Math.max(...inputsPositions.map(node => node.position_x)); + const minY = Math.min(...inputsPositions.map(node => node.position_y)); result.x = maxX + DISTANCE_X; result.y = minY; } else { diff --git a/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/node-context-menu.tsx b/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/node-context-menu.tsx index 898ca938..6fc378ca 100644 --- a/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/node-context-menu.tsx +++ b/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/node-context-menu.tsx @@ -191,10 +191,10 @@ export function NodeContextMenu({ isOpen, operation, cursorX, cursorY, onHide }: onClick={handleOpenSchema} /> ) : null} - {isMutable && !operation?.result && operation?.operation_type === OperationType.INPUT ? ( + {isMutable && !operation?.result && operation?.arguments.length === 0 ? ( } disabled={isProcessing} onClick={handleInputCreate}