From 2deeee756cf54f44f06a122f4b50362efa6aa063 Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Tue, 15 Aug 2023 21:43:15 +0300 Subject: [PATCH] Refactor common help elements --- .../src/components/Help/ConstituentaInfo.tsx | 22 ++++++++++++++ .../src/components/Help/CstStatusInfo.tsx | 29 +++++++++++++++++++ .../pages/RSFormPage/EditorConstituenta.tsx | 16 ++-------- .../src/pages/RSFormPage/EditorItems.tsx | 14 ++------- .../src/pages/RSFormPage/EditorTermGraph.tsx | 29 +++++-------------- .../elements/ConstituentaTooltip.tsx | 9 ++---- rsconcept/frontend/src/utils/constants.ts | 3 +- 7 files changed, 68 insertions(+), 54 deletions(-) create mode 100644 rsconcept/frontend/src/components/Help/ConstituentaInfo.tsx create mode 100644 rsconcept/frontend/src/components/Help/CstStatusInfo.tsx diff --git a/rsconcept/frontend/src/components/Help/ConstituentaInfo.tsx b/rsconcept/frontend/src/components/Help/ConstituentaInfo.tsx new file mode 100644 index 00000000..07e34d2e --- /dev/null +++ b/rsconcept/frontend/src/components/Help/ConstituentaInfo.tsx @@ -0,0 +1,22 @@ +import { IConstituenta } from '../../utils/models'; +import { getCstTypificationLabel } from '../../utils/staticUI'; + +interface ConstituentaInfoProps +extends React.HTMLAttributes { + data: IConstituenta +} + +function ConstituentaInfo({ data, ...props }: ConstituentaInfoProps) { + return ( +
+

Конституента {data.alias}

+

Типизация: {getCstTypificationLabel(data)}

+

Термин: {data.term.resolved || data.term.raw}

+ {data.definition.formal &&

Выражение: {data.definition.formal}

} + {data.definition.text.resolved &&

Определение: {data.definition.text.resolved}

} + {data.convention &&

Конвенция: {data.convention}

} +
+ ); +} + +export default ConstituentaInfo; \ No newline at end of file diff --git a/rsconcept/frontend/src/components/Help/CstStatusInfo.tsx b/rsconcept/frontend/src/components/Help/CstStatusInfo.tsx new file mode 100644 index 00000000..e1a0c78d --- /dev/null +++ b/rsconcept/frontend/src/components/Help/CstStatusInfo.tsx @@ -0,0 +1,29 @@ +import { prefixes } from '../../utils/constants'; +import { mapStatusInfo } from '../../utils/staticUI'; + +interface CstStatusInfoProps { + title?: string +} + +function CstStatusInfo({ title }: CstStatusInfoProps) { + return ( + <> + { title &&

{title}

} + { [... mapStatusInfo.values()].map( + (info, index) => { + return ( +

+ + {info.text} + + - + + {info.tooltip} + +

); + })} + + ); +} + +export default CstStatusInfo; diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta.tsx index 4f8a428d..459ac9d4 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta.tsx @@ -6,10 +6,11 @@ import Divider from '../../components/Common/Divider'; import MiniButton from '../../components/Common/MiniButton'; import SubmitButton from '../../components/Common/SubmitButton'; import TextArea from '../../components/Common/TextArea'; +import CstStatusInfo from '../../components/Help/CstStatusInfo'; import { DumpBinIcon, HelpIcon, SaveIcon, SmallPlusIcon } from '../../components/Icons'; import { useRSForm } from '../../context/RSFormContext'; import { type CstType, EditMode, ICstUpdateData, SyntaxTree } from '../../utils/models'; -import { getCstTypeLabel, getCstTypificationLabel, mapStatusInfo } from '../../utils/staticUI'; +import { getCstTypeLabel, getCstTypificationLabel } from '../../utils/staticUI'; import EditorRSExpression from './EditorRSExpression'; import ViewSideConstituents from './elements/ViewSideConstituents'; @@ -173,18 +174,7 @@ function EditorConstituenta({ activeID, onShowAST, onCreateCst, onOpenEdit, onDe

- при наведении на ID конституенты отображаются ее атрибуты

- столбец "Описание" содержит один из непустых текстовых атрибутов

-

Статусы

- { [... mapStatusInfo.values()].map((info, index) => { - return (

- - {info.text} - - - - - {info.tooltip} - -

); - })} + diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorItems.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorItems.tsx index 9d0b0d00..5c6afa2e 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorItems.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorItems.tsx @@ -5,6 +5,7 @@ import Button from '../../components/Common/Button'; import ConceptDataTable from '../../components/Common/ConceptDataTable'; import ConceptTooltip from '../../components/Common/ConceptTooltip'; import Divider from '../../components/Common/Divider'; +import CstStatusInfo from '../../components/Help/CstStatusInfo'; import { ArrowDownIcon, ArrowsRotateIcon, ArrowUpIcon, DumpBinIcon, HelpIcon, SmallPlusIcon } from '../../components/Icons'; import { useRSForm } from '../../context/RSFormContext'; import { useConceptTheme } from '../../context/ThemeContext'; @@ -316,18 +317,7 @@ function EditorItems({ onOpenEdit, onCreateCst, onDeleteCst }: EditorItemsProps)

Delete - удаление конституент

Alt + 1-6,Q,W - добавление конституент

-

Статусы

- { [... mapStatusInfo.values()].map(info => { - return (

- - {info.text} - - - - - {info.tooltip} - -

); - })} + diff --git a/rsconcept/frontend/src/pages/RSFormPage/EditorTermGraph.tsx b/rsconcept/frontend/src/pages/RSFormPage/EditorTermGraph.tsx index 0346dc0e..97f5ce13 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/EditorTermGraph.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/EditorTermGraph.tsx @@ -8,6 +8,8 @@ import Checkbox from '../../components/Common/Checkbox'; import ConceptSelect from '../../components/Common/ConceptSelect'; import ConceptTooltip from '../../components/Common/ConceptTooltip'; import Divider from '../../components/Common/Divider'; +import ConstituentaInfo from '../../components/Help/ConstituentaInfo'; +import CstStatusInfo from '../../components/Help/CstStatusInfo'; import { ArrowsRotateIcon, HelpIcon } from '../../components/Icons'; import { useRSForm } from '../../context/RSFormContext'; import { useConceptTheme } from '../../context/ThemeContext'; @@ -15,7 +17,7 @@ import useLocalStorage from '../../hooks/useLocalStorage'; import { prefixes, resources } from '../../utils/constants'; import { Graph } from '../../utils/Graph'; import { IConstituenta } from '../../utils/models'; -import { getCstStatusColor, getCstTypeColor, getCstTypificationLabel, +import { getCstStatusColor, getCstTypeColor, GraphColoringSelector, GraphLayoutSelector, mapColoringLabels, mapLayoutLabels, mapStatusInfo } from '../../utils/staticUI'; @@ -200,14 +202,10 @@ function EditorTermGraph({ onOpenEdit }: EditorTermGraphProps) {
{hoverCst &&
-
-

Конституента {hoverCst.alias}

-

Типизация: {getCstTypificationLabel(hoverCst)}

-

Термин: {hoverCst.term.resolved || hoverCst.term.raw}

- {hoverCst.definition.formal &&

Выражение: {hoverCst.definition.formal}

} - {hoverCst.definition.text.resolved &&

Определение: {hoverCst.definition.text.resolved}

} - {hoverCst.convention &&

Конвенция: {hoverCst.convention}

} -
+
}
-

Конституента {data.alias}

-

Типизация: {getCstTypificationLabel(data)}

-

Термин: {data.term.resolved || data.term.raw}

- {data.definition.formal &&

Выражение: {data.definition.formal}

} - {data.definition.text.resolved &&

Определение: {data.definition.text.resolved}

} - {data.convention &&

Конвенция: {data.convention}

} + ); } diff --git a/rsconcept/frontend/src/utils/constants.ts b/rsconcept/frontend/src/utils/constants.ts index e14e1276..b620bcf5 100644 --- a/rsconcept/frontend/src/utils/constants.ts +++ b/rsconcept/frontend/src/utils/constants.ts @@ -28,5 +28,6 @@ export const resources = { } export const prefixes = { - cst_list: 'cst-list-' + cst_list: 'cst-list-', + cst_status_list: 'cst-status-list-' }