From 6cdcbd555d68416552ba1727af575d70f92e798d 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 7893568..b64b143 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -736,18 +736,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 85fbaf8..aaa3ed0 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 @@ -436,6 +436,7 @@
Request details
    + [% type = request.get_type %]
  1. [% request.borrowernumber | html %] @@ -461,7 +462,7 @@
  2. - [% request.getType | html %] + [% type ? type : 'N/A' | html %]
  3. @@ -570,7 +571,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 4912fa7..4f4aa84 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -125,6 +125,7 @@ [% FOREACH request IN requests %] [% status = request.status | html %] + [% type = request.get_type %] [% request.id | html %] @@ -134,7 +135,7 @@ [% IF request.metadata.Title %][% request.metadata.Title | html %][% ELSE %]N/A[% END %] [% request.backend | html %] - [% request.getType | html %] + [% type ? type : 'N/A' | html %] [% request.capabilities.$status.name | html %] [% request.placed | html %] [% request.updated | html %] @@ -153,6 +154,7 @@
    Details from library
      + [% type = request.get_type %]
    1. [% request.id | html %] @@ -177,7 +179,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 511bff4..97df6d8 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.1.4