[freeside-commits] freeside/httemplate/elements select-cgp_rule_condition.html, 1.2, 1.3 select.html, 1.2, 1.3 input-text.html, 1.1, 1.2 select-cgp_rule_action.html, 1.3, 1.4
Ivan,,,
ivan at wavetail.420.am
Thu Apr 29 00:40:48 PDT 2010
Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv2577/httemplate/elements
Modified Files:
select-cgp_rule_condition.html select.html input-text.html
select-cgp_rule_action.html
Log Message:
communigate (phase 2): rules: adding conditions and actions to rule edit. RT#7514
Index: select-cgp_rule_condition.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-cgp_rule_condition.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- select-cgp_rule_condition.html 29 Apr 2010 02:59:22 -0000 1.2
+++ select-cgp_rule_condition.html 29 Apr 2010 07:40:45 -0000 1.3
@@ -1,25 +1,42 @@
% unless ( $opt{'js_only'} ) {
+
+ <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
+
<% include( 'select.html',
- %opt,
+ 'field' => $name.'_condition',
+ 'id' => $id.'_condition',
'options' => \@conditions,
+ 'curr_value' => scalar($cgi->param($name.'_condition'))
+ || $cgp_rule_condition->condition,
'labels' => { '' => 'Select Condition' },
- 'onchange' => $key.'_changed',
+ 'onchange' => $name.'_changed',
)
%>
+
<% include( 'select.html',
- 'name' => $opt{'field'}.'_op',
- 'id' => $key.'_op',
+ 'field' => $name.'_op',
+ 'id' => $id.'_op',
'options' => \@op,
- #XXX curr op
+ 'curr_value' => scalar($cgi->param($name.'_op'))
+ || $cgp_rule_condition->op,
+ 'disabled' => $disabled,
+ 'style' => $style,
)
%>
+
<% include( 'input-text.html',
- 'name' => $opt{'field'}.'_params',
- 'id' => $key.'_params',
- #XXX curr value... anything else?
+ 'field' => $name.'_params',
+ 'id' => $id.'_params',
+ 'curr_value' => scalar($cgi->param($name.'_params'))
+ || $cgp_rule_condition->params,
+ 'disabled' => $disabled,
+ 'style' => $style,
+ 'nodarken_disabled' => 1,
)
%>
+
% # could add more UI sugar for date/time ranges, string #lists, etc.
+
% }
% unless ( $opt{'html_only'} || $opt{'js_only'} ) {
<SCRIPT TYPE="text/javascript">
@@ -32,20 +49,19 @@
what.options[length] = optionName;
}
- function <% $key %>_changed(what) {
+ function <% $name %>_changed(what) {
- <% $opt{'onchange'} %>
+ <% $onchange %>
- var <% $key %>_value = what.options[what.selectedIndex].value;
- //alert ("condition changed to " + <% $key %>_value );
+ var <% $name %>_value = what.options[what.selectedIndex].value;
- var op_Element = what.form.<% $key %>_op;
- var params_Element = what.form.<% $key %>_params;
+ var op_Element = what.form.<% $name %>_op;
+ var params_Element = what.form.<% $name %>_params;
//cond2op in javascript... not as elegant cause my js << my perl
// if bool, hide/disable _op and _params entirely
- if ( <%$key%>_value == '' || <%$key%>_value == 'Human Generated' ) {
+ if ( <%$name%>_value == '' || <%$name%>_value == 'Human Generated' ) {
op_Element.disabled = true;
op_Element.style.visibility = "hidden";
params_Element.disabled = true;
@@ -56,13 +72,13 @@
var OpArray = [ 'is', 'is not' ];
// if lt_ge, add em
- if ( <%$key%>_value == 'Message Size' || <%$key%>_value == 'Time of Day' || <%$key%>_value == 'Current Date' ) {
+ if ( <%$name%>_value == 'Message Size' || <%$name%>_value == 'Time of Day' || <%$name%>_value == 'Current Date' ) {
OpArray.push('less than');
OpArray.push('greater than');
}
// unless no_in, add em
- if ( <%$key%>_value != 'Message Size' && <%$key%>_value != 'Current Date' && <%$key%>_value != 'Existing Mailbox' ) {
+ if ( <%$name%>_value != 'Message Size' && <%$name%>_value != 'Current Date' && <%$name%>_value != 'Existing Mailbox' ) {
OpArray.push('in');
OpArray.push('not in');
}
@@ -73,7 +89,7 @@
// update the _op select with this new array
for ( var s = 0; s < OpArray.length; s++ )
- opt(what.form.<% $key %>_op, OpArray[s], OpArray[s]);
+ opt(what.form.<% $name %>_op, OpArray[s], OpArray[s]);
// show _op and _params (in case we were a bool before)
op_Element.disabled = false;
@@ -123,22 +139,22 @@
'Each Route'
);
-my %bool = ( #hide the op and valud dropdowns entirely
- '' => 1, #XXX hide _op and _params on "Select Condition"
- 'Human Generated' => 1,
-);
+my %bool = ( map { $_=>1 } ( #hide the op and valud dropdowns entirely
+ '',
+ 'Human Generated',
+));
-my %no_in = ( #hide in/not in
- 'Message Size' => 1,
- 'Current Date' => 1,
- 'Existing Mailbox' => 1,
-);
+my %no_in = ( map { $_=>1 } ( #hide in/not in
+ 'Message Size',
+ 'Current Date',
+ 'Existing Mailbox',
+));
-my %lt_gt = ( #add less than/greater than
- 'Message Size' => 1,
- 'Time of Day', => 1,
- 'Current Date', => 1,
-);
+my %lt_gt = ( map { $_=>1 } ( #add less than/greater than
+ 'Message Size',
+ 'Time of Day',
+ 'Current Date',
+));
my $cond2op = sub {
my $cond = shift;
@@ -154,10 +170,29 @@
my %opt = @_;
-my $key = $opt{'field'} || $opt{'id'};
+my $name = $opt{'element_name'} || $opt{'field'} || 'ruleconditionnum';
+#my $id = $opt{'id'} || 'contactnum';
+my $id = $opt{'id'} || $opt{'field'} || 'ruleconditionnum';
-#XXX curr value -> hidden op / param / param selects depending
-#my @op = &$cond2op($curr_value);
-my @op = &$cond2op();
+my $curr_value = $opt{'curr_value'} || $opt{'value'};
+
+my $onchange = '';
+if ( $opt{'onchange'} ) {
+ $onchange = $opt{'onchange'};
+ $onchange .= '(what)' unless $onchange =~ /\(\w*\);?$/;
+}
+
+my $cgp_rule_condition;
+if ( $curr_value ) {
+ $cgp_rule_condition = qsearchs('cgp_rule_condition',
+ { 'ruleconditionnum' => $curr_value } );
+} else {
+ $cgp_rule_condition = new FS::cgp_rule_condition {};
+}
+
+my @op = &$cond2op($curr_value);
+
+my $disabled = scalar(@op) ? '' : 1;
+my $style = $disabled ? 'visibility:hidden' : '';
</%init>
Index: select.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select.html,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- select.html 27 Apr 2010 10:58:16 -0000 1.2
+++ select.html 29 Apr 2010 07:40:46 -0000 1.3
@@ -4,6 +4,8 @@
ID = "<% $opt{id} %>"
previousValue = "<% $curr_value %>"
previousText = "<% $labels->{$curr_value} || $curr_value %>"
+ <% $style %>
+ <% $opt{disabled} %>
<% $onchange %>
>
@@ -60,4 +62,18 @@
$onchange = 'onChange="'. $onchange. '"' unless $onchange =~ /^onChange=/i;
}
+$opt{'disabled'} = &{ $opt{'disabled'} }( \%opt )
+ if ref($opt{'disabled'}) eq 'CODE';
+$opt{'disabled'} = 'DISABLED'
+ if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah?
+
+my @style = ref($opt{'style'})
+ ? @{ $opt{'style'} }
+ : $opt{'style'}
+ ? ( $opt{'style'} )
+ : ();
+
+my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
+
+
</%init>
Index: input-text.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/input-text.html,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- input-text.html 28 Jun 2008 23:03:09 -0000 1.1
+++ input-text.html 29 Apr 2010 07:40:46 -0000 1.2
@@ -31,13 +31,17 @@
$opt{'disabled'} = 'DISABLED'
if $opt{'disabled'} && $opt{'disabled'} !~ /disabled/i; # uuh... yeah?
-my @style = ();
+my @style = ref($opt{'style'})
+ ? @{ $opt{'style'} }
+ : $opt{'style'}
+ ? ( $opt{'style'} )
+ : ();
push @style, 'text-align: '. $opt{'text-align'}
if $opt{'text-align'};
push @style, 'background-color: #dddddd'
- if $opt{'disabled'};
+ if $opt{'disabled'} && ! $opt{'nodarken_disabled'};
my $style = scalar(@style) ? 'STYLE="'. join(';', @style). '"' : '';
Index: select-cgp_rule_action.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-cgp_rule_action.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- select-cgp_rule_action.html 29 Apr 2010 02:59:21 -0000 1.3
+++ select-cgp_rule_action.html 29 Apr 2010 07:40:46 -0000 1.4
@@ -1,22 +1,59 @@
-%# XXX CSS to verticially align the select vs. the textarea
+% unless ( $opt{'js_only'} ) {
+
+ <INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<%$curr_value%>">
+
<% include( 'select.html',
- %opt,
- 'options' => \@actions, #reverse order if we ever need to specify
+ '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 = "<% $opt{field} %>_params"
-%# ID = "<% $opt{id} %>"
+
+ <TEXTAREA NAME = "<% $name %>_params"
+ ID = "<% $id %>_params"
+ <% $disabled %>
+ <% $style %>
%# <% $rows %>
%# <% $cols %>
%# <% $onchange %>
-%# ><% $curr_value |h %></TEXTAREA>
- >
-%# XXX curr value
- </TEXTAREA>
-<%init>
+ ><% scalar($cgi->param($name.'_params')) || $cgp_rule_action->params |h %></TEXTAREA>
-my %opt = @_;
+% }
+% 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 @@
'Accept Request',
);
-#XXX hmm, hide textarea w/Stop Processing,Discard like _condition.html
+my %noparam = ( map { $_=>1 } '', 'Stop Processing', 'Discard' );
-</%Init>
+</%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>
More information about the freeside-commits
mailing list