Bugzilla – Attachment 109049 Details for
Bug 23166
Simplify code related to orders in catalogue/*detail.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23166: Call the methods from the .inc
Bug-23166-Call-the-methods-from-the-inc.patch (text/plain), 3.68 KB, created by
Joonas Kylmälä
on 2020-08-24 20:55:30 UTC
(
hide
)
Description:
Bug 23166: Call the methods from the .inc
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2020-08-24 20:55:30 UTC
Size:
3.68 KB
patch
obsolete
>From 8b5f5cad82ae5c5699b5eef42172ed3cf1ba78ad Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 5 May 2020 15:51:25 +0200 >Subject: [PATCH] Bug 23166: Call the methods from the .inc >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >We do not longer need the order variables to be passed from the >controllers, we can call the methods on the biblio object instead. > >There is something wrong with our ->search method and TT behaviours, it >is hard to retrieve object list in a scalar context. >If [% objects.method.count %] is called, objects.method will get the >first object of the list and count will explode (Koha::Object->count >does not exist) > >We need to force the call in a scalar context to retrieve an iterator >and prevent to fetch all the objects (we could have called all then >size, but it's not efficient) > >If adopted I will move the plugin on a separate bug report to ease >backport > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > Koha/Template/Plugin/Context.pm | 47 ++++++++++++++++++++++ > .../prog/en/includes/catalog-strings.inc | 8 +++- > 2 files changed, 53 insertions(+), 2 deletions(-) > create mode 100644 Koha/Template/Plugin/Context.pm > >diff --git a/Koha/Template/Plugin/Context.pm b/Koha/Template/Plugin/Context.pm >new file mode 100644 >index 0000000000..03c024b609 >--- /dev/null >+++ b/Koha/Template/Plugin/Context.pm >@@ -0,0 +1,47 @@ >+package Koha::Template::Plugin::Context; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use base qw( Template::Plugin ); >+ >+use C4::Context; >+ >+=head1 NAME >+ >+Koha::Template::Plugin::Scalar - Return object set in scalar context >+ >+=head1 SYNOPSIS >+ >+If you need to force scalar context when calling a method on a object set. >+Especially useful to call ->search >+ >+=cut >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+sub Scalar { >+ my ( $self, $set, $method ) = @_; >+ $set = $set->$method; >+ return $set; >+} >+ >+1; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc >index 3e77d6a998..78980c334e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/catalog-strings.inc >@@ -1,3 +1,4 @@ >+[% USE Context %] > <!-- catalog-strings.inc --> > <script> > /* Strings for translation */ >@@ -17,8 +18,11 @@ > var biblionumber = [% biblionumber | html %]; > var count = [% count | html %]; > var holdcount = [% holdcount | html %]; >- var countorders = [% countorders | html %]; >- var countdeletedorders = [% countdeletedorders | html %]; >+ [% SET orders = biblio.orders %] >+ [% SET current = Context.Scalar(orders, "filter_by_current") %] >+ [% SET cancelled = Context.Scalar(orders, "filter_by_cancelled") %] >+ var countorders = [% current.count || 0 | html %]; >+ var countdeletedorders = [% cancelled.count || 0 | html %]; > > /* provide Z3950 search points */ > function GetZ3950Terms(){ >-- >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 23166
:
90824
|
90825
|
90826
|
90827
|
90828
|
104365
|
104366
|
104367
|
104368
|
104369
|
104370
|
108991
|
108992
|
108993
|
108994
|
108995
|
108996
|
108997
|
108998
|
108999
|
109000
|
109001
|
109002
|
109019
|
109020
|
109021
|
109022
|
109023
|
109024
|
109025
|
109026
|
109037
|
109038
|
109039
|
109040
|
109041
|
109042
|
109043
|
109044
|
109045
|
109046
|
109047
|
109048
| 109049 |
109050
|
109058
|
109059