1 % unless ( $opt{'js_only'} ) {
2 <% include( 'select.html',
4 'options' => \@conditions,
5 'labels' => { '' => 'Select Condition' },
6 'onchange' => $key.'_changed',
9 <% include( 'select.html',
10 'name' => $opt{'field'}.'_op',
16 <% include( 'input-text.html',
17 'name' => $opt{'field'}.'_params',
18 'id' => $key.'_params',
19 #XXX curr value... anything else?
22 % # could add more UI sugar for date/time ranges, string #lists, etc.
24 % unless ( $opt{'html_only'} || $opt{'js_only'} ) {
25 <SCRIPT TYPE="text/javascript">
27 % unless ( $opt{'html_only'} ) {
29 function opt(what,value,text) {
30 var optionName = new Option(text, value, false, false);
31 var length = what.length;
32 what.options[length] = optionName;
35 function <% $key %>_changed(what) {
37 <% $opt{'onchange'} %>
39 var <% $key %>_value = what.options[what.selectedIndex].value;
40 //alert ("condition changed to " + <% $key %>_value );
42 var op_Element = what.form.<% $key %>_op;
43 var params_Element = what.form.<% $key %>_params;
45 //cond2op in javascript... not as elegant cause my js << my perl
47 // if bool, hide/disable _op and _params entirely
48 if ( <%$key%>_value == '' || <%$key%>_value == 'Human Generated' ) {
49 op_Element.disabled = true;
50 op_Element.style.visibility = "hidden";
51 params_Element.disabled = true;
52 params_Element.style.visibility = "hidden";
56 var OpArray = [ 'is', 'is not' ];
59 if ( <%$key%>_value == 'Message Size' || <%$key%>_value == 'Time of Day' || <%$key%>_value == 'Current Date' ) {
60 OpArray.push('less than');
61 OpArray.push('greater than');
64 // unless no_in, add em
65 if ( <%$key%>_value != 'Message Size' && <%$key%>_value != 'Current Date' && <%$key%>_value != 'Existing Mailbox' ) {
67 OpArray.push('not in');
70 // blank the current op list
71 for ( var i = op_Element.length; i >= 0; i-- )
72 op_Element.options[i] = null;
74 // update the _op select with this new array
75 for ( var s = 0; s < OpArray.length; s++ )
76 opt(what.form.<% $key %>_op, OpArray[s], OpArray[s]);
78 // show _op and _params (in case we were a bool before)
79 op_Element.disabled = false;
80 op_Element.style.visibility = "visible";
81 params_Element.disabled = false;
82 params_Element.style.visibility = "visible";
86 % unless ( $opt{'html_only'} || $opt{'js_only'} ) {
94 #generic http://www.communigate.com/CommunigatePro/Rules.html#Conditions
103 #email http://www.communigate.com/CommunigatePro/QueueRules.html#Conditions
126 my %bool = ( #hide the op and valud dropdowns entirely
127 '' => 1, #XXX hide _op and _params on "Select Condition"
128 'Human Generated' => 1,
131 my %no_in = ( #hide in/not in
134 'Existing Mailbox' => 1,
137 my %lt_gt = ( #add less than/greater than
140 'Current Date', => 1,
145 return () if $bool{$cond};
146 my @op = ( 'is', 'is not' );
147 push @op, 'less than', 'greater than' if $lt_gt{$cond};
148 push @op, 'in', 'not in' unless $no_in{$cond};
157 my $key = $opt{'field'} || $opt{'id'};
159 #XXX curr value -> hidden op / param / param selects depending
160 #my @op = &$cond2op($curr_value);
161 my @op = &$cond2op();