[Rt-commit] rt branch, hierarchical-cf, updated. 7e430d0d46394bc0482a3db1f54a50d9d1334d09

Alex M Vandiver alexmv at bestpractical.com
Fri Sep 18 21:47:19 EDT 2009


The branch, hierarchical-cf has been updated
       via  7e430d0d46394bc0482a3db1f54a50d9d1334d09 (commit)
      from  fd95bc993fb71079c60b823f190cfc23a953d460 (commit)

Summary of changes:
 share/html/Admin/CustomFields/Modify.html       |    7 +------
 share/html/Admin/Elements/AddCustomFieldValue   |    9 +++++++--
 share/html/Admin/Elements/EditCustomFieldValues |   14 ++++++++++++--
 3 files changed, 20 insertions(+), 10 deletions(-)

- Log -----------------------------------------------------------------
commit 7e430d0d46394bc0482a3db1f54a50d9d1334d09
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Fri Sep 18 19:54:40 2009 -0400

    Refactor to not use /Elements/EditCustomField, but save O(n) queries

diff --git a/share/html/Admin/CustomFields/Modify.html b/share/html/Admin/CustomFields/Modify.html
index c61bd30..f75607a 100644
--- a/share/html/Admin/CustomFields/Modify.html
+++ b/share/html/Admin/CustomFields/Modify.html
@@ -196,11 +196,8 @@ if ( $ARGS{'Update'} && $id ne 'new' ) {
     # Update any existing values
     my $values = $CustomFieldObj->ValuesObj;
     while ( my $value = $values->Next ) {
-        my $prefix = $paramtag . "-" . $value->Id;
-        $ARGS{"$prefix-Category"} = delete $ARGS{$_}
-            for grep /^$prefix-BasedOn-\d+-Values$/, keys %ARGS;
         foreach my $attr qw(Name Description SortOrder Category) {
-            my $param = "$prefix-$attr";
+            my $param = join("-", $paramtag, $value->Id, $attr);
             next unless exists $ARGS{$param};
             next if ($value->$attr()||'') eq ($ARGS{$param}||'');
 
@@ -212,8 +209,6 @@ if ( $ARGS{'Update'} && $id ne 'new' ) {
 
     # Add any new values
     if ( defined $ARGS{ $paramtag ."-new-Name" } && length $ARGS{ $paramtag ."-new-Name" } ) {
-        $ARGS{"$paramtag-new-Category"} = delete $ARGS{$_}
-            for grep /^$paramtag-new-BasedOn-\d+-Values$/, keys %ARGS;
         my ($id, $msg) = $CustomFieldObj->AddValue(
             map { $_ => $ARGS{ $paramtag ."-new-$_" } }
                 qw( Name Description SortOrder Category )
diff --git a/share/html/Admin/Elements/AddCustomFieldValue b/share/html/Admin/Elements/AddCustomFieldValue
index e768e3e..9fe464a 100755
--- a/share/html/Admin/Elements/AddCustomFieldValue
+++ b/share/html/Admin/Elements/AddCustomFieldValue
@@ -66,8 +66,13 @@
 % if ( $CustomField->Type ne 'Combobox' ) {
 <td>
 % my $BasedOnObj = $CustomField->BasedOnObj;
-%   if ( $BasedOnObj and $BasedOnObj->id ) {
-<& /Elements/EditCustomField, CustomField => $BasedOnObj, Rows => 1, NamePrefix => "$paramtag-BasedOn-", Default => "" &>
+% if ( $BasedOnObj and $BasedOnObj->id ) {
+% my $Categories = $BasedOnObj->Values;
+<select name="<% $paramtag %>-Category" size="1">
+<option value=""><&|/l&>(no value)</&></option>
+% while (my $Value = $Categories->Next) {
+<option value="<% $Value->Name %>"><% $Value->Name %></option>
+% }
 %   } else {
 <input type="text" size="10" name="<% $paramtag %>-Category" value="" />
 %   }
diff --git a/share/html/Admin/Elements/EditCustomFieldValues b/share/html/Admin/Elements/EditCustomFieldValues
index cbb3c77..96610b2 100755
--- a/share/html/Admin/Elements/EditCustomFieldValues
+++ b/share/html/Admin/Elements/EditCustomFieldValues
@@ -71,8 +71,14 @@
 <td><input type="text" size="45" name="<% $paramtag %>-Description" value="<% $value->Description %>" /></td>
 % if ( $CustomField->Type ne 'Combobox' ) {
 <td>
-%   if ( $BasedOnObj->id ) {
-<& /Elements/EditCustomField, CustomField => $BasedOnObj, Rows => 1, NamePrefix => "$paramtag-BasedOn-", Default => $value->Category &>
+%   if ( $Categories ) {
+% my $selected = $value->Category;
+% $selected = '' unless defined $selected;
+<select name="<% $paramtag %>-Category" size="1">
+<option value=""<% $selected eq '' ? q[ selected="selected"] : "" |n%>><&|/l&>(no value)</&></option>
+% while (my $Value = $Categories->Next) {
+<option value="<% $Value->Name %>"<% $selected eq $Value->Name ? q[ selected="selected"] : "" |n%>><% $Value->Name %></option>
+% }
 %   } else {
 <input type="text" size="10" name="<% $paramtag %>-Category" value="<% $value->Category || '' %>" />
 %   }
@@ -88,6 +94,10 @@
 my $values = $CustomField->ValuesObj();
 
 my $BasedOnObj = $CustomField->BasedOnObj;
+my $Categories;
+if ($BasedOnObj and $BasedOnObj->Id) {
+    $Categories = $BasedOnObj->Values;
+}
 </%init>
 <%args>
 $CustomField => undef

-----------------------------------------------------------------------


More information about the Rt-commit mailing list