Bugzilla – Attachment 47469 Details for
Bug 15692
Move some patron entry form JavaScript into members.js
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15692 - Move some patron entry form JavaScript into members.js
Bug-15692---Move-some-patron-entry-form-JavaScript.patch (text/plain), 14.48 KB, created by
Kyle M Hall (khall)
on 2016-01-29 17:17:23 UTC
(
hide
)
Description:
Bug 15692 - Move some patron entry form JavaScript into members.js
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-01-29 17:17:23 UTC
Size:
14.48 KB
patch
obsolete
>From 46a245f3d9da83a1bc1bbb0a8fabf0fb33764e4d Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 28 Jan 2016 10:20:07 -0500 >Subject: [PATCH] Bug 15692 - Move some patron entry form JavaScript into > members.js >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >We should strive to keep as much JavaScript as possible out of templates >in order to keep things modular and maximize the benefits of browser >caching. This patch moves JavaScript out of the patron entry template > >Two other minor edits: Missing semicolons added on the advice of JSHint. > >To test, apply the patch and confirm that the following interactions >still work on the patron entry form: > >1. clear_entry(): With ExtendedPatronAttributes enabled, the "Clear" > link next to any attribute form field should work to clear the field. > >2. clone_entry(): With ExtendedPatronAttributes enabled and a repeatable > attribute defined, it should be possible to click the "New" link to > add another instance of that attribute's entry field. > >3. update_category_code(): With ExtendedPatronAttributes enabled and an > attribute defined which is limited to a single patron category, > changing the patron category selection should correctly show or hide the > attribute entry form. > >4. select_user(): When adding or editing a patron with a "Child" > category it should be possible to search for and select a guarantor > to add to the record by clicking the "Set to patron" button. > Selecting a new guarantor should change the text of the button from > "Set to patron" to "Change." > >5. noEnterSubmit(): This function should be correctly preventing you > from hitting "ENTER" in any form field to submit the form. > >6. guarantordelete(): When adding or editing a patron with a "Child" > category, it should be possible to clear existing guarantor > information by clicking the "Delete" button. Clicking the "Delete" > button should change the text of the adjacent button to "Set to > patron." > >7. select_city(): With one or more cities defined it should be possible > to use the drop-down menu of cities to populate the city, state, zip, > and country fields. > >8. Date of birth entry should have a maximum date limit of yesterday. > The drop-down menu of years should go back 100 years. > >9. Client-side validation rules should be in effect, requiring that a > valid email address be entered in the primary email, secondary email, > and alternate address email fields. > >10.When editing a patron, the "Add manual restriction" link should > display the form for adding a manual restriction, and clicking the > "Cancel" link should hide it. > >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > koha-tmpl/intranet-tmpl/prog/en/js/members.js | 135 ++++++++++++++++++++- > .../prog/en/modules/members/memberentrygen.tt | 131 +------------------- > 2 files changed, 136 insertions(+), 130 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/members.js b/koha-tmpl/intranet-tmpl/prog/en/js/members.js >index 75e230b..59deeae 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/members.js >@@ -143,10 +143,80 @@ function Dopop(link) { > } > > function Dopopguarantor(link) { >- > var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top'); > } > >+function clear_entry(node) { >+ var original = $(node).parent(); >+ $("textarea", original).attr('value', ''); >+ $("select", original).attr('value', ''); >+} >+ >+function clone_entry(node) { >+ var original = $(node).parent(); >+ var clone = original.clone(); >+ >+ var newId = 50 + parseInt(Math.random() * 100000); >+ $("input,select,textarea", clone).attr('id', function() { >+ return this.id.replace(/patron_attr_\d+/, 'patron_attr_' + newId); >+ }); >+ $("input,select,textarea", clone).attr('name', function() { >+ return this.name.replace(/patron_attr_\d+/, 'patron_attr_' + newId); >+ }); >+ $("label", clone).attr('for', function() { >+ return $(this).attr("for").replace(/patron_attr_\d+/, 'patron_attr_' + newId); >+ }); >+ $("input#patron_attr_" + newId, clone).attr('value',''); >+ $("select#patron_attr_" + newId, clone).attr('value',''); >+ $(original).after(clone); >+ return false; >+} >+ >+function update_category_code(category_code) { >+ if ( $(category_code).is("select") ) { >+ category_code = $("#categorycode_entry").find("option:selected").val(); >+ } >+ var mytables = $(".attributes_table"); >+ $(mytables).find("li").hide(); >+ $(mytables).find(" li[data-category_code='"+category_code+"']").show(); >+ $(mytables).find(" li[data-category_code='']").show(); >+} >+ >+function select_user(borrowernumber, borrower) { >+ var form = $('#entryform').get(0); >+ if (form.guarantorid.value) { >+ $("#contact-details").find('a').remove(); >+ $("#contactname, #contactfirstname").parent().find('span').remove(); >+ } >+ >+ var id = borrower.borrowernumber; >+ form.guarantorid.value = id; >+ $('#contact-details') >+ .show() >+ .find('span') >+ .after('<a target="blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' + id + '">' + id + '</a>'); >+ >+ $(form.contactname) >+ .val(borrower.surname) >+ .before('<span>' + borrower.surname + '</span>').get(0).type = 'hidden'; >+ $(form.contactfirstname) >+ .val(borrower.firstname) >+ .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden'; >+ >+ form.streetnumber.value = borrower.streetnumber; >+ form.address.value = borrower.address; >+ form.address2.value = borrower.address2; >+ form.city.value = borrower.city; >+ form.state.value = borrower.state; >+ form.zipcode.value = borrower.zipcode; >+ form.country.value = borrower.country; >+ form.branchcode.value = borrower.branchcode; >+ >+ form.guarantorsearch.value = LABEL_CHANGE; >+ >+ return 0; >+} >+ > $(document).ready(function(){ > if($("#yesdebarred").is(":checked")){ > $("#debarreduntil").show(); >@@ -165,4 +235,67 @@ $(document).ready(function(){ > $(mandatory_fields).each(function(){ > $("[name='"+this+"']").attr('required', 'required'); > }); >+ >+ $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); >+ >+ $("#guarantordelete").click(function() { >+ $("#contact-details").hide().find('a').remove(); >+ $("#guarantorid, #contactname, #contactfirstname").each(function () { this.value = ""; }); >+ $("#contactname, #contactfirstname") >+ .each(function () { this.type = 'text'; }) >+ .parent().find('span').remove(); >+ $("#guarantorsearch").val(LABEL_SET_TO_PATRON); >+ }); >+ >+ $("#select_city").change(function(){ >+ var myRegEx=new RegExp(/(.*)\|(.*)\|(.*)\|(.*)/); >+ document.form.select_city.value.match(myRegEx); >+ document.form.zipcode.value=RegExp.$1; >+ document.form.city.value=RegExp.$2; >+ document.form.state.value=RegExp.$3; >+ document.form.country.value=RegExp.$4; >+ }); >+ >+ $("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" }); >+ >+ $("#entryform").validate({ >+ rules: { >+ email: { >+ email: true >+ }, >+ emailpro: { >+ email: true >+ }, >+ B_email: { >+ email: true >+ } >+ }, >+ submitHandler: function(form) { >+ $("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting'); >+ if (form.beenSubmitted) >+ return false; >+ else >+ form.beenSubmitted = true; >+ form.submit(); >+ } >+ }); >+ >+ var mrform = $("#manual_restriction_form"); >+ var mrlink = $("#add_manual_restriction"); >+ mrform.hide(); >+ mrlink.on("click",function(e){ >+ $(this).hide(); >+ mrform.show(); >+ e.preventDefault(); >+ }); >+ >+ $("#cancel_manual_restriction").on("click",function(e){ >+ $('#debarred_expiration').val(''); >+ $('#add_debarment').val(0); >+ $('#debarred_comment').val(''); >+ mrlink.show(); >+ mrform.hide(); >+ e.preventDefault(); >+ }); >+ > }); >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 8a8d3d4..4e403aa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -7,23 +7,6 @@ > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function() { >- $("fieldset.rows input, fieldset.rows select").addClass("noEnterSubmit"); >- $("#guarantordelete").click(function() { >- $("#contact-details").hide().find('a').remove(); >- $("#guarantorid, #contactname, #contactfirstname").each(function () { this.value = "" }); >- $("#contactname, #contactfirstname") >- .each(function () { this.type = 'text' }) >- .parent().find('span').remove(); >- $("#guarantorsearch").val(_("Set to patron")); >- }); >- $("#select_city").change(function(){ >- var myRegEx=new RegExp(/(.*)\|(.*)\|(.*)\|(.*)/); >- document.form.select_city.value.match(myRegEx); >- document.form.zipcode.value=RegExp.$1; >- document.form.city.value=RegExp.$2; >- document.form.state.value=RegExp.$3; >- document.form.country.value=RegExp.$4; >- }); > > [% IF categorycode %] > update_category_code( "[% categorycode %]" ); >@@ -33,120 +16,8 @@ > update_category_code( category_code ); > } > [% END %] >- $("#dateofbirth").datepicker({ maxDate: "-1D", yearRange: "c-120:" }); >- $("#entryform").validate({ >- rules: { >- email: { >- email: true >- }, >- emailpro: { >- email: true >- }, >- B_email: { >- email: true >- } >- }, >- submitHandler: function(form) { >- $("body, form input[type='submit'], form button[type='submit'], form a").addClass('waiting'); >- if (form.beenSubmitted) >- return false; >- else >- form.beenSubmitted = true; >- form.submit(); >- } >- }); >- >- var mrform = $("#manual_restriction_form"); >- var mrlink = $("#add_manual_restriction"); >- mrform.hide(); >- mrlink.on("click",function(e){ >- $(this).hide(); >- mrform.show(); >- e.preventDefault(); >- }); >- $("#cancel_manual_restriction").on("click",function(e){ >- $('#debarred_expiration').val(''); >- $('#add_debarment').val(0); >- $('#debarred_comment').val(''); >- mrlink.show(); >- mrform.hide(); >- e.preventDefault(); >- }); > }); > >- function clear_entry(node) { >- var original = $(node).parent(); >- $("textarea", original).attr('value', ''); >- $("select", original).attr('value', ''); >- } >- >- function clone_entry(node) { >- var original = $(node).parent(); >- var clone = original.clone(); >- >- var newId = 50 + parseInt(Math.random() * 100000); >- $("input,select,textarea", clone).attr('id', function() { >- return this.id.replace(/patron_attr_\d+/, 'patron_attr_' + newId); >- }); >- $("input,select,textarea", clone).attr('name', function() { >- return this.name.replace(/patron_attr_\d+/, 'patron_attr_' + newId); >- }); >- $("label", clone).attr('for', function() { >- return $(this).attr("for").replace(/patron_attr_\d+/, 'patron_attr_' + newId); >- }); >- $("input#patron_attr_" + newId, clone).attr('value',''); >- $("select#patron_attr_" + newId, clone).attr('value',''); >- $(original).after(clone); >- return false; >- } >- >- function update_category_code(category_code) { >- if ( $(category_code).is("select") ) { >- category_code = $("#categorycode_entry").find("option:selected").val(); >- } >- var mytables = $(".attributes_table"); >- $(mytables).find("li").hide(); >- $(mytables).find(" li[data-category_code='"+category_code+"']").show(); >- $(mytables).find(" li[data-category_code='']").show(); >- } >- >- function select_user(borrowernumber, borrower) { >- var form = $('#entryform').get(0); >- if (form.guarantorid.value) { >- $("#contact-details").find('a').remove(); >- $("#contactname, #contactfirstname").parent().find('span').remove(); >- } >- >- var id = borrower.borrowernumber; >- form.guarantorid.value = id; >- $('#contact-details') >- .show() >- .find('span') >- .after('<a target="blank" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=' + id + '">' + id + '</a>'); >- >- $(form.contactname) >- .val(borrower.surname) >- .before('<span>' + borrower.surname + '</span>').get(0).type = 'hidden'; >- $(form.contactfirstname) >- .val(borrower.firstname) >- .before('<span>' + borrower.firstname + '</span>').get(0).type = 'hidden'; >- >- form.streetnumber.value = borrower.streetnumber; >- form.address.value = borrower.address; >- form.address2.value = borrower.address2; >- form.city.value = borrower.city; >- form.state.value = borrower.state; >- form.zipcode.value = borrower.zipcode; >- form.country.value = borrower.country; >- form.branchcode.value = borrower.branchcode; >- >- form.guarantorsearch.value = _("Change"); >- >- return 0; >- } >- >- >- > var MSG_SEPARATOR = _("Separator must be / in field %s"); > var MSG_INCORRECT_DAY = _("Invalid day entered in field %s"); > var MSG_INCORRECT_MONTH = _("Invalid month entered in field %s"); >@@ -157,6 +28,8 @@ > var MSG_DUPLICATE_SUSPICION = _("Please confirm whether this is a duplicate patron"); > var MSG_PASSWORD_MISMATCH = _("The passwords entered do not match"); > var MSG_PASSWORD_CONTAINS_TRAILING_SPACES = _("Password contains leading and/or trailing spaces."); >+ var LABEL_CHANGE = _("Change"); >+ var LABEL_SET_TO_PATRON = _("Set to patron"); > //]]> > </script> > <script type="text/javascript" src="[% themelang %]/js/members.js"></script> >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15692
:
47392
|
47453
| 47469