Bug Hunting Session
Bug 104156 - [postMessage] "Save" state changes
Summary: [postMessage] "Save" state changes
Status: NEW
Alias: None
Product: LibreOffice Online
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords: difficultyBeginner, easyHack, skillJavaScript
Depends on:
Blocks:
 
Reported: 2016-11-25 09:27 UTC by Aleksander Machniak
Modified: 2019-06-21 12:18 UTC (History)
7 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aleksander Machniak 2016-11-25 09:27:47 UTC
So, we have the "Save" button on the host page. I'd like to make it active only when there are unsaved changes in the document, and deactivate it as soon as the changes have been saved.

This is also needed for one scenario. When user is to terminate the session (with Close_Session postMessage) and there are unsaved changes we display a warning. Currently we don't know the state and cannot really warn him that there are unsaved changes.
Comment 1 jby601 2016-11-25 14:27:19 UTC
This may be a regression.

Now using LibreOffice 5.1.4.2. In the previous version that came with Linux Mint 17.3, the 'save' button was greyed-out if the document was unchanged, or sufficient stabs at Ctrl-Z had reverted the document to its original form.

There is, as far as I can see, no alternative indication that unsaved changes have been made.
Comment 2 Aleksander Machniak 2016-11-25 14:35:38 UTC
I'm talking about providing postMessage API messages to set the button state on the LibreOffice Online editor host page.
Comment 3 jby601 2016-11-26 13:15:40 UTC
Sorry, my bad
Comment 4 Pranav Kant 2018-01-30 12:25:17 UTC
Let's add this to the easyHack list. 

The task is to find the code which is responsible for showing the 'Document saved' text in the statusbar and then use that code to route the document modified status through the postMessage API to hosts.
Comment 5 Jan Holesovsky 2019-03-29 09:33:15 UTC
Aleksander: I'd advise against disabling the Save button, because the user might have reasons to use that even when the document is not modified.  That is for the cases when the user wants to save information that is not actually changing the 'document modified' status, but still is part of the file format.

Most notable example is the position of the view and of the cursor in a spreadsheet: When you move the cursor, the view and the cursor position changes, but the document modification status does not.  The users should have the possibility to save the spreadsheet when they just move the cursor.

We used to disable the Save button in the desktop version based on the 'document modified' status in the past, but changed that due to the reasons described above.

Regarding the "and there are unsaved changes" - there are never unsaved changes, the document is always saved when the session is closed.  Or do you want to warn the user in a "this is not a cancel, your unfinished changes will be saved anyway" kind of way?  Wouldn't that be annoying? :-)
Comment 6 Aleksander Machniak 2019-06-21 12:18:10 UTC
I wasn't aware that changes are saved on Close_Session. However, I'm confused, because the desktop version does not behave like that. Well, at least not in single user mode.

When you change anything in LibreOffice Writer document and press Close button (in window or from menu) it will ask you if you want to keep the changes. Why something like this could not exist in Online version?

So, I could probably workaround that and not use Close_Session and just close the window in case the user wan't to close and cancel changes. However, Close_Session has one feature that would be hard to workaround. It informs all users in the session that the session has been closed.

Maybe Close_Session should have a parameter to disable saving changes.

BTW, Close_Session is not documented in https://www.collaboraoffice.com/collabora-online-editor-api-reference