Skip to content

Commit

Permalink
Merge branch '5.0/update-tsv-header' into 5.0-trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Mar 25, 2024
2 parents 9b66970 + 610fd14 commit 783c845
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
11 changes: 11 additions & 0 deletions docs/UPGRADING-5.0
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,17 @@ This will result in new email being sent when it wasn't previously. We believe
this fixes the previous incorrect behavior. However, if you relied on this behavior,
and don't want the new email, you may need to modify your scrip configurations.

=item Spreadsheet (TSV) Download Format

The format of some column headers in spreadsheets (TSV files) downloaded from ticket
search results has been updated. Specifically custom fields and custom roles no
longer show "CustomField.{}" or "CustomRole.{}" in the header. Also, multi-word
headers like "EmailAddress" now have spaces added so the header will appear like
"Email Address".

This should make headers more readable, but if you have any automated processes that
parse the headers, you will need to update your parsing code.

=back

=cut
31 changes: 27 additions & 4 deletions share/html/Elements/TSVExport
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
6 changes: 3 additions & 3 deletions t/web/download_user_info.t
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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\t37\t$date_created\tTicket created\t\t\tThis transaction appears to have no content
1\t39\t$date_commented\tComments added\t\t\tTest - Comment
1\t40\t$date_correspondence\tCorrespondence added\t\t\tTest - Reply
Expand All @@ -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

Expand Down

0 comments on commit 783c845

Please sign in to comment.