(ctrlKey = event.ctrlKey)}
+ onKeyDown={event => (ctrlKey = event.ctrlKey)}
+ >
void;
+ setFocus: (cstID: ConstituentaID) => void;
onEdit: (cstID: ConstituentaID) => void;
}
-function ViewHidden({ items, selected, toggleSelection, schema, coloringScheme, onEdit }: ViewHiddenProps) {
+function ViewHidden({ items, selected, toggleSelection, setFocus, schema, coloringScheme, onEdit }: ViewHiddenProps) {
const { colors, calculateHeight } = useConceptOptions();
const windowSize = useWindowSize();
const localSelected = useMemo(() => items.filter(id => selected.includes(id)), [items, selected]);
const [isFolded, setIsFolded] = useLocalStorage(storage.rsgraphFoldHidden, false);
+ const handleClick = useCallback(
+ (cstID: ConstituentaID, event: CProps.EventMouse) => {
+ if (event.ctrlKey) {
+ setFocus(cstID);
+ } else {
+ toggleSelection(cstID);
+ }
+ },
+ [setFocus, toggleSelection]
+ );
+
if (!schema || items.length <= 0) {
return null;
}
@@ -93,7 +106,7 @@ function ViewHidden({ items, selected, toggleSelection, schema, coloringScheme,
backgroundColor: colorBgGraphNode(cst, adjustedColoring, colors),
...(localSelected.includes(cstID) ? { outlineWidth: '2px', outlineStyle: 'solid' } : {})
}}
- onClick={() => toggleSelection(cstID)}
+ onClick={event => handleClick(cstID, event)}
onDoubleClick={() => onEdit(cstID)}
>
{cst.alias}
diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorTermGraph/useGraphFilter.ts b/rsconcept/frontend/src/pages/RSFormPage/EditorTermGraph/useGraphFilter.ts
index 7de5ad13..91870e2c 100644
--- a/rsconcept/frontend/src/pages/RSFormPage/EditorTermGraph/useGraphFilter.ts
+++ b/rsconcept/frontend/src/pages/RSFormPage/EditorTermGraph/useGraphFilter.ts
@@ -2,9 +2,9 @@ import { useLayoutEffect, useMemo, useState } from 'react';
import { Graph } from '@/models/Graph';
import { GraphFilterParams } from '@/models/miscellaneous';
-import { CstType, IRSForm } from '@/models/rsform';
+import { ConstituentaID, CstType, IConstituenta, IRSForm } from '@/models/rsform';
-function useGraphFilter(schema: IRSForm | undefined, params: GraphFilterParams) {
+function useGraphFilter(schema: IRSForm | undefined, params: GraphFilterParams, focusCst: IConstituenta | undefined) {
const [filtered, setFiltered] = useState(new Graph());
const allowedTypes: CstType[] = useMemo(() => {
@@ -29,32 +29,45 @@ function useGraphFilter(schema: IRSForm | undefined, params: GraphFilterParams)
if (params.noHermits) {
graph.removeIsolated();
}
- if (params.noTransitive) {
- graph.transitiveReduction();
- }
if (params.noTemplates) {
schema.items.forEach(cst => {
- if (cst.is_template) {
+ if (cst !== focusCst && cst.is_template) {
graph.foldNode(cst.id);
}
});
}
if (allowedTypes.length < Object.values(CstType).length) {
schema.items.forEach(cst => {
- if (!allowedTypes.includes(cst.cst_type)) {
+ if (cst !== focusCst && !allowedTypes.includes(cst.cst_type)) {
graph.foldNode(cst.id);
}
});
}
- if (params.foldDerived) {
+ if (!focusCst && params.foldDerived) {
schema.items.forEach(cst => {
- if (cst.parent_alias) {
+ if (cst.parent) {
graph.foldNode(cst.id);
}
});
}
+ if (focusCst) {
+ const includes: ConstituentaID[] = [
+ focusCst.id,
+ ...focusCst.children,
+ ...(params.focusShowInputs ? schema.graph.expandInputs([focusCst.id]) : []),
+ ...(params.focusShowOutputs ? schema.graph.expandOutputs([focusCst.id]) : [])
+ ];
+ schema.items.forEach(cst => {
+ if (!includes.includes(cst.id)) {
+ graph.foldNode(cst.id);
+ }
+ });
+ }
+ if (params.noTransitive) {
+ graph.transitiveReduction();
+ }
setFiltered(graph);
- }, [schema, params, allowedTypes]);
+ }, [schema, params, allowedTypes, focusCst]);
return filtered;
}
diff --git a/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx b/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx
index a165a401..3bfc9e36 100644
--- a/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx
+++ b/rsconcept/frontend/src/pages/RSFormPage/RSTabs.tsx
@@ -145,11 +145,11 @@ function RSTabs() {
const onOpenCst = useCallback(
(cstID: ConstituentaID) => {
- if (cstID !== activeCst?.id) {
+ if (cstID !== activeCst?.id || activeTab !== RSTabID.CST_EDIT) {
navigateTab(RSTabID.CST_EDIT, cstID);
}
},
- [navigateTab, activeCst]
+ [navigateTab, activeCst, activeTab]
);
const onDestroySchema = useCallback(() => {
diff --git a/rsconcept/frontend/src/utils/constants.ts b/rsconcept/frontend/src/utils/constants.ts
index 36750dba..22080ede 100644
--- a/rsconcept/frontend/src/utils/constants.ts
+++ b/rsconcept/frontend/src/utils/constants.ts
@@ -90,7 +90,7 @@ export const storage = {
librarySearchStrategy: 'library.search.strategy',
libraryPagination: 'library.pagination',
- rsgraphFilter: 'rsgraph.filter_options',
+ rsgraphFilter: 'rsgraph.filter2',
rsgraphLayout: 'rsgraph.layout',
rsgraphColoring: 'rsgraph.coloring',
rsgraphSizing: 'rsgraph.sizing',