From d5ccf1b9a9cbbcf5f951e97c94d51eeb13f2f39e Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Tue, 4 Nov 2025 20:12:54 +0300 Subject: [PATCH] F: Improve template dialog --- .../dlg-cst-template/tab-arguments.tsx | 79 +++++++------------ .../src/features/rsform/models/rsform-api.ts | 20 ++++- 2 files changed, 48 insertions(+), 51 deletions(-) diff --git a/rsconcept/frontend/src/features/rsform/dialogs/dlg-cst-template/tab-arguments.tsx b/rsconcept/frontend/src/features/rsform/dialogs/dlg-cst-template/tab-arguments.tsx index ed98109b..9b1d8e5b 100644 --- a/rsconcept/frontend/src/features/rsform/dialogs/dlg-cst-template/tab-arguments.tsx +++ b/rsconcept/frontend/src/features/rsform/dialogs/dlg-cst-template/tab-arguments.tsx @@ -6,13 +6,14 @@ import { createColumnHelper } from '@tanstack/react-table'; import { MiniButton } from '@/components/control'; import { DataTable, type IConditionalStyle } from '@/components/data-table'; -import { IconAccept, IconRemove, IconReset } from '@/components/icons'; +import { IconReset } from '@/components/icons'; import { NoData } from '@/components/view'; import { type ICreateConstituentaDTO } from '../../backend/types'; import { PickConstituenta } from '../../components/pick-constituenta'; import { RSInput } from '../../components/rs-input'; import { type IConstituenta, type IRSForm } from '../../models/rsform'; +import { isFunctional, isLogical } from '../../models/rsform-api'; import { type IArgumentValue } from '../../models/rslang'; import { useTemplateContext } from './template-context'; @@ -31,18 +32,13 @@ export function TabArguments({ schema }: TabArgumentsProps) { const [selectedCst, setSelectedCst] = useState(null); const [selectedArgument, setSelectedArgument] = useState(args.length > 0 ? args[0] : null); - const [argumentValue, setArgumentValue] = useState(''); - function handleSelectArgument(arg: IArgumentValue) { setSelectedArgument(arg); - if (arg.value) { - setArgumentValue(arg.value); - } } function handleSelectConstituenta(cst: IConstituenta) { setSelectedCst(cst); - setArgumentValue(cst.alias); + handleAssignArgument(selectedArgument!, cst.alias); } function handleClearArgument(target: IArgumentValue) { @@ -51,48 +47,56 @@ export function TabArguments({ schema }: TabArgumentsProps) { setSelectedArgument(newArg); } - function handleReset() { - setArgumentValue(selectedArgument?.value ?? ''); - } - function handleAssignArgument(target: IArgumentValue, argValue: string) { const newArg = { ...target, value: argValue }; onChangeArguments(args.map(arg => (arg.alias !== target.alias ? arg : newArg))); setSelectedArgument(newArg); } + function cstFilter(cst: IConstituenta) { + return cst.id === selectedCst?.id || (!isFunctional(cst.cst_type) && !isLogical(cst.cst_type)); + } + + const filteredItems = schema.items.filter(cstFilter); + const columns = [ argumentsHelper.accessor('alias', { id: 'alias', + header: 'Имя', size: 40, minSize: 40, maxSize: 40, - cell: props =>
{props.getValue()}
+ cell: props =>
{props.getValue()}
}), argumentsHelper.accessor(arg => arg.value || 'свободный аргумент', { id: 'value', + header: 'Значение', size: 200, minSize: 200, maxSize: 200 }), argumentsHelper.accessor(arg => arg.typification, { id: 'type', + header: 'Типизация', enableHiding: true, cell: props =>
{props.getValue()}
}), argumentsHelper.display({ id: 'actions', size: 0, - cell: props => - props.row.original.value ? ( - } - onClick={() => handleClearArgument(props.row.original)} - /> - ) : null + cell: props => ( +
+ {props.row.original.value ? ( + } + onClick={() => handleClearArgument(props.row.original)} + /> + ) : null} +
+ ) }) ]; @@ -108,8 +112,7 @@ export function TabArguments({ schema }: TabArgumentsProps) { -
- - {selectedArgument?.alias || 'ARG'} - - = - setArgumentValue(newValue)} /> -
- } - onClick={() => handleAssignArgument(selectedArgument!, argumentValue)} - disabled={!argumentValue || !selectedArgument} - /> - } - /> -
-
+

Конституенты

diff --git a/rsconcept/frontend/src/features/rsform/models/rsform-api.ts b/rsconcept/frontend/src/features/rsform/models/rsform-api.ts index 072d9914..0cb18130 100644 --- a/rsconcept/frontend/src/features/rsform/models/rsform-api.ts +++ b/rsconcept/frontend/src/features/rsform/models/rsform-api.ts @@ -200,7 +200,7 @@ export function isBaseSet(type: CstType): boolean { } /** - * Evaluate if {@link CstType} is function. + * Evaluate if {@link CstType} is a function. */ export function isFunctional(type: CstType): boolean { // prettier-ignore @@ -217,6 +217,24 @@ export function isFunctional(type: CstType): boolean { } } +/** + * Evaluate if {@link CstType} is logical. + */ +export function isLogical(type: CstType): boolean { + // prettier-ignore + switch (type) { + case CstType.NOMINAL: return false; + case CstType.BASE: return false; + case CstType.CONSTANT: return false; + case CstType.STRUCTURED: return false; + case CstType.AXIOM: return true; + case CstType.TERM: return false; + case CstType.FUNCTION: return false; + case CstType.PREDICATE: return false; + case CstType.THEOREM: return true; + } +} + /** * Evaluate if {@link IConstituenta} can be used produce structure. */