From 5d00045a2d043fbda43bc8329a056b0a97ddc573 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 26 Apr 2016 12:04:44 -0400 Subject: [PATCH] Bug 3534 [Follow-up] Patron quick add form Content-Type: text/plain; charset="utf-8" This follow-up move the full/quick add toggle control to the top of the patron entry form, reformating it as a link with a Font Awesome icon The previous patch defined a new $(document).ready() block. This patch moves that code into the existing $(document).ready() to keep things organized. This patch also makes some minor corrections to the markup, converting some single quotes in HTML to double, and correcting capitalization. To test, apply the patch and follow the original test plan. Confirm that the toggle between full and brief form works correctly. --- .../prog/en/modules/members/memberentrygen.tt | 139 +++++++++++---------- 1 file changed, 72 insertions(+), 67 deletions(-) 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 a0979e7..6c37b45 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -59,6 +59,41 @@ $(document).ready(function() { mrform.hide(); e.preventDefault(); }); + + var toggle_quick_add = $(".toggle_quick_add"); + $(toggle_quick_add).click(function(e){ + toggle_quick_add.toggle(); + e.preventDefault(); + var toggle_to = ''; + var toggle_from = ''; + if( $("#entryform:visible").length ) { + toggle_to = "#quick_add_form label"; + toggle_from = "#entryform label"; + } else { + toggle_to="#entryform label"; + toggle_from = "#quick_add_form label"; + } + $(toggle_from).each(function() { + var input_label = $(this).attr('for'); + if ( input_label == 'sex-male' || input_label == 'sex-none' || input_label == 'sex-female' ) { + $(toggle_to+"[for='"+input_label+"']").next().prop('checked', $(this).next().prop('checked') ); + return; + } + if( $(this).next().val() != '' ) { $(toggle_to+"[for='"+input_label+"']").next().val( $(this).next().val() );} + }); + + $(".toggler").toggle(); + }); + + $(".save_quick_add").click(function(){ + $("#quick_add_form").validate(); + if( $("#quick_add_form").valid()){ + $('.toggle_quick_add').click(); + $('#entryform input[name="save"]').click(); + } + else {return false;} + }); + }); function clear_entry(node) { @@ -157,40 +192,6 @@ function select_user(borrowernumber, borrower) { hint.html(age_string); } -$(document).ready(function() { - $(".toggle_quick_add").click(function(){ - var toggle_to = ''; - var toggle_from = ''; - if( $("#entryform:visible").length ) { - toggle_to = "#quick_add_form label"; - toggle_from = "#entryform label"; - } else { - toggle_to="#entryform label"; - toggle_from = "#quick_add_form label"; - } - $(toggle_from).each(function() { - var input_label = $(this).attr('for'); - if ( input_label == 'sex-male' || input_label == 'sex-none' || input_label == 'sex-female' ) { - $(toggle_to+"[for='"+input_label+"']").next().prop('checked', $(this).next().prop('checked') ); - return; - } - if( $(this).next().val() != '' ) { $(toggle_to+"[for='"+input_label+"']").next().val( $(this).next().val() );} - }); - - $(".toggler").toggle(); -// return false; - }); - - - $(".save_quick_add").click(function(){ - $("#quick_add_form").validate(); - if( $("#quick_add_form").valid()){ - $('.toggle_quick_add').click(); - $('#entryform input[name="save"]').click(); - } - else {return false;} - }); - }); var MSG_SEPARATOR = _("Separator must be / in field %s"); var MSG_INCORRECT_DAY = _("Invalid day entered in field %s"); @@ -239,6 +240,14 @@ $(document).ready(function() { [% UNLESS ( no_add ) %]

[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] patron [% IF (firstname) %][% firstname %] [% END %][% IF (surname) %][% surname %] [% END %]([%IF ( categoryname ) %][% categoryname %][% ELSE %][% IF ( I ) %]Organization[% END %][% IF ( A ) %]Adult[% END %][% IF ( C ) %]Child[% END %][% IF ( P ) %]Professional[% END %][% IF ( S ) %]Staff[% END %][% END %])

+ [% IF quickadd && opadd %] + Show full form + + [% ELSE %] + + Show brief form + [% END %] + [% IF ( check_member ) %]

Duplicate patron record?

@@ -309,7 +318,7 @@ $(document).ready(function() { [% END %] -[% UNLESS ( check_member ) %]
+[% UNLESS ( check_member ) %] [% END %] @@ -1182,9 +1191,6 @@ $(document).ready(function() { [% UNLESS ( check_member ) %]
- [% IF quickadd && opadd %] - - [% END %] [% IF ( opadd ) %] Cancel @@ -1197,35 +1203,34 @@ $(document).ready(function() { [% IF quickadd && opadd && !check_member %] -
-
Quick Add -
    -
-
- -
- - - Cancel -
- -
- +
+
Quick add +
    +
+
+ +
+ + Cancel +
+ +
+ [% END %]
-- 2.1.4