From bdab63f1bb178cf3eb7ff88a64b62f8002712c61 Mon Sep 17 00:00:00 2001 From: popovspiridon99 Date: Thu, 25 Sep 2025 17:12:10 +0900 Subject: [PATCH] use Dialog for MapPrint --- .../src/components/map/MapPrint/MapPrint.tsx | 262 ++++++++++++------ 1 file changed, 175 insertions(+), 87 deletions(-) diff --git a/client/src/components/map/MapPrint/MapPrint.tsx b/client/src/components/map/MapPrint/MapPrint.tsx index df955c0..cda2f78 100644 --- a/client/src/components/map/MapPrint/MapPrint.tsx +++ b/client/src/components/map/MapPrint/MapPrint.tsx @@ -1,4 +1,4 @@ -import { IconHelp, IconWindowMaximize, IconWindowMinimize, IconX } from '@tabler/icons-react' +import { IconHelp, IconWindowMaximize, IconWindowMinimize } from '@tabler/icons-react' import React, { useEffect, useRef, useState } from 'react' import { clearPrintArea, PrintScale, setPreviousView, setPrintScale, setPrintScaleLine, useMapStore } from '../../../store/map' import { PrintFormat, PrintOrientation, printResolutions, setPrintOrientation, setPrintResolution, usePrintStore } from '../../../store/print' @@ -8,7 +8,8 @@ import { useObjectsStore } from '../../../store/objects' import jsPDF from 'jspdf' import { getCenter } from 'ol/extent' import ScaleLine from 'ol/control/ScaleLine' -import { Button, Checkbox, Dropdown, Field, Option, Radio, RadioGroup, Text } from '@fluentui/react-components' +import { Button, Checkbox, Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, Dropdown, Field, Option, Radio, RadioGroup, Text } from '@fluentui/react-components' +import { Dismiss24Regular } from '@fluentui/react-icons' const MapPrint = ({ id, @@ -116,8 +117,11 @@ const MapPrint = ({ minWidth: 125 })) + const [opened, setOpened] = useState(false) + + useEffect(() => { - if (printArea) { + if (printArea && opened) { // backup view before entering print mode setPreviousView(id, map?.getView()) @@ -130,7 +134,7 @@ const MapPrint = ({ }) map?.removeInteraction(printAreaDraw) } - }, [printArea, map]) + }, [printArea, map, opened]) useEffect(() => { if (printScaleLine && printArea) { @@ -140,8 +144,6 @@ const MapPrint = ({ } }, [printScaleLine, printArea]) - const [opened, setOpened] = useState(false) - useEffect(() => { if (!!printArea) { setOpened(true) @@ -157,98 +159,78 @@ const MapPrint = ({ }, [opened]) return ( -
-
-
- - Предпросмотр области печати - + + + + +
+ }>Предпросмотр области печати -
-
+ +
+ Область печати можно передвигать. -
- Область печати можно передвигать. + +
+ + setPrintOrientation(data.value as PrintOrientation)}> + + + + -
- - setPrintOrientation(data.value as PrintOrientation)}> - - - - - - - setPrintResolution(Number(data.optionValue))} - > - {printResolutions.map((res) => ( - - ))} - - + + setPrintResolution(Number(data.optionValue))} + > + {printResolutions.map((res) => ( + + ))} + + - - setPrintScale(id, data.optionValue as PrintScale)} - > - {scaleOptions.map((opt) => ( - - ))} - - + + setPrintScale(id, data.optionValue as PrintScale)} + > + {scaleOptions.map((opt) => ( + + ))} + + +
+
+ + setPrintScaleLine(id, event.currentTarget.checked)} /> -
- -
-
-
- - + + + + ) + + // return ( + //
+ //
+ //
+ // + // Предпросмотр области печати + // + + //
+ //
+ //
+ + //
+ // Область печати можно передвигать. + + // + + //
+ // + // setPrintOrientation(data.value as PrintOrientation)}> + // + // + // + // + + // + // setPrintResolution(Number(data.optionValue))} + // > + // {printResolutions.map((res) => ( + // + // ))} + // + // + + + // + // setPrintScale(id, data.optionValue as PrintScale)} + // > + // {scaleOptions.map((opt) => ( + // + // ))} + // + // + + // setPrintScaleLine(id, event.currentTarget.checked)} + // /> + //
+ + //
+ // + //
+ //
+ //
+ //
+ // ) } export default MapPrint \ No newline at end of file