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)
|
serializer.is_valid(raise_exception=True)
|
||||||
|
|
||||||
operation: m.Operation = cast(m.Operation, serializer.validated_data['target'])
|
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({
|
raise serializers.ValidationError({
|
||||||
'target': msg.operationNotInput(operation.alias)
|
'target': msg.operationHasArguments(operation.alias)
|
||||||
})
|
})
|
||||||
if operation.result is not None:
|
if operation.result is not None:
|
||||||
raise serializers.ValidationError({
|
raise serializers.ValidationError({
|
||||||
|
|
|
@ -34,6 +34,10 @@ def operationNotInput(title: str):
|
||||||
return f'Операция не является Загрузкой: {title}'
|
return f'Операция не является Загрузкой: {title}'
|
||||||
|
|
||||||
|
|
||||||
|
def operationHasArguments(title: str):
|
||||||
|
return f'Операция имеет аргументы: {title}'
|
||||||
|
|
||||||
|
|
||||||
def operationResultFromAnotherOSS():
|
def operationResultFromAnotherOSS():
|
||||||
return 'Схема является результатом другой ОСС'
|
return 'Схема является результатом другой ОСС'
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ export function DlgCreateOperation() {
|
||||||
const isValid = !!alias && !oss.items.some(operation => operation.alias === alias);
|
const isValid = !!alias && !oss.items.some(operation => operation.alias === alias);
|
||||||
|
|
||||||
function onSubmit(data: IOperationCreateDTO) {
|
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,
|
x: defaultX,
|
||||||
y: defaultY
|
y: defaultY
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,7 +23,7 @@ import { infoMsg } from '@/utils/labels';
|
||||||
import { TextMatcher } from '@/utils/utils';
|
import { TextMatcher } from '@/utils/utils';
|
||||||
|
|
||||||
import { Graph } from '../../../models/graph';
|
import { Graph } from '../../../models/graph';
|
||||||
import { type IOperationPosition, OperationType } from '../backend/types';
|
import { type IOperationPosition } from '../backend/types';
|
||||||
import { describeSubstitutionError } from '../labels';
|
import { describeSubstitutionError } from '../labels';
|
||||||
|
|
||||||
import { type IOperation, type IOperationSchema, SubstitutionErrorType } from './oss';
|
import { type IOperation, type IOperationSchema, SubstitutionErrorType } from './oss';
|
||||||
|
@ -493,7 +493,6 @@ export function getRelocateCandidates(
|
||||||
*/
|
*/
|
||||||
export function calculateInsertPosition(
|
export function calculateInsertPosition(
|
||||||
oss: IOperationSchema,
|
oss: IOperationSchema,
|
||||||
operationType: OperationType,
|
|
||||||
argumentsOps: number[],
|
argumentsOps: number[],
|
||||||
positions: IOperationPosition[],
|
positions: IOperationPosition[],
|
||||||
defaultPosition: Position2D
|
defaultPosition: Position2D
|
||||||
|
@ -503,15 +502,15 @@ export function calculateInsertPosition(
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operationType === OperationType.INPUT || argumentsOps.length === 0) {
|
if (argumentsOps.length === 0) {
|
||||||
let inputsNodes = positions.filter(pos =>
|
let inputsPositions = positions.filter(pos =>
|
||||||
oss.items.find(operation => operation.operation_type === OperationType.INPUT && operation.id === pos.id)
|
oss.items.find(operation => operation.arguments.length === 0 && operation.id === pos.id)
|
||||||
);
|
);
|
||||||
if (inputsNodes.length > 0) {
|
if (inputsPositions.length === 0) {
|
||||||
inputsNodes = positions;
|
inputsPositions = positions;
|
||||||
}
|
}
|
||||||
const maxX = Math.max(...inputsNodes.map(node => node.position_x));
|
const maxX = Math.max(...inputsPositions.map(node => node.position_x));
|
||||||
const minY = Math.min(...inputsNodes.map(node => node.position_y));
|
const minY = Math.min(...inputsPositions.map(node => node.position_y));
|
||||||
result.x = maxX + DISTANCE_X;
|
result.x = maxX + DISTANCE_X;
|
||||||
result.y = minY;
|
result.y = minY;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -191,10 +191,10 @@ export function NodeContextMenu({ isOpen, operation, cursorX, cursorY, onHide }:
|
||||||
onClick={handleOpenSchema}
|
onClick={handleOpenSchema}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{isMutable && !operation?.result && operation?.operation_type === OperationType.INPUT ? (
|
{isMutable && !operation?.result && operation?.arguments.length === 0 ? (
|
||||||
<DropdownButton
|
<DropdownButton
|
||||||
text='Создать схему'
|
text='Создать схему'
|
||||||
title='Создать пустую схему для загрузки'
|
title='Создать пустую схему'
|
||||||
icon={<IconNewRSForm size='1rem' className='icon-green' />}
|
icon={<IconNewRSForm size='1rem' className='icon-green' />}
|
||||||
disabled={isProcessing}
|
disabled={isProcessing}
|
||||||
onClick={handleInputCreate}
|
onClick={handleInputCreate}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user