From ed2ad1395db82ab80728983e376a093bd113c32b Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 18 Nov 2015 15:52:14 +0100 Subject: [PATCH] Bug 15219: Server-side processing and pagination on checkouts tables Some libraries have patrons with more than 1000 checkouts. Loading all of them at once can be very long, and sometimes can cause timeout errors. This patch prevent that by enabling server-side processing and pagination on checkouts tables. This affects patron's checkouts and patron's relatives' checkouts tables on pages circ/circulation.pl and members/moremember.pl. As server-side processing can be useless and cumbersome with small sets of data, a new system preference is introduced to control this behaviour (server-side processing is disabled by default). Additionally, this patch: - adds a switch to turn off and on row grouping (today's checkouts vs previous checkouts) (on by default) - adds "column settings" for relatives' checkouts tables - factorize some code that was duplicated across the two DataTables configurations (mDataProp) Test plan: 1. Find (or create) a patron that have at least 10 checkouts and where the relatives checkouts table contain at least 10 checkouts. 2. Go to the patron's detail page and check everything works fine in both tables (sorting, pagination, the data itself, ...) 3. Do the same on circulation page (circulation.pl) 4. Enable system preference ServerSideCheckoutsTable 5. Repeat steps 2 and 3 Signed-off-by: Eric Gosselin --- admin/columns_settings.yml | 71 +- .../data/mysql/atomicupdate/bug_15219.sql | 2 + installer/data/mysql/sysprefs.sql | 1 + .../plugins/jquery.dataTables.rowGrouping.js | 10 +- .../en/includes/checkouts-table-footer.inc | 2 +- .../prog/en/includes/checkouts-table.inc | 2 - .../prog/en/includes/checkouts.js.inc | 27 + .../en/includes/relatives-issues-table.inc | 2 - .../prog/en/includes/strings.inc | 1 + .../admin/preferences/circulation.pref | 6 + .../prog/en/modules/circ/circulation.tt | 12 +- .../prog/en/modules/members/moremember.tt | 12 +- koha-tmpl/intranet-tmpl/prog/js/checkouts.js | 882 +++++++++--------- svc/checkouts | 105 ++- 14 files changed, 579 insertions(+), 556 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_15219.sql create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/checkouts.js.inc diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index 3c5d2a9181..39844261bd 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -531,7 +531,7 @@ modules: moremember: issues-table: - - columnname: sort_order + columnname: group_order cannot_be_toggled: 1 cannot_be_modified: 1 is_hidden: 1 @@ -540,11 +540,6 @@ modules: cannot_be_toggled: 1 cannot_be_modified: 1 is_hidden: 1 - - - columnname: due_date_unformatted - cannot_be_toggled: 1 - cannot_be_modified: 1 - is_hidden: 1 - columnname: due_date - @@ -557,11 +552,6 @@ modules: columnname: location - columnname: homebranch - - - columnname: checkout_on_unformatted - cannot_be_toggled: 1 - cannot_be_modified: 1 - is_hidden: 1 - columnname: checkout_on - @@ -584,6 +574,29 @@ modules: columnname: export cannot_be_toggled: 1 cannot_be_modified: 1 + relatives-issues-table: + - + columnname: due_date + - + columnname: title + - + columnname: item_type + - + columnname: location + - + columnname: checkout_on + - + columnname: checkout_from + - + columnname: callno + - + columnname: charge + - + columnname: fine + - + columnname: price + - + columnname: patron holdshistory: holdshistory-table: @@ -744,7 +757,7 @@ modules: circulation: issues-table: - - columnname: sort_order + columnname: group_order cannot_be_toggled: 1 cannot_be_modified: 1 is_hidden: 1 @@ -753,11 +766,6 @@ modules: cannot_be_toggled: 1 cannot_be_modified: 1 is_hidden: 1 - - - columnname: due_date_unformatted - cannot_be_toggled: 1 - cannot_be_modified: 1 - is_hidden: 1 - columnname: due_date - @@ -770,11 +778,6 @@ modules: columnname: location - columnname: homebranch - - - columnname: checkout_on_unformatted - cannot_be_toggled: 1 - cannot_be_modified: 1 - is_hidden: 1 - columnname: checkout_on - @@ -797,6 +800,29 @@ modules: columnname: export cannot_be_toggled: 1 cannot_be_modified: 1 + relatives-issues-table: + - + columnname: due_date + - + columnname: title + - + columnname: item_type + - + columnname: location + - + columnname: checkout_on + - + columnname: checkout_from + - + columnname: callno + - + columnname: charge + - + columnname: fine + - + columnname: price + - + columnname: patron table_borrowers: - columnname: name @@ -815,6 +841,7 @@ modules: - columnname: phone is_hidden: 1 + returns: checkedintable: - diff --git a/installer/data/mysql/atomicupdate/bug_15219.sql b/installer/data/mysql/atomicupdate/bug_15219.sql new file mode 100644 index 0000000000..a186d45abe --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_15219.sql @@ -0,0 +1,2 @@ +INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) +VALUES ('ServerSideCheckoutsTables','0',NULL,'If enabled, use the "server-side processing" feature for checkouts tables. Can improve performance when there is a big number of checkouts to display.','YesNo'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 6ce6ee15e0..d033012942 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -548,6 +548,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('SendAllEmailsTo','',NULL,'All emails will be redirected to this email if it is not empty','free'), ('SeparateHoldings','0',NULL,'Separate current branch holdings from other holdings','YesNo'), ('SeparateHoldingsBranch','homebranch','homebranch|holdingbranch','Branch used to separate holdings','Choice'), +('ServerSideCheckoutsTables','0',NULL,'If enabled, use the "server-side processing" feature for checkouts tables. Can improve performance when there is a big number of checkouts per patron.','YesNo'), ('SessionRestrictionByIP','1','Check for change in remote IP address for session security. Disable only when remote IP address changes frequently.','','YesNo'), ('SessionStorage','mysql','mysql|Pg|tmp','Use database or a temporary file for storing session data','Choice'), ('ShelfBrowserUsesCcode','1','0','Use the item collection code when finding items for the shelf browser.','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.rowGrouping.js b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.rowGrouping.js index 126ff63357..12a88e4dba 100644 --- a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.rowGrouping.js +++ b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/jquery.dataTables.rowGrouping.js @@ -608,15 +608,15 @@ } - oTable.fnSetColumnVis(properties.iGroupingColumnIndex, !properties.bHideGroupingColumn); + oTable.fnSetColumnVis(properties.iGroupingColumnIndex, !properties.bHideGroupingColumn, false); if (properties.bCustomColumnOrdering) { - oTable.fnSetColumnVis(properties.iGroupingOrderByColumnIndex, !properties.bHideGroupingOrderByColumn); + oTable.fnSetColumnVis(properties.iGroupingOrderByColumnIndex, !properties.bHideGroupingOrderByColumn, false); } if (properties.iGroupingColumnIndex2 != -1) { - oTable.fnSetColumnVis(properties.iGroupingColumnIndex2, !properties.bHideGroupingColumn2); + oTable.fnSetColumnVis(properties.iGroupingColumnIndex2, !properties.bHideGroupingColumn2, false); } if (properties.bCustomColumnOrdering2) { - oTable.fnSetColumnVis(properties.iGroupingOrderByColumnIndex2, !properties.bHideGroupingOrderByColumn2); + oTable.fnSetColumnVis(properties.iGroupingOrderByColumnIndex2, !properties.bHideGroupingOrderByColumn2, false); } oTable.fnSettings().aoDrawCallback.push({ "fn": _fnDrawCallBackWithGrouping, @@ -687,4 +687,4 @@ }); }; -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc index 931d92f36c..cb4a84b57d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table-footer.inc @@ -1,6 +1,6 @@ - Totals: + Totals: diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc index 1276e70ab1..dc37a2de61 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts-table.inc @@ -13,13 +13,11 @@     Due date - Due date Title Item type Collection Location Home library -   Checked out on Checked out from Call no diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts.js.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts.js.inc new file mode 100644 index 0000000000..7ef8e914e0 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/checkouts.js.inc @@ -0,0 +1,27 @@ +[% USE Asset %] +[% USE Koha %] +[% USE raw %] + + + +[% Asset.js('js/checkouts.js') | $raw %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/relatives-issues-table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/relatives-issues-table.inc index 28addf4815..4dceda1364 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/relatives-issues-table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/relatives-issues-table.inc @@ -4,13 +4,11 @@ - - diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc index eb7bfda139..48da4c28ba 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc @@ -46,4 +46,5 @@ var CURRENT = _(" (current) "); var MSG_NO_ITEMTYPE = _("No itemtype"); var MSG_CHECKOUTS_BY_ITEMTYPE = _("Number of checkouts by item type"); + var GROUP_TODAYS_CHECKOUTS = _("Group today's checkouts"); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 199809f139..6e4c303ecf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -52,6 +52,12 @@ Circulation: asc: earliest to latest desc: latest to earliest - due date. + - + - pref: ServerSideCheckoutsTables + choices: + yes: Enable + no: Do not enable + - server-side processing on checkouts tables. It can improve performance when there is a big number of checkouts to display. - - pref: SpecifyDueDate choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt index 5fb4889bed..dd06f3583c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt @@ -986,30 +986,20 @@ [% INCLUDE 'timepicker.inc' %] [% Asset.js("lib/jquery/plugins/jquery.dataTables.rowGrouping.js") | $raw %] [% Asset.js("js/pages/circulation.js") | $raw %] - [% Asset.js("js/checkouts.js") | $raw %] + [% INCLUDE 'checkouts.js.inc' %] [% Asset.js("js/holds.js") | $raw %] [% Asset.js("js/circ-patron-search-results.js") | $raw %]
Due date (unformatted, hidden) Due date Title Item type Collection code LocationChecked out on (hidden, unformatted) Checked out on Checked out from Call no