diff --git a/rsconcept/frontend/src/app/ApplicationLayout.tsx b/rsconcept/frontend/src/app/ApplicationLayout.tsx index 4b92bba5..29f67481 100644 --- a/rsconcept/frontend/src/app/ApplicationLayout.tsx +++ b/rsconcept/frontend/src/app/ApplicationLayout.tsx @@ -9,6 +9,7 @@ import { NavigationState } from '@/context/NavigationContext'; import { useAppLayoutStore, useMainHeight, useViewportHeight } from '@/stores/appLayout'; import { globals } from '@/utils/constants'; +import { GlobalDialogs } from './GlobalDialogs'; import { GlobalTooltips } from './GlobalTooltips'; function ApplicationLayout() { @@ -29,6 +30,7 @@ function ApplicationLayout() { pauseOnFocusLoss={false} /> + diff --git a/rsconcept/frontend/src/app/GlobalDialogs.tsx b/rsconcept/frontend/src/app/GlobalDialogs.tsx new file mode 100644 index 00000000..a20ce7db --- /dev/null +++ b/rsconcept/frontend/src/app/GlobalDialogs.tsx @@ -0,0 +1,83 @@ +'use client'; + +import DlgChangeInputSchema from '@/dialogs/DlgChangeInputSchema'; +import DlgChangeLocation from '@/dialogs/DlgChangeLocation'; +import DlgCloneLibraryItem from '@/dialogs/DlgCloneLibraryItem'; +import DlgCreateCst from '@/dialogs/DlgCreateCst'; +import DlgCreateOperation from '@/dialogs/DlgCreateOperation'; +import DlgCreateVersion from '@/dialogs/DlgCreateVersion'; +import DlgCstTemplate from '@/dialogs/DlgCstTemplate'; +import DlgDeleteCst from '@/dialogs/DlgDeleteCst'; +import DlgDeleteOperation from '@/dialogs/DlgDeleteOperation'; +import DlgEditEditors from '@/dialogs/DlgEditEditors'; +import DlgEditOperation from '@/dialogs/DlgEditOperation'; +import DlgEditReference from '@/dialogs/DlgEditReference'; +import DlgEditVersions from '@/dialogs/DlgEditVersions'; +import DlgEditWordForms from '@/dialogs/DlgEditWordForms'; +import DlgGraphParams from '@/dialogs/DlgGraphParams'; +import DlgInlineSynthesis from '@/dialogs/DlgInlineSynthesis'; +import DlgRelocateConstituents from '@/dialogs/DlgRelocateConstituents'; +import DlgRenameCst from '@/dialogs/DlgRenameCst'; +import DlgShowAST from '@/dialogs/DlgShowAST'; +import DlgShowQR from '@/dialogs/DlgShowQR'; +import DlgShowTypeGraph from '@/dialogs/DlgShowTypeGraph'; +import DlgSubstituteCst from '@/dialogs/DlgSubstituteCst'; +import DlgUploadRSForm from '@/dialogs/DlgUploadRSForm'; +import { DialogType } from '@/models/miscellaneous'; +import { useDialogsStore } from '@/stores/dialogs'; + +export const GlobalDialogs = () => { + const active = useDialogsStore(state => state.active); + + if (active === undefined) { + return null; + } + switch (active) { + case DialogType.CONSTITUENTA_TEMPLATE: + return ; + case DialogType.CREATE_CONSTITUENTA: + return ; + case DialogType.CREATE_OPERATION: + return ; + case DialogType.DELETE_CONSTITUENTA: + return ; + case DialogType.EDIT_EDITORS: + return ; + case DialogType.EDIT_OPERATION: + return ; + case DialogType.EDIT_REFERENCE: + return ; + case DialogType.EDIT_VERSIONS: + return ; + case DialogType.EDIT_WORD_FORMS: + return ; + case DialogType.INLINE_SYNTHESIS: + return ; + case DialogType.SHOW_AST: + return ; + case DialogType.SHOW_TYPE_GRAPH: + return ; + case DialogType.CHANGE_INPUT_SCHEMA: + return ; + case DialogType.CHANGE_LOCATION: + return ; + case DialogType.CLONE_LIBRARY_ITEM: + return ; + case DialogType.CREATE_VERSION: + return ; + case DialogType.DELETE_OPERATION: + return ; + case DialogType.GRAPH_PARAMETERS: + return ; + case DialogType.RELOCATE_CONSTITUENTS: + return ; + case DialogType.RENAME_CONSTITUENTA: + return ; + case DialogType.SHOW_QR_CODE: + return ; + case DialogType.SUBSTITUTE_CONSTITUENTS: + return ; + case DialogType.UPLOAD_RSFORM: + return ; + } +}; diff --git a/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx b/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx index a1687fab..4c2e1ed2 100644 --- a/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx +++ b/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx @@ -9,13 +9,13 @@ import { EditorView } from 'codemirror'; import { forwardRef, useRef, useState } from 'react'; import Label from '@/components/ui/Label'; -import DlgEditReference from '@/dialogs/DlgEditReference'; import { ReferenceType } from '@/models/language'; +import { DialogType } from '@/models/miscellaneous'; import { ConstituentaID, IRSForm } from '@/models/rsform'; +import { useDialogsStore } from '@/stores/dialogs'; import { usePreferencesStore } from '@/stores/preferences'; import { APP_COLORS } from '@/styling/color'; import { CodeMirrorWrapper } from '@/utils/codemirror'; -import { PARAMETER } from '@/utils/constants'; import { refsNavigation } from './clickNavigation'; import { NaturalLanguage, ReferenceTokens } from './parse'; @@ -96,7 +96,10 @@ const RefsInput = forwardRef( const [isFocused, setIsFocused] = useState(false); - const [showEditor, setShowEditor] = useState(false); + const showEditReference = useDialogsStore(state => state.showEditReference); + const activeDialog = useDialogsStore(state => state.active); + const isActive = activeDialog === DialogType.EDIT_REFERENCE; + const [currentType, setCurrentType] = useState(ReferenceType.ENTITY); const [refText, setRefText] = useState(''); const [hintText, setHintText] = useState(''); @@ -146,7 +149,7 @@ const RefsInput = forwardRef( } function handleInput(event: React.KeyboardEvent) { - if (!thisRef.current?.view) { + if (!thisRef.current?.view || !schema) { event.preventDefault(); event.stopPropagation(); return; @@ -174,7 +177,17 @@ const RefsInput = forwardRef( setMainRefs(mainNodes.map(node => wrap.getText(node.from, node.to))); setBasePosition(mainNodes.filter(node => node.to <= selection.from).length); - setShowEditor(true); + showEditReference({ + schema: schema, + initial: { + type: currentType, + refRaw: refText, + text: hintText, + basePosition: basePosition, + mainRefs: mainRefs + }, + onSave: handleInputReference + }); } } @@ -187,27 +200,8 @@ const RefsInput = forwardRef( wrap.replaceWith(referenceText); } - function hideEditReference() { - setShowEditor(false); - setTimeout(() => thisRef.current?.view?.focus(), PARAMETER.refreshTimeout); - } - return (
- {showEditor && schema ? ( - - ) : null}