From: ivan Date: Thu, 29 Apr 2010 02:59:22 +0000 (+0000) Subject: communigate (phase 2): rules: adding conditions and actions to rule edit. RT#7514 X-Git-Tag: root_of_svc_elec_features~288 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=fa6176ab2df85c4b66026e9fe2a7242293d20ce5 communigate (phase 2): rules: adding conditions and actions to rule edit. RT#7514 --- diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html index 494e974de..4da82b476 100644 --- a/httemplate/edit/elements/edit.html +++ b/httemplate/edit/elements/edit.html @@ -559,8 +559,9 @@ Example: var newrow = <% include(@layer_opt, html_only=>1) |js_string %>; -% if ( $type eq 'selectlayers' ) { #until the rest have html/js_only - var newfunc = <% include(@layer_opt, js_only =>1) |js_string %>; +% #until the rest have html/js_only +% if ( $type eq 'selectlayers' || $type =~ /^select-cgp_rule_/ ) { + var newfunc = <% include(@layer_opt, js_only=>1) |js_string %>; % } else { var newfunc = ''; % } diff --git a/httemplate/elements/select-cgp_rule_action.html b/httemplate/elements/select-cgp_rule_action.html index 24301b59b..25c3a2567 100644 --- a/httemplate/elements/select-cgp_rule_action.html +++ b/httemplate/elements/select-cgp_rule_action.html @@ -20,6 +20,16 @@ my %opt = @_; my @actions = ( '', + + #generic http://www.communigate.com/CommunigatePro/Rules.html#Actions + 'Reject', + 'SendURL', + 'Send IM', + 'FingerNotify', + 'Write To Log', + "Remember 'From' in", + + #email http://www.communigate.com/CommunigatePro/QueueRules.html#Actions 'Stop Processing', 'Discard', 'Reject With', diff --git a/httemplate/elements/select-cgp_rule_condition.html b/httemplate/elements/select-cgp_rule_condition.html index 1ce85bdb6..eaf7211fa 100644 --- a/httemplate/elements/select-cgp_rule_condition.html +++ b/httemplate/elements/select-cgp_rule_condition.html @@ -1,26 +1,106 @@ -<% include( 'select.html', - %opt, - 'options' => \@conditions, #reverse order if we ever need to spec - 'labels' => { '' => 'Select Condition' }, - ) -%> -<% include( 'select.html', - 'name' => $opt{'field'}.'_op', - 'id' => ($opt{'field'}||$opt{'id'}).'_op', - 'options' => \@myop, - ) -%> -<% include( 'input-text.html', - 'name' => $opt{'field'}.'_params', - #XXX curr value... anything else? - ) -%> -<%init> +% 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', @@ -43,21 +123,41 @@ my @conditions = ( 'Each Route' ); -my %bool = ( +my %bool = ( #hide the op and valud dropdowns entirely + '' => 1, #XXX hide _op and _params on "Select Condition" 'Human Generated' => 1, ); -my %number = ( +my %no_in = ( #hide in/not in 'Message Size' => 1, + 'Current Date' => 1, + 'Existing Mailbox' => 1, ); -#XXX curr value -> hidden op / param / param selects depending +my %lt_gt = ( #add less than/greater than + 'Message Size' => 1, + 'Time of Day', => 1, + 'Current Date', => 1, +); -my @op = ( 'is', 'is not', 'in', 'not in' ); -my @op_number = ( 'is', 'is_not', 'less than', 'greater than' ); +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; +}; -my @myop = @op; #XXX $number{$curr_value} ? @op_number : @op; -#XXX and a fancy onchange handler... yes. -#XXX (and for total hiding of the %bool one) + +<%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();