From f64f6a6c3d0f4a8e0f838886296007301cf8b6ba Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Thu, 23 Nov 2023 19:34:37 +0300 Subject: [PATCH] Fix minor UI issues --- .../frontend/src/components/Common/Modal.tsx | 4 +-- .../frontend/src/dialogs/DlgDeleteCst.tsx | 25 +++++++++++++------ .../frontend/src/pages/RSFormPage/RSTabs.tsx | 7 ++++-- .../pages/RSFormPage/elements/RSItemsMenu.tsx | 2 ++ rsconcept/frontend/src/utils/constants.ts | 3 +++ 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/rsconcept/frontend/src/components/Common/Modal.tsx b/rsconcept/frontend/src/components/Common/Modal.tsx index 64e24f5f..bb17ab67 100644 --- a/rsconcept/frontend/src/components/Common/Modal.tsx +++ b/rsconcept/frontend/src/components/Common/Modal.tsx @@ -40,10 +40,10 @@ function Modal({
{ title &&

{title}

} -
+
{children}
diff --git a/rsconcept/frontend/src/dialogs/DlgDeleteCst.tsx b/rsconcept/frontend/src/dialogs/DlgDeleteCst.tsx index c0988b24..6e56e380 100644 --- a/rsconcept/frontend/src/dialogs/DlgDeleteCst.tsx +++ b/rsconcept/frontend/src/dialogs/DlgDeleteCst.tsx @@ -3,6 +3,7 @@ import { useMemo, useState } from 'react'; import Checkbox from '../components/Common/Checkbox'; import Modal, { ModalProps } from '../components/Common/Modal'; import { useRSForm } from '../context/RSFormContext'; +import { prefixes } from '../utils/constants'; import { labelConstituenta } from '../utils/labels'; interface DlgDeleteCstProps @@ -37,17 +38,25 @@ function DlgDeleteCst({ hideWindow, selected, onDelete }: DlgDeleteCstProps) {

Выбраны к удалению: {selected.length}

- {selected.map(id => { - const cst = schema!.items.find(cst => cst.id === id); - return (cst &&

{labelConstituenta(cst)}

); - })} + {selected.map( + (id) => { + const cst = schema!.items.find(cst => cst.id === id); + return (cst && +

+ {labelConstituenta(cst)} +

); + })}

Зависимые конституенты: {expansion.length}

- {expansion.map(id => { - const cst = schema!.items.find(cst => cst.id === id); - return (cst &&

{labelConstituenta(cst)}

); - })} + {expansion.map( + (id) => { + const cst = schema!.items.find(cst => cst.id === id); + return (cst && +

+ {labelConstituenta(cst)} +

); + })}
{ const deletedNames = deleted.map(id => schema.items.find(cst => cst.id === id)?.alias).join(', '); toast.success(`Конституенты удалены: ${deletedNames}`); + if (deleted.length === schema.items.length) { navigateTab(RSTabID.CST_LIST); - } - if (activeIndex) { + } else if (activeIndex === -1) { + navigateTab(activeTab); + } else { while (activeIndex < schema.items.length && deleted.find(id => id === schema.items[activeIndex].id)) { ++activeIndex; } @@ -210,6 +212,7 @@ function RSTabs() { } navigateTab(activeTab, schema.items[activeIndex].id); } + if (afterDelete) afterDelete(deleted); }); }, [afterDelete, cstDelete, schema, activeID, activeTab, navigateTab]); diff --git a/rsconcept/frontend/src/pages/RSFormPage/elements/RSItemsMenu.tsx b/rsconcept/frontend/src/pages/RSFormPage/elements/RSItemsMenu.tsx index 52071dc0..9892b1a9 100644 --- a/rsconcept/frontend/src/pages/RSFormPage/elements/RSItemsMenu.tsx +++ b/rsconcept/frontend/src/pages/RSFormPage/elements/RSItemsMenu.tsx @@ -9,6 +9,7 @@ import { ArrowDownIcon, ArrowDropdownIcon, ArrowUpIcon, CloneIcon, DiamondIcon, import { useRSForm } from '../../../context/RSFormContext'; import useDropdown from '../../../hooks/useDropdown'; import { CstType } from '../../../models/rsform'; +import { prefixes } from '../../../utils/constants'; import { labelCstType } from '../../../utils/labels'; import { getCstTypePrefix, getCstTypeShortcut } from '../../../utils/misc'; @@ -79,6 +80,7 @@ function RSItemsMenu({ const type = typeStr as CstType; return ( onCreate(type)} tooltip={getCstTypeShortcut(type)} > diff --git a/rsconcept/frontend/src/utils/constants.ts b/rsconcept/frontend/src/utils/constants.ts index 09374c7c..6fc2ccec 100644 --- a/rsconcept/frontend/src/utils/constants.ts +++ b/rsconcept/frontend/src/utils/constants.ts @@ -74,6 +74,9 @@ export const prefixes = { cst_status_list: 'cst-status-list-', cst_match_mode_list: 'cst-match-mode-list-', cst_source_list: 'cst-source-list-', + cst_delete_list: 'cst-delete-list-', + cst_dependant_list: 'cst-dependant-list-', + csttype_list: 'csttype-', library_filters_list: 'library-filters-list-', topic_list: 'topic-list-', library_list: 'library-list-',