[Rt-commit] rt branch, 4.2/more-about-requestor-extrainfo-with-tables, created. rt-4.1.6-284-gcb3b5a5
Kevin Falcone
falcone at bestpractical.com
Tue Feb 26 15:48:52 EST 2013
The branch, 4.2/more-about-requestor-extrainfo-with-tables has been created
at cb3b5a57b1e887fa28e648a8d35b7a0c9b06c86f (commit)
- Log -----------------------------------------------------------------
commit 4772f2a9b72f4a5580cb08fdc88ce4b91c95140e
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Feb 26 14:36:04 2013 -0500
Refactor ShowRequestorExtraInfo off into a /User/Elements component
This allows other code to borrow this scary Format parsing code that
spits out ColumnMap information in a vertical format.
This component now accepts the Format to pull from the config file and
the prefix to use on the css classes as arguments.
diff --git a/share/html/Ticket/Elements/ShowRequestorExtraInfo b/share/html/Ticket/Elements/ShowRequestorExtraInfo
index 0418a00..159a145 100644
--- a/share/html/Ticket/Elements/ShowRequestorExtraInfo
+++ b/share/html/Ticket/Elements/ShowRequestorExtraInfo
@@ -45,45 +45,7 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<div class="more-about-requestor-extra">
-% for my $column (@formats) {
-% my $title = $column->{title} || '';
-% my $attr = $column->{'attribute'} || $column->{'last_attribute'};
-% unless (defined $column->{title}) {
-% $title = $fetch_columnmap->($attr,'title',[$attr]);
-% }
-% $title = $m->comp('/Elements/ScrubHTML', Content => $title);
-<div class="more-about-requestor-extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
-<span class="label"><% loc($title) %></span>
-% my @out;
-% foreach my $subcol ( @{ $column->{output} } ) {
-% my ($col) = ($subcol =~ /^__(.*?)__$/);
-% unless ( $col ) {
-% push @out, $subcol;
-% next;
-% }
-% push @out, $fetch_columnmap->($col, 'value', [$Requestor]);
-% }
-% @out = grep { defined $_ and length $_ } @out;
-<span class="value"><% join(' ', at out) %></span>
-</div>
-% }
-</div>
-<%INIT>
-my $format = RT->Config->Get('MoreAboutRequestorExtraInfo');
-my @formats = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $format);
-
-my $fetch_columnmap = sub {
- my ($name, $attr, $arguments) = @_;
- my $tmp = $m->comp( '/Elements/ColumnMap',
- Class => $Class,
- Name => $name,
- Attr => $attr,
- );
- return ProcessColumnMapValue( $tmp, Arguments => $arguments, Escape => 0 );
-};
-</%INIT>
+<& /User/Elements/UserInfo, User => $Requestor, FormatConfig => 'MoreAboutRequestorExtraInfo', ClassPrefix => 'more-about-requestor' &>
<%ARGS>
$Requestor => undef
-$Class => 'RT__User';
</%ARGS>
diff --git a/share/html/Ticket/Elements/ShowRequestorExtraInfo b/share/html/User/Elements/UserInfo
similarity index 89%
copy from share/html/Ticket/Elements/ShowRequestorExtraInfo
copy to share/html/User/Elements/UserInfo
index 0418a00..c1322b8 100644
--- a/share/html/Ticket/Elements/ShowRequestorExtraInfo
+++ b/share/html/User/Elements/UserInfo
@@ -45,7 +45,7 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<div class="more-about-requestor-extra">
+<div class="<% $ClassPrefix %>-extra">
% for my $column (@formats) {
% my $title = $column->{title} || '';
% my $attr = $column->{'attribute'} || $column->{'last_attribute'};
@@ -53,7 +53,7 @@
% $title = $fetch_columnmap->($attr,'title',[$attr]);
% }
% $title = $m->comp('/Elements/ScrubHTML', Content => $title);
-<div class="more-about-requestor-extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
+<div class="<% $ClassPrefix %> extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
<span class="label"><% loc($title) %></span>
% my @out;
% foreach my $subcol ( @{ $column->{output} } ) {
@@ -62,7 +62,7 @@
% push @out, $subcol;
% next;
% }
-% push @out, $fetch_columnmap->($col, 'value', [$Requestor]);
+% push @out, $fetch_columnmap->($col, 'value', [$User]);
% }
% @out = grep { defined $_ and length $_ } @out;
<span class="value"><% join(' ', at out) %></span>
@@ -70,7 +70,9 @@
% }
</div>
<%INIT>
-my $format = RT->Config->Get('MoreAboutRequestorExtraInfo');
+return unless $FormatConfig;
+my $format = RT->Config->Get($FormatConfig);
+return unless $format;
my @formats = $m->comp('/Elements/CollectionAsTable/ParseFormat', Format => $format);
my $fetch_columnmap = sub {
@@ -84,6 +86,8 @@ my $fetch_columnmap = sub {
};
</%INIT>
<%ARGS>
-$Requestor => undef
+$User => undef
$Class => 'RT__User';
+$FormatConfig => undef,
+$ClassPrefix => undef,
</%ARGS>
commit cb3b5a57b1e887fa28e648a8d35b7a0c9b06c86f
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Feb 26 15:39:01 2013 -0500
Switch from divs/spans to tables
I'm not sure why I wrote this with divs originally but it leads to
really horrible formatting once you start showing more than 1 or 2 extra
pieces of information below the user.
diff --git a/share/html/User/Elements/UserInfo b/share/html/User/Elements/UserInfo
index c1322b8..b5bd68b 100644
--- a/share/html/User/Elements/UserInfo
+++ b/share/html/User/Elements/UserInfo
@@ -45,7 +45,7 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-<div class="<% $ClassPrefix %>-extra">
+<table class="<% $ClassPrefix %>-extra">
% for my $column (@formats) {
% my $title = $column->{title} || '';
% my $attr = $column->{'attribute'} || $column->{'last_attribute'};
@@ -53,8 +53,8 @@
% $title = $fetch_columnmap->($attr,'title',[$attr]);
% }
% $title = $m->comp('/Elements/ScrubHTML', Content => $title);
-<div class="<% $ClassPrefix %> extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
-<span class="label"><% loc($title) %></span>
+<tr class="<% $ClassPrefix %> extra-field <% $fetch_columnmap->($attr,'attribute',[$attr]) %>" >
+<td class="label"><% loc($title) %></td>
% my @out;
% foreach my $subcol ( @{ $column->{output} } ) {
% my ($col) = ($subcol =~ /^__(.*?)__$/);
@@ -65,10 +65,10 @@
% push @out, $fetch_columnmap->($col, 'value', [$User]);
% }
% @out = grep { defined $_ and length $_ } @out;
-<span class="value"><% join(' ', at out) %></span>
-</div>
+<td class="value"><% join(' ', at out) %></td>
+</tr>
% }
-</div>
+</table>
<%INIT>
return unless $FormatConfig;
my $format = RT->Config->Get($FormatConfig);
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list