summaryrefslogtreecommitdiff
path: root/httemplate/elements/select-cgp_rule_action.html
diff options
context:
space:
mode:
authorivan <ivan>2010-04-29 07:40:46 +0000
committerivan <ivan>2010-04-29 07:40:46 +0000
commit2ac302e18d723563692cdbbd74f3e9e5331a3014 (patch)
treece25a3f91382098fa749f0d8c5dde7c77699b631 /httemplate/elements/select-cgp_rule_action.html
parentfa6176ab2df85c4b66026e9fe2a7242293d20ce5 (diff)
communigate (phase 2): rules: adding conditions and actions to rule edit. RT#7514
Diffstat (limited to 'httemplate/elements/select-cgp_rule_action.html')
-rw-r--r--httemplate/elements/select-cgp_rule_action.html99
1 files changed, 79 insertions, 20 deletions
diff --git a/httemplate/elements/select-cgp_rule_action.html b/httemplate/elements/select-cgp_rule_action.html
index 25c3a2567..9ac930633 100644
--- a/httemplate/elements/select-cgp_rule_action.html
+++ b/httemplate/elements/select-cgp_rule_action.html
@@ -1,22 +1,59 @@
-%# 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' },
- )
-%>
- <TEXTAREA NAME = "<% $opt{field} %>_params"
-%# ID = "<% $opt{id} %>"
-%# <% $rows %>
-%# <% $cols %>
-%# <% $onchange %>
-%# ><% $curr_value |h %></TEXTAREA>
- >
-%# XXX curr value
- </TEXTAREA>
-<%init>
+% unless ( $opt{'js_only'} ) {
-my %opt = @_;
+ <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<%$curr_value%>">
+
+ <% include( 'select.html',
+ 'field' => $name.'_action',
+ 'id' => $id.'_action',
+ 'options' => \@actions,
+ 'curr_value' => scalar($cgi->param($name.'_action'))
+ || $cgp_rule_action->action,
+ 'labels' => { '' => 'Select Action' },
+ 'onchange' => $name.'_changed',
+ 'style' => 'vertical-align:top',
+ )
+ %>
+
+ <TEXTAREA NAME = "<% $name %>_params"
+ ID = "<% $id %>_params"
+ <% $disabled %>
+ <% $style %>
+%# <% $rows %>
+%# <% $cols %>
+%# <% $onchange %>
+ ><% scalar($cgi->param($name.'_params')) || $cgp_rule_action->params |h %></TEXTAREA>
+
+% }
+% unless ( $opt{'html_only'} || $opt{'js_only'} ) {
+ <SCRIPT TYPE="text/javascript">
+% }
+% unless ( $opt{'html_only'} ) {
+
+ function <% $name %>_changed(what) {
+
+ <% $opt{'onchange'} %>
+
+ var <% $name %>_value = what.options[what.selectedIndex].value;
+
+ var params_Element = what.form.<% $name %>_params;
+
+ // if bool, hide/disable _op and _params entirely
+ if ( <%$name%>_value == '' || <%$name%>_value == 'Stop Processing' || <%$name%>_value == 'Discard' ) {
+ params_Element.disabled = true;
+ params_Element.style.visibility = "hidden";
+ } else {
+ params_Element.disabled = false;
+ params_Element.style.visibility = "visible";
+
+ }
+
+ }
+
+% }
+% unless ( $opt{'html_only'} || $opt{'js_only'} ) {
+ </SCRIPT>
+% }
+<%once>
my @actions = (
'',
@@ -50,6 +87,28 @@ my @actions = (
'Accept Request',
);
-#XXX hmm, hide textarea w/Stop Processing,Discard like _condition.html
+my %noparam = ( map { $_=>1 } '', 'Stop Processing', 'Discard' );
+
+</%once>
+<%init>
+
+my %opt = @_;
+
+my $name = $opt{'element_name'} || $opt{'field'} || 'ruleactionnum';
+#my $id = $opt{'id'} || 'contactnum';
+my $id = $opt{'id'} || $opt{'field'} || 'ruleactionnum';
+
+my $curr_value = $opt{'curr_value'} || $opt{'value'};
+
+my $cgp_rule_action;
+if ( $curr_value ) {
+ $cgp_rule_action = qsearchs('cgp_rule_action',
+ { 'ruleactionnum' => $curr_value } );
+} else {
+ $cgp_rule_action = new FS::cgp_rule_action {};
+}
+
+my $disabled = $noparam{$curr_value} ? 'DISABLED' : '';
+my $style = $disabled ? 'STYLE="visibility:hidden"' : '';
-</%Init>
+</%init>