From 7cecc27e0152e310a7286ddd9bab96597b91891e 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 Signed-off-by: Nick Clemens --- Koha/Illrequest.pm | 10 +++++----- .../intranet-tmpl/prog/en/modules/ill/ill-requests.tt | 6 ++++-- .../opac-tmpl/bootstrap/en/modules/opac-illrequests.tt | 8 +++++--- t/db_dependent/Illrequests.t | 8 ++++---- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index a46158fa50..0ce24d2b32 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -737,18 +737,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 a8ed6ebb07..63d5ae212f 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 @@ -424,6 +424,7 @@
Request details
    + [% type = request.get_type %]
  1. [% request.borrowernumber | html %] @@ -449,7 +450,7 @@
  2. - [% request.getType | html %] + [% type ? type : 'N/A' | html %]
  3. @@ -558,7 +559,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 e9ad1b9ff7..4374bfcd4f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt @@ -125,7 +125,8 @@ [% FOREACH request IN requests %] - [% status = request.status %] + [% status = request.status | html %] + [% type = request.get_type %] [% request.id | html %] @@ -135,7 +136,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 | $KohaDates %] [% request.updated | $KohaDates %] @@ -154,6 +155,7 @@
    Details from library
      + [% type = request.get_type %]
    1. [% request.id | html %] @@ -178,7 +180,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 3f7ba1e9e6..13bba7d3a3 100644 --- a/t/db_dependent/Illrequests.t +++ b/t/db_dependent/Illrequests.t @@ -85,8 +85,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 => { @@ -95,8 +95,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.39.5