[Rt-devel] PATCH: silence warnings Elements/EditCustomFieldSelect

Jim Meyer purp at acm.org
Wed Nov 16 20:40:23 EST 2005


Hello!

On Wed, 2005-11-16 at 16:55, Jesse Vincent wrote:
> > While there's a bit of a refactor involved toward the end, this diff is
> > largely just a rework of the indents to be consistent (which makes it
> > easier to refactor =). I pulled a bunch of "... && ... && ... &&" stuff
> > out of a <%%> element around the 'SELECTED' line and collapsed the logic
> > a bit.
> 
> It's very hard to see what you actually changed with the big indent
> change. Could you do this as two layered patches?

Happily so, and I've corrected the subject's misplaced location, too.

Attached are the indent revision (EditCustomFieldSelect.indent.patch)
and the silencing of the warnings (EditCustomFieldSelect.fixes.patch).

Cheers!

--j
-- 
Jim Meyer, Geek at Large                                    purp at acm.org
-------------- next part --------------
--- local/html/Elements/EditCustomFieldSelect.indents	2005-11-16 17:32:12.000000000 -0800
+++ local/html/Elements/EditCustomFieldSelect	2005-11-16 16:22:15.000000000 -0800
@@ -86,9 +86,9 @@
 % my @levels;
 % while ($CFVs and my $value = $CFVs->Next ) {
 %     my $category = $value->Category;
 %     if (1) { # length $category) {
-%         my $level = (split(/:/, $category))[0];
+%         my $level = (split(/:/, $category || ''))[0];
 %         while (@levels) {
 %             if ($levels[-1] eq $level) {
 %                 undef $level;
 %                 last;
@@ -98,20 +98,22 @@
 %             } else {
 %                 last;
 %             }
 %         }
-%         if (length $level) {
+%         if ($level) {
 %             push @$CategoryRef, [0+ at levels, $level];
         <optgroup style="padding-left: <% @levels/2 %>em" label="<%$category%>">
 %             push @levels, $level;
 %         }
 %     }
         <option value="<%$value->Name%>" 
-% if ($Values) {
-            <% $Values->HasEntry($value->Name) && ($$SelectedRef = 1) && 'SELECTED' %>
-% } elsif ($Default) {
-            <% ($Default eq $value->Name) && ($$SelectedRef = 1) && 'SELECTED' %>
-% }
+%     if ($value->Name && $SelectedRef && ref($SelectedRef) && 
+%         $$SelectedRef == 1) {
+%         if (($Values && $Values->HasEntry($value->Name)) || 
+%             ($Default && ($Default eq $value->Name))) {
+        'SELECTED'
+%         }
+%     }
             ><% $value->Name%></option>
 % }
 % for (@levels) {
             </optgroup>
-------------- next part --------------
--- share/html/Elements/EditCustomFieldSelect	2005-08-18 19:39:27.000000000 -0700
+++ local/html/Elements/EditCustomFieldSelect.indents	2005-11-16 17:32:12.000000000 -0800
@@ -84,28 +84,28 @@
 % my $selected;
 % my $CFVs = $CustomField->Values;
 % my @levels;
 % while ($CFVs and my $value = $CFVs->Next ) {
-%       my $category = $value->Category;
-%       if (1) { # length $category) {
-%           my $level = (split(/:/, $category))[0];
-%           while (@levels) {
-%               if ($levels[-1] eq $level) {
-%                   undef $level;
-%                   last;
-%               } elsif (index($level, $levels[-1]) != 0) {
+%     my $category = $value->Category;
+%     if (1) { # length $category) {
+%         my $level = (split(/:/, $category))[0];
+%         while (@levels) {
+%             if ($levels[-1] eq $level) {
+%                 undef $level;
+%                 last;
+%             } elsif (index($level, $levels[-1]) != 0) {
         </optgroup>
-%                   pop @levels;
-%               } else {
-%                   last;
-%               }
-%           }
-%           if (length $level) {
-%               push @$CategoryRef, [0+ at levels, $level];
+%                 pop @levels;
+%             } else {
+%                 last;
+%             }
+%         }
+%         if (length $level) {
+%             push @$CategoryRef, [0+ at levels, $level];
         <optgroup style="padding-left: <% @levels/2 %>em" label="<%$category%>">
-%               push @levels, $level;
-%           }
-%       }
+%             push @levels, $level;
+%         }
+%     }
         <option value="<%$value->Name%>" 
 % if ($Values) {
             <% $Values->HasEntry($value->Name) && ($$SelectedRef = 1) && 'SELECTED' %>
 % } elsif ($Default) {


More information about the Rt-devel mailing list