[Rt-commit] rt branch 5.0/update-tsv-header created. rt-5.0.2-57-gd4ddc501d8
BPS Git Server
git at git.bestpractical.com
Tue Jan 11 15:42:18 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/update-tsv-header has been created
at d4ddc501d83f95df97c0011686c1579bddf26914 (commit)
- Log -----------------------------------------------------------------
commit d4ddc501d83f95df97c0011686c1579bddf26914
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jan 11 22:45:31 2022 +0800
Update tests for the updated header in TSV output
The header changes are made in 13594ea381.
diff --git a/t/web/download_user_info.t b/t/web/download_user_info.t
index 79e381cbc3..7b2c776fa3 100644
--- a/t/web/download_user_info.t
+++ b/t/web/download_user_info.t
@@ -49,7 +49,7 @@ $agent->login( 'root' => 'password' );
$agent->follow_link_ok( { text => 'User Data' } );
my $user_info_tsv = <<EOF;
-id\tName\tEmailAddress\tRealName\tNickName\tOrganization\tHomePhone\tWorkPhone\tMobilePhone\tPagerPhone\tAddress1\tAddress2\tCity\tState\tZip\tCountry\tGecos\tLang\tTimezone\tFreeFormContactInfo
+id\tName\tEmail Address\tReal Name\tNick Name\tOrganization\tHome Phone\tWork Phone\tMobile Phone\tPager Phone\tAddress1\tAddress2\tCity\tState\tZip\tCountry\tGecos\tLang\tTimezone\tFree Form Contact Info
14\troot\troot\@localhost\tEnoch Root\t\t\t\t\t\t\t\t\t\t\t\t\troot\t\t\t
EOF
@@ -61,7 +61,7 @@ EOF
$agent->follow_link_ok( { text => 'User Transactions' } );
my $transaction_info_tsv = <<EOF;
-Ticket Id\tid\tCreated\tDescription\tOldValue\tNewValue\tContent
+Ticket Id\tid\tCreated\tDescription\tOld Value\tNew Value\tContent
1\t32\t$date_created\tTicket created\t\t\tThis transaction appears to have no content
1\t34\t$date_commented\tComments added\t\t\tTest - Comment
1\t35\t$date_correspondence\tCorrespondence added\t\t\tTest - Reply
@@ -75,7 +75,7 @@ EOF
$agent->follow_link_ok( { text => 'User Tickets' } );
my $ticket_info_tsv = <<EOF;
-id\tSubject\tStatus\tQueueName\tOwner\tPriority\tRequestors
+id\tSubject\tStatus\tQueue\tOwner\tPriority\tRequestor
1\tTest\topen\tGeneral\tNobody in particular\tLow\troot (Enoch Root)
EOF
commit 13594ea38133f9f8c16fc5c08f7df50886222428
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Jan 11 22:15:53 2022 +0800
Make header in TSV more consistent with the one in web UI
The noticable changes include:
* Bare custom field names are shown(without "CustomField.{}")
* Bare custom role names are shown(without "CustomRole.{}")
* Combined column names like EmailAddress are split(e.g. "Email Address")
diff --git a/share/html/Elements/TSVExport b/share/html/Elements/TSVExport
index 7d3e2563fd..7350346c43 100644
--- a/share/html/Elements/TSVExport
+++ b/share/html/Elements/TSVExport
@@ -72,11 +72,34 @@ my $should_loc = { map { $_ => 1 } qw(Status) };
my $col_entry = sub {
my $col = shift;
- # in tsv output, "#" is often a comment character but we use it for "id"
- delete $col->{title}
- if $col->{title} and $col->{title} =~ /^\s*#\s*$/;
+ my $attr = $col->{'attribute'} || $col->{'last_attribute'};
+ my $title = $col->{'title'};
+ my $loc_title;
+
+ if ( $attr && !defined $title ) {
+ # Mainly copied from /Elements/CollectionAsTable/Header
+
+ # if title is not defined then use defined attribute or last
+ # one we saw in the format
+ my $tmp = $m->comp( '/Elements/ColumnMap',
+ Class => $Class->can('ColumnMapClassName') ? $Class->ColumnMapClassName : 'RT__Ticket',
+ Name => $attr,
+ Attr => 'title',
+ );
+ $title = ProcessColumnMapValue( $tmp, Arguments => [ $attr ] );
+
+ # in case title is not defined in ColumnMap
+ # the following regex changes $attr like from "ReferredToBy" to "Referred To By"
+ $title = join ' ', split /(?<=[a-z])(?=[A-Z])/, $attr unless defined $title;
+ $loc_title = $attr =~ /^(?:CustomField|CF)\./ ? $title : loc($title);
+ }
+ else {
+ $loc_title = $title || '';
+ }
+
return {
- header => loc($col->{title} || $col->{attribute}),
+ # in tsv output, "#" is often a comment character but we use it for "id"
+ header => $loc_title =~ /^\s*#\s*$/ ? loc($attr) : $loc_title,
map => $m->comp(
"/Elements/ColumnMap",
Name => $col->{attribute},
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list