[freeside-commits] freeside/httemplate/elements radius_attr.html, NONE, 1.1 select-table.html, 1.22, 1.23 select.html, 1.3, 1.4
Mark Wells
mark at wavetail.420.am
Wed Nov 23 10:39:09 PST 2011
Update of /home/cvs/cvsroot/freeside/httemplate/elements
In directory wavetail.420.am:/tmp/cvs-serv14549/httemplate/elements
Modified Files:
select-table.html select.html
Added Files:
radius_attr.html
Log Message:
RADIUS group attributes, #15017
Index: select-table.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select-table.html,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -w -d -r1.22 -r1.23
--- select-table.html 1 Mar 2010 22:00:25 -0000 1.22
+++ select-table.html 23 Nov 2011 18:39:06 -0000 1.23
@@ -124,7 +124,7 @@
my( %opt ) = @_;
-warn "elements/select-table.html: \n". Dumper(%opt)
+warn "elements/select-table.html: \n". Dumper(\%opt)
if exists $opt{debug} && $opt{debug};
$opt{'extra_option_attributes'} ||= [];
Index: select.html
===================================================================
RCS file: /home/cvs/cvsroot/freeside/httemplate/elements/select.html,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- select.html 29 Apr 2010 07:40:46 -0000 1.3
+++ select.html 23 Nov 2011 18:39:07 -0000 1.4
@@ -45,9 +45,10 @@
my %opt = @_;
-my $onchange = $opt{'onchange'}
- ? 'onChange="'. $opt{'onchange'}. '(this)"'
- : '';
+#no-op code...
+#my $onchange = $opt{'onchange'}
+# ? 'onChange="'. $opt{'onchange'}. '(this)"'
+# : '';
my $labels = $opt{'option_labels'} || $opt{'labels'};
--- NEW FILE: radius_attr.html ---
% if ( $first_row ) {
% $first_row = '';
<SCRIPT TYPE="text/javascript">
var ops_for_type = {
% foreach my $type ('C','R') {
'<%$type%>': [<% join(',', map {"'$_'"} FS::radius_attr->ops($type)) %>],
% }
};
function change_attrtype(what) {
var new_type = what.value;
var select_op = document.getElementById(
what.id.replace(/_attrtype$/, '_op')
);
if ( select_op ) {
var options = select_op.options;
var new_ops = ops_for_type[new_type];
while ( options.length > 0 )
options.remove(0);
for ( var x in new_ops ) {
// Option(text, value, defaultSelected)
options.add(new Option(new_ops[x], new_ops[x], (options.length == 0)));
}
}
<% $onchange %>(what);
}
</SCRIPT>
% } #if $first_row
<INPUT TYPE="hidden" NAME="<%$name%>" ID="<%$id%>" VALUE="<% $curr_value %>">
<& select.html,
field => $name.'_attrtype',
id => $name.'_attrtype',
options => ['C','R'],
labels => { 'C' => 'Check', 'R' => 'Reply' },
curr_value => $radius_attr->attrtype,
onchange => 'change_attrtype(this)',
&>
<& input-text.html,
field => $name.'_attrname',
curr_value => $radius_attr->attrname,
onchange => $onchange,
size => 40, #longest attribute name in freeradius dict = 46
&>
<& select.html,
field => $name.'_op',
id => $name.'_op',
options => [ FS::radius_attr->ops($radius_attr->attrtype) ],
curr_value => $radius_attr->op,
onchange => $onchange,
&>
<& input-text.html,
field => $name.'_value',
curr_value => $radius_attr->value,
onchange => $onchange,
size => 20, #tend to be shorter than attribute names
&>
<%shared>
my $first_row = 1;
</%shared>
<%init>
my( %opt ) = @_;
# for an 'onchange' option that will work in both select.html and
# input-text.html:
# - don't start with "onchange="
# - don't end with (what) or (this)
# - don't end with a semicolon
# - don't have quotes
my $onchange = $opt{'onchange'} || '';
$onchange =~ s/\((what|this)\);?$//;
my $name = $opt{'element_name'} || $opt{'field'} || 'attrnum';
my $id = $opt{'id'} || 'attrnum';
my $curr_value = $opt{'curr_value'} || $opt{'value'};
my $radius_attr;
if ( $curr_value ) {
$radius_attr = qsearchs('radius_attr', { 'attrnum' => $curr_value })
or die "attrnum $curr_value not found";
}
else {
$radius_attr = new FS::radius_attr {
'attrtype' => 'C',
'op' => '==',
};
}
</%init>
More information about the freeside-commits
mailing list