public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin][RM6193] Should warn before closing if opened in a new tab
2+ messages / 2 participants
[nested] [flat]
* [pgAdmin][RM6193] Should warn before closing if opened in a new tab
@ 2021-02-01 08:42 Aditya Toshniwal <[email protected]>
2021-02-02 07:29 ` Re: [pgAdmin][RM6193] Should warn before closing if opened in a new tab Akshay Joshi <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Aditya Toshniwal @ 2021-02-01 08:42 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
ERD will now throw warning before closing unsaved changes if opened in a
new tab.
Please review.
--
Thanks,
Aditya Toshniwal
pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
<http://edbpostgres.com;
"Don't Complain about Heat, Plant a TREE"
Attachments:
[application/octet-stream] RM6193.patch (1.8K, 3-RM6193.patch)
download | inline diff:
diff --git a/web/pgadmin/tools/erd/static/js/erd_tool/ERDCore.js b/web/pgadmin/tools/erd/static/js/erd_tool/ERDCore.js
index f2de8edb9..3935af360 100644
--- a/web/pgadmin/tools/erd/static/js/erd_tool/ERDCore.js
+++ b/web/pgadmin/tools/erd/static/js/erd_tool/ERDCore.js
@@ -355,9 +355,14 @@ export default class ERDCore {
zoomOut() {
let model = this.getEngine().getModel();
- let zoomLevel = model.getZoomLevel();
- if(model && zoomLevel > 25) {
- model.setZoomLevel(zoomLevel - 25);
+ if(model) {
+ let zoomLevel = model.getZoomLevel();
+ zoomLevel -= 25;
+ /* Don't go belo zoom level 10 */
+ if(zoomLevel <= 10) {
+ zoomLevel = 10;
+ }
+ model.setZoomLevel(zoomLevel);
this.repaint();
}
}
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 90c284ab8..5451e868f 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
@@ -235,6 +235,12 @@ export default class BodyWidget extends React.Component {
if(this.props.params.gen) {
await this.loadTablesData();
}
+
+ window.addEventListener('beforeunload', this.onBeforeUnload.bind(this));
+ }
+
+ componentWillUnmount() {
+ window.removeEventListener('beforeunload', this.onBeforeUnload.bind(this));
}
componentDidUpdate() {
@@ -348,6 +354,15 @@ export default class BodyWidget extends React.Component {
}
}
+ onBeforeUnload(e) {
+ if(this.state.dirty) {
+ e.preventDefault();
+ e.returnValue = 'prevent';
+ } else {
+ delete e['returnValue'];
+ }
+ }
+
onEditNode() {
const selected = this.diagram.getSelectedNodes();
if(selected.length == 1) {
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [pgAdmin][RM6193] Should warn before closing if opened in a new tab
2021-02-01 08:42 [pgAdmin][RM6193] Should warn before closing if opened in a new tab Aditya Toshniwal <[email protected]>
@ 2021-02-02 07:29 ` Akshay Joshi <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Akshay Joshi @ 2021-02-02 07:29 UTC (permalink / raw)
To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers
Thanks, patch applied.
On Mon, Feb 1, 2021 at 2:13 PM Aditya Toshniwal <
[email protected]> wrote:
> Hi Hackers,
>
> ERD will now throw warning before closing unsaved changes if opened in a
> new tab.
> Please review.
>
> --
> Thanks,
> Aditya Toshniwal
> pgAdmin hacker | Sr. Software Engineer | *edbpostgres.com*
> <http://edbpostgres.com;
> "Don't Complain about Heat, Plant a TREE"
>
--
*Thanks & Regards*
*Akshay Joshi*
*pgAdmin Hacker | Principal Software Architect*
*EDB Postgres <http://edbpostgres.com>*
*Mobile: +91 976-788-8246*
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2021-02-02 07:29 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-02-01 08:42 [pgAdmin][RM6193] Should warn before closing if opened in a new tab Aditya Toshniwal <[email protected]>
2021-02-02 07:29 ` Akshay Joshi <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox