[Rt-commit] rt branch, 3.8-trunk, updated. 06fb91c59e50cdb38af35b7c1f950a0ea46aeef0

Ruslan Zakirov ruz at bestpractical.com
Wed Aug 26 07:57:07 EDT 2009


The branch, 3.8-trunk has been updated
       via  06fb91c59e50cdb38af35b7c1f950a0ea46aeef0 (commit)
       via  9e94e652891d020243164e34cb4fb4a4d3953321 (commit)
       via  78307ec2127a29e5f96f40ecccf401ad7fd730ac (commit)
       via  83484ef9537d5abdc1a20462715be41f3b6807d3 (commit)
       via  e98a0c969d0877be0a6d93c34f1100b40bcd591c (commit)
      from  588f6208eefbe93a9f343c181bc9cdc2732b3945 (commit)

Summary of changes:
 lib/RT/Interface/Web.pm                           |   21 +++++++++++++++
 share/html/Elements/CollectionAsTable/Header      |   16 ++---------
 share/html/Elements/CollectionAsTable/ParseFormat |   25 ++++++-----------
 share/html/Elements/CollectionAsTable/Row         |   29 ++++++--------------
 share/html/Elements/RT__Ticket/ColumnMap          |    2 +-
 5 files changed, 43 insertions(+), 50 deletions(-)

- Log -----------------------------------------------------------------
commit e98a0c969d0877be0a6d93c34f1100b40bcd591c
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Aug 25 15:27:06 2009 +0400

    add ProcessColumnMapValue function

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 9ed75e0..8e6b6a0 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1577,6 +1577,26 @@ sub GetColumnMapEntry {
     return undef;
 }
 
+sub ProcessColumnMapValue {
+    my $value = shift;
+    my %args = ( Arguments => [], Escape => 1, @_ );
+
+    if ( ref $value ) {
+        if ( UNIVERSAL::isa( $value, 'CODE' ) ) {
+            my @tmp = $value->( @{ $args{'Arguments'} } );
+            return ProcessColumnMapValue( (@tmp > 1? \@tmp: $tmp[0]), %args );
+        }
+        elsif ( UNIVERSAL::isa( $value, 'ARRAY' ) ) {
+            return join '', map ProcessColumnMapValue($_, %args), @$value;
+        } elsif ( UNIVERSAL::isa( $value, 'SCALAR' ) ) {
+            return $$value;
+        }
+    }
+
+    return $m->interp->apply_escapes( $value, 'h' ) if $args{'Escape'};
+    return $value;
+}
+
 =head2 _load_container_object ( $type, $id );
 
 Instantiate container object for saving searches.

commit 83484ef9537d5abdc1a20462715be41f3b6807d3
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Aug 25 15:28:01 2009 +0400

    switch over ProcessColumnMapValue in important places

