Bugzilla – Attachment 69201 Details for
Bug 19603
Move admin templates JavaScript to the footer: Patrons and circulation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19603: Move admin templates JavaScript to the footer: Patrons and circulation
Bug-19603-Move-admin-templates-JavaScript-to-the-f.patch (text/plain), 34.92 KB, created by
Owen Leonard
on 2017-11-17 15:50:29 UTC
(
hide
)
Description:
Bug 19603: Move admin templates JavaScript to the footer: Patrons and circulation
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2017-11-17 15:50:29 UTC
Size:
34.92 KB
patch
obsolete
>From 5d286c862ddf7589cab9f4d9056af3e97332a92b Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 9 Nov 2017 14:30:26 +0000 >Subject: [PATCH] Bug 19603: Move admin templates JavaScript to the footer: > Patrons and circulation > >This patch modifies the staff client patrons and circulation-related >administration 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, >tabs, etc. >--- > .../en/modules/admin/branch_transfer_limits.tt | 80 +++---- > .../prog/en/modules/admin/categories.tt | 21 +- > .../intranet-tmpl/prog/en/modules/admin/cities.tt | 35 +-- > .../en/modules/admin/item_circulation_alerts.tt | 101 +++++---- > .../prog/en/modules/admin/patron-attr-types.tt | 39 ++-- > .../prog/en/modules/admin/smart-rules.tt | 247 +++++++++++---------- > .../prog/en/modules/admin/transport-cost-matrix.tt | 116 +++++----- > 7 files changed, 333 insertions(+), 306 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt >index d8a029d..f7d57f2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/branch_transfer_limits.tt >@@ -1,48 +1,12 @@ > [% USE Branches %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Library checkin and transfer policy</title> > [% INCLUDE 'doc-head-close.inc' %] > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> >-[% INCLUDE 'datatables.inc' %] >-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >-<script type="text/javascript"> >-//<![CDATA[ >- $(document).ready(function(){ >- $("#CheckAll").click(function(){ $("#transferlimit_tabs").checkCheckboxes(); return false; }); >- $("#UncheckAll").click(function(){ $("#transferlimit_tabs").unCheckCheckboxes(); return false; }); >- $('#transferlimit_tabs').tabs(); >- >- $('#branchselect').change(function() { >- $('#selectlibrary').submit(); >- }); >- >- var checkall = $(".checkall"); >- var uncheckall = $(".uncheckall"); >- >- $(checkall).click(function(){ >- var tid = $(this).attr("id"); >- tid = tid.replace("CheckAll",""); >- $("#"+tid).checkCheckboxes(); >- return false; >- }); >- >- $(uncheckall).click(function(){ >- var tid = $(this).attr("id"); >- tid = tid.replace("UncheckAll",""); >- $("#"+tid).unCheckCheckboxes(); >- return false; >- }); >- $(".sorted").dataTable($.extend(true, {}, dataTablesDefaults, { >- "aoColumnDefs": [ >- { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, >- ], >- 'bPaginate': false >- })); >- }); >-//]]> >-</script> > <style type="text/css">td { text-align: center; } .sorted { min-width: 50%; }</style> > </head> >+ > <body id="admin_branch_transfer_limits" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'prefs-admin-search.inc' %] >@@ -119,4 +83,44 @@ > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ [% INCLUDE 'datatables.inc' %] >+ <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >+ <script type="text/javascript"> >+ $(document).ready(function(){ >+ $("#CheckAll").click(function(){ $("#transferlimit_tabs").checkCheckboxes(); return false; }); >+ $("#UncheckAll").click(function(){ $("#transferlimit_tabs").unCheckCheckboxes(); return false; }); >+ $('#transferlimit_tabs').tabs(); >+ >+ $('#branchselect').change(function() { >+ $('#selectlibrary').submit(); >+ }); >+ >+ var checkall = $(".checkall"); >+ var uncheckall = $(".uncheckall"); >+ >+ $(checkall).click(function(){ >+ var tid = $(this).attr("id"); >+ tid = tid.replace("CheckAll",""); >+ $("#"+tid).checkCheckboxes(); >+ return false; >+ }); >+ >+ $(uncheckall).click(function(){ >+ var tid = $(this).attr("id"); >+ tid = tid.replace("UncheckAll",""); >+ $("#"+tid).unCheckCheckboxes(); >+ return false; >+ }); >+ $(".sorted").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false }, >+ ], >+ 'bPaginate': false >+ })); >+ }); >+ </script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt >index eb6be8d..d017e9f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt >@@ -1,21 +1,16 @@ > [% USE Koha %] > [% USE KohaDates %] > [% USE Price %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Patron categories › [% IF op == 'add_form' %][% IF ( categorycode ) %]Modify category '[% categorycode |html %]'[% ELSE %]New category[% END %][% END %] > [% IF op == 'delete_confirm' %][% IF ( patrons_in_category > 0 ) %]Cannot delete: category [% categorycode |html %] in use[% ELSE %]Confirm deletion of category '[% categorycode |html %]'[% END %][% END %] > </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"> >- var MSG_BOTH_ENROLLMENTPERIODS = _("Please choose only one enrollment period setting."); >- var MSG_ONE_ENROLLMENTPERIOD = ("Please choose an enrollment period in months OR by date."); >-</script> >-<script type="text/javascript" src="[% themelang %]/js/categories.js"></script> > <style type="text/css">#enrolmentmessage.hint { display : none; }</style> > </head> >+ > <body id="admin_categorie" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'patrons-admin-search.inc' %] >@@ -494,4 +489,16 @@ > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ [% INCLUDE 'calendar.inc' %] >+ [% INCLUDE 'datatables.inc' %] >+ <script type="text/javascript"> >+ var MSG_CATEGORYCODE_CHARS = _("Category code can only contain the following characters: letters, numbers, - and _."); >+ var MSG_BOTH_ENROLLMENTPERIODS = _("Please choose only one enrollment period setting."); >+ var MSG_ONE_ENROLLMENTPERIOD = ("Please choose an enrollment period in months OR by date."); >+ </script> >+ <script type="text/javascript" src="[% themelang %]/js/categories.js"></script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt >index a440cf1..869edc9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt >@@ -1,23 +1,10 @@ >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › [% IF op =='add_form' %]Cities › [% IF city.cityid %] Modify city[% ELSE %] New city[% END %][% ELSE %][% IF op == 'delete_confirm' %]Cities › Confirm deletion of city[% ELSE %] Cities[% END %][% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" /> >-[% INCLUDE 'datatables.inc' %] >-<script type="text/javascript"> >-//<![CDATA[ >- $(document).ready(function() { >- $("#table_cities").dataTable($.extend(true, {}, dataTablesDefaults, { >- "aoColumnDefs": [ >- { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, >- ], >- "aaSorting": [[ 1, "asc" ]], >- "iDisplayLength": 10, >- "sPaginationType": "full_numbers" >- })); >- }); >-//]]> >-</script> > </head> >+ > <body id="admin_cities" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'cities-admin-search.inc' %] >@@ -185,5 +172,21 @@ > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >-[% INCLUDE 'intranet-bottom.inc' %] > >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ [% INCLUDE 'datatables.inc' %] >+ <script type="text/javascript"> >+ $(document).ready(function() { >+ $("#table_cities").dataTable($.extend(true, {}, dataTablesDefaults, { >+ "aoColumnDefs": [ >+ { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false }, >+ ], >+ "aaSorting": [[ 1, "asc" ]], >+ "iDisplayLength": 10, >+ "sPaginationType": "full_numbers" >+ })); >+ }); >+ </script> >+[% END %] >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt >index a765174..9dd1fd0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/item_circulation_alerts.tt >@@ -1,4 +1,5 @@ > [% USE Branches %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Item circulation alerts</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -37,55 +38,8 @@ table.grid td.default { > background: #f88; > } > </style> >- >-<script type="text/javascript">//<![CDATA[ >-var $branch = "[% branch %]"; >-$(function(){ >- $('#alerttabs').tabs(); >- >- var blocked = _("Blocked!"); >- var saving = _("Saving..."); >- var disabledForAll = _("Disabled for all"); >- var disabledForCurrent = _("Disabled for %s").format($branch); >- >- $('#branch_selector input:submit').hide(); >- $('#branch').change(function(){ >- $('#branch_selector').submit(); >- }); >- >- $('table.grid.active tbody td').click(function(ev){ >- var id = this.id; >- var td = $(this); >- if (td.hasClass('default') && $branch != '*') { >- td.html(blocked); >- window.setTimeout( >- function(){ td.html(disabledForAll) }, >- 3000 >- ); >- } else { >- td.html(saving); >- $.ajax({ >- url : '/cgi-bin/koha/admin/item_circulation_alerts.pl', >- type : 'POST', >- dataType : 'json', >- data : { action: 'toggle', id: id, branch: $branch }, >- success : function(response){ >- if ($branch == '*' && response.classes.match(/default/)) { >- td.html(disabledForAll); >- } else if (response.classes.match(/disabled/)) { >- td.html(disabledForCurrent); >- } else { >- td.html(' '); >- } >- td.attr('class', response.classes); >- } >- }); >- } >- }); >- >-}); //]]> >-</script> > </head> >+ > <body id="admin_item_circulation_alerts" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'prefs-admin-search.inc' %] >@@ -202,4 +156,55 @@ $(function(){ > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ <script type="text/javascript"> >+ var $branch = "[% branch %]"; >+ $(function(){ >+ $('#alerttabs').tabs(); >+ >+ var blocked = _("Blocked!"); >+ var saving = _("Saving..."); >+ var disabledForAll = _("Disabled for all"); >+ var disabledForCurrent = _("Disabled for %s").format($branch); >+ >+ $('#branch_selector input:submit').hide(); >+ $('#branch').change(function(){ >+ $('#branch_selector').submit(); >+ }); >+ >+ $('table.grid.active tbody td').click(function(ev){ >+ var id = this.id; >+ var td = $(this); >+ if (td.hasClass('default') && $branch != '*') { >+ td.html(blocked); >+ window.setTimeout( >+ function(){ td.html(disabledForAll) }, >+ 3000 >+ ); >+ } else { >+ td.html(saving); >+ $.ajax({ >+ url : '/cgi-bin/koha/admin/item_circulation_alerts.pl', >+ type : 'POST', >+ dataType : 'json', >+ data : { action: 'toggle', id: id, branch: $branch }, >+ success : function(response){ >+ if ($branch == '*' && response.classes.match(/default/)) { >+ td.html(disabledForAll); >+ } else if (response.classes.match(/disabled/)) { >+ td.html(disabledForCurrent); >+ } else { >+ td.html(' '); >+ } >+ td.attr('class', response.classes); >+ } >+ }); >+ } >+ }); >+ >+ }); >+ </script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >index cfbbf2c..5a5f293 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >@@ -1,4 +1,5 @@ > [% USE AuthorisedValues %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Patron attribute types > [% IF ( attribute_type_form ) %] >@@ -13,25 +14,8 @@ > [% END %] > </title> > [% INCLUDE 'doc-head-close.inc' %] >- >-<script type="text/javascript"> >-//<![CDATA[ >-$(document).ready(function() { >- if ( $("#branches option:selected").length < 1 ) { >- $("#branches option:first").attr("selected", "selected"); >- } >- >- $("#opac_display").change( function() { >- if ( this.checked ) { >- $("#opac_editable").removeAttr('disabled').parent().removeAttr('aria-disabled'); >- } else { >- $("#opac_editable").attr('disabled', true).parent().attr('aria-disabled', 'true'); >- } >- } ).change(); >-} ); >-//]]> >-</script> > </head> >+ > <body id="admin_patron-attr-types" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'prefs-admin-search.inc' %] >@@ -313,4 +297,23 @@ $(document).ready(function() { > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ <script type="text/javascript"> >+ $(document).ready(function() { >+ if ( $("#branches option:selected").length < 1 ) { >+ $("#branches option:first").attr("selected", "selected"); >+ } >+ >+ $("#opac_display").change( function() { >+ if ( this.checked ) { >+ $("#opac_editable").removeAttr('disabled').parent().removeAttr('aria-disabled'); >+ } else { >+ $("#opac_editable").attr('disabled', true).parent().attr('aria-disabled', 'true'); >+ } >+ } ).change(); >+ }); >+ </script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >index 99c03d3..6dc5042 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt >@@ -1,130 +1,10 @@ > [% USE Branches %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Circulation and fine rules</title> > [% INCLUDE 'doc-head-close.inc' %] >-[% INCLUDE 'calendar.inc' %] >-<script type="text/javascript"> >-//<![CDATA[ >- >-function clear_edit(){ >- var cancel = confirm(_("Are you sure you want to cancel your changes?")); >- if ( !cancel ) return; >- $('#default-circulation-rules td').removeClass('highlighted-row'); >- var edit_row = $("#edit_row"); >- $(edit_row).find("input").each(function(){ >- var type = $(this).attr("type"); >- if (type != "button" && type != "submit" ) { >- $(this).val(""); >- $(this).prop('disabled', false); >- } >- if ( type == "checkbox" ) { >- $(this).prop('checked', false); >- } >- }); >- $(edit_row).find("select").prop('disabled', false); >- $(edit_row).find("select option:first").attr("selected", "selected"); >- $(edit_row).find("td:last input[name='clear']").remove(); >-} >- >-var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone."); >- >- >-$(document).ready(function() { >- $(".delete").on("click",function(){ >- return confirmDelete(MSG_CONFIRM_DELETE); >- }); >- >- $("#clone_rules").on("click",function(){ >- var library_dropdown = document.getElementById("branch"); >- var selected_library = library_dropdown.options[library_dropdown.selectedIndex].value; >- var selected_library_text = $("#branch option:selected").text(); >- var to_library = $("#tobranch option:selected").text(); >- var MSG_CONFIRM_CLONE; >- if (selected_library === "*") { >- MSG_CONFIRM_CLONE = _("Are you sure you want to clone this standard rule to %s library? This will override the existing rules in this library.").format(to_library); >- return confirmClone(MSG_CONFIRM_CLONE); >- } else { >- MSG_CONFIRM_CLONE = _("Are you sure you want to clone this circulation and fine rule from %s to %s library? This will override the existing rules in this library.").format(selected_library_text, to_library); >- return confirmClone(MSG_CONFIRM_CLONE); >- } >- }); >- >- $('#cap_fine_to_replacement_price').on('change', function(){ >- $('#overduefinescap').prop('disabled', $(this).is(':checked') ); >- }); >- $('#selectlibrary').find("input:submit").hide(); >- $('#branch').change(function() { >- $('#selectlibrary').submit(); >- }); >- $(".editrule").click(function(){ >- if ( $("#edit_row").find("input[type='text']").filter(function(){return this.value.length > 0 }).length > 0 ) { >- var edit = confirm(_("Are you sure you want to edit another rule?")); >- if (!edit) return false; >- } >- $('#default-circulation-rules td').removeClass('highlighted-row'); >- $(this).parent().parent().find("td").each(function (i) { >- $(this).addClass('highlighted-row'); >- itm = $(this).text(); >- itm = itm.replace(/^\s*|\s*$/g,''); >- var current_column = $("#edit_row td:eq("+i+")"); >- if ( i == 7 ) { >- // specific processing for the Hard due date column >- var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val(); >- var input_value = ''; >- if (typeof select_value === 'undefined'){ >- select_value = '-1'; >- }else { >- input_value = itm.split(' ')[1]; >- } >- $(current_column).find("input[type='text']").val(input_value); >- $(current_column).find("select").val(select_value); >- } else if ( i == 13 ) { >- // specific processing for cap_fine_to_replacement_price >- var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']"); >- $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') ); >- $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') ); >- } else { >- $(current_column).find("input[type='text']").val(itm); >- // select the corresponding option >- $(current_column).find("select option").each(function(){ >- opt = $(this).text().toLowerCase(); >- opt = opt.replace(/^\s*|\s*$/g,''); >- if ( opt == itm.toLowerCase() ) { >- $(this).attr('selected', 'selected'); >- } >- }); >- if ( i == 0 || i == 1 ) { >- // Disable the 2 first columns, we cannot update them. >- var val = $(current_column).find("select option:selected").val(); >- var name = "categorycode"; >- if ( i == 1 ) { >- name="itemtype"; >- } >- // Remove potential previous input added >- $(current_column).find("input").remove(); >- $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />"); >- } else if ( i == 3 || i == 4 ) { >- // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed" >- // The value is "Unlimited" (or an equivalent translated string) >- // an it should be set to an empty string >- if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) { >- $(current_column).find("input[type='text']").val(""); >- } >- } >- } >- }); >- $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true); >- $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true); >- return false; >- }); >- $(".clear_edit").on("click",function(e){ >- e.preventDefault(); >- clear_edit(); >- }); >-}); >-//]]> >-</script> > </head> >+ > <body id="admin_smart-rules" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'prefs-admin-search.inc' %] >@@ -834,4 +714,127 @@ $(document).ready(function() { > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ [% INCLUDE 'calendar.inc' %] >+ <script type="text/javascript"> >+ >+ function clear_edit(){ >+ var cancel = confirm(_("Are you sure you want to cancel your changes?")); >+ if ( !cancel ) return; >+ $('#default-circulation-rules td').removeClass('highlighted-row'); >+ var edit_row = $("#edit_row"); >+ $(edit_row).find("input").each(function(){ >+ var type = $(this).attr("type"); >+ if (type != "button" && type != "submit" ) { >+ $(this).val(""); >+ $(this).prop('disabled', false); >+ } >+ if ( type == "checkbox" ) { >+ $(this).prop('checked', false); >+ } >+ }); >+ $(edit_row).find("select").prop('disabled', false); >+ $(edit_row).find("select option:first").attr("selected", "selected"); >+ $(edit_row).find("td:last input[name='clear']").remove(); >+ } >+ >+ var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this rule? This cannot be undone."); >+ >+ $(document).ready(function() { >+ $(".delete").on("click",function(){ >+ return confirmDelete(MSG_CONFIRM_DELETE); >+ }); >+ >+ $("#clone_rules").on("click",function(){ >+ var library_dropdown = document.getElementById("branch"); >+ var selected_library = library_dropdown.options[library_dropdown.selectedIndex].value; >+ var selected_library_text = $("#branch option:selected").text(); >+ var to_library = $("#tobranch option:selected").text(); >+ var MSG_CONFIRM_CLONE; >+ if (selected_library === "*") { >+ MSG_CONFIRM_CLONE = _("Are you sure you want to clone this standard rule to %s library? This will override the existing rules in this library.").format(to_library); >+ return confirmClone(MSG_CONFIRM_CLONE); >+ } else { >+ MSG_CONFIRM_CLONE = _("Are you sure you want to clone this circulation and fine rule from %s to %s library? This will override the existing rules in this library.").format(selected_library_text, to_library); >+ return confirmClone(MSG_CONFIRM_CLONE); >+ } >+ }); >+ >+ $('#cap_fine_to_replacement_price').on('change', function(){ >+ $('#overduefinescap').prop('disabled', $(this).is(':checked') ); >+ }); >+ $('#selectlibrary').find("input:submit").hide(); >+ $('#branch').change(function() { >+ $('#selectlibrary').submit(); >+ }); >+ $(".editrule").click(function(){ >+ if ( $("#edit_row").find("input[type='text']").filter(function(){return this.value.length > 0 }).length > 0 ) { >+ var edit = confirm(_("Are you sure you want to edit another rule?")); >+ if (!edit) return false; >+ } >+ $('#default-circulation-rules td').removeClass('highlighted-row'); >+ $(this).parent().parent().find("td").each(function (i) { >+ $(this).addClass('highlighted-row'); >+ itm = $(this).text(); >+ itm = itm.replace(/^\s*|\s*$/g,''); >+ var current_column = $("#edit_row td:eq("+i+")"); >+ if ( i == 7 ) { >+ // specific processing for the Hard due date column >+ var select_value = $(this).find("input[type='hidden'][name='hardduedatecomparebackup']").val(); >+ var input_value = ''; >+ if (typeof select_value === 'undefined'){ >+ select_value = '-1'; >+ }else { >+ input_value = itm.split(' ')[1]; >+ } >+ $(current_column).find("input[type='text']").val(input_value); >+ $(current_column).find("select").val(select_value); >+ } else if ( i == 13 ) { >+ // specific processing for cap_fine_to_replacement_price >+ var cap_fine_to_replacement_price = $(this).find("input[type='checkbox']"); >+ $('#cap_fine_to_replacement_price').prop('checked', cap_fine_to_replacement_price.is(':checked') ); >+ $('#overduefinescap').prop('disabled', cap_fine_to_replacement_price.is(':checked') ); >+ } else { >+ $(current_column).find("input[type='text']").val(itm); >+ // select the corresponding option >+ $(current_column).find("select option").each(function(){ >+ opt = $(this).text().toLowerCase(); >+ opt = opt.replace(/^\s*|\s*$/g,''); >+ if ( opt == itm.toLowerCase() ) { >+ $(this).attr('selected', 'selected'); >+ } >+ }); >+ if ( i == 0 || i == 1 ) { >+ // Disable the 2 first columns, we cannot update them. >+ var val = $(current_column).find("select option:selected").val(); >+ var name = "categorycode"; >+ if ( i == 1 ) { >+ name="itemtype"; >+ } >+ // Remove potential previous input added >+ $(current_column).find("input").remove(); >+ $(current_column).append("<input type='hidden' name='"+name+"' value='"+val+"' />"); >+ } else if ( i == 3 || i == 4 ) { >+ // If the value is not an integer for "Current checkouts allowed" or "Current on-site checkouts allowed" >+ // The value is "Unlimited" (or an equivalent translated string) >+ // an it should be set to an empty string >+ if( !((parseFloat(itm) == parseInt(itm)) && !isNaN(itm)) ) { >+ $(current_column).find("input[type='text']").val(""); >+ } >+ } >+ } >+ }); >+ $("#default-circulation-rules tr:last td:eq(0) select").prop('disabled', true); >+ $("#default-circulation-rules tr:last td:eq(1) select").prop('disabled', true); >+ return false; >+ }); >+ $(".clear_edit").on("click",function(e){ >+ e.preventDefault(); >+ clear_edit(); >+ }); >+ }); >+ </script> >+[% END %] > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt >index 7c6ee3f..281c2c5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/transport-cost-matrix.tt >@@ -1,70 +1,15 @@ > [% USE Branches %] >+[% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Administration › Transport cost matrix</title> > [% INCLUDE 'doc-head-close.inc' %] >- >-<script type="text/javascript"> >-//<![CDATA[ >-function check_transport_cost(e) { >- var val = e.value; >- if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) { >- return; >- } >- alert(_("Cost must be expressed as a decimal number >= 0")); >-} >-function disable_transport_cost_chg(e) { >- var input_name = e.name; >- var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name >- disable_transport_cost(cost_id, e.checked); >-} >-function disable_transport_cost(cost_id, disable) { >- if (disable) { >- $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer'); >- } else { >- $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer'); >- } >-} >-function enable_cost_input(cost_id) { >- var cell = $('#celldiv_'+cost_id); >- var cost = $(cell).text(); >- var disabled = $(cell).hasClass('disabled-transfer'); >- $(cell).removeClass('disabled-transfer'); >- >- $('#celldiv_'+cost_id).html( >- '<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+ >- '<br/>Disable <input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />' >- ); >- disable_transport_cost(cost_id, disabled); >-} >- >-function form_submit (f) { >- $(f).find('input:disabled').prop('disabled', false); >- return true; >-} >-$(document).ready(function(){ >- $(".enable_cost_input").on("click",function(){ >- var cost_id = $(this).data("cost-id"); >- enable_cost_input( cost_id ); >- }); >- $("body").on("blur",".cost_input",function(){ >- check_transport_cost(this); >- }); >- $("body").on("change",".disable_transport_cost",function(){ >- disable_transport_cost_chg(this); >- }); >- $("#cost_matrix_form").on("submit",function(){ >- return form_submit(this); >- }); >-}) >-//]]> >-</script> > <style type="text/css"> > .disabled-transfer { > background-color: #FF8888; > } > </style> >- > </head> >+ > <body id="admin_transport_cost_matrix" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'prefs-admin-search.inc' %] >@@ -144,4 +89,61 @@ $(document).ready(function(){ > [% INCLUDE 'admin-menu.inc' %] > </div> > </div> >+ >+[% MACRO jsinclude BLOCK %] >+ <script type="text/javascript" src="[% interface %]/[% theme %]/js/admin-menu.js"></script> >+ <script type="text/javascript"> >+ function check_transport_cost(e) { >+ var val = e.value; >+ if (val && val != '' && !isNaN(parseFloat(val)) && val >= 0.0) { >+ return; >+ } >+ alert(_("Cost must be expressed as a decimal number >= 0")); >+ } >+ function disable_transport_cost_chg(e) { >+ var input_name = e.name; >+ var cost_id = input_name.replace(/disable_/,''); // Parse the code_id out of the input name >+ disable_transport_cost(cost_id, e.checked); >+ } >+ function disable_transport_cost(cost_id, disable) { >+ if (disable) { >+ $('#celldiv_'+cost_id).find('input[type=text]').prop('disabled', true).addClass('disabled-transfer'); >+ } else { >+ $('#celldiv_'+cost_id).find('input:disabled').prop('disabled', false).removeClass('disabled-transfer'); >+ } >+ } >+ function enable_cost_input(cost_id) { >+ var cell = $('#celldiv_'+cost_id); >+ var cost = $(cell).text(); >+ var disabled = $(cell).hasClass('disabled-transfer'); >+ $(cell).removeClass('disabled-transfer'); >+ >+ $('#celldiv_'+cost_id).html( >+ '<input type="text" name="cost_'+cost_id+'" class="cost_input" size="4" value="'+$.trim(cost)+'" />'+ >+ '<br/>Disable <input name="disable_'+cost_id+'" value="1" class="disable_transport_cost" type="checkbox" '+(disabled ? 'checked' : '')+' />' >+ ); >+ disable_transport_cost(cost_id, disabled); >+ } >+ >+ function form_submit (f) { >+ $(f).find('input:disabled').prop('disabled', false); >+ return true; >+ } >+ $(document).ready(function(){ >+ $(".enable_cost_input").on("click",function(){ >+ var cost_id = $(this).data("cost-id"); >+ enable_cost_input( cost_id ); >+ }); >+ $("body").on("blur",".cost_input",function(){ >+ check_transport_cost(this); >+ }); >+ $("body").on("change",".disable_transport_cost",function(){ >+ disable_transport_cost_chg(this); >+ }); >+ $("#cost_matrix_form").on("submit",function(){ >+ return form_submit(this); >+ }); >+ }); >+ </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 19603
:
69058
|
69201
|
69311
|
69734
|
70152
|
70153