From ae1fceafcfae6c13df6e597fee2ff5ca08984717 Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:54:18 +0300 Subject: [PATCH] M: Remove MockCst from sideView --- .../frontend/src/components/DomainIcons.tsx | 2 - .../src/components/info/BadgeConstituenta.tsx | 7 +-- .../frontend/src/models/miscellaneous.ts | 1 - rsconcept/frontend/src/models/rsformAPI.ts | 53 +------------------ .../ViewConstituents/ConstituentsSearch.tsx | 13 +---- .../TableSideConstituents.tsx | 8 +-- rsconcept/frontend/src/utils/labels.ts | 2 - 7 files changed, 6 insertions(+), 80 deletions(-) diff --git a/rsconcept/frontend/src/components/DomainIcons.tsx b/rsconcept/frontend/src/components/DomainIcons.tsx index 015dba50..514a1d80 100644 --- a/rsconcept/frontend/src/components/DomainIcons.tsx +++ b/rsconcept/frontend/src/components/DomainIcons.tsx @@ -96,8 +96,6 @@ export function DependencyIcon({ value, size = '1.25rem', className }: DomIconPr switch (value) { case DependencyMode.ALL: return ; - case DependencyMode.EXPRESSION: - return ; case DependencyMode.OUTPUTS: return ; case DependencyMode.INPUTS: diff --git a/rsconcept/frontend/src/components/info/BadgeConstituenta.tsx b/rsconcept/frontend/src/components/info/BadgeConstituenta.tsx index 789e24b9..08eb2216 100644 --- a/rsconcept/frontend/src/components/info/BadgeConstituenta.tsx +++ b/rsconcept/frontend/src/components/info/BadgeConstituenta.tsx @@ -1,7 +1,6 @@ import clsx from 'clsx'; import { CstClass, IConstituenta } from '@/models/rsform'; -import { isMockCst } from '@/models/rsformAPI'; import { colorFgCstStatus, IColorTheme } from '@/styling/color'; import { CProps } from '../props'; @@ -28,11 +27,7 @@ function BadgeConstituenta({ value, prefixID, className, style, theme }: BadgeCo style={{ borderColor: colorFgCstStatus(value.status, theme), color: colorFgCstStatus(value.status, theme), - backgroundColor: isMockCst(value) - ? theme.bgWarning - : value.cst_class === CstClass.BASIC - ? theme.bgGreen25 - : theme.bgInput, + backgroundColor: value.cst_class === CstClass.BASIC ? theme.bgGreen25 : theme.bgInput, ...style }} > diff --git a/rsconcept/frontend/src/models/miscellaneous.ts b/rsconcept/frontend/src/models/miscellaneous.ts index 248555eb..94d2eae3 100644 --- a/rsconcept/frontend/src/models/miscellaneous.ts +++ b/rsconcept/frontend/src/models/miscellaneous.ts @@ -12,7 +12,6 @@ import { IOperation } from './oss'; */ export enum DependencyMode { ALL = 0, - EXPRESSION, OUTPUTS, INPUTS, EXPAND_OUTPUTS, diff --git a/rsconcept/frontend/src/models/rsformAPI.ts b/rsconcept/frontend/src/models/rsformAPI.ts index 81839749..835aab16 100644 --- a/rsconcept/frontend/src/models/rsformAPI.ts +++ b/rsconcept/frontend/src/models/rsformAPI.ts @@ -6,15 +6,7 @@ import { TextMatcher } from '@/utils/utils'; import { BASIC_SCHEMAS, ILibraryItem } from './library'; import { CstMatchMode } from './miscellaneous'; -import { - CATEGORY_CST_TYPE, - ConstituentaID, - CstClass, - CstType, - ExpressionStatus, - IConstituenta, - IRSForm -} from './rsform'; +import { CATEGORY_CST_TYPE, CstClass, CstType, ExpressionStatus, IConstituenta, IRSForm } from './rsform'; import { ParsingStatus, ValueClass } from './rslang'; /** @@ -111,49 +103,6 @@ export function inferClass(type: CstType, isTemplate: boolean = false): CstClass } } -/** - * Creates a mock {@link IConstituenta} object with the provided parameters and default values for other properties. - */ -export function createMockConstituenta(id: ConstituentaID, alias: string, comment: string): IConstituenta { - return { - id: id, - spawner: id, - spawn: [], - spawn_alias: [], - is_simple_expression: false, - schema: -1, - alias: alias, - convention: comment, - cst_type: CstType.BASE, - term_raw: '', - term_resolved: '', - term_forms: [], - definition_formal: '', - definition_raw: '', - definition_resolved: '', - status: ExpressionStatus.INCORRECT, - parent_schema_index: 0, - is_template: false, - is_inherited: false, - has_inherited_children: false, - cst_class: CstClass.DERIVED, - parse: { - status: ParsingStatus.INCORRECT, - valueClass: ValueClass.INVALID, - typification: 'N/A', - syntaxTree: '', - args: [] - } - }; -} - -/** - * Checks if given {@link IConstituenta} is mock. - */ -export function isMockCst(cst: IConstituenta) { - return cst.id <= 0; -} - /** * Apply filter based on start {@link IConstituenta} type. */ diff --git a/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ConstituentsSearch.tsx b/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ConstituentsSearch.tsx index 74fedb3d..2dd9c5b2 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ConstituentsSearch.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ConstituentsSearch.tsx @@ -11,8 +11,7 @@ import useLocalStorage from '@/hooks/useLocalStorage'; import { CstMatchMode, DependencyMode } from '@/models/miscellaneous'; import { applyGraphFilter } from '@/models/miscellaneousAPI'; import { ConstituentaID, IConstituenta, IRSForm } from '@/models/rsform'; -import { createMockConstituenta, matchConstituenta } from '@/models/rsformAPI'; -import { extractGlobals } from '@/models/rslangAPI'; +import { matchConstituenta } from '@/models/rsformAPI'; import { storage } from '@/utils/constants'; interface ConstituentsSearchProps { @@ -35,15 +34,7 @@ function ConstituentsSearch({ schema, activeID, activeExpression, dense, setFilt return; } let result: IConstituenta[] = []; - if (filterSource === DependencyMode.EXPRESSION) { - const aliases = extractGlobals(activeExpression); - result = schema.items.filter(cst => aliases.has(cst.alias)); - const names = result.map(cst => cst.alias); - const diff = Array.from(aliases).filter(name => !names.includes(name)); - if (diff.length > 0) { - diff.forEach((alias, index) => result.push(createMockConstituenta(-index, alias, 'Конституента отсутствует'))); - } - } else if (!activeID) { + if (!activeID) { result = schema.items; } else { result = applyGraphFilter(schema, activeID, filterSource); diff --git a/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/TableSideConstituents.tsx b/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/TableSideConstituents.tsx index 8a8ec30a..8c5f4788 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/TableSideConstituents.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/TableSideConstituents.tsx @@ -8,7 +8,6 @@ import NoData from '@/components/ui/NoData'; import TextContent from '@/components/ui/TextContent'; import { useConceptOptions } from '@/context/ConceptOptionsContext'; import { ConstituentaID, IConstituenta } from '@/models/rsform'; -import { isMockCst } from '@/models/rsformAPI'; import { PARAMETER, prefixes } from '@/utils/constants'; import { describeConstituenta } from '@/utils/labels'; @@ -53,9 +52,7 @@ function TableSideConstituents({ const handleRowClicked = useCallback( (cst: IConstituenta) => { - if (!isMockCst(cst)) { - onOpenEdit(cst.id); - } + onOpenEdit(cst.id); }, [onOpenEdit] ); @@ -90,8 +87,7 @@ function TableSideConstituents({ maxLength={DESCRIPTION_MAX_SYMBOLS} style={{ textWrap: 'pretty', - fontSize: 12, - color: isMockCst(props.row.original) ? colors.fgWarning : undefined + fontSize: 12 }} /> ) diff --git a/rsconcept/frontend/src/utils/labels.ts b/rsconcept/frontend/src/utils/labels.ts index 1f16d980..e3c0ae38 100644 --- a/rsconcept/frontend/src/utils/labels.ts +++ b/rsconcept/frontend/src/utils/labels.ts @@ -244,7 +244,6 @@ export function labelCstSource(mode: DependencyMode): string { // prettier-ignore switch (mode) { case DependencyMode.ALL: return 'не ограничен'; - case DependencyMode.EXPRESSION: return 'выражение'; case DependencyMode.OUTPUTS: return 'потребители'; case DependencyMode.INPUTS: return 'поставщики'; case DependencyMode.EXPAND_OUTPUTS: return 'зависимые'; @@ -259,7 +258,6 @@ export function describeCstSource(mode: DependencyMode): string { // prettier-ignore switch (mode) { case DependencyMode.ALL: return 'все конституенты'; - case DependencyMode.EXPRESSION: return 'имена из выражения'; case DependencyMode.OUTPUTS: return 'прямые исходящие'; case DependencyMode.INPUTS: return 'прямые входящие'; case DependencyMode.EXPAND_OUTPUTS: return 'цепочка исходящих';