[Rt-commit] rt branch, experimental/4.2/pluggable-cf-types, created. rt-4.0.1rc1-49-g603149d
Alex Vandiver
alexmv at bestpractical.com
Wed Nov 27 17:50:49 EST 2013
The branch, experimental/4.2/pluggable-cf-types has been created
at 603149d19e451069cb08f94dd51fe56d9dd66ee3 (commit)
- Log -----------------------------------------------------------------
commit 603149d19e451069cb08f94dd51fe56d9dd66ee3
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Wed Jun 22 15:42:04 2011 -0400
checkpoint
diff --git a/lib/RT/CustomField/Type.pm b/lib/RT/CustomField/Type.pm
index 6640ea0..e453c7d 100644
--- a/lib/RT/CustomField/Type.pm
+++ b/lib/RT/CustomField/Type.pm
@@ -118,6 +118,15 @@ sub Stringify {
}
}
+=head2 $class->StringifyForDisplay($ocfv)
+
+=cut
+
+sub StringifyForDisplay {
+ my ($self, $ocfv) = @_;
+ return $self->Stringify($ocfv);
+}
+
=head1 methods for web interaction
The mason component F<share/html/Elements/EditCustomField$TypeName>
diff --git a/lib/RT/CustomField/Type/DateTime.pm b/lib/RT/CustomField/Type/DateTime.pm
index b46e25e..220e808 100644
--- a/lib/RT/CustomField/Type/DateTime.pm
+++ b/lib/RT/CustomField/Type/DateTime.pm
@@ -123,4 +123,16 @@ sub SearchBuilderUIArguments {
});
}
+sub StringifyForDisplay {
+ my ($self, $ocfv) = @_;
+ my $content = $ocfv->_Value('Content');
+ my $DateObj = RT::Date->new( $ocfv->CurrentUser );
+ $DateObj->Set(
+ Format => 'ISO',
+ Value => $content,
+ );
+ return $DateObj->AsString;
+}
+
+
1;
diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm
index 9a485e5..e5fa62c 100644
--- a/lib/RT/Interface/Web.pm
+++ b/lib/RT/Interface/Web.pm
@@ -2233,12 +2233,7 @@ sub _ProcessObjectCustomFieldUpdates {
}
}
- if ( exists $_args->{'AddValue'} ) { # tested by t/web/cf_onqueue.t
- foreach my $value ($class->ValuesFromWeb( $cf, $_args->{'AddValue'} )) {
- $_add_ocfv->(Value => $value);
- }
- }
- elsif ( exists $_args->{'Value'} ) { # tested by t/web/cf_onqueue.t
+ if ( exists $_args->{'Value'} ) { # tested by t/web/cf_onqueue.t
foreach my $value ($class->ValuesFromWeb( $cf, $_args->{'Value'} )) {
$_add_ocfv->(Value => $value);
}
diff --git a/lib/RT/ObjectCustomFieldValue.pm b/lib/RT/ObjectCustomFieldValue.pm
index 43c21af..8594129 100644
--- a/lib/RT/ObjectCustomFieldValue.pm
+++ b/lib/RT/ObjectCustomFieldValue.pm
@@ -251,6 +251,18 @@ sub Content {
return $class->Stringify( $self );
}
+=head2 DisplayContent
+
+Returns this custom field's content, formatted for display to the user.
+
+=cut
+
+sub DisplayContent {
+ my $self = shift;
+ my $class = $self->CustomFieldObj->GetTypeClass;
+ return $class->StringifyForDisplay( $self );
+}
+
=head2 Object
Returns the object this value applies to
diff --git a/lib/RT/Record.pm b/lib/RT/Record.pm
index fcc7bed..7afadb5 100644
--- a/lib/RT/Record.pm
+++ b/lib/RT/Record.pm
@@ -1643,9 +1643,9 @@ sub _AddCustomFieldValue {
$values->RedoSearch if $i; # redo search if have deleted at least one value
}
- my ( $old_value, $old_content );
+ my ( $old_value );
if ( $old_value = $values->First ) {
- $old_content = $old_value->Content;
+ my $old_content = $old_value->Content;
$old_content = undef if defined $old_content && !length $old_content;
my $is_the_same = 1;
@@ -1698,35 +1698,16 @@ sub _AddCustomFieldValue {
);
}
- my $new_content = $new_value->Content;
- # For datetime, we need to display them in "human" format in result message
- #XXX TODO how about date without time?
- if ($cf->Type eq 'DateTime') {
- my $DateObj = RT::Date->new( $self->CurrentUser );
- $DateObj->Set(
- Format => 'ISO',
- Value => $new_content,
- );
- $new_content = $DateObj->AsString;
-
- if ( defined $old_content && length $old_content ) {
- $DateObj->Set(
- Format => 'ISO',
- Value => $old_content,
- );
- $old_content = $DateObj->AsString;
- }
- }
+ my $new_content = $new_value ? $new_value->DisplayContent : undef;
+ my $old_content = $old_value ? $old_value->DisplayContent : undef;
- unless ( defined $old_content && length $old_content ) {
+ if ( !defined $old_content or !length $old_content ) {
return ( $new_value_id, $self->loc( "[_1] [_2] added", $cf->Name, $new_content ));
- }
- elsif ( !defined $new_content || !length $new_content ) {
+ } elsif ( !defined $new_content or !length $new_content ) {
return ( $new_value_id,
$self->loc( "[_1] [_2] deleted", $cf->Name, $old_content ) );
- }
- else {
+ } else {
return ( $new_value_id, $self->loc( "[_1] [_2] changed to [_3]", $cf->Name, $old_content, $new_content));
}
@@ -1786,6 +1767,7 @@ sub DeleteCustomFieldValue {
return ( 0, $self->loc( "Custom field [_1] not found", $args{'Field'} ) );
}
+ my $old_value = $cf->DisplayContent;
my ( $val, $msg ) = $cf->DeleteValueForObject(
Object => $self,
Id => $args{'ValueId'},
@@ -1805,16 +1787,6 @@ sub DeleteCustomFieldValue {
return ( 0, $self->loc( "Couldn't create a transaction: [_1]", $Msg ) );
}
- my $old_value = $TransactionObj->OldValue;
- # For datetime, we need to display them in "human" format in result message
- if ( $cf->Type eq 'DateTime' ) {
- my $DateObj = RT::Date->new( $self->CurrentUser );
- $DateObj->Set(
- Format => 'ISO',
- Value => $old_value,
- );
- $old_value = $DateObj->AsString;
- }
return (
$TransactionId,
$self->loc(
-----------------------------------------------------------------------
More information about the rt-commit
mailing list