[Rt-commit] r9521 - in rt/branches/3.6-EXPERIMENTAL-CATEGORIES: .
lib/RT lib/RT/Interface
falcone at bestpractical.com
falcone at bestpractical.com
Wed Oct 31 22:23:18 EDT 2007
Author: falcone
Date: Wed Oct 31 22:23:18 2007
New Revision: 9521
Modified:
rt/branches/3.6-EXPERIMENTAL-CATEGORIES/ (props changed)
rt/branches/3.6-EXPERIMENTAL-CATEGORIES/html/Elements/EditCustomFieldSelect
rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/CustomField_Overlay.pm
rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/Interface/Web.pm
rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/ObjectCustomFieldValue_Overlay.pm
rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/Record.pm
Log:
r26015 at ketch: falcone | 2007-10-31 11:25:16 -0400
* handle setting the Category on ObjectCustomFieldValues properly
Modified: rt/branches/3.6-EXPERIMENTAL-CATEGORIES/html/Elements/EditCustomFieldSelect
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-CATEGORIES/html/Elements/EditCustomFieldSelect (original)
+++ rt/branches/3.6-EXPERIMENTAL-CATEGORIES/html/Elements/EditCustomFieldSelect Wed Oct 31 22:23:18 2007
@@ -106,7 +106,9 @@
% push @levels, $level;
% }
% }
- <option value="<%$value->Name%>"
+% # use <<>> as a bizarre joiner and we'll disallow it in category names
+% my $optionname = join(">>|<<",("Category", $category, $value->Name));
+ <option value="<%$optionname%>"
% if ($Values) {
<% ($Values->HasEntry($value->Name)||'') && ($$SelectedRef = 1) && 'SELECTED' %>
% } elsif ($Default) {
Modified: rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/CustomField_Overlay.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/CustomField_Overlay.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/CustomField_Overlay.pm Wed Oct 31 22:23:18 2007
@@ -1002,6 +1002,7 @@
LargeContent
ContentType
+ Category
=cut
@@ -1012,6 +1013,7 @@
Content => undef,
LargeContent => undef,
ContentType => undef,
+ Category => undef,
@_
);
my $obj = $args{'Object'} or return;
@@ -1059,7 +1061,8 @@
Content => $args{'Content'},
LargeContent => $args{'LargeContent'},
ContentType => $args{'ContentType'},
- CustomField => $self->Id
+ CustomField => $self->Id,
+ Category => $args{'Category'}
);
unless ($val) {
Modified: rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/Interface/Web.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/Interface/Web.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/Interface/Web.pm Wed Oct 31 22:23:18 2007
@@ -1324,20 +1324,29 @@
my %values_hash;
foreach my $value ( @values ) {
+ my $category;
+ $RT::Logger->error("value [$value]");
+ if ($value =~ /Category>>\|<<(.*?)>>\|<<(.*)/) {
+ $category = $1;
+ $value = $2;
+ }
+ $RT::Logger->error("category [$category] value [$value]");
# build up a hash of values that the new set has
- $values_hash{$value} = 1;
+ $values_hash{"$category-$value"} = 1;
next if $cf_values->HasEntry( $value );
my ( $val, $msg ) = $args{'Object'}->AddCustomFieldValue(
Field => $cf,
- Value => $value
+ Value => $value,
+ Category => $category
);
push ( @results, $msg );
}
$cf_values->RedoSearch;
while ( my $cf_value = $cf_values->Next ) {
- next if $values_hash{ $cf_value->Content };
+ $RT::Logger->error("value hash lookup ". ($cf_value->Category||'') . '-' . $cf_value->Content);
+ next if $values_hash{ ($cf_value->Category||'') . '-' . $cf_value->Content };
my ( $val, $msg ) = $args{'Object'}->DeleteCustomFieldValue(
Field => $cf,
Modified: rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/ObjectCustomFieldValue_Overlay.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/ObjectCustomFieldValue_Overlay.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/ObjectCustomFieldValue_Overlay.pm Wed Oct 31 22:23:18 2007
@@ -62,6 +62,7 @@
LargeContent => '',
ContentType => '',
ContentEncoding => '',
+ Category => '',
@_);
@@ -77,7 +78,7 @@
$self->_EncodeLOB( $args{'LargeContent'}, $args{'ContentType'} )
if ( $args{'LargeContent'} );
- $self->SUPER::Create(
+ my ($id, $msg) = $self->SUPER::Create(
CustomField => $args{'CustomField'},
ObjectType => $args{'ObjectType'},
ObjectId => $args{'ObjectId'},
@@ -85,10 +86,13 @@
Content => $args{'Content'},
LargeContent => $args{'LargeContent'},
ContentType => $args{'ContentType'},
- ContentEncoding => $args{'ContentEncoding'},
-);
+ ContentEncoding => $args{'ContentEncoding'});
+ if ($id) {
+ $self->SetCategory($args{'Category'});
+ }
+ return ($id, $msg);
}
@@ -256,7 +260,61 @@
return $self->_FillInTemplateURL($self->CustomFieldObj->IncludeContentForValue);
}
+=head2 Category
+
+Returns the Category Attribute for this Value
+If there is no Category, returns undef
+
+=cut
+
+sub Category {
+ my $self = shift;
+ my $attr = $self->FirstAttribute('Category') or return undef;
+ return $attr->Content;
+}
+
+
+=head2 SetCategory Category
+Sets the Category Attribute for this Value.
+Assumes there is only one Category per Value
+=cut
+
+sub SetCategory {
+ my $self = shift;
+ my $category = shift;
+ $self->SetAttribute(Name => 'Category', Content => $category);
+}
+
+=head2 DeleteCategory
+
+Removes the Category Attribute from this Value
+
+=cut
+
+sub DeleteCategory {
+ my $self = shift;
+ my $attr = $self->FirstAttribute('Category') or return (-1,'No Category Set');
+ return $attr->Delete;
+}
+
+=head2 Delete
+
+Make sure that the Category Attribute is deleted when we're deleted
+
+=cut
+
+sub Delete {
+ my $self = shift;
+
+ my ($result, $msg) = $self->DeleteCategory;
+
+ unless ($result) {
+ return ($result, $msg);
+ }
+
+ return $self->SUPER::Delete(@_);
+}
1;
Modified: rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/Record.pm
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/Record.pm (original)
+++ rt/branches/3.6-EXPERIMENTAL-CATEGORIES/lib/RT/Record.pm Wed Oct 31 22:23:18 2007
@@ -1600,6 +1600,7 @@
Field => undef,
Value => undef,
RecordTransaction => 1,
+ Category => undef,
@_
);
@@ -1671,6 +1672,7 @@
Content => $args{'Value'},
LargeContent => $args{'LargeContent'},
ContentType => $args{'ContentType'},
+ Category => $args{'Category'}
);
unless ($new_value_id) {
More information about the Rt-commit
mailing list