Bug 20941: (QA follow-up) Fix return value of get_type, make templates more consistant
authorJosef Moravec <josef.moravec@gmail.com>
Thu, 4 Oct 2018 07:44:53 +0000 (07:44 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 31 Oct 2018 13:45:56 +0000 (13:45 +0000)
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Koha/Illrequest.pm
koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt
t/db_dependent/Illrequests.t

index 0ce24d2..4dc64ae 100644 (file)
@@ -748,7 +748,8 @@ Return a string representing the material type of this request or undef
 sub get_type {
     my ($self) = @_;
     my $attr = $self->illrequestattributes->find({ type => 'type'});
-    return $attr ? $attr->value : undef;
+    return if !$attr;
+    return $attr->value;
 };
 
 #### Illrequests Imports
index 63d5ae2..7c32678 100644 (file)
                                 </li>
                                 <li class="medium">
                                     <label class="medium">Request type:</label>
-                                    [% type ? type : 'N/A' | html %]
+                                    [% type || 'N/A' | html %]
                                 </li>
                                 <li class="cost">
                                     <label class="cost">Cost:</label>
                                 </div>
                                 <div class="medium">
                                     <span class="label medium">Request type:</span>
-                                    [% type = request.get_type  %]
-                                    [% type ? type : 'N/A' | html %]
+                                    % type = request.get_type %]
+                                    [% type || 'N/A' | html %]
                                 </div>
                                 <div class="cost">
                                     <span class="label cost">Cost:</span>
index 4374bfc..f92e350 100644 (file)
                                         [% IF request.metadata.Title %][% request.metadata.Title | html %][% ELSE %]<span>N/A</span>[% END %]
                                     </td>
                                     <td>[% request.backend | html %]</td>
-                                    <td>[% type ? type : '<span>N/A</span>' | html %]</td>
+                                    <td>[% type || 'N/A' | html %]</td>
                                     <td>[% request.capabilities.$status.name | html %]</td>
                                     <td><span title="[% request.placed | html %]">[% request.placed | $KohaDates %]</span></td>
                                     <td><span title="[% request.updated | html %]">[% request.updated | $KohaDates %]</span></td>
                                     </li>
                                     <li>
                                         <label for="medium">Request type:</label>
-                                        [% type ? type : '<span>N/A</span>' | html %]
+                                        [% type || 'N/A' | html %]
                                     </li>
                                     <li>
                                         <label for="placed">Request placed:</label>
index 13bba7d..1411eac 100644 (file)
@@ -85,8 +85,8 @@ subtest 'Basic object tests' => sub {
     is($illrq_obj->backend, $illrq->{backend},
        "Backend getter works.");
 
-    is($illrq_obj->get_type, '<span>N/A</span>',
-        'get_type() returns placeholder if no type is set');
+    is($illrq_obj->get_type, undef,
+        'get_type() returns undef if no type is set');
     $builder->build({
         source => 'Illrequestattribute',
         value  => {