From 6874a21f3cb26a167e49cc1324df30119c6ed75d Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 27 Apr 2010 10:56:51 +0000 Subject: [PATCH] communigate (phase 2): rules: start of adding conditions and actions to rule edit. RT#7514 --- httemplate/edit/cgp_rule.html | 34 ++++++++++-- httemplate/elements/select-cgp_rule_action.html | 46 ++++++++++++++++ httemplate/elements/select-cgp_rule_condition.html | 63 +++++++++++++++++++++ httemplate/elements/select.html | 64 ++++++++++++++++++++++ httemplate/elements/tr-select.html | 61 ++++----------------- 5 files changed, 211 insertions(+), 57 deletions(-) create mode 100644 httemplate/elements/select-cgp_rule_action.html create mode 100644 httemplate/elements/select-cgp_rule_condition.html create mode 100644 httemplate/elements/select.html diff --git a/httemplate/edit/cgp_rule.html b/httemplate/edit/cgp_rule.html index 9c03a52f0..6f2d80161 100644 --- a/httemplate/edit/cgp_rule.html +++ b/httemplate/edit/cgp_rule.html @@ -1,10 +1,12 @@ <% include('elements/edit.html', 'name_singular' => 'rule', 'table' => 'cgp_rule', - 'labels' => { 'rulenum' => 'Rule', - 'name' => 'Name', - 'comment' => 'Comment', - 'priority' => 'Priority', + 'labels' => { 'rulenum' => 'Rule', + 'name' => 'Name', + 'comment' => 'Comment', + 'priority' => 'Priority', + 'ruleconditionnum' => 'Condition', + 'ruleactionnum' => 'Action', }, 'fields' => [ 'name', 'comment', @@ -13,7 +15,25 @@ 'options' => [ 0 .. 10 ], 'labels' => { 0 => 'Inactive' }, }, - { 'field' => 'svcnum', 'type' => 'hidden', }, + { 'field' => 'svcnum', 'type' => 'hidden', }, + { 'type' => 'tablebreak-tr-title', + 'value' => 'Conditions', + }, + { 'field' => 'ruleconditionnum', + 'type' => 'select-cgp_rule_condition', + 'o2m_table' => 'cgp_rule_condition', + 'm2_label' => 'Condition', + #XXX m2_error_callback + }, + { 'type' => 'tablebreak-tr-title', + 'value' => 'Actions', + }, + { 'field' => 'ruleactionnum', + 'type' => 'select-cgp_rule_action', + 'o2m_table' => 'cgp_rule_action', + 'm2_label' => 'Action', + #XXX m2_error_callback + }, ], 'new_callback' => sub { my( $cgi, $cgp_rule ) = @_; $cgp_rule->svcnum( $cgi->param('svcnum') ); @@ -24,7 +44,9 @@ %> <%init> -#my $svcnum #huh +my %opt = @_; + +#my $svcnum #huh XXX #my $viewall_url = $p. "browse/$table.html?svcnum=$svcnum"; diff --git a/httemplate/elements/select-cgp_rule_action.html b/httemplate/elements/select-cgp_rule_action.html new file mode 100644 index 000000000..b53a96e9e --- /dev/null +++ b/httemplate/elements/select-cgp_rule_action.html @@ -0,0 +1,46 @@ +%# XXX CSS to verticially align the select vs. the textarea +<% include( 'select.html', + %opt, + 'options' => \@actions, #reverse order if we ever need to specify + 'labels' => { '' => 'Select Action' }, + ) +%> + + > +%# XXX curr value + +<%init> + +my %opt = @_; +warn "SELECT-CGP_RULE-ACTION.HTML: ". join ' / ', %opt; + +my @actions = ( + '', + 'Stop Processing', + 'Discard', + 'Reject With', + 'Mark', + 'Add Header', + 'Tag Subject', + 'Store in', + 'Redirect to', + 'Forward to', + 'Mirror to', + 'Reply with', + 'Reply to All with', + 'React with', + 'store Encrypted in', + 'Copy attachments into', + 'Execute', + 'ExternalFilter', + 'Accept Request', +); + +#XXX hmm, hide textarea w/Stop Processing,Discard like _condition.html + + diff --git a/httemplate/elements/select-cgp_rule_condition.html b/httemplate/elements/select-cgp_rule_condition.html new file mode 100644 index 000000000..1ce85bdb6 --- /dev/null +++ b/httemplate/elements/select-cgp_rule_condition.html @@ -0,0 +1,63 @@ +<% 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> + +my %opt = @_; + +my @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 = ( + 'Human Generated' => 1, +); + +my %number = ( + 'Message Size' => 1, +); + +#XXX curr value -> hidden op / param / param selects depending + +my @op = ( 'is', 'is not', 'in', 'not in' ); +my @op_number = ( 'is', 'is_not', 'less than', 'greater than' ); + +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) + + diff --git a/httemplate/elements/select.html b/httemplate/elements/select.html new file mode 100644 index 000000000..7aa4180b6 --- /dev/null +++ b/httemplate/elements/select.html @@ -0,0 +1,64 @@ +% unless ( $opt{'js_only'} ) { + + + +% } +<%init> + +my %opt = @_; +warn "SELECT.HTML: ". join ' / ', %opt; + +my $onchange = $opt{'onchange'} + ? 'onChange="'. $opt{'onchange'}. '(this)"' + : ''; + +my $labels = $opt{'option_labels'} || $opt{'labels'}; + +my $curr_value = $opt{'curr_value'}; + +my $onchange = ''; +if ( $opt{'onchange'} ) { + $onchange = $opt{'onchange'}; + $onchange .= '(this)' unless $onchange =~ /\(\w*\);?$/; + $onchange =~ s/\(what\);/\(this\);/g; #ugh, terrible hack. all onchange + #callbacks should act the same + $onchange = 'onChange="'. $onchange. '"' unless $onchange =~ /^onChange=/i; +} + + diff --git a/httemplate/elements/tr-select.html b/httemplate/elements/tr-select.html index f9d54f118..f9c768c60 100644 --- a/httemplate/elements/tr-select.html +++ b/httemplate/elements/tr-select.html @@ -1,63 +1,22 @@ -<% include('tr-td-label.html', @_ ) %> +% unless ( $opt{'js_only'} ) { - <% $style %>> + <% include('tr-td-label.html', %opt ) %> - - - - - + <% include('select.html', %opt ) %> +% unless ( $opt{'js_only'} ) { + + +% } <%init> my %opt = @_; - -my $onchange = $opt{'onchange'} - ? 'onChange="'. $opt{'onchange'}. '(this)"' - : ''; - -my $labels = $opt{'option_labels'} || $opt{'labels'}; - +warn join ' / ', %opt; my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : ''; -my $curr_value = $opt{'curr_value'}; - my $colspan = $opt{'colspan'} ? 'COLSPAN="'.$opt{'colspan'}.'"' : ''; -- 2.11.0