M: Remove MockCst from sideView

This commit is contained in:
Ivan 2024-09-23 11:54:18 +03:00
parent 00a1deda32
commit ae1fceafcf
7 changed files with 6 additions and 80 deletions

View File

@ -96,8 +96,6 @@ export function DependencyIcon({ value, size = '1.25rem', className }: DomIconPr
switch (value) { switch (value) {
case DependencyMode.ALL: case DependencyMode.ALL:
return <IconSettings size={size} className={className} />; return <IconSettings size={size} className={className} />;
case DependencyMode.EXPRESSION:
return <IconText size={size} className={className ?? 'clr-text-primary'} />;
case DependencyMode.OUTPUTS: case DependencyMode.OUTPUTS:
return <IconGraphOutputs size={size} className={className ?? 'clr-text-primary'} />; return <IconGraphOutputs size={size} className={className ?? 'clr-text-primary'} />;
case DependencyMode.INPUTS: case DependencyMode.INPUTS:

View File

@ -1,7 +1,6 @@
import clsx from 'clsx'; import clsx from 'clsx';
import { CstClass, IConstituenta } from '@/models/rsform'; import { CstClass, IConstituenta } from '@/models/rsform';
import { isMockCst } from '@/models/rsformAPI';
import { colorFgCstStatus, IColorTheme } from '@/styling/color'; import { colorFgCstStatus, IColorTheme } from '@/styling/color';
import { CProps } from '../props'; import { CProps } from '../props';
@ -28,11 +27,7 @@ function BadgeConstituenta({ value, prefixID, className, style, theme }: BadgeCo
style={{ style={{
borderColor: colorFgCstStatus(value.status, theme), borderColor: colorFgCstStatus(value.status, theme),
color: colorFgCstStatus(value.status, theme), color: colorFgCstStatus(value.status, theme),
backgroundColor: isMockCst(value) backgroundColor: value.cst_class === CstClass.BASIC ? theme.bgGreen25 : theme.bgInput,
? theme.bgWarning
: value.cst_class === CstClass.BASIC
? theme.bgGreen25
: theme.bgInput,
...style ...style
}} }}
> >

View File

@ -12,7 +12,6 @@ import { IOperation } from './oss';
*/ */
export enum DependencyMode { export enum DependencyMode {
ALL = 0, ALL = 0,
EXPRESSION,
OUTPUTS, OUTPUTS,
INPUTS, INPUTS,
EXPAND_OUTPUTS, EXPAND_OUTPUTS,

View File

@ -6,15 +6,7 @@ import { TextMatcher } from '@/utils/utils';
import { BASIC_SCHEMAS, ILibraryItem } from './library'; import { BASIC_SCHEMAS, ILibraryItem } from './library';
import { CstMatchMode } from './miscellaneous'; import { CstMatchMode } from './miscellaneous';
import { import { CATEGORY_CST_TYPE, CstClass, CstType, ExpressionStatus, IConstituenta, IRSForm } from './rsform';
CATEGORY_CST_TYPE,
ConstituentaID,
CstClass,
CstType,
ExpressionStatus,
IConstituenta,
IRSForm
} from './rsform';
import { ParsingStatus, ValueClass } from './rslang'; 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. * Apply filter based on start {@link IConstituenta} type.
*/ */

View File

@ -11,8 +11,7 @@ import useLocalStorage from '@/hooks/useLocalStorage';
import { CstMatchMode, DependencyMode } from '@/models/miscellaneous'; import { CstMatchMode, DependencyMode } from '@/models/miscellaneous';
import { applyGraphFilter } from '@/models/miscellaneousAPI'; import { applyGraphFilter } from '@/models/miscellaneousAPI';
import { ConstituentaID, IConstituenta, IRSForm } from '@/models/rsform'; import { ConstituentaID, IConstituenta, IRSForm } from '@/models/rsform';
import { createMockConstituenta, matchConstituenta } from '@/models/rsformAPI'; import { matchConstituenta } from '@/models/rsformAPI';
import { extractGlobals } from '@/models/rslangAPI';
import { storage } from '@/utils/constants'; import { storage } from '@/utils/constants';
interface ConstituentsSearchProps { interface ConstituentsSearchProps {
@ -35,15 +34,7 @@ function ConstituentsSearch({ schema, activeID, activeExpression, dense, setFilt
return; return;
} }
let result: IConstituenta[] = []; let result: IConstituenta[] = [];
if (filterSource === DependencyMode.EXPRESSION) { if (!activeID) {
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) {
result = schema.items; result = schema.items;
} else { } else {
result = applyGraphFilter(schema, activeID, filterSource); result = applyGraphFilter(schema, activeID, filterSource);

View File

@ -8,7 +8,6 @@ import NoData from '@/components/ui/NoData';
import TextContent from '@/components/ui/TextContent'; import TextContent from '@/components/ui/TextContent';
import { useConceptOptions } from '@/context/ConceptOptionsContext'; import { useConceptOptions } from '@/context/ConceptOptionsContext';
import { ConstituentaID, IConstituenta } from '@/models/rsform'; import { ConstituentaID, IConstituenta } from '@/models/rsform';
import { isMockCst } from '@/models/rsformAPI';
import { PARAMETER, prefixes } from '@/utils/constants'; import { PARAMETER, prefixes } from '@/utils/constants';
import { describeConstituenta } from '@/utils/labels'; import { describeConstituenta } from '@/utils/labels';
@ -53,9 +52,7 @@ function TableSideConstituents({
const handleRowClicked = useCallback( const handleRowClicked = useCallback(
(cst: IConstituenta) => { (cst: IConstituenta) => {
if (!isMockCst(cst)) {
onOpenEdit(cst.id); onOpenEdit(cst.id);
}
}, },
[onOpenEdit] [onOpenEdit]
); );
@ -90,8 +87,7 @@ function TableSideConstituents({
maxLength={DESCRIPTION_MAX_SYMBOLS} maxLength={DESCRIPTION_MAX_SYMBOLS}
style={{ style={{
textWrap: 'pretty', textWrap: 'pretty',
fontSize: 12, fontSize: 12
color: isMockCst(props.row.original) ? colors.fgWarning : undefined
}} }}
/> />
) )

View File

@ -244,7 +244,6 @@ export function labelCstSource(mode: DependencyMode): string {
// prettier-ignore // prettier-ignore
switch (mode) { switch (mode) {
case DependencyMode.ALL: return 'не ограничен'; case DependencyMode.ALL: return 'не ограничен';
case DependencyMode.EXPRESSION: return 'выражение';
case DependencyMode.OUTPUTS: return 'потребители'; case DependencyMode.OUTPUTS: return 'потребители';
case DependencyMode.INPUTS: return 'поставщики'; case DependencyMode.INPUTS: return 'поставщики';
case DependencyMode.EXPAND_OUTPUTS: return 'зависимые'; case DependencyMode.EXPAND_OUTPUTS: return 'зависимые';
@ -259,7 +258,6 @@ export function describeCstSource(mode: DependencyMode): string {
// prettier-ignore // prettier-ignore
switch (mode) { switch (mode) {
case DependencyMode.ALL: return 'все конституенты'; case DependencyMode.ALL: return 'все конституенты';
case DependencyMode.EXPRESSION: return 'имена из выражения';
case DependencyMode.OUTPUTS: return 'прямые исходящие'; case DependencyMode.OUTPUTS: return 'прямые исходящие';
case DependencyMode.INPUTS: return 'прямые входящие'; case DependencyMode.INPUTS: return 'прямые входящие';
case DependencyMode.EXPAND_OUTPUTS: return 'цепочка исходящих'; case DependencyMode.EXPAND_OUTPUTS: return 'цепочка исходящих';