[freeside-commits] freeside/httemplate/elements checkboxes-table-name.html, 1.4, 1.5 checkboxes.html, NONE, 1.1 select-rate.html, NONE, 1.1 tr-select-rate.html, NONE, 1.1
Ivan,,,
ivan at wavetail.420.am
Sun Jan 4 16:26:56 PST 2009
Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv7561/httemplate/elements
Modified Files:
checkboxes-table-name.html
Added Files:
checkboxes.html select-rate.html tr-select-rate.html
Log Message:
add rate copying, RT#4431
--- NEW FILE: tr-select-rate.html ---
% unless ( $opt{'js_only'} ) {
<% include('tr-td-label.html', @_ ) %>
<TD <% $style %>>
% }
<% include( '/elements/select-rate.html', %opt ) %>
% unless ( $opt{'js_only'} ) {
</TD>
</TR>
% }
<%init>
my( %opt ) = @_;
my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : '';
</%init>
--- NEW FILE: checkboxes.html ---
<%doc>
Example:
include( '/elements/checkboxes.html',
# required
#? 'name_callback' => sub { },
'names_list' => [ 'value',
'other value',
[ 'complex value' => { 'desc' => "Add'l description",
'note' => ' *',
}
],
],
'element_name_prefix' => "$link_table.",
#recommended
'checked_callback' => sub { my( $cgi, $name ) = @_; },
)
</%doc>
<TABLE CELLSPACING=0 CELLPADDING=0>
<TR>
<TD COLSPAN=2 ALIGN="center"><FONT SIZE="-1">(
<A HREF="javascript:setAll<%$prefix%>(true)">select all</A> |
<A HREF="javascript:setAll<%$prefix%>(false)">unselect all</A> |
<A HREF="javascript:toggleAll<%$prefix%>()">toggle all</A>
)</FONT></TD>
</TR>
% my $num=0;
% foreach my $item ( @{ $opt{'names_list'} } ) {
%
% my $name = ref($item) ? $item->[0] : $item;
% ( my $display = $name ) =~ s/ / /g;
% $display .= $item->[1]{note} if ref($item) && $item->[1]{note};
% my $desc = ref($item) && $item->[1]{desc} ? $item->[1]{desc} : '';
%
% my $callback =
% ( $cgi->param('error') ? 'error_' : '' ). 'checked_callback';
% my $checked = &{ $opt{$callback} }( $cgi, $name ) ? 'CHECKED' : '';
<TR>
<TD VALIGN="top">
<INPUT TYPE="checkbox" NAME="<% $opt{'element_name_prefix'}. $name %>" <% $checked %> ID="<%$prefix.$num++%>" VALUE="ON">
</TD>
<TD><% $display %>
% if ( $desc ) {
<BR><FONT SIZE="-2"><% $desc %></FONT>
% }
</TD>
</TR>
% }
</TABLE>
<SCRIPT TYPE="text/javascript">
function setAll<%$prefix%>(setTo) {
% for ( 0 .. ($num-1) ) {
document.getElementById('<%$prefix.$_%>').checked = setTo;
% }
}
function toggleAll<%$prefix%>(setTo) {
% for ( 0 .. ($num-1) ) {
var element = document.getElementById('<%$prefix.$_%>');
if ( element.checked == true ) {
element.checked = false;
} else {
element.checked = true;
}
% }
}
</SCRIPT>
<%init>
my( %opt ) = @_;
my @pset = ( 'a'..'z', 'A'..'Z', '0'..'9' );
my $prefix = $opt{prefix}
|| join('', map $pset[ int(rand $#pset) ], (0..20) );
$opt{checked_callback} ||= sub {};
$opt{'error_checked_callback'} ||= sub {
my( $cgi, $name ) = @_;
$cgi->param($opt{'element_name_prefix'}. $name );
};
</%init>
--- NEW FILE: select-rate.html ---
<% include( '/elements/select-table.html',
'table' => 'rate',
'name_col' => 'ratename',
'empty_label' => 'Select rate plan',
#'hashref' => { 'disabled' => '' },
'order_by' => ' ORDER BY ratenum', #ratename ?
@_,
)
%>
Index: checkboxes-table-name.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/checkboxes-table-name.html,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- checkboxes-table-name.html 24 Aug 2008 22:35:14 -0000 1.4
+++ checkboxes-table-name.html 5 Jan 2009 00:26:53 -0000 1.5
@@ -41,79 +41,12 @@
</%doc>
-<TABLE CELLSPACING=0 CELLPADDING=0>
-
-<TR>
- <TD COLSPAN=2 ALIGN="center"><FONT SIZE="-1">(
- <A HREF="javascript:setAll<%$prefix%>(true)">select all</A> |
- <A HREF="javascript:setAll<%$prefix%>(false)">unselect all</A> |
- <A HREF="javascript:toggleAll<%$prefix%>()">toggle all</A>
- )</FONT></TD>
-</TR>
-
-% my $num=0;
-% foreach my $item ( @{ $opt{'names_list'} } ) {
-%
-% my $name = ref($item) ? $item->[0] : $item;
-% ( my $display = $name ) =~ s/ / /g;
-% $display .= $item->[1]{note} if ref($item) && $item->[1]{note};
-% my $desc = ref($item) && $item->[1]{desc} ? $item->[1]{desc} : '';
-%
-% my $checked;
-% if ( $cgi->param('error') ) {
-%
-% $checked = $cgi->param($opt{'link_table'}. ".$name" )
-% ? 'CHECKED'
-% : '';
-%
-% } else {
-%
-% $checked =
-% qsearchs( $opt{'link_table'}, {
-% $source_pkey => $sourcenum,
-% $opt{'name_col'} => $name,
-% %$link_static,
-% } )
-% ? 'CHECKED'
-% : ''
-%
-% }
-
- <TR>
- <TD VALIGN="top">
- <INPUT TYPE="checkbox" NAME="<% $opt{'link_table'}. ".$name" %>" <% $checked %> ID="<%$prefix.$num++%>" VALUE="ON">
- </TD>
- <TD><% $display %>
-% if ( $desc ) {
- <BR><FONT SIZE="-2"><% $desc %></FONT>
-% }
- </TD>
- </TR>
-
-% }
-
-</TABLE>
-
-<SCRIPT TYPE="text/javascript">
-
- function setAll<%$prefix%>(setTo) {
-% for ( 0 .. ($num-1) ) {
- document.getElementById('<%$prefix.$_%>').checked = setTo;
-% }
- }
-
- function toggleAll<%$prefix%>(setTo) {
-% for ( 0 .. ($num-1) ) {
- var element = document.getElementById('<%$prefix.$_%>');
- if ( element.checked == true ) {
- element.checked = false;
- } else {
- element.checked = true;
- }
-% }
- }
-
-</SCRIPT>
+<% include('checkboxes.html',
+ 'names_list' => $opt{'names_list'},
+ 'checked_callback' => $checked_callback,
+ 'element_name_prefix' => $opt{'link_table'}. '.',
+ )
+%>
<%init>
@@ -145,4 +78,13 @@
my $link_static = $opt{'link_static'} || {};
+my $checked_callback = sub {
+ my( $cgi, $name ) = @_;
+ qsearchs( $opt{'link_table'}, {
+ $source_pkey => $sourcenum,
+ $opt{'name_col'} => $name,
+ %$link_static,
+ });
+};
+
</%init>
More information about the freeside-commits
mailing list