[Rt-commit] rt branch, 3.8-trunk, updated. 159268587285e931df81e64720b56ed64224b363
Ruslan Zakirov
ruz at bestpractical.com
Wed Sep 2 16:45:15 EDT 2009
The branch, 3.8-trunk has been updated
via 159268587285e931df81e64720b56ed64224b363 (commit)
via 161f4dc0debf2e0f7cf910a615169dfcc0e9eaab (commit)
via b956e86e19c465269ab6f471958248e8d8462a58 (commit)
via 16dc61a4eaef50ab9eb52655e5434a0a65663c19 (commit)
via 70e6b9e8d2319b51cc43cf462e09a40f790fd249 (commit)
from b998ecf5ab26bb3f9ab3b07a545e81cfd873abed (commit)
Summary of changes:
share/html/Elements/CollectionAsTable/Header | 23 +++++----
share/html/Elements/CollectionAsTable/ParseFormat | 30 ++++++------
share/html/Elements/CollectionAsTable/Row | 53 ++++++++++++---------
3 files changed, 57 insertions(+), 49 deletions(-)
- Log -----------------------------------------------------------------
commit 70e6b9e8d2319b51cc43cf462e09a40f790fd249
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Sep 3 00:15:58 2009 +0400
refactor ParseFormat
* allow users to define leading attribute. When a column consist of
multiple properties of a record then user can use attribute
to choose sorting by and other properties
* don't set title if it's not defined using /TITLE:..., so later
we can distinguish different situations
* define last_attribute
diff --git a/share/html/Elements/CollectionAsTable/ParseFormat b/share/html/Elements/CollectionAsTable/ParseFormat
index 7365598..f74b884 100644
--- a/share/html/Elements/CollectionAsTable/ParseFormat
+++ b/share/html/Elements/CollectionAsTable/ParseFormat
@@ -61,42 +61,42 @@ while ($Format =~ /($RE{delimited}{-delim=>qq{\'"}}|[{}\w.]+)/go) {
substr($col,-1,1) = "";
}
- my $colref = {
- title => '',
- };
+ my $colref = { };
$m->callback(CallbackName => 'PreColumn', Column => $colref, col => \$col);
- while ( $col =~ s{/(STYLE|CLASS|TITLE|ALIGN|SPAN):([^/]+)}{}i ) {
+ while ( $col =~ s{/(STYLE|CLASS|TITLE|ALIGN|SPAN|ATTRIBUTE):([^/]*)}{}i ) {
$colref->{ lc $1 } = $2;
}
+ $colref->{'last_attribute'} = $colref->{'attribute'};
unless ( length $col ) {
$colref->{'output'} = [];
- $colref->{'attribute'} = '';
+ $colref->{'last_attribute'} = $colref->{'attribute'} = ''
+ unless defined $colref->{'attribute'};
}
elsif ( $col =~ /__(.*?)__/io ) {
my @subcols;
while ( $col =~ s/^(.*?)__(.*?)__//o ) {
push ( @subcols, $1 ) if $1;
push ( @subcols, "__$2__" );
- $colref->{'attribute'} = $2;
+ $colref->{'last_attribute'} = $2;
}
- push ( @subcols, $col );
+ push @subcols, $col;
$colref->{'output'} = \@subcols;
+ $colref->{'attribute'} = $colref->{'last_attribute'}
+ unless defined $colref->{'attribute'};
+ }
+ elsif ( $col eq 'NEWLINE' || $col eq 'NBSP' ) {
+ $colref->{'title'} = $col;
}
else {
$colref->{'output'} = [ "__" . $col . "__" ];
- $colref->{'attribute'} = $col;
+ $colref->{'last_attribute'} = $col;
+ $colref->{'attribute'} = $col
+ unless defined $colref->{'attribute'};
}
- if ( !$colref->{'title'} && grep { /^__(.+?)__$/io }
- @{ $colref->{'output'} } )
- {
- $colref->{'title'} = $1;
- $colref->{'attribute'} = $1;
- }
-
$m->callback(CallbackName => 'PostColumn', Column => $colref, col => \$col);
push @Columns, $colref;
commit 16dc61a4eaef50ab9eb52655e5434a0a65663c19
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Sep 3 00:26:22 2009 +0400
fix defining colspan in format
space was never added right before colspan attribute
diff --git a/share/html/Elements/CollectionAsTable/Header b/share/html/Elements/CollectionAsTable/Header
index 89b1bcb..f43feb3 100644
--- a/share/html/Elements/CollectionAsTable/Header
+++ b/share/html/Elements/CollectionAsTable/Header
@@ -91,7 +91,7 @@ foreach my $col ( @Format ) {
$item += ($span || 1);
$m->out('<th class="collection-as-table"');
- $m->out('colspan="' . $m->interp->apply_escapes($span => 'h') . '"')
+ $m->out(' colspan="' . $m->interp->apply_escapes($span => 'h') . '"')
if $span;
$m->out('>');
commit b956e86e19c465269ab6f471958248e8d8462a58
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Sep 3 00:29:54 2009 +0400
refactor the way we render title of columns
if title parsed from format is not defined only then we
use column map to generate title
diff --git a/share/html/Elements/CollectionAsTable/Header b/share/html/Elements/CollectionAsTable/Header
index f43feb3..550ce9f 100644
--- a/share/html/Elements/CollectionAsTable/Header
+++ b/share/html/Elements/CollectionAsTable/Header
@@ -95,17 +95,18 @@ foreach my $col ( @Format ) {
if $span;
$m->out('>');
- $title =~ s/^__(.*)__$/$1/o;
- my $tmp = $m->comp( '/Elements/ColumnMap',
- Class => $Class,
- Name => $title,
- Attr => 'title',
- );
-
- unless( $tmp ) {
- $title = $m->comp('/Elements/ScrubHTML', Content => $title);
+ # if title is not defined then use defined attribute or last
+ # one we saw in the format
+ unless ( defined $col->{'title'} ) {
+ my $attr = $col->{'attribute'} || $col->{'last_attribute'};
+ my $tmp = $m->comp( '/Elements/ColumnMap',
+ Class => $Class,
+ Name => $attr,
+ Attr => 'title',
+ );
+ $title = ProcessColumnMapValue( $tmp, Arguments => [ $attr ] );
} else {
- $title = ProcessColumnMapValue( $tmp, Arguments => [ $title ] );
+ $title = $m->comp('/Elements/ScrubHTML', Content => $title);
}
if ( $AllowSorting and $col->{'attribute'}
commit 161f4dc0debf2e0f7cf910a615169dfcc0e9eaab
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Sep 3 00:33:55 2009 +0400
refactor rows rendering in result sets, return back performance
* if align, style or span is not set via format string only then
we lookup in column map and only once using attribute or
last_attribute
* use column map cache we have
diff --git a/share/html/Elements/CollectionAsTable/Row b/share/html/Elements/CollectionAsTable/Row
index 6e99d17..70babfc 100644
--- a/share/html/Elements/CollectionAsTable/Row
+++ b/share/html/Elements/CollectionAsTable/Row
@@ -79,11 +79,34 @@ foreach my $column (@Format) {
my $class = $column->{class} ? encode_entities( $column->{class}, q{'"&<>} ) : 'collection-as-table';
$m->out(qq{<td class="$class" });
- my $align = $column->{align};
- my $style = $column->{style};
- my $span = $column->{span};
+ my %attrs;
+ foreach my $attr (qw(style align)) {
+ if ( defined $column->{ $attr } ) {
+ $attrs{ $attr } = $column->{ $attr };
+ next;
+ }
- $item += ($span || 1);
+ # if it's not defined then use column map
+ unless ( exists $ColumnMap->{$col}{$attr} ) {
+ my $col = $column->{'attribute'} || $column->{'last_attribute'};
+ next unless $col;
+
+ $ColumnMap->{$col}{$attr} = $m->comp(
+ "/Elements/ColumnMap",
+ Class => $Class,
+ Name => $col,
+ Attr => $attr,
+ );
+ }
+ $attrs{ $attr } = ProcessColumnMapValue(
+ $ColumnMap->{$col}{$attr},
+ Arguments => [$record, $i],
+ Escape = 0,
+ );
+ }
+
+ $attrs{colspan} = $column->{span};
+ $item += ($attrs{'colspan'} || 1);
my @out;
foreach my $subcol ( @{ $column->{output} } ) {
@@ -93,18 +116,6 @@ foreach my $column (@Format) {
next;
}
- $style = $m->comp(
- "/Elements/ColumnMap",
- Class => $Class,
- Name => $col,
- Attr => 'style'
- );
- $align = $m->comp(
- "/Elements/ColumnMap",
- Class => $Class,
- Name => $col,
- Attr => 'align'
- );
unless ( exists $ColumnMap->{$col}{'value'} ) {
$ColumnMap->{$col}{'value'} = $m->comp(
"/Elements/ColumnMap",
@@ -116,17 +127,13 @@ foreach my $column (@Format) {
push @out, ProcessColumnMapValue(
$ColumnMap->{$col}{'value'},
- Arguments => [$record, $i]
+ Arguments => [$record, $i],
);
}
s/\n/<br \/>/gs for @out;
- $m->out( 'align="' . $m->interp->apply_escapes( $align => 'h' ) . '"' )
- if $align;
- $m->out( 'style="' . $m->interp->apply_escapes( $style => 'h' ) . '"' )
- if $style;
- $m->out( 'colspan="' . $m->interp->apply_escapes( $span => 'h' ) . '"' )
- if $span;
+ $m->out( $_ .'="'. $m->interp->apply_escapes( $attrs{$_} => 'h' ) .'"' )
+ foreach grep $attrs{$_}, qw(align style colspan);
$m->out('>');
$m->out(@out) if @out;
commit 159268587285e931df81e64720b56ed64224b363
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Thu Sep 3 00:42:50 2009 +0400
fix some typos in recent changes
diff --git a/share/html/Elements/CollectionAsTable/Row b/share/html/Elements/CollectionAsTable/Row
index 70babfc..fa7474b 100644
--- a/share/html/Elements/CollectionAsTable/Row
+++ b/share/html/Elements/CollectionAsTable/Row
@@ -87,8 +87,8 @@ foreach my $column (@Format) {
}
# if it's not defined then use column map
+ my $col = $column->{'attribute'} || $column->{'last_attribute'};
unless ( exists $ColumnMap->{$col}{$attr} ) {
- my $col = $column->{'attribute'} || $column->{'last_attribute'};
next unless $col;
$ColumnMap->{$col}{$attr} = $m->comp(
@@ -101,7 +101,7 @@ foreach my $column (@Format) {
$attrs{ $attr } = ProcessColumnMapValue(
$ColumnMap->{$col}{$attr},
Arguments => [$record, $i],
- Escape = 0,
+ Escape => 0,
);
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list