From cdf83f0ab9fd1597293a6708f01c22934235e2cd Mon Sep 17 00:00:00 2001 From: Josef Moravec Date: Wed, 12 Jun 2019 07:44:54 +0000 Subject: [PATCH] Bug 23100: Add leave page confirmation to patron edit form Test plan: 1) Apply the patch 2) Try to edit a patron, change some value and try to go out without saving, you should be notified you have unsaved changes --- .../prog/en/modules/members/memberentrygen.tt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 62fc2db2de..5cd3118b38 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -1256,6 +1256,7 @@ var LABEL_SET_TO_PATRON = _("Set to patron"); var LABEL_AGE = _("Age"); var MSG_MESSAGING_DFEAULTS = _("Change messaging preferences to default for this category?"); + var MSG_PATRON_MODIFIED = _("You made some modification, are you sure you want to leave this page?"); [% IF quickadd && opadd && !check_member %] $(document).ready(function () { @@ -1290,6 +1291,21 @@ }); [% END %] + $(document).ready(function () { + $("#entryform :input").change(function() { + $("#entryform").data("modified", true); + }); + + $("#entryform").submit(function(){ + $(this).data("modified",false); + }); + + window.onbeforeunload = function (e) { + if ($("#entryform").data("modified")) { + return MSG_PATRON_MODIFIED; + } + }; + }); [% Asset.js("js/members.js") | $raw %] [% Asset.js("js/messaging-preference-form.js") | $raw %] -- 2.11.0