ondras / wwwsqldesigner

WWW SQL Designer, your online SQL diagramming tool
https://sql.toad.cz/?keyword=online_library
BSD 3-Clause "New" or "Revised" License
2.86k stars 722 forks source link

State should not be dirty #319

Open bilogic opened 1 year ago

bilogic commented 1 year ago

If we were to

  1. Load https://ondras.zarovi.cz/sql/demo/?keyword=default
  2. Click on an empty space once
  3. Try to close or jump to another URL
  4. Browser prompts us to save
  5. It should not, since no changes were made
ondras commented 1 year ago

Good suggestion. We will need a way to track (unsaved) changes, though.

bilogic commented 1 year ago

I have gotten this working, but need to understand which of my PRs you can accept so that I can find a suitable spot to PR this in. Thank you.

bilogic commented 1 year ago

temporary parking spot for my code

// globals.js
window.onbeforeunload = function (e) {
    if (SQL.Designer.is_dirty) {
        return "" /* some browsers will show this text, some won't. */;
    } else {
        return undefined;
    }
};

// wwwsqldesigner.js
SQL.Designer = function () {
    SQL.Designer = this;

    this.is_dirty = false;

SQL.Designer.prototype.dirty = function (value, remarks) {
    if (value === undefined) {
        value = true;
    }
    this.is_dirty = value;
    console.log("Dirty flag set to", this.is_dirty, remarks);
};

// rowmanager.js - nothing
// row.js::update, up, down, changeComment, addRelation, removeRelation, addKey, removeKey, destroy
SQL.Designer.dirty();

// io.js 
SQL.Designer.dirty(false, "serversave");
SQL.Designer.dirty(false, "loadresponse");
ondras commented 1 year ago

I have gotten this working, but need to understand which of my PRs you can accept so that I can find a suitable spot to PR this in. Thank you.

Sorry for being late all the time. As far as I can tell, there is only one PR pending right now (keyboard shortcuts); please feel free to submit this one based on the current master.

bilogic commented 1 year ago

ok thanks!

bilogic commented 1 year ago

@ondras this is the other one https://github.com/ondras/wwwsqldesigner/pull/321

bilogic commented 1 year ago

bump :)

bilogic commented 1 year ago

@ondras help :)