% unless ( $opt{'js_only'} ) { <% include( 'select.html', %opt, 'options' => \@conditions, 'labels' => { '' => 'Select Condition' }, 'onchange' => $key.'_changed', ) %> <% include( 'select.html', 'name' => $opt{'field'}.'_op', 'id' => $key.'_op', 'options' => \@op, #XXX curr op ) %> <% include( 'input-text.html', 'name' => $opt{'field'}.'_params', 'id' => $key.'_params', #XXX curr value... anything else? ) %> % # could add more UI sugar for date/time ranges, string #lists, etc. % } % unless ( $opt{'html_only'} || $opt{'js_only'} ) { % } <%once> my @conditions = ( '', #generic http://www.communigate.com/CommunigatePro/Rules.html#Conditions 'Submit Address', 'Time of Day', 'Current Date', 'Current Day', 'Preference', 'FreeBusy', 'Existing Mailbox', #email http://www.communigate.com/CommunigatePro/QueueRules.html#Conditions 'From', 'Sender', 'To', 'Cc', 'Reply-To', 'Any To or Cc', 'Each To or Cc', 'Return-Path', "'From' Name", 'Subject', 'Message-ID', 'Message Size', 'Human Generated', 'Header Field', 'Any Recipient', 'Each Recipient', 'Source', 'Security', 'Any Route', 'Each Route' ); my %bool = ( #hide the op and valud dropdowns entirely '' => 1, #XXX hide _op and _params on "Select Condition" 'Human Generated' => 1, ); my %no_in = ( #hide in/not in 'Message Size' => 1, 'Current Date' => 1, 'Existing Mailbox' => 1, ); my %lt_gt = ( #add less than/greater than 'Message Size' => 1, 'Time of Day', => 1, 'Current Date', => 1, ); my $cond2op = sub { my $cond = shift; return () if $bool{$cond}; my @op = ( 'is', 'is not' ); push @op, 'less than', 'greater than' if $lt_gt{$cond}; push @op, 'in', 'not in' unless $no_in{$cond}; @op; }; <%init> my %opt = @_; my $key = $opt{'field'} || $opt{'id'}; #XXX curr value -> hidden op / param / param selects depending #my @op = &$cond2op($curr_value); my @op = &$cond2op();