wwwsqldesigner icon indicating copy to clipboard operation
wwwsqldesigner copied to clipboard

State should not be dirty

Open bilogic opened this issue 3 years ago • 8 comments

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

bilogic avatar Sep 11 '22 13:09 bilogic

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

ondras avatar Sep 15 '22 15:09 ondras

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 avatar Sep 18 '22 14:09 bilogic

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");

bilogic avatar Sep 18 '22 14:09 bilogic

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.

ondras avatar Oct 03 '22 06:10 ondras

ok thanks!

bilogic avatar Oct 03 '22 06:10 bilogic

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

bilogic avatar Oct 03 '22 06:10 bilogic

bump :)

bilogic avatar Oct 17 '22 07:10 bilogic

@ondras help :)

bilogic avatar Oct 24 '22 07:10 bilogic