-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor component structure of modal and add export excel feature
- Refactor the modal structure - Allow renaming of files when exporting to PDF and DrawDB. - Add a feature to exclude exporting relationships when exporting to SQL. - Add an export to Excel feature
- Loading branch information
1 parent
bf74463
commit 3c45476
Showing
32 changed files
with
2,186 additions
and
865 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Modal as SemiUIModal } from "@douyinfe/semi-ui"; | ||
import { useTranslation } from "react-i18next"; | ||
|
||
export default function Modal({children, modalTitle, okText, onOk, onCancel, okBtnDisabled, width}) { | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<SemiUIModal | ||
title={modalTitle || ""} | ||
visible={true} | ||
onOk={onOk} | ||
onCancel={onCancel} | ||
centered | ||
closeOnEsc={true} | ||
okText={okText || t("confirm")} | ||
okButtonProps={{ | ||
disabled: okBtnDisabled | ||
}} | ||
cancelText={t("cancel")} | ||
width={width || 600} | ||
// bodyStyle={{ maxHeight: window.innerHeight - 280, overflow: "auto" }} | ||
> | ||
{children} | ||
</SemiUIModal> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { | ||
useAreas, | ||
useNotes, | ||
useTables, | ||
useTypes, | ||
} from "../../../hooks"; | ||
import ExportModal from "./ExportModal"; | ||
|
||
export default function ExportDrawDB({ title, hideModal }) { | ||
const { t } = useTranslation(); | ||
const { tables, relationships } = useTables(); | ||
const { notes } = useNotes(); | ||
const { areas } = useAreas(); | ||
const { types } = useTypes(); | ||
|
||
const rawData = JSON.stringify( | ||
{ | ||
author: "Unnamed", | ||
title: title, | ||
date: new Date().toISOString(), | ||
tables: tables, | ||
relationships: relationships, | ||
notes: notes, | ||
subjectAreas: areas, | ||
types: types, | ||
}, | ||
null, | ||
2, | ||
); | ||
const [exportData, setExportData] = useState({ | ||
data: new Blob( | ||
[rawData], | ||
{ type: "text/plain;charset=utf-8" } | ||
), | ||
filename: `${title}_${new Date().toISOString()}`, | ||
extension: "ddb", | ||
}); | ||
|
||
return ( | ||
<ExportModal | ||
modalTitle={t("export_diagram")} | ||
onCancel={hideModal} | ||
exportData={exportData} | ||
setExportData={setExportData} | ||
/> | ||
) | ||
} |
Oops, something went wrong.