From 709471356fb78da5ae2b0cb1acc5258b0839a40e Mon Sep 17 00:00:00 2001 From: Ivan <8611739+IRBorisov@users.noreply.github.com> Date: Wed, 23 Jul 2025 22:32:35 +0300 Subject: [PATCH] M: Small UI fixes --- .../src/features/ai/components/prompt-input/tooltip.ts | 2 +- .../frontend/src/features/ai/stores/ai-context.ts | 8 +++++++- .../features/oss/dialogs/dlg-relocate-constituents.tsx | 6 +++--- .../frontend/src/features/oss/models/oss-layout-api.ts | 6 +++++- .../frontend/src/features/oss/models/oss-layout.ts | 4 ++++ .../editor-oss-graph/side-panel/view-schema.tsx | 9 ++++++++- .../src/features/oss/pages/oss-page/oss-edit-state.tsx | 10 ++++++++++ .../pages/rsform-page/editor-term-graph/tg-flow.tsx | 2 +- 8 files changed, 39 insertions(+), 8 deletions(-) diff --git a/rsconcept/frontend/src/features/ai/components/prompt-input/tooltip.ts b/rsconcept/frontend/src/features/ai/components/prompt-input/tooltip.ts index be1b1a7b..1251b423 100644 --- a/rsconcept/frontend/src/features/ai/components/prompt-input/tooltip.ts +++ b/rsconcept/frontend/src/features/ai/components/prompt-input/tooltip.ts @@ -62,7 +62,7 @@ function domTooltipVariable(varName: string, isAvailable: boolean): TooltipView dom.className = clsx( 'max-h-100 max-w-100 min-w-40', 'dense', - 'px-2 py-1 flex flex-col', + 'p-2 flex flex-col', 'rounded-md shadow-md', 'cc-scroll-y', 'text-sm bg-card', diff --git a/rsconcept/frontend/src/features/ai/stores/ai-context.ts b/rsconcept/frontend/src/features/ai/stores/ai-context.ts index 96229dc3..a585f107 100644 --- a/rsconcept/frontend/src/features/ai/stores/ai-context.ts +++ b/rsconcept/frontend/src/features/ai/stores/ai-context.ts @@ -1,6 +1,6 @@ import { create } from 'zustand'; -import { type IBlock, type IOperationSchema } from '@/features/oss/models/oss'; +import { type IBlock, type IOperation, type IOperationSchema } from '@/features/oss/models/oss'; import { type IConstituenta, type IRSForm } from '@/features/rsform'; import { PromptVariableType } from '../models/prompting'; @@ -25,6 +25,9 @@ interface AIContextStore { currentBlock: IBlock | null; setCurrentBlock: (value: IBlock | null) => void; + currentOperation: IOperation | null; + setCurrentOperation: (value: IOperation | null) => void; + currentConstituenta: IConstituenta | null; setCurrentConstituenta: (value: IConstituenta | null) => void; } @@ -39,6 +42,9 @@ export const useAIStore = create()(set => ({ currentBlock: null, setCurrentBlock: value => set({ currentBlock: value }), + currentOperation: null, + setCurrentOperation: value => set({ currentOperation: value }), + currentConstituenta: null, setCurrentConstituenta: value => set({ currentConstituenta: value }) })); diff --git a/rsconcept/frontend/src/features/oss/dialogs/dlg-relocate-constituents.tsx b/rsconcept/frontend/src/features/oss/dialogs/dlg-relocate-constituents.tsx index 26abd183..32118810 100644 --- a/rsconcept/frontend/src/features/oss/dialogs/dlg-relocate-constituents.tsx +++ b/rsconcept/frontend/src/features/oss/dialogs/dlg-relocate-constituents.tsx @@ -119,10 +119,10 @@ export function DlgRelocateConstituents() { helpTopic={HelpTopic.UI_RELOCATE_CST} >
-
+
rootElements.includes(pos.nodeID)); preventOverlap(newPosition, positions); - } else if (!rectanglesOverlap(target, parent)) { + } else if (!rectanglesStrictOverlap(target, parent)) { newPosition.x = parent.x + MIN_DISTANCE; newPosition.y = parent.y + MIN_DISTANCE; @@ -202,6 +202,10 @@ function rectanglesOverlap(a: Rectangle2D, b: Rectangle2D): boolean { ); } +function rectanglesStrictOverlap(a: Rectangle2D, b: Rectangle2D): boolean { + return !(a.x + a.width <= b.x || b.x + b.width <= a.x || a.y + a.height <= b.y || b.y + b.height <= a.y); +} + function preventOverlap( target: Rectangle2D, fixedRectangles: Rectangle2D[], diff --git a/rsconcept/frontend/src/features/oss/models/oss-layout.ts b/rsconcept/frontend/src/features/oss/models/oss-layout.ts index be1e1d95..d8ff1059 100644 --- a/rsconcept/frontend/src/features/oss/models/oss-layout.ts +++ b/rsconcept/frontend/src/features/oss/models/oss-layout.ts @@ -34,6 +34,8 @@ export interface OperationInternalNode { data: { label: string; operation: IOperation; + isParent: boolean; + isChild: boolean; }; selected: boolean; dragging: boolean; @@ -47,6 +49,8 @@ export interface BlockInternalNode { data: { label: string; block: IBlock; + isParent: boolean; + isChild: boolean; }; selected: boolean; dragging: boolean; diff --git a/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/side-panel/view-schema.tsx b/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/side-panel/view-schema.tsx index ad3dc49a..4e1a2205 100644 --- a/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/side-panel/view-schema.tsx +++ b/rsconcept/frontend/src/features/oss/pages/oss-page/editor-oss-graph/side-panel/view-schema.tsx @@ -1,5 +1,6 @@ -import { useState } from 'react'; +import { useEffect, useState } from 'react'; +import { useAIStore } from '@/features/ai/stores/ai-context'; import { type IConstituenta } from '@/features/rsform'; import { useRSFormSuspense } from '@/features/rsform/backend/use-rsform'; import { RSFormStats } from '@/features/rsform/components/rsform-stats'; @@ -20,9 +21,15 @@ export function ViewSchema({ schemaID, isMutable }: ViewSchemaProps) { const [activeID, setActiveID] = useState(null); const activeCst = activeID ? schema.cstByID.get(activeID) ?? null : null; const showEditCst = useDialogsStore(state => state.showEditCst); + const setCurrentSchema = useAIStore(state => state.setCurrentSchema); const listHeight = useFitHeight('14.5rem', '10rem'); + useEffect(() => { + setCurrentSchema(schema); + return () => setCurrentSchema(null); + }, [schema, setCurrentSchema]); + function handleEditCst(cst: IConstituenta) { showEditCst({ schema: schema, target: cst }); } diff --git a/rsconcept/frontend/src/features/oss/pages/oss-page/oss-edit-state.tsx b/rsconcept/frontend/src/features/oss/pages/oss-page/oss-edit-state.tsx index c2244258..1c2540d2 100644 --- a/rsconcept/frontend/src/features/oss/pages/oss-page/oss-edit-state.tsx +++ b/rsconcept/frontend/src/features/oss/pages/oss-page/oss-edit-state.tsx @@ -33,6 +33,7 @@ export const OssEditState = ({ itemID, children }: React.PropsWithChildren state.location); const setCurrentOSS = useAIStore(state => state.setCurrentOSS); const setCurrentBlock = useAIStore(state => state.setCurrentBlock); + const setCurrentOperation = useAIStore(state => state.setCurrentOperation); const { user } = useAuthSuspense(); const { schema } = useOssSuspense({ itemID: itemID }); @@ -67,6 +68,15 @@ export const OssEditState = ({ itemID, children }: React.PropsWithChildren { + const selectedOperation = selectedItems.find(item => item.nodeType === NodeType.OPERATION); + if (selectedOperation) { + setCurrentOperation(selectedOperation); + return () => setCurrentOperation(null); + } + setCurrentOperation(null); + }, [selectedItems, setCurrentOperation]); + function navigateTab(tab: OssTabID) { const url = urls.oss_props({ id: schema.id, diff --git a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/tg-flow.tsx b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/tg-flow.tsx index 5d3fd929..7e3b01c0 100644 --- a/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/tg-flow.tsx +++ b/rsconcept/frontend/src/features/rsform/pages/rsform-page/editor-term-graph/tg-flow.tsx @@ -166,7 +166,7 @@ export function TGFlow() { return (
-
+
setFocus(null)} /> {!focusCst ? (