From 06c12fd1999224c7126ca1d81b6fe7886eab51b9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 27 Mar 2014 16:01:22 +0100 Subject: [PATCH] Bug 9016: (follow-up) Add some validation on the letter form 1/ Code and Name are mandatory. 2/ At least 1 template should be filled on saving. Signed-off-by: Jonathan Druart Signed-off-by: Marcel de Rooy Signed-off-by: Galen Charlton --- .../prog/en/modules/tools/letter.tt | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index aeea068966..2a1fe8f15a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -26,6 +26,7 @@ $(document).ready(function() { [% END %] $("#submit").click( function(event) { + var at_least_one_exists = 0; $("fieldset.mtt").each( function(){ var title = $(this).find('input[name="title"]').val(); var content = $(this).find('textarea[name="content"]').val(); @@ -36,10 +37,19 @@ $(document).ready(function() { var mtt = $(this).find('input[name="message_transport_type"]').val(); var msg = _("Please specify title and content for %s"); msg = msg.replace( "%s", mtt ); + at_least_one_exists = 1; alert(msg) event.preventDefault(); + return false; + } else if ( title.length > 0 && content.length > 0 ) { + at_least_one_exists = 1; } } ); + if ( ! at_least_one_exists ) { + alert( _("Please fill at least one template.") ); + event.preventDefault(); + return false; + } return true; }); @@ -212,7 +222,7 @@ $(document).ready(function() { [% IF ( add_form ) %]

[% IF ( modify ) %]Modify notice[% ELSE %]Add notice[% END %]

-
+ [% IF ( modify ) %] @@ -280,14 +290,23 @@ $(document).ready(function() { [% ELSE %] [% END %] - - -
  • - Code:[% IF ( adding ) %][% ELSE %][% code %][% END %] -
  • -
  • - -
  • + + +
  • + [% IF adding %] + + + Required + [% ELSE %] + + [% code %] + [% END %] +
  • +
  • + + + Required +
  • [% FOREACH letter IN letters %]
  • -- 2.39.5