Bug 19267

Summary: Advanced Editor - Rancor - Add warning before leaving page if there are unsaved modifications
Product: Koha Reporter: Nick Clemens <nick>
Component: CatalogingAssignee: Nick Clemens <nick>
Status: CLOSED FIXED QA Contact: Josef Moravec <josef.moravec>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, josef.moravec, m.de.rooy, niamh.walker-headon
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 21064    
Attachments: Bug 19267: Rancor - Warn before leaving page if record modified
Bug 19267: Rancor - Warn before leaving page if record modified
Bug 19267: Followup - only fire if changes and don't use javascript
Bug 19267: Rancor - Warn before leaving page if record modified
Bug 19267: Rancor - Warn before leaving page if record modified
Bug 19267: Rancor - Warn before leaving page if record modified

Description Nick Clemens 2017-09-07 09:40:24 UTC

    
Comment 1 Nick Clemens 2017-09-07 09:44:52 UTC
Created attachment 66911 [details] [review]
Bug 19267: Rancor - Warn before leaving page if record modified

To test:
1 - Open the advanced editor
2 - Make some changes to a record
3 - Click on 'Patrons' or leave the page in some way
4 - Note there is no warning and changes are not saved
5 - Apply patch
6 - Open the advanced editor
7 - Make some changes
8 - Leave the page
9 - Note you get a warning of unsaved changes and can stay on the page
Comment 2 Katrin Fischer 2017-09-20 21:53:32 UTC
Created attachment 67274 [details] [review]
Bug 19267: Rancor - Warn before leaving page if record modified

To test:
1 - Open the advanced editor
2 - Make some changes to a record
3 - Click on 'Patrons' or leave the page in some way
4 - Note there is no warning and changes are not saved
5 - Apply patch
6 - Open the advanced editor
7 - Make some changes
8 - Leave the page
9 - Note you get a warning of unsaved changes and can stay on the page

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 3 Josef Moravec 2017-12-22 20:48:12 UTC
Sorry, but this is wrong.

You need to return 'undefined' in case there are no changes, this patch just fires the question dialog everytime.

See this page for more:
https://stackoverflow.com/questions/7317273/warn-user-before-leaving-web-page-with-unsaved-changes

We could also consider to add this functionality to all Koha pages (or almost all) through some existing plugin like http://plugins.jquery.com/are-you-sure/
but thats definitely out of scope of this bug, as Rancor is a special case.
Comment 4 Josef Moravec 2017-12-22 20:51:47 UTC
One more thing: You even don't need jquery this should be enough:

window.onbeforeunload = function() { ... };
Comment 5 Nick Clemens 2018-01-08 16:54:46 UTC
Created attachment 70326 [details] [review]
Bug 19267: Followup - only fire if changes and don't use javascript
Comment 6 Josef Moravec 2018-01-10 11:09:40 UTC
Please, squash the patches and ask for new sign-off, it's completely different code now...
Comment 7 Nick Clemens 2018-03-15 10:36:34 UTC
Created attachment 72924 [details] [review]
Bug 19267: Rancor - Warn before leaving page if record modified

To test:
1 - Open the advanced editor
2 - Make some changes to a record
3 - Click on 'Patrons' or leave the page in some way
4 - Note there is no warning and changes are not saved
5 - Apply patch
6 - Open the advanced editor
7 - Make some changes
8 - Leave the page
9 - Note you get a warning of unsaved changes and can stay on the page
Comment 8 Charles Farmer 2018-03-30 21:12:43 UTC
Created attachment 73505 [details] [review]
Bug 19267: Rancor - Warn before leaving page if record modified

To test:
1 - Open the advanced editor
2 - Make some changes to a record
3 - Click on 'Patrons' or leave the page in some way
4 - Note there is no warning and changes are not saved
5 - Apply patch
6 - Open the advanced editor
7 - Make some changes
8 - Leave the page
9 - Note you get a warning of unsaved changes and can stay on the page

Signed-off-by: Charles Farmer <charles.farmer@inLibro.com>
Comment 9 Josef Moravec 2018-04-04 11:17:21 UTC
Created attachment 73609 [details] [review]
Bug 19267: Rancor - Warn before leaving page if record modified

To test:
1 - Open the advanced editor
2 - Make some changes to a record
3 - Click on 'Patrons' or leave the page in some way
4 - Note there is no warning and changes are not saved
5 - Apply patch
6 - Open the advanced editor
7 - Make some changes
8 - Leave the page
9 - Note you get a warning of unsaved changes and can stay on the page

Signed-off-by: Charles Farmer <charles.farmer@inLibro.com>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 10 Jonathan Druart 2018-04-04 19:07:37 UTC
Pushed to master for 18.05, thanks to everybody involved!
Comment 11 Nick Clemens 2018-05-14 21:14:19 UTC
Pushed to stable for 17.11.06

Awesome work all!
Comment 12 Fridolin Somers 2018-05-22 10:48:12 UTC
Pushed to 17.05.x for v17.05.12