From b2a980d5c6e68b7a3745d511b87071a718a05a9a Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Wed, 3 Oct 2018 12:05:40 +0100 Subject: [PATCH] Bug 20941: (follow-up) Carry out comment #4 advice - Switch getType -> get_type - get_type now returns a type or undef - Ternary now performed in template Signed-off-by: Josef Moravec --- Koha/Illrequest.pm | 10 +++++----- koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt | 6 ++++-- koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt | 6 ++++-- t/db_dependent/Illrequests.t | 8 ++++---- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 104df11683..0fab257942 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -724,18 +724,18 @@ sub getPrefix { || ""; # "the empty prefix" } -=head3 getType +=head3 get_type - my $type = $abstract->getType(); + my $type = $abstract->get_type(); -Return a string representing the material type of this request +Return a string representing the material type of this request or undef =cut -sub getType { +sub get_type { my ($self) = @_; my $attr = $self->illrequestattributes->find({ type => 'type'}); - return $attr ? $attr->value : 'N/A'; + return $attr ? $attr->value : undef; }; #### Illrequests Imports diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index f6c6a191f2..1157b0daf0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -412,6 +412,7 @@
Request details
    + [% type = request.get_type %]
  1. @@ -437,7 +438,7 @@
  2. - [% request.getType | html %] + [% type ? type : 'N/A' | html %]
  3. @@ -537,7 +538,8 @@
    Request type: - [% request.getType | html %] + [% type = request.get_type %] + [% type ? type : 'N/A' | html %]
    Cost: diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt index a94a168f3e..6345a6e6fc 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -124,11 +124,12 @@ [% FOREACH request IN requests %] [% status = request.status | html %] + [% type = request.get_type %] [% request.metadata.Author || 'N/A' | html %] [% request.metadata.Title || 'N/A' | html %] [% request.backend | html %] - [% request.getType | html %] + [% type ? type : 'N/A' | html %] [% request.capabilities.$status.name | html %] [% request.placed | html %] [% request.updated | html %] @@ -147,6 +148,7 @@
    Details from library
      + [% type = request.get_type %]
    1. [% request.backend | html %] @@ -167,7 +169,7 @@
    2. - [% request.getType | html %] + [% type ? type : 'N/A' | html %]
    3. diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Illrequests.t index 511bff492d..97df6d85f3 100644 --- a/t/db_dependent/Illrequests.t +++ b/t/db_dependent/Illrequests.t @@ -83,8 +83,8 @@ subtest 'Basic object tests' => sub { is($illrq_obj->backend, $illrq->{backend}, "Backend getter works."); - is($illrq_obj->getType, 'N/A', - 'getType() returns placeholder if no type is set'); + is($illrq_obj->get_type, 'N/A', + 'get_type() returns placeholder if no type is set'); $builder->build({ source => 'Illrequestattribute', value => { @@ -93,8 +93,8 @@ subtest 'Basic object tests' => sub { value => 'book' } }); - is($illrq_obj->getType, 'book', - 'getType() returns correct type if set'); + is($illrq_obj->get_type, 'book', + 'get_type() returns correct type if set'); isnt($illrq_obj->status, 'COMP', "ILL is not currently marked complete."); -- 2.11.0