From e10525c444d6f003114f534d6a78d5a77daf2dc6 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 (cherry picked from commit e95ffe8da341b44184dfe1c9b9c2c18d44ff8482) Signed-off-by: Fridolin Somers --- .../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 6a58c63a27..48d3aea187 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 @@ -55,24 +55,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 %] @@ -154,24 +154,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 %] @@ -186,24 +186,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 40dcd5236e..c30899dd89 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-messaging.tt @@ -88,9 +88,9 @@ [% IF ( messaging_preference.transport_sms ) %] [% IF ( messaging_preference.transports_sms ) %] - + [% ELSE %] - + [% END %] [% ELSE %] @@ -102,11 +102,13 @@ [% IF ( messaging_preference.transports_phone ) %] [% ELSE %] @@ -121,11 +123,13 @@ [% IF ( messaging_preference.transports_itiva ) %] [% ELSE %] @@ -139,9 +143,9 @@ [% IF ( messaging_preference.transport_email ) %] [% IF ( messaging_preference.transports_email ) %] - + [% ELSE %] - + [% END %] [% ELSE %] @@ -254,6 +258,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