[Rt-commit] rt branch, 4.2/preserve-format-select, created. rt-4.2.3-88-ge90bc99

Alex Vandiver alexmv at bestpractical.com
Tue Apr 22 15:32:20 EDT 2014


The branch, 4.2/preserve-format-select has been created
        at  e90bc99c4ea9771e1b4d9e7ae2e2c2fe0a5e58e3 (commit)

- Log -----------------------------------------------------------------
commit 89427df55797b52a94cca4e727e0ed34a2f4461e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Apr 22 15:23:43 2014 -0400

    Preserve the current selection in "Add Columns" and "Show Columns"
    
    The selection in "Show Columns" is approximate, and fails in the case
    where a column appears more than once.  Guaranteedly selecting the
    correct row would require re-deriving the new row number from the last
    button pushed -- which, while possible, would require repetition of
    code, and is unnecessary in most cases.
    
    Fixes I#16972.

diff --git a/share/html/Search/Elements/EditFormat b/share/html/Search/Elements/EditFormat
index dbd4148..235ae9f 100644
--- a/share/html/Search/Elements/EditFormat
+++ b/share/html/Search/Elements/EditFormat
@@ -59,7 +59,8 @@
 <td valign="top"><select size="6" name="SelectDisplayColumns" multiple="multiple">
 % my %seen;
 % foreach my $field ( grep !$seen{lc $_}++, @$AvailableColumns) {
-<option value="<% $field %>"><% $field =~ /^(?:CustomField|CF)\./ ? $field : loc($field) %></option>
+<option value="<% $field %>" <% $selected{$field} ? 'selected="selected"' : '' |n%>>\
+<% $field =~ /^(?:CustomField|CF)\./ ? $field : loc($field) %></option>
 % }
 </select></td>
 <td>
@@ -105,8 +106,10 @@
 <td valign="top">
 <select size="4" name="CurrentDisplayColumns">
 % my $i=0;
+% my $current = $ARGS{CurrentDisplayColumns} || ''; $current =~ s/^\d+>//;
 % foreach my $field ( @$CurrentFormat ) {
-<option value="<% $i++ %>><% $field->{Column} %>"><% $field->{Column} =~ /^(?:CustomField|CF)\./ ? $field->{Column} : loc( $field->{Column} ) %></option>
+<option value="<% $i++ %>><% $field->{Column} %>" <% $field->{Column} eq $current ? 'selected="selected"' : '' |n%>>\
+<% $field->{Column} =~ /^(?:CustomField|CF)\./ ? $field->{Column} : loc( $field->{Column} ) %></option>
 % }
 </select>
 <br />
@@ -120,6 +123,12 @@
 </tr>
 </table>
 
+<%init>
+my $selected = $ARGS{SelectDisplayColumns};
+$selected = [ $selected ] unless ref $selected;
+my %selected;
+$selected{$_}++ for grep {defined} @{ $selected };
+</%init>
 <%ARGS>
 $CurrentFormat => undef
 $AvailableColumns => undef

commit e90bc99c4ea9771e1b4d9e7ae2e2c2fe0a5e58e3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Apr 22 15:24:05 2014 -0400

    Warnings avoidance for when no "Show Columns" is selected

diff --git a/share/html/Search/Elements/BuildFormatString b/share/html/Search/Elements/BuildFormatString
index 66362fb..babe939 100644
--- a/share/html/Search/Elements/BuildFormatString
+++ b/share/html/Search/Elements/BuildFormatString
@@ -130,8 +130,7 @@ foreach my $field (@format) {
 
 if ( $RemoveCol ) {
     # we do this regex match to avoid a non-numeric warning
-    my ($index) = $CurrentDisplayColumns =~ /^(\d+)/;
-    my $column = $seen[$index];
+    my ($index) = ($CurrentDisplayColumns // '') =~ /^(\d+)/;
     if ( defined($index) ) {
         delete $seen[$index];
         my @temp = @seen;
@@ -196,7 +195,7 @@ elsif ( $AddCol ) {
     }
 }
 elsif ( $ColUp ) {
-    my $index = $CurrentDisplayColumns;
+    my ($index) = ($CurrentDisplayColumns // '') =~ /^(\d+)/;
     if ( defined $index && ( $index - 1 ) >= 0 ) {
         my $column = $seen[$index];
         $seen[$index]       = $seen[ $index - 1 ];
@@ -205,7 +204,7 @@ elsif ( $ColUp ) {
     }
 }
 elsif ( $ColDown ) {
-    my $index = $CurrentDisplayColumns;
+    my ($index) = ($CurrentDisplayColumns // '') =~ /^(\d+)/;
     if ( defined $index && ( $index + 1 ) < scalar @seen ) {
         my $column = $seen[$index];
         $seen[$index]       = $seen[ $index + 1 ];

-----------------------------------------------------------------------


More information about the rt-commit mailing list