public inbox for [email protected]
help / color / mirror / Atom feedFrom: Aditya Toshniwal <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin][RM7333] ERD Tool: drag table throws Uncaught TypeError
Date: Tue, 26 Apr 2022 16:02:40 +0530
Message-ID: <CAM9w-_=2KC+c4s18pPvs56s=OK9=76h6mdbdCEnxDTftCjpW4g@mail.gmail.com> (raw)
Hi Hackers,
Attached patch fixes the error when drag and drop table in ERD.
Please review.
--
Thanks,
Aditya Toshniwal
pgAdmin Hacker | Software Architect | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"
Attachments:
[application/octet-stream] RM7333.patch (2.6K, 3-RM7333.patch)
download | inline diff:
diff --git a/web/pgadmin/tools/erd/static/js/erd_tool/nodes/TableNode.jsx b/web/pgadmin/tools/erd/static/js/erd_tool/nodes/TableNode.jsx
index 8c3686f09..be4e2c9a9 100644
--- a/web/pgadmin/tools/erd/static/js/erd_tool/nodes/TableNode.jsx
+++ b/web/pgadmin/tools/erd/static/js/erd_tool/nodes/TableNode.jsx
@@ -209,7 +209,7 @@ export class TableNodeWidget extends React.Component {
}
render() {
- let tableData = this.props.node.getData();
+ let tableData = this.props.node.getData() || {};
let tableMetaData = this.props.node.getMetadata();
let localFkCols = [];
(tableData.foreign_key||[]).forEach((fk)=>{
diff --git a/web/pgadmin/tools/erd/static/js/erd_tool/ui_components/BodyWidget.jsx b/web/pgadmin/tools/erd/static/js/erd_tool/ui_components/BodyWidget.jsx
index 6a1586ff8..4132ae1e9 100644
--- a/web/pgadmin/tools/erd/static/js/erd_tool/ui_components/BodyWidget.jsx
+++ b/web/pgadmin/tools/erd/static/js/erd_tool/ui_components/BodyWidget.jsx
@@ -96,7 +96,7 @@ export default class BodyWidget extends React.Component {
_.bindAll(this, ['onLoadDiagram', 'onSaveDiagram', 'onSaveAsDiagram', 'onSQLClick',
'onImageClick', 'onAddNewNode', 'onEditTable', 'onCloneNode', 'onDeleteNode', 'onNoteClick',
'onNoteClose', 'onOneToManyClick', 'onManyToManyClick', 'onAutoDistribute', 'onDetailsToggle',
- 'onDetailsToggle', 'onHelpClick', 'onDropNode',
+ 'onDetailsToggle', 'onHelpClick', 'onDropNode', 'onBeforeUnload',
]);
this.diagram.zoomToFit = this.diagram.zoomToFit.bind(this.diagram);
@@ -223,6 +223,7 @@ export default class BodyWidget extends React.Component {
});
this.props.panel?.on(window.wcDocker?.EVENT.CLOSING, () => {
+ window.removeEventListener('beforeunload', this.onBeforeUnload);
if(this.state.dirty) {
this.closeOnSave = false;
this.confirmBeforeClose();
@@ -241,11 +242,11 @@ export default class BodyWidget extends React.Component {
await this.loadTablesData();
}
- window.addEventListener('beforeunload', this.onBeforeUnload.bind(this));
+ window.addEventListener('beforeunload', this.onBeforeUnload);
}
componentWillUnmount() {
- window.removeEventListener('beforeunload', this.onBeforeUnload.bind(this));
+ window.removeEventListener('beforeunload', this.onBeforeUnload);
}
componentDidUpdate() {
@@ -306,7 +307,6 @@ export default class BodyWidget extends React.Component {
}
closePanel() {
- window.onbeforeunload = null;
this.props.panel.off(window.wcDocker.EVENT.CLOSING);
this.props.pgWindow.pgAdmin.Browser.docker.removePanel(this.props.panel);
}
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin][RM7333] ERD Tool: drag table throws Uncaught TypeError
In-Reply-To: <CAM9w-_=2KC+c4s18pPvs56s=OK9=76h6mdbdCEnxDTftCjpW4g@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox