[Rt-commit] r5778 - rt/branches/3.4-RELEASE/html/Elements

ruz at bestpractical.com ruz at bestpractical.com
Wed Aug 16 18:56:58 EDT 2006


Author: ruz
Date: Wed Aug 16 18:56:58 2006
New Revision: 5778

Modified:
   rt/branches/3.4-RELEASE/html/Elements/ShowCustomFields

Log:
* display one value without html lists

Modified: rt/branches/3.4-RELEASE/html/Elements/ShowCustomFields
==============================================================================
--- rt/branches/3.4-RELEASE/html/Elements/ShowCustomFields	(original)
+++ rt/branches/3.4-RELEASE/html/Elements/ShowCustomFields	Wed Aug 16 18:56:58 2006
@@ -44,36 +44,42 @@
 %# 
 %# END BPS TAGGED BLOCK }}}
 <table>
-% my @entry_fields;
-% while (my $CustomField = $CustomFields->Next()) {
-% my $Values = $Object->CustomFieldValues($CustomField->Id);
+% while ( my $CustomField = $CustomFields->Next ) {
+% my $Values = $Object->CustomFieldValues( $CustomField->Id );
+% my $count = $Values->Count;
   <tr>
-    <td class="label"><%$CustomField->Name%>:</td>
+    <td class="label"><% $CustomField->Name %>:</td>
     <td class="value">
+% unless ( $count ) {
+<i><&|/l&>(no value)</&></i>
+% } elsif ( $count == 1 ) {
+%   $print_value->( $CustomField, $Values->First );
+% } else {
 <ul>
-% while (my $Value = $Values->Next()) {
-<li>
-% my $comp = "ShowCustomField".$CustomField->Type;
-% if ($m->comp_exists($comp)) {
-<& $comp, Object => $Value &>
-%   } else {
-<%$Value->Content%>
-%   }
-</li>
-% }
-% unless ($Values->Count()) {
-<li><i><&|/l&>(no value)</&></i></li>
+% while ( my $Value = $Values->Next ) {
+<li><% $print_value->( $CustomField, $Value ) |n %></li>
 % }
 </ul>
+% }
     </td>
   </tr>
 % }
 </table>
 <%INIT>
 my $CustomFields = $Object->CustomFields;
- $m->comp('/Elements/Callback', _CallbackName => 'MassageCustomFields',
+$m->comp('/Elements/Callback', _CallbackName => 'MassageCustomFields',
                                 CustomFields => $CustomFields);
 
+my $print_value = sub {
+    my ($cf, $value) = @_;
+    my $comp = "ShowCustomField". $cf->Type;
+    if ( $m->comp_exists( $comp ) ) {
+        $m->comp( $comp, Object => $value );
+    } else {
+        $m->print( $value->Content );
+    }
+};
+
 </%INIT>
 <%ARGS>
 $Object => undef


More information about the Rt-commit mailing list