[Rt-commit] r2946 - rt/branches/CHALDEA-EXPERIMENTAL/html/Elements

autrijus at bestpractical.com autrijus at bestpractical.com
Tue May 24 14:18:50 EDT 2005


Author: autrijus
Date: Tue May 24 14:18:49 2005
New Revision: 2946

Modified:
   rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/EditCustomFieldSelect
Log:
* first cut at two-selectbox style of cascading.

Modified: rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/EditCustomFieldSelect
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/EditCustomFieldSelect	(original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/EditCustomFieldSelect	Tue May 24 14:18:49 2005
@@ -43,11 +43,30 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
-      <select name="<%$NamePrefix%><%$CustomField->Id%>-Values"
+
+%# Build up the set of cascading select boxes as "guides"
+%# each one limits the options of the final one a bit
+%# (perhaps by tweaking the .display style?)
+%       my $selected = 0;
+%       my @category;
+%       my $id = $NamePrefix . $CustomField->Id;
+%       my $out = $m->scomp('SELF:options', %ARGS, SelectedRef => \$selected, CategoryRef => \@category);
+%       if (@category) {
+<script type="text/javascript" src="<%$RT::WebPath%>/NoAuth/cascaded.js"></script>
+%#      XXX - Hide this select from w3m?
+      <select onchange="filter_cascade('<% $id %>-Values', this.value)" name="<%$id%>-Category"
+        <option value="" <% !$selected && 'SELECTED' %>><&|/l&>(no value)</&></option>
+%           foreach my $cat (@category) {
+%               my ($depth, $name) = @$cat;
+        <option value="<% $name %>"><% '&nbsp;' x $depth |n %><%$name%></option>
+%           }
+      </select>
+%       }
+      <select name="<%$id%>-Values" id="<%$id%>-Values"
+%       if ($Multiple or !@category) {
         size="<%$Rows%>"
+%       }
         <% $Multiple && 'MULTIPLE' %>>
-%       my $selected = 0;
-%       my $out = $m->scomp('SELF:options', %ARGS, SelectedRef => \$selected);
         <option value="" <% !$selected && 'SELECTED' %>><&|/l&>(no value)</&></option>
 %       $m->out($out);
       </select>
@@ -68,7 +87,7 @@
 % while ($CFVs and my $value = $CFVs->Next ) {
 %       my $category = $value->Category;
 %       if (length $category) {
-%           my $level = (split(/\s/, $category))[0];
+%           my $level = (split(/:/, $category))[0];
 %           while (@levels) {
 %               if ($levels[-1] eq $level) {
 %                   undef $level;
@@ -81,7 +100,8 @@
 %               }
 %           }
 %           if (defined $level) {
-        <optgroup label="<% '&nbsp;' x @levels |n %><%$category%>">
+%               push @$CategoryRef, [0+ at levels, $level];
+        <optgroup style="padding-left: <% @levels/2 %>em" label="<%$category%>">
 %               push @levels, $level;
 %           }
 %       }
@@ -101,5 +121,6 @@
 $Default
 $Values
 $SelectedRef
+$CategoryRef
 </%args>
 </%method>


More information about the Rt-commit mailing list