diff options
author | Dave Arter <davea@mysociety.org> | 2015-05-20 17:17:22 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2015-10-06 09:09:26 +0100 |
commit | ac0eb14185cfb20b8a1a53a3c504d2661cf99871 (patch) | |
tree | 705b889a9aa4f8ae8b2f33468ecd68aa31079ef6 | |
parent | cdb42c5efbc075ae2500dc6de58234b34ef31d09 (diff) |
[Zurich] Ask for confirmation when rotating photo if other fields have changed.
Because there is no easy way to do the photo rotation asynchronously, make sure
the user is aware that any changes they've made to the other form fields will
be lost when clicking the rotate photo buttons.
See mysociety/FixMyStreet-Commercial#690
-rw-r--r-- | templates/web/zurich/admin/report_edit.html | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/templates/web/zurich/admin/report_edit.html b/templates/web/zurich/admin/report_edit.html index cba9d31e1..2efcbbcf6 100644 --- a/templates/web/zurich/admin/report_edit.html +++ b/templates/web/zurich/admin/report_edit.html @@ -298,10 +298,12 @@ <script type="text/javascript"> $(function(){ + var form_fields_changed = false; $('#form_time_spent').spinner({ spin: function (e, ui) { if (ui.value < 0) { return false } + form_fields_changed = true; } }); @@ -380,6 +382,18 @@ $(function(){ return false; } } + // If the user has clicked to rotate a photo and has edited other + // fields, ask for confirmation before submitting the form + if (/rotate_photo/.test(clicked) && form_fields_changed) { + var message = "[% loc('Rotating this photo will discard unsaved changes to the report.') %]"; + if (!confirm(message)) { + return false; + } + } + }); + + $("form#report_edit").find("input, select, textarea").change(function() { + form_fields_changed = true; }); }); </script> |