Bugzilla – Attachment 53884 Details for
Bug 16962
Remove the use of "onclick" from serial collection template
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16962 - Remove the use of "onclick" from serial collection and serial edit templates
Bug-16962---Remove-the-use-of-onclick-from-serial-.patch (text/plain), 20.72 KB, created by
Jonathan Druart
on 2016-08-02 10:27:35 UTC
(
hide
)
Description:
Bug 16962 - Remove the use of "onclick" from serial collection and serial edit templates
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-08-02 10:27:35 UTC
Size:
20.72 KB
patch
obsolete
>From 6ebee15524a5e0fcb18335453064a82f20154339 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 20 Jul 2016 11:37:06 -0400 >Subject: [PATCH] Bug 16962 - Remove the use of "onclick" from serial > collection and serial edit templates >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch removes the use of event attributes like "onclick" from the >serial collection and serial edit templates. Events are now defined in >JavaScript. > >Also changed: Converted "create routing list," "edit routing list," and >"Renew" links to Bootstrap buttons. The "select all" and "clear all" >links have Font Awesome icons added. > >To test, apply the patch and go to Serials > >- Locate or create a subscription for which an item record is NOT > created when receiving. > - On the serial collection page for this subscription, test that the > "Multi receiving" button works correctly. >- For any subscription, test that the "Generate next" button works > correctly. >- In each tab, test that the "select all" and "clear all" links work > correctly. >- On a subscription which has expired, test that the "Renew" button > works correctly. >- On the serial collection page, select multiple issues and click the > "Edit serials" button. > - Testing with a subscription for which an item record is NOT created > when receiving: > - Changing the status to "Arrived" or "Claimed" should change the > "Expected on" date to today's date. Selecting any other status > should leave the "expected on" date as it was or return it to its > original value. > - Test that the "Multi receiving" button works correctly. > - Testing with a subscription for which an item record IS created when > receiving: > - Changing the status of an issue should work as above but should > also trigger the appearance of the item add form when the status > is "Arrived" or "Claimed," and hide the form otherwise. > - Cliking the "Item" link at the top of the item add form should > hide it. > - Clicking the "Add item" link under any issue should display the > item add form. > - In the item add form, test that repeatable fields are correctly > duplicated when you click the "clone" button. > - On the "Supplemental issue" line, changing the status to "Arrived" > should work as described above. Changing the status on this line > to "Claimed" should only change the "Expected on" date. > - Adding regular and supplemental issues should work correctly. > >Signed-off-by: Frédéric Demians <f.demians@tamil.fr> > Works as described. > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../prog/en/modules/serials/serials-collection.tt | 62 ++++++++++----- > .../prog/en/modules/serials/serials-edit.tt | 91 ++++++++++++++++++---- > 2 files changed, 119 insertions(+), 34 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >index 9a79eca..868cf8b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-collection.tt >@@ -6,7 +6,6 @@ > [% 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[ >@@ -51,14 +50,6 @@ function generateNext(subscriptionid) { > } > } > >-function CheckAll( node ) { >- $("#"+node).checkCheckboxes(); >- return false; >-} >-function CheckNone( node ) { >- $("#"+node).unCheckCheckboxes(); >- return false; >-} > $(document).ready(function() { > $('#subscription_years').tabs(); > $(".subscription-year-table").dataTable($.extend(true, {}, dataTablesDefaults, { >@@ -73,6 +64,37 @@ $(document).ready(function() { > "bInfo": false, > "bFilter": false, > } )); >+ $(".renew_subscription").on("click",function(e){ >+ e.preventDefault(); >+ var subscriptionid = $(this).data("subscriptionid"); >+ popup( subscriptionid ); >+ }); >+ $(".generate_next").on("click",function(e){ >+ e.preventDefault(); >+ var subscriptionidlist = $(this).data("subscriptionidlist"); >+ generateNext( subscriptionidlist ); >+ }); >+ $(".multi_receiving").on("click",function(e){ >+ e.preventDefault(); >+ var subscriptionidlist = $(this).data("subscriptionidlist"); >+ generateReceive( subscriptionidlist ); >+ }); >+ $(".CheckAll").on("click",function(e){ >+ e.preventDefault(); >+ var node = $(this).data("subscription_year"); >+ $(".checkboxed","#"+node).prop("checked",1); >+ }); >+ $(".CheckNone").on("click",function(e){ >+ e.preventDefault(); >+ var node = $(this).data("subscription_year"); >+ $(".checkboxed","#"+node).prop("checked",0); >+ }); >+ $(".print_list").on("click",function(e){ >+ e.preventDefault(); >+ var subscriptionid = $(this).data("subscriptionid"); >+ var issue =- $(this).data("issue"); >+ print_slip( subscriptionid, issue ); >+ }); > }); > > //]]> >@@ -136,17 +158,19 @@ $(document).ready(function() { > <td> > [% UNLESS subscription.closed %] > [% IF ( subscription.hasRouting ) %] >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]">Edit routing list</a> >+ <a class="btn btn-mini" href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]"><i class="fa fa-pencil"></i> Edit routing list</a> > [% ELSE %] >- <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]&op=new">Create routing list</a> >+ <a class="btn btn-mini" href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscription.subscriptionid %]&op=new"><i class="fa fa-plus"></i> Create routing list</a> > [% END %] > [% END %] > </td> > [% END %] > [% UNLESS subscription.closed %] >- [% IF ( subscription.abouttoexpire ) %]<td class="problem"> <a href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscription.subscriptionid %]" onclick="popup([% subscription.subscriptionid %]); return false;">Renew</a></td> >+ [% IF ( subscription.abouttoexpire ) %] >+ <td class="problem"> <a class="btn btn-mini renew_subscription" data-subscriptionid="[% subscription.subscriptionid %]" href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscription.subscriptionid %]"><i class="fa fa-refresh"></i> Renew</a></td> > [% ELSE %] >- [% IF ( subscription.subscriptionexpired ) %]<td class="problem"> <a href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscription.subscriptionid %]" onclick="popup([% subscription.subscriptionid %]); return false;">Renew</a></td> >+ [% IF ( subscription.subscriptionexpired ) %] >+ <td class="problem"> <a class="btn btn-mini renew_subscription" data-subscriptionid="[% subscription.subscriptionid %]" href="/cgi-bin/koha/serials/subscription-renew.pl?subscriptionid=[% subscription.subscriptionid %]"><i class="fa fa-refresh"></i> Renew</a></td> > [% ELSE %] > <td> </td> > [% END %] >@@ -186,16 +210,18 @@ $(document).ready(function() { > <p> > <input type="submit" value="Edit serials" /> > [% UNLESS subscription.closed %] >- <input type="button" value="Generate next" onclick="javascript:generateNext([% subscriptionidlist %])" /> >- [% IF ( subscriptions.size == 1 and !serialsadditems ) %] <input type="button" value="Multi receiving" onclick="javascript:generateReceive([% subscriptionidlist %])" />[% END %] >+ <input type="button" class="generate_next" data-subscriptionidlist="[% subscriptionidlist %]" value="Generate next" /> >+ [% IF ( subscriptions.size == 1 and !serialsadditems ) %] >+ <input type="button" class="multi_receiving" data-subscriptionidlist="[% subscriptionidlist %]" value="Multi receiving" /> >+ [% END %] > [% END %] > </p> > [% END %] > <span class="checkall"> >- <a class="CheckAll" href="#" onclick="CheckAll('subscription-year-[% year.year %]'); return false;">Select all</a> >+ <a class="CheckAll" href="#" data-subscription_year="subscription-year-[% year.year %]"><i class="fa fa-check"></i> Select all</a> > </span> | > <span class="clearall"> >- <a class="CheckNone" href="#" onclick="CheckNone('subscription-year-[% year.year %]'); return false;">Clear all</a> >+ <a class="CheckNone" href="#" data-subscription_year="subscription-year-[% year.year %]"><i class="fa fa-remove"></i> Clear all</a> > </span> > <table class="subscription-year-table"> > <thead> >@@ -304,7 +330,7 @@ $(document).ready(function() { > </td> > [% IF ( routing ) %] > <td> >- <a href="" onclick="print_slip([% serial.subscriptionid |html %], '[% serial.serialseq.replace("'", "\\'") |html %] ([% serial.publisheddate | $KohaDates %])'); return false" >Print list</a> >+ <a href="#" class="btn btn-mini print_list" data-subscriptionid="[% serial.subscriptionid |html %]" data-issue="[% serial.serialseq.replace("'", "\\'") |html %] ([% serial.publisheddate | $KohaDates %])"><i class="fa fa-print"></i> Print list</a> > </td> > [% END %] > </tr> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt >index a32c604..584f72e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt >@@ -1,11 +1,12 @@ > [% USE AuthorisedValues %] >+[% USE To %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Serials › Serial edition [% bibliotitle %]</title> > [% INCLUDE 'doc-head-close.inc' %] > <script type="text/javascript" src="[% interface %]/[% theme %]/js/cataloging.js"></script> > <script type="text/javascript" src="[% interface %]/[% theme %]/js/prevent_submit.js"></script> > [% INCLUDE 'calendar.inc' %] >-<script language="JavaScript" type="text/javascript"> >+<script type="text/javascript"> > //<![CDATA[ > function generateReceive() { > var subscriptionid = document.getElementsByName("subscriptionid")[0].value; >@@ -62,6 +63,65 @@ $(document).ready(function() { > }); > > $(".datepicker").datepicker(); >+ $(".serialsadditems_status").on("change",function(){ >+ var serialdata = $(this).data("serialdata"); >+ if ( this.value == 2 ){ >+ unHideItems('items'+ serialdata.subscriptionid + serialdata.serialid,'label'+ serialdata.subscriptionid + serialdata.serialid, serialdata.serialid); >+ changeDate(this, serialdata.arriveddate); >+ } else if ( this.value == 7 ){ >+ changeDate(this, serialdata.arriveddate); >+ } else { >+ HideItems('items'+ serialdata.subscriptionid + serialdata.serialid,'label' + serialdata.subscriptionid + serialdata.serialid); >+ changeDate(this, serialdata.planneddate); >+ } >+ }); >+ $(".noserialsadditems_status").on("change",function(){ >+ var serialdata = $(this).data("serialdata"); >+ if ( this.value == 2 || this.value == 7 ){ >+ changeDate(this, serialdata.arriveddate); >+ } else { >+ changeDate(this, serialdata.planneddate); >+ } >+ }); >+ $(".add_serial_item").on("click",function(e){ >+ e.preventDefault(); >+ var serialid = $(this).data("serialid"); >+ var serialdata = $("#status" + serialid).data("serialdata"); >+ unHideItems('items'+ serialdata.subscriptionid + serialdata.serialid,'label' + serialdata.subscriptionid + serialdata.serialid, serialdata.serialid); >+ setStatus( serialdata.serialid ); >+ }); >+ $(".new_serial_item").on("click",function(e){ >+ e.preventDefault(); >+ var newserialloo = $(this).data("serialdata"); >+ unHideItems('items'+ newserialloo.subscriptionid + newserialloo.serialid,'label' + newserialloo.subscriptionid + newserialloo.serialid, newserialloo.serialid); >+ }); >+ $(".hide_item_form").on("click",function(e){ >+ e.preventDefault(); >+ var serialid = $(this).data("serialid"); >+ var serialdata = $("#status" + serialid).data("serialdata"); >+ HideItems('items' + serialdata.subscriptionid + serialdata.serialid,'label' + serialdata.subscriptionid + serialdata.serialid); >+ }); >+ >+ $(".clone_subfield").on("click",function(e){ >+ e.preventDefault(); >+ CloneItemSubfield( this.parentNode ); >+ }); >+ $(".multi_receiving").on("click",function(e){ >+ e.preventDefault(); >+ generateReceive(); >+ }); >+ $(".newserialitem_status").on("click",function(){ >+ var newserialloo = $(this).data("serialdata"); >+ if ( this.value == 2){ >+ unHideItems('items' + newserialloo.subscriptionid + newserialloo.serialid,'label' + newserialloo.subscriptionid + newserialloo.serialid, newserialloo.serialid); >+ changeDate(this, newserialloo.arriveddate); >+ } else if ( this.value == 7 ){ >+ changeDate(this, newserialloo.arriveddate); >+ } else { >+ HideItems('items' + newserialloo.subscriptionid + newserialloo.serialid, 'label' + newserialloo.subscriptionid + newserialloo.serialid); >+ changeDate(this, newserialloo.planneddate); >+ } >+ }); > }); > //]]> > </script> >@@ -137,13 +197,13 @@ $(document).ready(function() { > <td> > [% IF ( serialslis.editdisable ) %] > <input type="hidden" name="status" id="status[% serialslis.serialid %]" value="[% serialslis.serstatus %]"> >- <select name="status" size="1" disabled="disabled"> >+ <select name="status" size="1" disabled="disabled"> > [% ELSE %] >- [% IF ( serialslis.serialsadditems ) %] >- <select name="status" size="1" id="status[% serialslis.serialid %]" onchange="if (this.value==2){unHideItems('items'+[% serialslis.subscriptionid %][% serialslis.serialid %],'label[% serialslis.subscriptionid %][% serialslis.serialid %]','[% serialslis.serialid %]'); changeDate(this, '[% serialslis.arriveddate %]')} else if (this.value==7){changeDate(this, '[% serialslis.arriveddate %]')} else { HideItems('items'+[% serialslis.subscriptionid %]+[% serialslis.serialid %],'label[% serialslis.subscriptionid %][% serialslis.serialid %]'); changeDate(this, '[% serialslis.planneddate %]')}" > >- [% ELSE %] >- <select name="status" size="1" id="status[% serialslis.serialid %]" onchange="if (this.value==2 || this.value==7){changeDate(this, '[% serialslis.arriveddate %]')} else {changeDate(this, '[% serialslis.planneddate %]')}" > >- [% END %] >+ [% IF ( serialslis.serialsadditems ) %] >+ <select name="status" data-serialdata="[% To.json(serialslis) | html %]" class="serialsadditems_status" id="status[% serialslis.serialid %]"> >+ [% ELSE %] >+ <select name="status" data-serialdata="[% To.json(serialslis) | html %]" class="noserialsadditems_status" id="status[% serialslis.serialid %]"> >+ [% END %] > [% END %] > [% IF ( serialslis.status1 ) %] > <option value="1" selected="selected">Expected</option> >@@ -214,10 +274,9 @@ $(document).ready(function() { > [% IF ( serialslis.serialsadditems ) %] > <tr> > <td colspan="6"> >- <a id="label[% serialslis.subscriptionid %][% serialslis.serialid %]" style="color: grey; font-size: 80%; cursor: pointer;" onclick="unHideItems('items[% serialslis.subscriptionid %][% serialslis.serialid %]','label[% serialslis.subscriptionid %][% serialslis.serialid %]', '[% serialslis.serialid %]');setStatus([% serialslis.serialid %]);"> >- Click to add item</a> >+ <a id="label[% serialslis.subscriptionid %][% serialslis.serialid %]" class="add_serial_item" data-serialid="[% serialslis.serialid %]" href="#"><i class="fa fa-plus"></i> Add item</a> > <fieldset class="rows" style="display:none;" id="items[% serialslis.subscriptionid %][% serialslis.serialid %]"> >- <legend><a style="cursor: pointer;" onclick="HideItems('items[% serialslis.subscriptionid %][% serialslis.serialid %]','label[% serialslis.subscriptionid %][% serialslis.serialid %]')"> >+ <legend><a href="#" data-serialid="[% serialslis.serialid %]" class="hide_item_form"> > Item</a> > </legend> > <div class="cataloguing_additem_itemlist"> >@@ -249,7 +308,7 @@ $(document).ready(function() { > <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" /> > <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" /> > [% IF ( iteminformatio.repeatable ) %] >- <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode); return false;"> >+ <a href="#" class="clone_subfield"> > <img src="[% interface %]/[% theme %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" /> > </a> > [% END %] >@@ -292,7 +351,7 @@ $(document).ready(function() { > <input type="text" name="planneddate" value="[% newserialloo.planneddate %]" size="10" maxlength="15" class="datepicker" /> > </td> > <td> >- <select name="status" size="1" id="addstatus[% newserialloo.serialid %]" onchange="if (this.value==2){unHideItems('items'+'[% newserialloo.subscriptionid %][% newserialloo.serialid %]','label[% newserialloo.subscriptionid %][% newserialloo.serialid %]','[% newserialloo.serialid %]'); changeDate(this, '[% newserialloo.arriveddate %]')} else if (this.value==7){changeDate(this, '[% newserialloo.arriveddate %]')} else { HideItems('items'+'[% newserialloo.subscriptionid %]'+[% newserialloo.serialid %],'label[% serialslis.subscriptionid %][% serialslis.serialid %]'); changeDate(this, '[% serialslis.planneddate %]')}" > >+ <select name="status" size="1" id="addstatus[% newserialloo.serialid %]" data-serialdata="[% To.json(newserialloo) | html %]" class="newserialitem_status"> > > <option value="">----</option> > [% IF ( newserialloo.status1 ) %] >@@ -361,8 +420,8 @@ $(document).ready(function() { > [% IF ( newserialloo.serialsadditems ) %] > <tr> > <td colspan="6"> >- <a id="label[% newserialloo.subscriptionid %][% newserialloo.serialid %]" style="color: grey; font-size: 80%; cursor: pointer;" onclick="unHideItems('items[% newserialloo.subscriptionid %][% newserialloo.serialid %]','label[% newserialloo.subscriptionid %][% newserialloo.serialid %]', '[% newserialloo.serialid %]')"> >- Click to add item</a> >+ <a id="label[% newserialloo.subscriptionid %][% newserialloo.serialid %]" href="#" class="new_serial_item" data-serialdata="[% To.json(newserialloo) | html %]"> >+ <i class="fa fa-plus"></i> Add item</a> > <fieldset class="rows" style="display:none;" id="items[% newserialloo.subscriptionid %][% newserialloo.serialid %]"> > <legend><a style="cursor: pointer;" onclick="HideItems('items[% newserialloo.subscriptionid %][% newserialloo.serialid %]','label[% newserialloo.subscriptionid %][% newserialloo.serialid %]')"> > Item</a> >@@ -395,7 +454,7 @@ $(document).ready(function() { > <input type="hidden" name="subfield" value="[% iteminformatio.subfield %]" /> > <input type="hidden" name="mandatory" value="[% iteminformatio.mandatory %]" /> > [% IF ( iteminformatio.repeatable ) %] >- <a href="#" class="buttonPlus" onclick="CloneItemSubfield(this.parentNode); return false;"> >+ <a href="#" class="clone_subfield"> > <img src="[% interface %]/[% theme %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" /> > </a> > [% END %] >@@ -422,7 +481,7 @@ $(document).ready(function() { > </table> > <fieldset class="action"> > <input type="submit" value="Save" class="button" accesskey="w" /> >- [% UNLESS ( serialsadditems ) %] <input type="button" onclick="javascript:generateReceive()" value="Multi receiving">[% END %] >+ [% UNLESS ( serialsadditems ) %] <input type="button" class="multi_receiving" value="Multi receiving">[% END %] > </fieldset> > </form> > >-- >2.8.1
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 16962
:
53647
|
53856
|
53884
|
59181
|
67814
|
100923
|
102647
|
103328
|
103381