From 3310d74ebb00b8b8b4896652a0e5d218d4b7f29b Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Tue, 9 Feb 2021 09:14:49 -0800 Subject: [PATCH] Progress on export. --- .../action-dispatcher/export-dialog/index.tsx | 133 ++++++++++++------ .../action-dispatcher/export-dialog/style.ts | 20 +++ .../maps-page/action-dispatcher/index.tsx | 2 +- 3 files changed, 112 insertions(+), 43 deletions(-) create mode 100644 packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/style.ts diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx index fa5c4e9e..51e76a9f 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/index.tsx @@ -1,22 +1,39 @@ import React, { useEffect } from "react"; -import { useIntl } from "react-intl"; +import { FormattedMessage, useIntl } from "react-intl"; import { fetchMapById, SimpleDialogProps } from ".."; import BaseDialog from "../base-dialog"; -import { FormControl, FormControlLabel, Radio, RadioGroup, Tooltip } from "@material-ui/core"; +import { FormControl, FormControlLabel, MenuItem, Radio, RadioGroup, Select, Tooltip, Typography } from "@material-ui/core"; +import { useStyles } from './style'; +import { Alert } from "@material-ui/lab"; +type ExportFormat = 'pdf' | 'svg' | 'jpeg' | 'png' | 'txt' | 'mm' | 'wxml'; +type ExportGroup = 'image' | 'document' | 'mindmap-tool'; -const ExportDialog = (props: SimpleDialogProps) => { +type ExportDialogProps = { + mapId: number, + enableImgExport: boolean, + onClose: () => void, +} + +const ExportDialog = (props: ExportDialogProps) => { const intl = useIntl(); - const { mapId, onClose } = props; + const { mapId, onClose, enableImgExport } = props; const [submit, setSubmit] = React.useState(false); - const [formExportRef, setExportFormRef] = React.useState(); // @Todo: review - const [formTransformtRef, setTransformFormRef] = React.useState(); // @Todo: review + const [formExportRef, setExportFormRef] = React.useState(); + const [formTransformtRef, setTransformFormRef] = React.useState(); + const [exportGroup, setExportGroup] = React.useState(enableImgExport ? 'image' : 'document'); + const [exportFormat, setExportFormat] = React.useState(enableImgExport ? 'svg' : 'pdf'); + const classes = useStyles(); - const [exportFormat, setExportFormat] = React.useState('mm'); - const handleChange = (event) => { + + const handleOnExportFormatChange = (event) => { setExportFormat(event.target.value); }; + const handleOnGroupChange = (event) => { + setExportGroup(event.target.value); + }; + const handleOnClose = (): void => { onClose(); }; @@ -28,9 +45,10 @@ const ExportDialog = (props: SimpleDialogProps) => { useEffect(() => { if (submit) { // Depending on the type of export. It will require differt POST. - if (exportFormat == 'pdf' || exportFormat == "svg" || exportFormat == "image") { + if (exportFormat == 'pdf' || exportFormat == "svg" || exportFormat == "jpeg" || exportFormat == "png") { formTransformtRef.submit(); } else { + formExportRef.submit(); } onClose(); @@ -46,41 +64,72 @@ const ExportDialog = (props: SimpleDialogProps) => { title={intl.formatMessage({ id: "export.title", defaultMessage: "Export" })} description={"Export this map in the format that you want and start using it in your presentations or sharing by email"} submitButton={intl.formatMessage({ id: "export.title", defaultMessage: "Export" })} > + + + + + - + + + } + label={intl.formatMessage({ id: "export.image", defaultMessage: "Image: Get a graphic representation of your map including all colors and shapes." })} + color="secondary" + style={{ fontSize: '9px' }} /> + {(exportGroup == 'image') && + () + } + + + } + label={intl.formatMessage({ id: "export.document", defaultMessage: "Document: Export your mindmap in a self-contained document ready to share" })} + color="secondary" /> + {exportGroup == 'document' && + () + } + - {/* SVG Based .... */} - - } label="Image" color="secondary" /> - - - - {/* Non - SVG .... */} - - } label="FREEMIND_EXPORT_FORMAT_09" color="secondary" /> - - - - } label="MINDJET_EXPORT_FORMAT" color="secondary" /> - - - - } label="WISEMAPPING_EXPORT_FORMAT" color="secondary" /> - - - - } label="TXT_EXPORT_FORMAT" color="secondary" /> - - - - } label="XLS_EXPORT_FORMAT" color="secondary" /> - - - - } label="OPEN_OFFICE_EXPORT_FORMAT" color="secondary" /> - - + + } + label={intl.formatMessage({ id: "export.document", defaultMessage: "Mindmap Tools: Export your mindmap in thirdparty mindmap tool formats" })} + color="secondary" /> + {exportGroup == 'mindmap-tool' && + () + } + @@ -91,7 +140,7 @@ const ExportDialog = (props: SimpleDialogProps) => { -
+ diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/style.ts b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/style.ts new file mode 100644 index 00000000..d7e23901 --- /dev/null +++ b/packages/webapp/src/components/maps-page/action-dispatcher/export-dialog/style.ts @@ -0,0 +1,20 @@ +import { createStyles, makeStyles, Theme } from "@material-ui/core"; + +export const useStyles = makeStyles((theme: Theme) => + createStyles({ + select: { + height: '40px', + borderRadius: '9px', + width: '300px', + fontSize: '14px', + // margin: '0px 30px' + }, + menu: { + fontSize: '14px' + }, + label: { + margin: '5px 0px' + } + + }) +); \ No newline at end of file diff --git a/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx b/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx index 6ba40152..c3cd7d0e 100644 --- a/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx +++ b/packages/webapp/src/components/maps-page/action-dispatcher/index.tsx @@ -57,7 +57,7 @@ const ActionDispatcher = (props: ActionDialogProps) => { {action === 'publish' && } {action === 'info' && } {action === 'create' && } - {action === 'export' && } + {action === 'export' && } ); }