Bugzilla – Attachment 69290 Details for
Bug 19680
Move JS to the footer: Patron and circulation tools
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19680: Move JS to the footer: Patron and circulation tools
Bug-19680-Move-JS-to-the-footer-Patron-and-circula.patch (text/plain), 18.12 KB, created by
Owen Leonard
on 2017-11-22 19:07:02 UTC
(
hide
)
Description:
Bug 19680: Move JS to the footer: Patron and circulation tools
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2017-11-22 19:07:02 UTC
Size:
18.12 KB
patch
obsolete
>From 3d5a4c077f3332904db8b0c617c52fd0de61653f Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 22 Nov 2017 19:03:15 +0000 >Subject: [PATCH] Bug 19680: Move JS to the footer: Patron and circulation > tools > >This patch modifies more staff client patrons and circulation tools >templates so that JavaScript is included in the footer instead of the >header. > >To test, apply the patch and test the JavaScript-driven features of >each modified template: All button controls, DataTables functionality, >form validation, etc. > > - Batch patron deletion/anonymization > - Overdue notice/status triggers > - Batch patron modification >--- > .../prog/en/modules/tools/cleanborrowers.tt | 82 +++---- > .../prog/en/modules/tools/modborrowers.tt | 252 +++++++++++---------- > .../prog/en/modules/tools/overduerules.tt | 39 ++-- > 3 files changed, 192 insertions(+), 181 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt >index f973d06..0d55337 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/cleanborrowers.tt >@@ -1,49 +1,12 @@ > [% USE Koha %] > [% USE KohaDates %] > [% USE Branches %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Tools › Batch patron deletion/anonymization [% IF step == 2 %]› Confirm[% END %][% IF step == 3 %]› Finished[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] >-[% INCLUDE 'calendar.inc' %] >-<script type="text/javascript"> >- $(document).ready(function(){ >- $("#delete_patrons_form").on("submit",function(){ >- return checkForm( this ); >- }); >- }); >- >- /** >- * checkForm(form) >- * This function check the form is correctly filled. >- */ >- function checkForm(form) { >- if((form.checkbox[0].checked)){ >- if ( (!form.date1.value) && (!form.borrower_dateexpiry.value) [% IF Koha.Preference('TrackLastPatronActivity') %]&& (!form.borrower_lastseen.value) [% END %]&& (!form.borrower_categorycode.value) && (!form.patron_list_id.value)){ >- alert(_("Please enter at least one criterion for deletion!")); >- return false; >- } >- } >- if((form.checkbox[1].checked)){ >- if(!(form.date2.value)){ >- alert(_("Please enter a date!")); >- return false; >- } >- } >- if(!form.checkbox[0].checked && !form.checkbox[1].checked) { >- alert( _("Please check at least one action") ); >- return false; >- } >- return true; >- } >- >- $(document).ready(function() { >- $('#branch').change(function() { >- $('#selectlibrary').submit(); >- }); >- }); >-</script> >- > </head> >+ > <body id="tools_cleanborrowers" class="tools"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'cat-search.inc' %] >@@ -240,4 +203,45 @@ > [% INCLUDE 'tools-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script> >+ [% INCLUDE 'calendar.inc' %] >+ <script type="text/javascript"> >+ $(document).ready(function(){ >+ $("#delete_patrons_form").on("submit",function(){ >+ return checkForm( this ); >+ }); >+ >+ $('#branch').change(function() { >+ $('#selectlibrary').submit(); >+ }); >+ }); >+ >+ /** >+ * checkForm(form) >+ * This function check the form is correctly filled. >+ */ >+ function checkForm(form) { >+ if((form.checkbox[0].checked)){ >+ if ( (!form.date1.value) && (!form.borrower_dateexpiry.value) [% IF Koha.Preference('TrackLastPatronActivity') %]&& (!form.borrower_lastseen.value) [% END %]&& (!form.borrower_categorycode.value) && (!form.patron_list_id.value)){ >+ alert(_("Please enter at least one criterion for deletion!")); >+ return false; >+ } >+ } >+ if((form.checkbox[1].checked)){ >+ if(!(form.date2.value)){ >+ alert(_("Please enter a date!")); >+ return false; >+ } >+ } >+ if(!form.checkbox[0].checked && !form.checkbox[1].checked) { >+ alert( _("Please check at least one action") ); >+ return false; >+ } >+ return true; >+ } >+ </script> >+[% END %] >+ > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >index 7470563..53b5c0d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt >@@ -1,134 +1,13 @@ > [% USE Koha %] > [% USE KohaDates %] > [% USE Branches %] >-[% INCLUDE 'doc-head-open.inc'%] >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Tools › Batch patron modification</title> > [% INCLUDE 'doc-head-close.inc' %] >-[% INCLUDE 'calendar.inc' %] > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> >-[% INCLUDE 'datatables.inc' %] >-<script type="text/javascript"> >-//<![CDATA[ >- var patron_attributes_lib = new Array(); >- var patron_attributes_values = new Array(); >- $(document).ready(function() { >- [% IF borrowers %] >- $("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, { >- "sDom": 't', >- [% IF ( op == 'show_results' ) %] >- "aoColumnDefs": [ >- { 'sType': "title-string", 'aTargets' : [ 'title-string'] } >- ], >- [% ELSE %] >- "aoColumnDefs": [ >- { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }, >- { 'sType': "title-string", 'aTargets' : [ 'title-string'] } >- ], >- [% END %] >- "bPaginate": false >- })); >- $("#selectallbutton").click(function() { >- $("#borrowerst").find("input:checkbox").each(function() { >- $(this).prop("checked", true); >- }); >- return false; >- }); >- $("#clearallbutton").click(function() { >- $("#borrowerst").find("input:checkbox").each(function() { >- $(this).prop("checked", false); >- }); >- return false; >- }); >- [% END %] >- >- var values = new Array(); >- var lib = new Array(); >- [% FOREACH pav IN patron_attributes_values %] >- values = new Array(); >- lib = new Array(); >- [% FOREACH option IN pav.options %] >- values.push("[% option.lib %]"); >- lib.push("[% option.authorised_value %]"); >- [% END %] >- patron_attributes_lib["[% pav.attribute_code %]"] = values; >- patron_attributes_values["[% pav.attribute_code %]"] = lib; >- [% END %] >- >- $('select[name="patron_attributes"]').change(function() { >- updateAttrValues(this); >- } ); >- >- $('select[name="patron_attributes"]').change(); >- >- $(".clear-date").on("click",function(e){ >- e.preventDefault(); >- var fieldID = this.id.replace("clear-date-",""); >- $("#" + fieldID).val(""); >- }); >- $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){ >- e.preventDefault(); >- add_attributes(); >- }); >- $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){ >- e.preventDefault(); >- del_attributes(this); >- }); >- }); >- >- function updateAttrValues (select_attr) { >- var attr_code = $(select_attr).val(); >- var type = $(select_attr).find("option:selected").attr('data-type'); >- var category = $(select_attr).find("option:selected").attr('data-category'); >- var span = $(select_attr).parent().parent().find('span.patron_attributes_value'); >- var information_category_node = $(select_attr).parent().parent().find('span.information_category'); >- information_category_node.html(""); >- if ( category.length > 0 ) { >- information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category)); >- } >- if ( type == 'select' ) { >- var options = '<option value = ""></option>'; >- for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) { >- options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>'; >- } >- span.html('<select name="patron_attributes_value">' + options + '</select>'); >- } else { >- span.html('<input type="text" name="patron_attributes_value"/>') >- } >- } >- >- function add_attributes() { >- var li_node = $("li.attributes:last"); >- var li_clone = $(li_node).clone(); >- if ( $(li_clone).find("a.del_attributes").length == 0 ) { >- $(li_clone).append('<a href="#" title="Delete" class="del_attributes"><i class="fa fa-fw fa-trash"></i> Delete</a>'); >- } >- $(li_clone).find('select[name="patron_attributes"]').change(function() { >- updateAttrValues(this); >- } ); >- >- $(li_clone).find('select[name="patron_attributes"]').change(); >- >- $("#fields_list>ol").append(li_clone); >- update_attr_values(); >- } >- >- function del_attributes(a_node) { >- $(a_node).parent('li').remove(); >- update_attr_values(); >- } >- >- function update_attr_values() { >- $("li.attributes").each(function(i) { >- $(this).find("input:checkbox").val("attr"+i+"_value"); >- }); >- } >- function clearDate(nodeid) { >- $("#"+nodeid).val(""); >- } >- >-//]]> >-</script> > </head> >+ > <body id="tools_modborrowers" class="tools"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'cat-search.inc' %] >@@ -412,4 +291,129 @@ > [% INCLUDE 'tools-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ [% INCLUDE 'calendar.inc' %] >+ [% INCLUDE 'datatables.inc' %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script> >+ <script type="text/javascript"> >+ var patron_attributes_lib = new Array(); >+ var patron_attributes_values = new Array(); >+ $(document).ready(function() { >+ [% IF borrowers %] >+ $("#borrowerst").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "sDom": 't', >+ [% IF ( op == 'show_results' ) %] >+ "aoColumnDefs": [ >+ { 'sType': "title-string", 'aTargets' : [ 'title-string'] } >+ ], >+ [% ELSE %] >+ "aoColumnDefs": [ >+ { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false }, >+ { 'sType': "title-string", 'aTargets' : [ 'title-string'] } >+ ], >+ [% END %] >+ "bPaginate": false >+ })); >+ $("#selectallbutton").click(function() { >+ $("#borrowerst").find("input:checkbox").each(function() { >+ $(this).prop("checked", true); >+ }); >+ return false; >+ }); >+ $("#clearallbutton").click(function() { >+ $("#borrowerst").find("input:checkbox").each(function() { >+ $(this).prop("checked", false); >+ }); >+ return false; >+ }); >+ [% END %] >+ >+ var values = new Array(); >+ var lib = new Array(); >+ [% FOREACH pav IN patron_attributes_values %] >+ values = new Array(); >+ lib = new Array(); >+ [% FOREACH option IN pav.options %] >+ values.push("[% option.lib %]"); >+ lib.push("[% option.authorised_value %]"); >+ [% END %] >+ patron_attributes_lib["[% pav.attribute_code %]"] = values; >+ patron_attributes_values["[% pav.attribute_code %]"] = lib; >+ [% END %] >+ >+ $('select[name="patron_attributes"]').change(function() { >+ updateAttrValues(this); >+ } ); >+ >+ $('select[name="patron_attributes"]').change(); >+ >+ $(".clear-date").on("click",function(e){ >+ e.preventDefault(); >+ var fieldID = this.id.replace("clear-date-",""); >+ $("#" + fieldID).val(""); >+ }); >+ $("#cataloguing_additem_newitem").on("click",".add_attributes",function(e){ >+ e.preventDefault(); >+ add_attributes(); >+ }); >+ $("#cataloguing_additem_newitem").on("click",".del_attributes",function(e){ >+ e.preventDefault(); >+ del_attributes(this); >+ }); >+ }); >+ >+ function updateAttrValues (select_attr) { >+ var attr_code = $(select_attr).val(); >+ var type = $(select_attr).find("option:selected").attr('data-type'); >+ var category = $(select_attr).find("option:selected").attr('data-category'); >+ var span = $(select_attr).parent().parent().find('span.patron_attributes_value'); >+ var information_category_node = $(select_attr).parent().parent().find('span.information_category'); >+ information_category_node.html(""); >+ if ( category.length > 0 ) { >+ information_category_node.html(_("This attribute will be only applied to the patron's category %s").format(category)); >+ } >+ if ( type == 'select' ) { >+ var options = '<option value = ""></option>'; >+ for ( var i = 0 ; i < patron_attributes_values[attr_code].length ; i++ ) { >+ options += '<option value="'+patron_attributes_values[attr_code][i]+'">'+patron_attributes_lib[attr_code][i]+'</option>'; >+ } >+ span.html('<select name="patron_attributes_value">' + options + '</select>'); >+ } else { >+ span.html('<input type="text" name="patron_attributes_value"/>') >+ } >+ } >+ >+ function add_attributes() { >+ var li_node = $("li.attributes:last"); >+ var li_clone = $(li_node).clone(); >+ if ( $(li_clone).find("a.del_attributes").length == 0 ) { >+ $(li_clone).append('<a href="#" title="Delete" class="del_attributes"><i class="fa fa-fw fa-trash"></i> Delete</a>'); >+ } >+ $(li_clone).find('select[name="patron_attributes"]').change(function() { >+ updateAttrValues(this); >+ } ); >+ >+ $(li_clone).find('select[name="patron_attributes"]').change(); >+ >+ $("#fields_list>ol").append(li_clone); >+ update_attr_values(); >+ } >+ >+ function del_attributes(a_node) { >+ $(a_node).parent('li').remove(); >+ update_attr_values(); >+ } >+ >+ function update_attr_values() { >+ $("li.attributes").each(function(i) { >+ $(this).find("input:checkbox").val("attr"+i+"_value"); >+ }); >+ } >+ function clearDate(nodeid) { >+ $("#"+nodeid).val(""); >+ } >+ </script> >+[% END %] >+ > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >index bb6e824..f27a8c2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/overduerules.tt >@@ -1,27 +1,11 @@ > [% USE Koha %] > [% USE Branches %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Tools › Overdue notice/status triggers</title> > [% INCLUDE 'doc-head-close.inc' %] >- >-<script type="text/javascript"> >-//<![CDATA[ >-var tab_map = { "1" : _("First"), "2" : _("Second"), "3" : _("Third")}; >-$(document).ready(function() { >- $('#selectlibrary').find("input:submit").hide(); >- $('#branch').change(function() { >- $('#selectlibrary').submit(); >- }); >- $("li>a.tab").each( function(){ >- var id = $(this).attr("data-number"); >- $(this).html(tab_map[id]); >- } ); >- $('#rulestabs').tabs(); >-}); >-//]]> >-</script> >- > </head> >+ > <body id="tools_overduerules" class="tools"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'cat-search.inc' %] >@@ -170,4 +154,23 @@ $(document).ready(function() { > [% INCLUDE 'tools-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script> >+ <script type="text/javascript"> >+ var tab_map = { "1" : _("First"), "2" : _("Second"), "3" : _("Third")}; >+ $(document).ready(function() { >+ $('#selectlibrary').find("input:submit").hide(); >+ $('#branch').change(function() { >+ $('#selectlibrary').submit(); >+ }); >+ $("li>a.tab").each( function(){ >+ var id = $(this).attr("data-number"); >+ $(this).html(tab_map[id]); >+ }); >+ $('#rulestabs').tabs(); >+ }); >+ </script> >+[% END %] >+ > [% INCLUDE 'intranet-bottom.inc' %] >-- >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 19680
:
69290
|
69501
|
69569