From e95ffe8da341b44184dfe1c9b9c2c18d44ff8482 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 22 Jan 2015 12:36:31 -0500 Subject: [PATCH] Bug 13613: Don't allow digest to be selected without a digest-able transport selected By default, only the email transport is enabled. This gives the messaging preferences the look of having email and digest and two options. I.E. to some users it appears that you check email for single emails, *or* you check digest for a digest email. To help remove this possible confusion, the digest mode checkbox should be disabled if no digest-able transports are checked for a given notice. Test Plan: 1) Apply this patch 2) For both the staff interface and the opac, note that the digest checkbox is disabled any time that no digest enabled transport ( email, sms if enabled ) is checked for the patron editor. Signed-off-by: Owen Leonard Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../en/includes/messaging-preference-form.inc | 24 +++++------ .../prog/js/messaging-preference-form.js | 31 +++++++++++++ .../bootstrap/en/modules/opac-messaging.tt | 43 +++++++++++++++++-- 3 files changed, 82 insertions(+), 16 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc index f2a2e0f241..be4119c7a5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/messaging-preference-form.inc @@ -56,24 +56,24 @@ + value="sms" class="sms" checked="checked" disabled="disabled" /> [% ELSE %] + value="sms" class="sms" disabled="disabled" /> [% END %] [% ELSE %] [% IF ( messaging_preference.transports_sms ) %] + value="sms" checked="checked" class="sms active_notify" data-attr-id="[% messaging_preference.message_attribute_id | html %]" /> [% ELSE %] + value="sms" class="sms active_notify" data-attr-id="[% messaging_preference.message_attribute_id | html %]" /> [% END %] [% END %] @@ -155,24 +155,24 @@ + value="email" class="email" checked="checked" disabled="disabled" /> [% ELSE %] + value="email" class="email" disabled="disabled" /> [% END %] [% ELSE %] [% IF ( messaging_preference.transports_email ) %] + value="email" checked="checked" class="email active_notify" data-attr-id="[% messaging_preference.message_attribute_id | html %]" /> [% ELSE %] + value="email" class="email active_notify" data-attr-id="[% messaging_preference.message_attribute_id | html %]" /> [% END %] [% END %] @@ -187,24 +187,24 @@ + name="digest" class="digest" checked="checked" disabled="disabled" /> [% ELSE %] + name="digest" class="digest" disabled="disabled" /> [% END %] [% ELSE %] [% IF ( messaging_preference.digest ) %] + name="digest" checked="checked" class="digest active_notify" data-attr-id="[% messaging_preference.message_attribute_id | html %]" /> [% ELSE %] + name="digest" class="digest active_notify" data-attr-id="[% messaging_preference.message_attribute_id | html %]" /> [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/messaging-preference-form.js b/koha-tmpl/intranet-tmpl/prog/js/messaging-preference-form.js index ea01a62d80..920a9f7926 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/messaging-preference-form.js +++ b/koha-tmpl/intranet-tmpl/prog/js/messaging-preference-form.js @@ -47,4 +47,35 @@ $(document).ready(function(){ }); }); } + + // At load time, we want digest disabled if no digest using transport is enabled + $("#memberentry_messaging_prefs .email").each(function(){ + var rowid = $(this).attr("id"); + id = Number(rowid.replace("email","")); + if ( $("#email"+id).prop("checked") || $("#sms"+id).prop("checked") ) { + $("#digest"+id).attr("disabled", false); + } else { + $("#digest"+id).attr("disabled", true).prop("checked",false); + } + }); + + // If user clears all digest using transports for a notice, disable digest checkbox + $(".email").click(function(){ + var rowid = $(this).attr("id"); + id = Number(rowid.replace("email","")); + if ( $("#email"+id).prop("checked") || $("#sms"+id).prop("checked") ) { + $("#digest"+id).attr("disabled", false); + } else { + $("#digest"+id).attr("disabled", true); + } + }); + $(".sms").click(function(){ + var rowid = $(this).attr("id"); + id = Number(rowid.replace("sms","")); + if ( $("#email"+id).prop("checked") || $("#sms"+id).prop("checked") ) { + $("#digest"+id).attr("disabled", false); + } else { + $("#digest"+id).attr("disabled", true).prop("checked",false); + } + }); }); diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt index 1420a33b4b..40ff5283b3 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -89,9 +89,9 @@ [% IF ( messaging_preference.transport_sms ) %] [% IF ( messaging_preference.transports_sms ) %] - + [% ELSE %] - + [% END %] [% ELSE %] @@ -103,11 +103,13 @@ [% IF ( messaging_preference.transports_phone ) %] [% ELSE %] @@ -122,11 +124,13 @@ [% IF ( messaging_preference.transports_itiva ) %] [% ELSE %] @@ -140,9 +144,9 @@ [% IF ( messaging_preference.transport_email ) %] [% IF ( messaging_preference.transports_email ) %] - + [% ELSE %] - + [% END %] [% ELSE %] @@ -255,6 +259,37 @@ } }); $("#info_digests").tooltip(); + + // At load time, we want digest disabled if no digest using transport is enabled + $(".email").each(function(){ + var rowid = $(this).attr("id"); + id = Number(rowid.replace("email","")); + if ( $("#email"+id).prop("checked") || $("#sms"+id).prop("checked") ) { + $("#digest"+id).attr("disabled", false); + } else { + $("#digest"+id).attr("disabled", true); + } + }); + + // If user clears all digest using transports for a notice, disable digest checkbox + $(".email").click(function(){ + var rowid = $(this).attr("id"); + id = Number(rowid.replace("email","")); + if ( $("#email"+id).prop("checked") || $("#sms"+id).prop("checked") ) { + $("#digest"+id).attr("disabled", false); + } else { + $("#digest"+id).attr("disabled", true).prop("checked",false); + } + }); + $(".sms").click(function(){ + var rowid = $(this).attr("id"); + id = Number(rowid.replace("sms","")); + if ( $("#email"+id).prop("checked") || $("#sms"+id).prop("checked") ) { + $("#digest"+id).attr("disabled", false); + } else { + $("#digest"+id).attr("disabled", true).prop("checked",false); + } + }); }); function normalizeSMS(value){ -- 2.39.5