[Rt-commit] rt branch, 4.2/more-extensible-txn-descriptions, created. rt-4.1.5-242-ga029f64
Thomas Sibley
trs at bestpractical.com
Fri Jan 4 22:45:20 EST 2013
The branch, 4.2/more-extensible-txn-descriptions has been created
at a029f6482270d7f1ec784897fbedd099884cec22 (commit)
- Log -----------------------------------------------------------------
commit a029f6482270d7f1ec784897fbedd099884cec22
Author: Thomas Sibley <trs at bestpractical.com>
Date: Fri Jan 4 19:34:46 2013 -0800
Add rope for more specific customization of transaction descriptions
This lets extensions, or core RT, define description handlers
which are specific to the transaction's ObjectType and Field, not just
Type. If Field is true, the following keys will be tried, in order:
ObjectType-Type-Field
Type-Field
ObjectType-Type
Type
If Field is false, only the last two will be tried.
This flexibility is especially important for the Set transaction type,
for example, which encompasses a wide range of Fields on many different
types of objects. Without the flexibility, adjusting Set from an
extension, or customizing it for a specific object type, requires
awkward wrapping of the existing code ref.
diff --git a/lib/RT/Transaction.pm b/lib/RT/Transaction.pm
index b6c7308..894eb46 100644
--- a/lib/RT/Transaction.pm
+++ b/lib/RT/Transaction.pm
@@ -634,7 +634,7 @@ sub BriefDescriptionAsHTML {
return ( $self->loc("Permission Denied") );
}
- my $type = $self->Type;
+ my ($objecttype, $type, $field) = ($self->ObjectType, $self->Type, $self->Field);
unless ( defined $type ) {
return $self->loc("No transaction type specified");
@@ -643,7 +643,7 @@ sub BriefDescriptionAsHTML {
my ($template, @params) = (
"Default: [_1]/[_2] changed from [_3] to [_4]", #loc
$type,
- $self->Field,
+ $field,
(
$self->OldValue
? "'" . $self->OldValue . "'"
@@ -656,8 +656,14 @@ sub BriefDescriptionAsHTML {
),
);
- if ( my $code = $_BriefDescriptions{$type} ) {
- ($template, @params) = $code->($self);
+ my @code = grep { ref eq 'CODE' } map { $_BriefDescriptions{$_} }
+ ( $field
+ ? ("$objecttype-$type-$field", "$type-$field")
+ : () ),
+ "$objecttype-$type", $type;
+
+ if (@code) {
+ ($template, @params) = $code[0]->($self);
}
unless ($template) {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list