[Rt-commit] rt branch, 4.6/simplified-changes-in-ticket-history, created. rt-4.4.2-96-g078c3f1ca
? sunnavy
sunnavy at bestpractical.com
Wed Apr 25 15:46:52 EDT 2018
The branch, 4.6/simplified-changes-in-ticket-history has been created
at 078c3f1cabc36f37747fd89f5cd74ea592d2fcea (commit)
- Log -----------------------------------------------------------------
commit 078c3f1cabc36f37747fd89f5cd74ea592d2fcea
Author: sunnavy <sunnavy at bestpractical.com>
Date: Thu Apr 26 03:05:46 2018 +0800
Simplify custom field changes in ticket history
Especially for fields with long values, "... changed to ..." is not
quite easy to parse. This change shows a shortcut version by default,
while also provides the full version in a hidden div, of which the
visibility could be toggled via the "Details" link.
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index 076b19395..388dbc330 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1774,6 +1774,7 @@ our %TRANSACTION_CLASSIFICATION = (
AttachmentTruncate => 'attachment-truncate',
AttachmentDrop => 'attachment-drop',
AttachmentError => 'error',
+ CustomField => 'custom-field',
__default => 'other',
);
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index bddf36b22..86b1ddeed 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -1004,17 +1004,10 @@ sub _CanonicalizeRoleName {
}
my $new = $self->NewValue;
- my $old = $self->OldValue;
if ( $cf ) {
if ( $cf->Type eq 'DateTime' ) {
- if ($old) {
- my $date = RT::Date->new( $self->CurrentUser );
- $date->Set( Format => 'ISO', Value => $old );
- $old = $date->AsString;
- }
-
if ($new) {
my $date = RT::Date->new( $self->CurrentUser );
$date->Set( Format => 'ISO', Value => $new );
@@ -1022,16 +1015,6 @@ sub _CanonicalizeRoleName {
}
}
elsif ( $cf->Type eq 'Date' ) {
- if ($old) {
- my $date = RT::Date->new( $self->CurrentUser );
- $date->Set(
- Format => 'unknown',
- Value => $old,
- Timezone => 'UTC',
- );
- $old = $date->AsString( Time => 0, Timezone => 'UTC' );
- }
-
if ($new) {
my $date = RT::Date->new( $self->CurrentUser );
$date->Set(
@@ -1044,15 +1027,7 @@ sub _CanonicalizeRoleName {
}
}
- if ( !defined($old) || $old eq '' ) {
- return ("[_1] [_2] added", $field, $new); #loc()
- }
- elsif ( !defined($new) || $new eq '' ) {
- return ("[_1] [_2] deleted", $field, $old); #loc()
- }
- else {
- return ("[_1] [_2] changed to [_3]", $field, $old, $new); #loc()
- }
+ return ("[_1]: [_2]", $field, $new // $self->loc('(no value)')); #loc()
},
Untake => sub {
my $self = shift;
@@ -1749,6 +1724,63 @@ sub ACLEquivalenceObjects {
}
+=head2 CustomFieldValueDescriptions
+
+For transactions with Field=CustomField, this method returns the descriptions
+of OldValue and NewValue. Right now it just converts Date/DateTime custom
+field values to the preferred format of current user.
+
+It returns an empty list for other transactions.
+
+=cut
+
+sub CustomFieldValueDescriptions {
+ my $self = shift;
+ return unless $self->Field;
+
+ my $cf = RT::CustomField->new( $self->CurrentUser );
+ $cf->SetContextObject( $self->Object );
+ $cf->Load( $self->Field );
+ return unless $cf->id;
+
+ my $old = $self->OldValue;
+ my $new = $self->NewValue;
+ if ( $cf->Type eq 'DateTime' ) {
+ if ( $old ) {
+ my $date = RT::Date->new( $self->CurrentUser );
+ $date->Set( Format => 'ISO', Value => $old );
+ $old = $date->AsString;
+ }
+
+ if ( $new ) {
+ my $date = RT::Date->new( $self->CurrentUser );
+ $date->Set( Format => 'ISO', Value => $new );
+ $new = $date->AsString;
+ }
+ }
+ elsif ( $cf->Type eq 'Date' ) {
+ if ( $old ) {
+ my $date = RT::Date->new( $self->CurrentUser );
+ $date->Set(
+ Format => 'unknown',
+ Value => $old,
+ Timezone => 'UTC',
+ );
+ $old = $date->AsString( Time => 0, Timezone => 'UTC' );
+ }
+
+ if ( $new ) {
+ my $date = RT::Date->new( $self->CurrentUser );
+ $date->Set(
+ Format => 'unknown',
+ Value => $new,
+ Timezone => 'UTC',
+ );
+ $new = $date->AsString( Time => 0, Timezone => 'UTC' );
+ }
+ }
+ return ( $old // $self->loc( '(no value)' ), $new // $self->loc( '(no value)' ) );
+}
diff --git a/share/html/Elements/ShowTransaction b/share/html/Elements/ShowTransaction
index bae9156cd..911aed9df 100644
--- a/share/html/Elements/ShowTransaction
+++ b/share/html/Elements/ShowTransaction
@@ -69,6 +69,17 @@
</div>
<div class="content">
+% if ( $txn_type eq 'CustomField' ) {
+ <div class="cf-details hidden" id="<% 'txn-' . $Transaction->id . '-cf-details' %>">
+% my ( $old, $new ) = $Transaction->CustomFieldValueDescriptions;
+ <div class="old-value">
+ <span class="label"><&|/l&>Old Value</&>:</span> <span class="value"><% $old %></span>
+ </div>
+ <div class="new-value">
+ <span class="label"><&|/l&>New Value</&>:</span> <span class="value"><% $new %></span>
+ </div>
+ </div>
+% }
<%PERL>
$m->comp('/Elements/ShowCustomFields', Object => $Transaction, HideEmpty => 1 ) if $HasTxnCFs;
$m->comp(
@@ -159,7 +170,15 @@ if ( $txn_type =~ /EmailRecord$/ ) {
$ShowBody = 0;
}
-
+elsif ( $txn_type eq 'CustomField' ) {
+ push @actions, {
+ title => loc('Details'),
+ hint => loc('Toggle visibility'),
+ class => 'cf-details',
+ onclick => sprintf( "return hideshow('txn-%s-cf-details')", $Transaction->id ),
+ path => 'javascript:;',
+ };
+}
# If the transaction has anything attached to it at all
elsif ( %$Attachments && $ShowActions ) {
my %has_right = map {
@@ -258,6 +277,14 @@ if ( @actions ) {
? ' class="'. $i->apply_escapes( $a->{'class'}, 'h' ) .'"'
: ''
)
+ . ($a->{'onclick'}
+ ? ' onclick="'. $i->apply_escapes( $a->{'onclick'}, 'h' ) .'"'
+ : ''
+ )
+ . ($a->{'hint'}
+ ? ' title="'. $i->apply_escapes( $a->{'hint'}, 'h' ) .'"'
+ : ''
+ )
.'>'. $i->apply_escapes( $a->{'title'}, 'h' ) .'</a>'
;
}
diff --git a/share/static/css/base/history.css b/share/static/css/base/history.css
index 21ac20e85..f7b83baf8 100644
--- a/share/static/css/base/history.css
+++ b/share/static/css/base/history.css
@@ -82,6 +82,7 @@ div.history-container {
}
+.transaction div.cf-details,
.transaction .messagebody {
font-size: 1em;
padding-left: 1em;
@@ -147,6 +148,7 @@ padding-right:0.25em;
.transaction.message .type { background: #069; }
.transaction.reminders .type { background: #369; }
.transaction.other .type { background: #abc; }
+.transaction.custom-field .type { background: #abc; }
.transaction.error .type { background: #abc; }
.transaction.attachment-truncate .type, .transaction.attachment-drop .type { background-color: #abc; }
@@ -163,3 +165,21 @@ padding-right:0.25em;
.transaction .message-header-value.verify.done.trust-FULL { color: #060; }
.transaction .message-header-value.verify.done.trust-FULLY { color: #060; }
.transaction .message-header-value.verify.done.trust-ULTIMATE { color: #060; }
+
+.transaction.custom-field .cf-details .label {
+ text-align: right;
+ display: inline-block;
+ min-width: 6em;
+}
+
+.transaction.custom-field .cf-details .value {
+ display: inline-block;
+}
+
+.transaction.custom-field .metadata .description {
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ max-width: 50%;
+ display: inline-block;
+}
diff --git a/share/static/css/rudder/history.css b/share/static/css/rudder/history.css
index b9949c39e..aa39bad75 100644
--- a/share/static/css/rudder/history.css
+++ b/share/static/css/rudder/history.css
@@ -78,3 +78,7 @@ div.history-container {
color: #ccc;
display: block;
}
+
+.transaction.custom-field div.content {
+ margin-left: 3em;
+}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list