diff --git a/share/html/Elements/CollectionAsTable/Header b/share/html/Elements/CollectionAsTable/Header
index cfa2fc3..c188675 100644
--- a/share/html/Elements/CollectionAsTable/Header
+++ b/share/html/Elements/CollectionAsTable/Header
@@ -105,19 +105,7 @@ foreach my $col ( @Format ) {
     unless( $tmp ) {
         $title = $m->comp('/Elements/ScrubHTML', Content => $title);
     } else {
-        if ( UNIVERSAL::isa( $tmp, 'CODE' ) ) {
-            my @tmp = $tmp->( $title );
-            $title = @tmp > 1? \@tmp: shift @tmp || '';
-        } else {
-            $title = $tmp;
-        }
-        if( UNIVERSAL::isa( $title, 'ARRAY' ) ) {
-            $title = join '', map { ref $_? $$_: $m->interp->apply_escapes( $_, 'h' ) } @$title;
-        } elsif( UNIVERSAL::isa( $title, 'SCALAR' ) ) {
-            $title = $$title;
-        } else {
-            $title = $m->interp->apply_escapes( $title, 'h' );
-        }
+        $title = ProcessColumnMapVaue( $tmp, Arguments => [ $title ] );
     }
 
     if ( $AllowSorting and $col->{'attribute'}
@@ -129,6 +117,8 @@ foreach my $col ( @Format ) {
         )
       )
     {
+        $attr = ProcessColumnMapVaue( $attr, Arguments => [ $col->{'attribute'} ], Escape => 0 );
+
         my $new_order = 'ASC';
         $new_order = $Order[0] eq 'ASC'? 'DESC': 'ASC'
             if $OrderBy[0] && $OrderBy[0] eq $attr;
diff --git a/share/html/Elements/CollectionAsTable/Row b/share/html/Elements/CollectionAsTable/Row
index ebc2eb3..4966b95 100644
--- a/share/html/Elements/CollectionAsTable/Row
+++ b/share/html/Elements/CollectionAsTable/Row
@@ -87,12 +87,12 @@ foreach my $column (@Format) {
 
     my @out;
     foreach my $subcol ( @{ $column->{output} } ) {
-        unless ( $subcol =~ /^__(.*?)__$/ ) {
+        my ($col) = ($subcol =~ /^__(.*?)__$/);
+        unless ( $col ) {
             push @out, $subcol;
             next;
         }
 
-        my $col = $1;
         $style = $m->comp(
             "/Elements/ColumnMap",
             Class => $Class,
@@ -105,7 +105,7 @@ foreach my $column (@Format) {
             Name  => $col,
             Attr  => 'align'
         );
-        unless ( exists $ColumnMap->{$col} ) {
+        unless ( exists $ColumnMap->{$col}{'value'} ) {
             $ColumnMap->{$col} = $m->comp(
                 "/Elements/ColumnMap",
                 Class => $Class,
@@ -114,23 +114,12 @@ foreach my $column (@Format) {
             );
         }
 
-        my $value = $ColumnMap->{$col};
-
-        if ( ref $value ) {
-
-            # All HTML snippets are returned by the callback function
-            # as scalar references.  Data fetched from the objects are
-            # plain scalars, and needs to be escaped properly.
-            push @out, grep defined && length,
-                map { ref($_) ? $$_ : $m->interp->apply_escapes( $_ => 'h' ) }
-                $value->( $record, $i );
-        } elsif ( defined $value && length $value ) {
-
-            # Simple value; just escape it.
-            push @out, $m->interp->apply_escapes( $value => 'h' );
-        }
-        s/\n/<br \/>/gs for @out;
+        push @out, ProcessColumnMapValue(
+            $ColumnMap->{$col}{'value'},
+            Arguments => [$record, $i]
+        );
     }
+    s/\n/<br \/>/gs for @out;
 
     $m->out( 'align="'   . $m->interp->apply_escapes( $align => 'h' ) . '"' )
         if $align;

commit 78307ec2127a29e5f96f40ecccf401ad7fd730ac
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Tue Aug 25 15:28:35 2009 +0400

    allow sorting by CFs by clicking on header

diff --git a/share/html/Elements/RT__Ticket/ColumnMap b/share/html/Elements/RT__Ticket/ColumnMap
index c08796a..157e5e8 100644
--- a/share/html/Elements/RT__Ticket/ColumnMap
+++ b/share/html/Elements/RT__Ticket/ColumnMap
@@ -304,7 +304,7 @@ $COLUMN_MAP = {
     },
 
     CustomField => {
-        attribute => undef,
+        attribute => sub { return pop @_ },
         title     => sub { return pop @_ },
         value     => sub {
             # Display custom field contents, separated by newlines.

commit 9e94e652891d020243164e34cb4fb4a4d3953321
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Aug 26 03:20:42 2009 +0400

    merge together repeated code, handle empty column better
    
    Just merge allowed qualifiers together in one regexp.
    
    When column was empty we returned '____' instead of empty

diff --git a/share/html/Elements/CollectionAsTable/ParseFormat b/share/html/Elements/CollectionAsTable/ParseFormat
index 1228a09..7365598 100644
--- a/share/html/Elements/CollectionAsTable/ParseFormat
+++ b/share/html/Elements/CollectionAsTable/ParseFormat
@@ -67,22 +67,15 @@ while ($Format =~ /($RE{delimited}{-delim=>qq{\'"}}|[{}\w.]+)/go) {
 
     $m->callback(CallbackName => 'PreColumn', Column => $colref, col => \$col);
 
-    if ( $col =~ s!/STYLE:([^/]+)!!io ) {
-        $colref->{'style'} = $1;
+    while ( $col =~ s{/(STYLE|CLASS|TITLE|ALIGN|SPAN):([^/]+)}{}i ) {
+        $colref->{ lc $1 } = $2;
     }
-    if ( $col =~ s!/CLASS:([^/]+)!!io ) {
-        $colref->{'class'} = $1;
-    }
-    if ( $col =~ s!/TITLE:([^/]+)!!io ) {
-        $colref->{'title'} = $1;
-    }
-    if ( $col =~ s!/ALIGN:([^\/]+)!!io ) {
-        $colref->{'align'} = $1;
-    }
-    if ( $col =~ s!/SPAN:([^\/]+)!!io ) {
-        $colref->{'span'} = $1;
+
+    unless ( length $col ) {
+        $colref->{'output'} = [];
+        $colref->{'attribute'} = '';
     }
-    if ( $col =~ /__(.*?)__/io ) {
+    elsif ( $col =~ /__(.*?)__/io ) {
         my @subcols;
         while ( $col =~ s/^(.*?)__(.*?)__//o ) {
             push ( @subcols, $1 ) if $1;
@@ -90,10 +83,10 @@ while ($Format =~ /($RE{delimited}{-delim=>qq{\'"}}|[{}\w.]+)/go) {
             $colref->{'attribute'} = $2;
         }
         push ( @subcols, $col );
-        @{ $colref->{'output'} } = @subcols;
+        $colref->{'output'} = \@subcols;
     }
     else {
-        @{ $colref->{'output'} } = ( "__" . $col . "__" );
+        $colref->{'output'} = [ "__" . $col . "__" ];
         $colref->{'attribute'} = $col;
     }
     

commit 06fb91c59e50cdb38af35b7c1f950a0ea46aeef0
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Aug 26 03:24:34 2009 +0400

    fix some typos I made during implementing sorting by CF

diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 8e6b6a0..e5d9d19 100755
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -1588,7 +1588,8 @@ sub ProcessColumnMapValue {
         }
         elsif ( UNIVERSAL::isa( $value, 'ARRAY' ) ) {
             return join '', map ProcessColumnMapValue($_, %args), @$value;
-        } elsif ( UNIVERSAL::isa( $value, 'SCALAR' ) ) {
+        }
+        elsif ( UNIVERSAL::isa( $value, 'SCALAR' ) ) {
             return $$value;
         }
     }
diff --git a/share/html/Elements/CollectionAsTable/Header b/share/html/Elements/CollectionAsTable/Header
index c188675..89b1bcb 100644
--- a/share/html/Elements/CollectionAsTable/Header
+++ b/share/html/Elements/CollectionAsTable/Header
@@ -105,7 +105,7 @@ foreach my $col ( @Format ) {
     unless( $tmp ) {
         $title = $m->comp('/Elements/ScrubHTML', Content => $title);
     } else {
-        $title = ProcessColumnMapVaue( $tmp, Arguments => [ $title ] );
+        $title = ProcessColumnMapValue( $tmp, Arguments => [ $title ] );
     }
 
     if ( $AllowSorting and $col->{'attribute'}
@@ -117,7 +117,7 @@ foreach my $col ( @Format ) {
         )
       )
     {
-        $attr = ProcessColumnMapVaue( $attr, Arguments => [ $col->{'attribute'} ], Escape => 0 );
+        $attr = ProcessColumnMapValue( $attr, Arguments => [ $col->{'attribute'} ], Escape => 0 );
 
         my $new_order = 'ASC';
         $new_order = $Order[0] eq 'ASC'? 'DESC': 'ASC'
diff --git a/share/html/Elements/CollectionAsTable/Row b/share/html/Elements/CollectionAsTable/Row
index 4966b95..6e99d17 100644
--- a/share/html/Elements/CollectionAsTable/Row
+++ b/share/html/Elements/CollectionAsTable/Row
@@ -106,7 +106,7 @@ foreach my $column (@Format) {
             Attr  => 'align'
         );
         unless ( exists $ColumnMap->{$col}{'value'} ) {
-            $ColumnMap->{$col} = $m->comp(
+            $ColumnMap->{$col}{'value'} = $m->comp(
                 "/Elements/ColumnMap",
                 Class => $Class,
                 Name  => $col,

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


More information about the Rt-commit mailing list