From da05bd6a12d917439d07b7e1e9629e4954e853b5 Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Fri, 8 Dec 2023 19:24:08 +0300 Subject: [PATCH] Refactor UI elements --- .../src/components/Common/ConceptSearch.tsx | 22 +- .../src/components/Common/SelectMulti.tsx | 2 +- .../src/components/Common/TextInput.tsx | 4 +- .../src/components/Common/TextURL.tsx | 10 +- rsconcept/frontend/src/components/Footer.tsx | 26 +- rsconcept/frontend/src/components/Icons.tsx | 4 +- .../src/components/Navigation/Navigation.tsx | 4 +- .../Navigation/ToggleNavigationButton.tsx | 43 ++- .../src/components/RSInput/textEditing.ts | 1 - .../components/Shared/ConstituentaPicker.tsx | 4 +- .../src/components/Shared/GrammemeBadge.tsx | 29 ++ .../src/components/Shared/SelectGrammeme.tsx | 43 +++ .../src/components/Shared/WordFormBadge.tsx | 22 ++ .../dialogs/DlgEditReference/EntityTab.tsx | 47 +-- ...{SelectTermform.tsx => SelectWordForm.tsx} | 6 +- .../frontend/src/dialogs/DlgEditWordForms.tsx | 316 ------------------ .../DlgEditWordForms/DlgEditWordForms.tsx | 209 ++++++++++++ .../DlgEditWordForms/WordFormsTable.tsx | 100 ++++++ .../src/dialogs/DlgEditWordForms/index.tsx | 1 + rsconcept/frontend/src/models/rslangAPI.ts | 5 - .../src/pages/LibraryPage/SearchPanel.tsx | 21 +- .../EditorConstituenta/EditorConstituenta.tsx | 18 +- .../EditorConstituenta/FormConstituenta.tsx | 2 +- .../ViewSideConstituents.tsx | 282 ---------------- .../EditorRSExpression.tsx | 46 +-- .../ParsingResult.tsx | 2 +- .../EditorRSExpression/RSAnalyzer.tsx | 58 ++++ .../RSEditControls.tsx | 0 .../RSLocalButton.tsx | 0 .../RSTokenButton.tsx | 0 .../StatusBar.tsx | 0 .../RSFormPage/EditorRSExpression/index.tsx | 1 + .../ViewConstituents/ConstituentsSearch.tsx | 140 ++++++++ .../ViewConstituents/ConstituentsTable.tsx | 135 ++++++++ .../ViewConstituents/ViewConstituents.tsx | 53 +++ .../RSFormPage/ViewConstituents/index.tsx | 1 + rsconcept/frontend/src/utils/codemirror.ts | 2 - 37 files changed, 901 insertions(+), 758 deletions(-) create mode 100644 rsconcept/frontend/src/components/Shared/GrammemeBadge.tsx create mode 100644 rsconcept/frontend/src/components/Shared/SelectGrammeme.tsx create mode 100644 rsconcept/frontend/src/components/Shared/WordFormBadge.tsx rename rsconcept/frontend/src/dialogs/DlgEditReference/{SelectTermform.tsx => SelectWordForm.tsx} (92%) delete mode 100644 rsconcept/frontend/src/dialogs/DlgEditWordForms.tsx create mode 100644 rsconcept/frontend/src/dialogs/DlgEditWordForms/DlgEditWordForms.tsx create mode 100644 rsconcept/frontend/src/dialogs/DlgEditWordForms/WordFormsTable.tsx create mode 100644 rsconcept/frontend/src/dialogs/DlgEditWordForms/index.tsx delete mode 100644 rsconcept/frontend/src/pages/RSFormPage/EditorConstituenta/ViewSideConstituents.tsx rename rsconcept/frontend/src/pages/RSFormPage/{EditorConstituenta => EditorRSExpression}/EditorRSExpression.tsx (77%) rename rsconcept/frontend/src/pages/RSFormPage/{EditorConstituenta => EditorRSExpression}/ParsingResult.tsx (97%) create mode 100644 rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/RSAnalyzer.tsx rename rsconcept/frontend/src/pages/RSFormPage/{EditorConstituenta => EditorRSExpression}/RSEditControls.tsx (100%) rename rsconcept/frontend/src/pages/RSFormPage/{EditorConstituenta => EditorRSExpression}/RSLocalButton.tsx (100%) rename rsconcept/frontend/src/pages/RSFormPage/{EditorConstituenta => EditorRSExpression}/RSTokenButton.tsx (100%) rename rsconcept/frontend/src/pages/RSFormPage/{EditorConstituenta => EditorRSExpression}/StatusBar.tsx (100%) create mode 100644 rsconcept/frontend/src/pages/RSFormPage/EditorRSExpression/index.tsx create mode 100644 rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ConstituentsSearch.tsx create mode 100644 rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ConstituentsTable.tsx create mode 100644 rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ViewConstituents.tsx create mode 100644 rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/index.tsx diff --git a/rsconcept/frontend/src/components/Common/ConceptSearch.tsx b/rsconcept/frontend/src/components/Common/ConceptSearch.tsx index e6f1a3d7..d7220225 100644 --- a/rsconcept/frontend/src/components/Common/ConceptSearch.tsx +++ b/rsconcept/frontend/src/components/Common/ConceptSearch.tsx @@ -1,23 +1,29 @@ import { MagnifyingGlassIcon } from '../Icons'; +import Overlay from './Overlay'; import TextInput from './TextInput'; interface ConceptSearchProps { value: string onChange?: (newValue: string) => void dense?: boolean + noBorder?: boolean + dimensions?: string } -function ConceptSearch({ value, onChange, dense }: ConceptSearchProps) { - const borderClass = dense ? 'border-t border-x': ''; +function ConceptSearch({ value, onChange, noBorder, dimensions, dense }: ConceptSearchProps) { + const borderClass = dense && !noBorder ? 'border-t border-x': ''; return ( -
Список пуст
-Добавьте словоформу
- - } - onRowClicked={handleRowClicked} - /> -Список пуст
+Добавьте словоформу
+ + } + onRowClicked={onFormSelect} + /> + >); +} + +export default WordFormsTable; \ No newline at end of file diff --git a/rsconcept/frontend/src/dialogs/DlgEditWordForms/index.tsx b/rsconcept/frontend/src/dialogs/DlgEditWordForms/index.tsx new file mode 100644 index 00000000..86ea2195 --- /dev/null +++ b/rsconcept/frontend/src/dialogs/DlgEditWordForms/index.tsx @@ -0,0 +1 @@ +export { default } from './DlgEditWordForms'; \ No newline at end of file diff --git a/rsconcept/frontend/src/models/rslangAPI.ts b/rsconcept/frontend/src/models/rslangAPI.ts index 05b0bc80..9743978e 100644 --- a/rsconcept/frontend/src/models/rslangAPI.ts +++ b/rsconcept/frontend/src/models/rslangAPI.ts @@ -91,11 +91,6 @@ export function substituteTemplateArgs(expression: string, args: IArgumentValue[ .every(local => local.every(match => !(match in mapping))) ).join(', '); - console.log(body); - console.log(head); - console.log(args); - console.log(mapping); - if (!head) { return body; } else { diff --git a/rsconcept/frontend/src/pages/LibraryPage/SearchPanel.tsx b/rsconcept/frontend/src/pages/LibraryPage/SearchPanel.tsx index 3c9f8b52..6e0da75c 100644 --- a/rsconcept/frontend/src/pages/LibraryPage/SearchPanel.tsx +++ b/rsconcept/frontend/src/pages/LibraryPage/SearchPanel.tsx @@ -1,7 +1,7 @@ import { useCallback, useLayoutEffect } from 'react'; import { useLocation } from 'react-router-dom'; -import { MagnifyingGlassIcon } from '../../components/Icons'; +import ConceptSearch from '../../components/Common/ConceptSearch'; import { useAuth } from '../../context/AuthContext'; import { useConceptNavigation } from '../../context/NagivationContext'; import { ILibraryFilter } from '../../models/miscelanious'; @@ -35,8 +35,7 @@ function SearchPanel({ total, filtered, query, setQuery, strategy, setStrategy, const search = useLocation().search; const { user } = useAuth(); - function handleChangeQuery(event: React.ChangeEvent{labelCstMathchMode(matchMode)}: {describeCstMathchMode(matchMode)}
-{labelCstSource(source)}: {describeCstSource(source)}
-Список конституент пуст
-Измените параметры фильтра
- - } - - onRowDoubleClicked={handleDoubleClick} - onRowClicked={handleRowClicked} - /> -{labelCstMathchMode(matchMode)}: {describeCstMathchMode(matchMode)}
+{labelCstSource(source)}: {describeCstSource(source)}
+Список конституент пуст
+Измените параметры фильтра
+ + } + + onRowDoubleClicked={handleDoubleClick} + onRowClicked={handleRowClicked} + />); +} + +export default ConstituentsTable; \ No newline at end of file diff --git a/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ViewConstituents.tsx b/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ViewConstituents.tsx new file mode 100644 index 00000000..cf56780d --- /dev/null +++ b/rsconcept/frontend/src/pages/RSFormPage/ViewConstituents/ViewConstituents.tsx @@ -0,0 +1,53 @@ +import { useMemo, useState } from 'react'; + +import { useConceptTheme } from '../../../context/ThemeContext'; +import { IConstituenta, IRSForm } from '../../../models/rsform'; +import ConstituentsSearch from './ConstituentsSearch'; +import ConstituentsTable from './ConstituentsTable'; + +// Height that should be left to accomodate navigation panel + bottom margin +const LOCAL_NAVIGATION_H = '2.1rem'; + +// Window width cutoff for expression show +const COLUMN_EXPRESSION_HIDE_THRESHOLD = 1500; + +interface ViewConstituentsProps { + expression: string + baseHeight: string + activeID?: number + schema?: IRSForm + onOpenEdit: (cstID: number) => void +} + +function ViewConstituents({ expression, baseHeight, schema, activeID, onOpenEdit }: ViewConstituentsProps) { + const { noNavigation } = useConceptTheme(); + + const [filteredData, setFilteredData] = useState