mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 04:50:36 +03:00
F: Improve OSS create operations
This commit is contained in:
parent
aecac71283
commit
84ba39ea68
|
@ -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({
|
||||
|
|
|
@ -34,6 +34,10 @@ def operationNotInput(title: str):
|
|||
return f'Операция не является Загрузкой: {title}'
|
||||
|
||||
|
||||
def operationHasArguments(title: str):
|
||||
return f'Операция имеет аргументы: {title}'
|
||||
|
||||
|
||||
def operationResultFromAnotherOSS():
|
||||
return 'Схема является результатом другой ОСС'
|
||||
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 ? (
|
||||
<DropdownButton
|
||||
text='Создать схему'
|
||||
title='Создать пустую схему для загрузки'
|
||||
title='Создать пустую схему'
|
||||
icon={<IconNewRSForm size='1rem' className='icon-green' />}
|
||||
disabled={isProcessing}
|
||||
onClick={handleInputCreate}
|
||||
|
|
Loading…
Reference in New Issue
Block a user