Bugzilla – Attachment 60642 Details for
Bug 15219
Server-side processing and pagination on checkouts tables
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15219: Fix date sorting when server-side processing is disabled
Bug-15219-Fix-date-sorting-when-server-side-proces.patch (text/plain), 23.02 KB, created by
Julian Maurice
on 2017-02-24 09:10:00 UTC
(
hide
)
Description:
Bug 15219: Fix date sorting when server-side processing is disabled
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2017-02-24 09:10:00 UTC
Size:
23.02 KB
patch
obsolete
>From be2798b2fadc7e62a1ab9ad829d275ef9d6ef606 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 24 Feb 2017 09:51:59 +0100 >Subject: [PATCH] Bug 15219: Fix date sorting when server-side processing is > disabled > >Use DataTables 'columns' option instead of 'aoColumns' >This allow more control on what data is used for display, sorting, >filtering, ... > >A large part of this patch is about rewording things to better match the >DataTables documentation. >The real change is that > > "mRender": renderingFunc > >becomes > > "render": { > "display": renderingFunc > } > >So the return value of renderingFunc is now only used for display (not >for filtering, sorting, ...) >--- > koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 311 +++++++++++++++------------ > 1 file changed, 175 insertions(+), 136 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >index cc25084df9..c5736842d0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/checkouts.js >@@ -22,206 +22,206 @@ function disableGrouping(datatable) { > } > } > >-var mRenders = { >- groupOrder: function (oData, sType, oObj) { >- if ( oObj.issued_today ) { >+var renderers = { >+ groupOrder: function (data, type, row) { >+ if ( row.issued_today ) { > return "1"; > } else { > return "0"; > } > }, >- groupName: function (oData, sType, oObj) { >- if (oObj.issued_today) { >+ groupName: function (data, type, row) { >+ if (row.issued_today) { > return "<strong>" + TODAYS_CHECKOUTS + "</strong>"; > } else { > return "<strong>" + PREVIOUS_CHECKOUTS + "</strong>"; > } > }, >- dateDueFormatted: function (oData, sType, oObj) { >- var due = oObj.date_due_formatted; >+ dateDueFormatted: function (data, type, row) { >+ var due = row.date_due_formatted; > >- if ( oObj.date_due_overdue ) { >+ if ( row.date_due_overdue ) { > due = "<span class='overdue'>" + due + "</span>"; > } > >- due = "<span id='date_due_" + oObj.itemnumber + "' class='date_due'>" + due + "</span>"; >+ due = "<span id='date_due_" + row.itemnumber + "' class='date_due'>" + due + "</span>"; > >- if ( oObj.lost ) { >- due += "<span class='lost'>" + oObj.lost + "</span>"; >+ if ( row.lost ) { >+ due += "<span class='lost'>" + row.lost + "</span>"; > } > >- if ( oObj.damaged ) { >- due += "<span class='dmg'>" + oObj.damaged + "</span>"; >+ if ( row.damaged ) { >+ due += "<span class='dmg'>" + row.damaged + "</span>"; > } > > return due; > }, >- title: function (oData, sType, oObj) { >+ title: function (data, type, row) { > var title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber=" >- + oObj.biblionumber >+ + row.biblionumber > + "'>" >- + oObj.title; >+ + row.title; > >- $.each(oObj.subtitle, function( index, value ) { >+ $.each(row.subtitle, function( index, value ) { > title += " " + value.subfield; > }); > >- if ( oObj.enumchron ) { >- title += " (" + oObj.enumchron + ")"; >+ if ( row.enumchron ) { >+ title += " (" + row.enumchron + ")"; > } > > title += "</a></span>"; > >- if ( oObj.author ) { >- title += " " + BY.replace( "_AUTHOR_", " " + oObj.author ); >+ if ( row.author ) { >+ title += " " + BY.replace( "_AUTHOR_", " " + row.author ); > } > >- if ( oObj.itemnotes ) { >+ if ( row.itemnotes ) { > var span_class = ""; >- if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { >+ if ( $.datepicker.formatDate('yy-mm-dd', new Date(row.issuedate) ) == ymd ) { > span_class = "circ-hlt"; > } >- title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>" >+ title += " - <span class='" + span_class + "'>" + row.itemnotes + "</span>" > } > >- if ( oObj.itemnotes_nonpublic ) { >+ if ( row.itemnotes_nonpublic ) { > var span_class = ""; >- if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) { >+ if ( $.datepicker.formatDate('yy-mm-dd', new Date(row.issuedate) ) == ymd ) { > span_class = "circ-hlt"; > } >- title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic + "</span>" >+ title += " - <span class='" + span_class + "'>" + row.itemnotes_nonpublic + "</span>" > } > > var onsite_checkout = ''; >- if ( oObj.onsite_checkout == 1 ) { >+ if ( row.onsite_checkout == 1 ) { > onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>"; > } > > title += " " > + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=" >- + oObj.biblionumber >+ + row.biblionumber > + "&itemnumber=" >- + oObj.itemnumber >+ + row.itemnumber > + "#" >- + oObj.itemnumber >+ + row.itemnumber > + "'>" >- + oObj.barcode >+ + row.barcode > + "</a>" > + onsite_checkout; > > return title; > }, >- itemtype: function (oData, sType, oObj) { >- return oObj.itemtype_description; >+ itemtype: function (data, type, row) { >+ return row.itemtype_description; > }, >- issuedate: function (oData, sType, oObj) { >- return oObj.issuedate_formatted; >+ issuedate: function (data, type, row) { >+ return row.issuedate_formatted; > }, >- branch: function (oData, sType, oObj) { >- return oObj.branchname; >+ branch: function (data, type, row) { >+ return row.branchname; > }, >- charge: function (oData, sType, oObj) { >- if (!oObj.charge) oObj.charge = 0; >- return '<span style="text-align: right; display: block;">' + parseFloat(oObj.charge).toFixed(2) + '<span>'; >+ charge: function (data, type, row) { >+ if (!row.charge) row.charge = 0; >+ return '<span style="text-align: right; display: block;">' + parseFloat(row.charge).toFixed(2) + '<span>'; > }, >- fine: function (oData, sType, oObj) { >- if (!oObj.fine) oObj.fine = 0; >- return '<span style="text-align: right; display: block;">' + parseFloat(oObj.fine).toFixed(2) + '<span>'; >+ fine: function (data, type, row) { >+ if (!row.fine) row.fine = 0; >+ return '<span style="text-align: right; display: block;">' + parseFloat(row.fine).toFixed(2) + '<span>'; > }, >- price: function (oData, sType, oObj) { >- if (!oObj.price) oObj.price = 0; >- return parseFloat(oObj.price).toFixed(2); >+ price: function (data, type, row) { >+ if (!row.price) row.price = 0; >+ return parseFloat(row.price).toFixed(2); > }, >- renew: function (oData, sType, oObj) { >+ renew: function (data, type, row) { > var content = ""; > var span_style = ""; > var span_class = ""; > > content += "<span>"; >- content += "<span style='padding: 0 1em;'>" + oObj.renewals_count + "</span>"; >+ content += "<span style='padding: 0 1em;'>" + row.renewals_count + "</span>"; > >- if ( oObj.can_renew ) { >+ if ( row.can_renew ) { > // Do nothing >- } else if ( oObj.can_renew_error == "on_reserve" ) { >+ } else if ( row.can_renew_error == "on_reserve" ) { > content += "<span class='renewals-disabled-no-override'>" >- + "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>" >+ + "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + row.biblionumber + "'>" + ON_HOLD + "</a>" > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "too_many" ) { >+ } else if ( row.can_renew_error == "too_many" ) { > content += "<span class='renewals-disabled'>" > + NOT_RENEWABLE > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "restriction" ) { >+ } else if ( row.can_renew_error == "restriction" ) { > content += "<span class='renewals-disabled'>" > + NOT_RENEWABLE_RESTRICTION > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "overdue" ) { >+ } else if ( row.can_renew_error == "overdue" ) { > content += "<span class='renewals-disabled'>" > + NOT_RENEWABLE_OVERDUE > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "too_soon" ) { >+ } else if ( row.can_renew_error == "too_soon" ) { > content += "<span class='renewals-disabled'>" >- + NOT_RENEWABLE_TOO_SOON.format( oObj.can_renew_date ) >+ + NOT_RENEWABLE_TOO_SOON.format( row.can_renew_date ) > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "auto_too_soon" ) { >+ } else if ( row.can_renew_error == "auto_too_soon" ) { > content += "<span class='renewals-disabled'>" > + NOT_RENEWABLE_AUTO_TOO_SOON > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "auto_too_late" ) { >+ } else if ( row.can_renew_error == "auto_too_late" ) { > content += "<span class='renewals-disabled'>" > + NOT_RENEWABLE_AUTO_TOO_LATE > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "auto_renew" ) { >+ } else if ( row.can_renew_error == "auto_renew" ) { > content += "<span class='renewals-disabled'>" > + NOT_RENEWABLE_AUTO_RENEW > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; >- } else if ( oObj.can_renew_error == "onsite_checkout" ) { >+ } else if ( row.can_renew_error == "onsite_checkout" ) { > // Don't display something if it's an onsite checkout > } else { > content += "<span class='renewals-disabled'>" >- + oObj.can_renew_error >+ + row.can_renew_error > + "</span>"; > > span_style = "display: none"; > span_class = "renewals-allowed"; > } > >- var can_force_renew = ( oObj.onsite_checkout == 0 ) && ( oObj.can_renew_error != "on_reserve" ); >- var can_renew = ( oObj.renewals_remaining > 0 && !oObj.can_renew_error ); >+ var can_force_renew = ( row.onsite_checkout == 0 ) && ( row.can_renew_error != "on_reserve" ); >+ var can_renew = ( row.renewals_remaining > 0 && !row.can_renew_error ); > if ( can_renew || can_force_renew ) { > content += "<span class='" + span_class + "' style='" + span_style + "'>" > + "<input type='checkbox' "; >- if ( oObj.date_due_overdue && can_renew ) { >+ if ( row.date_due_overdue && can_renew ) { > content += "checked='checked' "; > } >- content += "class='renew' id='renew_" + oObj.itemnumber + "' name='renew' value='" + oObj.itemnumber +"'/>" >+ content += "class='renew' id='renew_" + row.itemnumber + "' name='renew' value='" + row.itemnumber +"'/>" > + "</span>"; > > content += "<span class='renewals'>(" >- + RENEWALS_REMAINING.format( oObj.renewals_remaining, oObj.renewals_allowed ) >+ + RENEWALS_REMAINING.format( row.renewals_remaining, row.renewals_allowed ) > + ")</span>"; > } > >@@ -229,22 +229,22 @@ var mRenders = { > > return content; > }, >- checkin: function (oData, sType, oObj) { >- if (oObj.can_renew_error == "on_reserve") { >- return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + oObj.biblionumber + "'>" + ON_HOLD + "</a>"; >+ checkin: function (data, type, row) { >+ if (row.can_renew_error == "on_reserve") { >+ return "<a href='/cgi-bin/koha/reserve/request.pl?biblionumber=" + row.biblionumber + "'>" + ON_HOLD + "</a>"; > } else { >- return "<input type='checkbox' class='checkin' id='checkin_" + oObj.itemnumber + "' name='checkin' value='" + oObj.itemnumber +"'></input>"; >+ return "<input type='checkbox' class='checkin' id='checkin_" + row.itemnumber + "' name='checkin' value='" + row.itemnumber +"'></input>"; > } > }, >- export: function (oData, sType, oObj) { >- var s = "<input type='checkbox' name='itemnumbers' value='" + oObj.itemnumber + "' style='visibility:hidden;' />"; >+ export: function (data, type, row) { >+ var s = "<input type='checkbox' name='itemnumbers' value='" + row.itemnumber + "' style='visibility:hidden;' />"; > >- s += "<input type='checkbox' class='export' id='export_" + oObj.biblionumber + "' name='biblionumbers' value='" + oObj.biblionumber + "' />"; >+ s += "<input type='checkbox' class='export' id='export_" + row.biblionumber + "' name='biblionumbers' value='" + row.biblionumber + "' />"; > return s; > }, >- patron: function (oData, sType, oObj) { >- return "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=" + oObj.borrowernumber + "'>" >- + oObj.borrower.firstname + " " + oObj.borrower.surname + " (" + oObj.borrower.cardnumber + ")</a>" >+ patron: function (data, type, row) { >+ return "<a href='/cgi-bin/koha/members/moremember.pl?borrowernumber=" + row.borrowernumber + "'>" >+ + row.borrower.firstname + " " + row.borrower.surname + " (" + row.borrower.cardnumber + ")</a>" > } > }; > >@@ -432,14 +432,14 @@ $(document).ready(function() { > "sPaginationType": "four_button", > "dom": 'B<"clearfix"><"top pager"ilp>rt', > "aaSorting": [], >- "aoColumns": [ >+ "columns": [ > { >- "mData": "issued_today", >- "mRender": mRenders.groupOrder >+ "data": "issued_today", >+ "render": renderers.groupOrder > }, > { >- "mData": function (oObj) { >- if (oObj.issued_today) { >+ "data": function (row) { >+ if (row.issued_today) { > return "<strong>" + TODAYS_CHECKOUTS + "</strong>"; > } else { > return "<strong>" + PREVIOUS_CHECKOUTS + "</strong>"; >@@ -447,57 +447,82 @@ $(document).ready(function() { > } > }, > { >- "mData": "date_due", >- "mRender": mRenders.dateDueFormatted >+ "data": "date_due", >+ "render": { >+ "display": renderers.dateDueFormatted >+ } > }, > { >- "mData": "title", >- "mRender": mRenders.title >+ "data": "title", >+ "render": { >+ "display": renderers.title >+ } > }, > { >- "mData": "itemtype", >- "mRender": mRenders.itemtype >+ "data": "itemtype", >+ "render": { >+ "display": renderers.itemtype >+ } > }, >- { "mData": "location" }, >- { "mData": "homebranch" }, >+ { "data": "location" }, >+ { "data": "homebranch" }, > { >- "mData": "issuedate", >- "mRender": mRenders.issuedate >+ "data": "issuedate", >+ "render": { >+ "display": renderers.issuedate >+ } > }, > { >- "mData": "branchcode", >- "mRender": mRenders.branch >+ "data": "branchcode", >+ "render": { >+ "display": renderers.branch >+ } > }, >- { "mData": "itemcallnumber" }, >+ { "data": "itemcallnumber" }, > { >- "mData": "charge", >- "mRender": mRenders.charge, >- "bSortable": ServerSideCheckoutsTables ? false : true >+ "data": "charge", >+ "render": { >+ "display": renderers.charge >+ }, >+ "orderable": ServerSideCheckoutsTables ? false : true > }, > { >- "mData": "fine", >- "mRender": mRenders.fine, >- "bSortable": ServerSideCheckoutsTables ? false : true >+ "data": "fine", >+ "render": { >+ "display": renderers.fine >+ }, >+ "orderable": ServerSideCheckoutsTables ? false : true > }, > { >- "mData": "replacementprice", >- "mRender": mRenders.price, >- "bSortable": ServerSideCheckoutsTables ? false : true >+ "data": "price", >+ "render": { >+ "display": renderers.price >+ }, >+ "orderable": ServerSideCheckoutsTables ? false : true > }, > { >- "bVisible": AllowCirculate ? true : false, >- "mRender": mRenders.renew, >- "bSortable": false >+ "data": null, >+ "render": { >+ "display": renderers.renew >+ }, >+ "visible": AllowCirculate ? true : false, >+ "orderable": false > }, > { >- "bVisible": AllowCirculate ? true : false, >- "mRender": mRenders.checkin, >- "bSortable": false >+ "data": null, >+ "render": { >+ "display": renderers.checkin >+ }, >+ "visible": AllowCirculate ? true : false, >+ "orderable": false > }, > { >- "bVisible": exports_enabled ? true : false, >- "bSortable": false, >- "mRender": mRenders.export >+ "data": null, >+ "render": { >+ "display": renderers.export >+ }, >+ "visible": exports_enabled ? true : false, >+ "orderable": false > } > ], > "fnFooterCallback": function ( nRow, aaData, iStart, iEnd, aiDisplay ) { >@@ -564,42 +589,56 @@ $(document).ready(function() { > }, > "bPaginate": true, > "sPaginationType": "four_button", >- "aoColumns": [ >+ "columns": [ > { >- "mData": "date_due", >- "mRender": mRenders.dateDueFormatted >+ "data": "date_due", >+ "render": { >+ "display": renderers.dateDueFormatted >+ } > }, > { >- "mData": "title", >- "mRender": mRenders.title, >+ "data": "title", >+ "render": { >+ "display": renderers.title >+ } > }, >- { "mData": "itemtype" }, >- { "mData": "location" }, >+ { "data": "itemtype" }, >+ { "data": "location" }, > { >- "mData": "issuedate", >- "mRender": mRenders.issuedate >+ "data": "issuedate", >+ "render": { >+ "display": renderers.issuedate >+ } > }, >- { "mData": "branchname" }, >- { "mData": "itemcallnumber" }, >+ { "data": "branchname" }, >+ { "data": "itemcallnumber" }, > { >- "mData": "charge", >- "mRender": mRenders.charge, >- "bSortable": ServerSideCheckoutsTables ? false : true >+ "data": "charge", >+ "render": { >+ "display": renderers.charge >+ }, >+ "orderable": ServerSideCheckoutsTables ? false : true > }, > { >- "mData": "fine", >- "mRender": mRenders.fine, >- "bSortable": ServerSideCheckoutsTables ? false : true >+ "data": "fine", >+ "render": { >+ "display": renderers.fine >+ }, >+ "orderable": ServerSideCheckoutsTables ? false : true > }, > { >- "mData": "replacementprice", >- "mRender": mRenders.price, >- "bSortable": ServerSideCheckoutsTables ? false : true >+ "data": "replacementprice", >+ "render": { >+ "display": renderers.price >+ }, >+ "orderable": ServerSideCheckoutsTables ? false : true > }, > { >- "mData": "borrowernumber", >- "mRender": mRenders.patron, >- "bSortable": ServerSideCheckoutsTables ? false : true >+ "data": "borrowernumber", >+ "render": { >+ "display": renderers.patron >+ }, >+ "orderable": ServerSideCheckoutsTables ? false : true > } > ] > }, relatives_columns_settings); >-- >2.11.0
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 15219
:
45018
|
45036
|
45054
|
48107
|
50075
|
60071
|
60642
|
61158
|
61159
|
61545
|
61546
|
72905
|
72906
|
74224
|
74225
|
75911
|
75912
|
75913
|
78555
|
78556
|
78557
|
78558
|
78559
|
79195
|
79196
|
79197
|
79198
|
79199
|
92776
|
92777
|
92778
|
92779
|
92780
|
92781
|
93921