Issue #139 resolved
AceAttorneyMaster111
created an issue

It has been an issue for quite some time that leaving the Editor without saving does not prompt you for confirmation, and one loses all of their progress since the last save point.

Comments (9)

  1. AceAttorneyMaster111 reporter

    I think there are two ways we could go with this. 1. We bring up a confirmation box when the user attempts to close the window/tab, go to a different page, press the back arrow, etc. that prompts something along the lines of "Are you sure you want to close this page?" with a OK/Cancel prompt. 2. We could also bring up a prompt along the lines of "Would you like to save before you leave the page?" with a No/Yes prompt. Yes would do the same thing as clicking on the Save Button except leaves the page/closes the tab/etc.

  2. Enthalpy

    The dialogue should only appear if there are unsaved changes. I frequently open trials in the editor to read the script or check cross-examinations, without editing them. Having to confirm that I don't want to save when I never changed a thing would be a nuisance.

    In that light, Option 2 makes far more sense. If unsaved changes trigger the message, than the message should be about unsaved changes.

  3. Arnaud Vié

    Currently, the editor has no way of knowing if any change was performed on the trial or not.

    This is one of the applications I originally planned for the BufferWrapper object though : if the BufferWrapper implementation is reliable and fast enough, the trial_data variable exposed throughout the editor could be wrapped into a buffer wrapper at load time, and when closing the tab we could quickly check the contents of this buffer's diff. If it has significant changes, then we could show the message about unsaved changes.

  4. Arnaud Vié

    Oh, I didn't really pay attention to what I was writing there. Yes, the warning probably should be displayed for any change - it's the user's responsibility to know whether it's trivial (and should be discarded) or it's significant.

    But the problem of being able to detect whether any change occured remains :-)

  5. AceAttorneyMaster111 reporter

    Once the BufferWrapper is ready, wouldn't it be easy just to do something like:

    if(BufferWrapper.trialData != this.trialData)
    {
        ...
    }
    

    Of course the code isn't exact, but wouldn't it be something along those lines?

  6. Arnaud Vié

    Not exactly.

    1. The != operator will not check that the contents of the objects are the same, it will check if the two variables point to exactly the same object in memory (which would always be false). If we wanted to to a full object content comparison, we would use the objCompare function I've written in objects.js
    2. A comparison of the whole object contents, especially on big trials, could take long, inducing a lag whenever we want to close the tab.

    The main feature of the BufferWrapper is to actually store a list of all changes performed to the object, the diff. So the test would rather be to check whether trial_data.__diff contains any change. Something like:

    Object.getOwnPropertyNames(trial_data.__diff).length > 0
    
  7. Log in to comment