diff options
author | ivan <ivan> | 2009-09-25 10:14:30 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-09-25 10:14:30 +0000 |
commit | 81e426fe755eaea508041bc2d7b25ac44c777434 (patch) | |
tree | 95a9a5fe952a77274f40e660400415e6b2db2997 /httemplate/config | |
parent | 25b0525eb1f0d018b893a7bdc96b92a8f446020f (diff) |
nomadix, RT#5876
Diffstat (limited to 'httemplate/config')
-rw-r--r-- | httemplate/config/config-process.cgi | 20 | ||||
-rw-r--r-- | httemplate/config/config-view.cgi | 23 | ||||
-rw-r--r-- | httemplate/config/config.cgi | 21 |
3 files changed, 53 insertions, 11 deletions
diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index f8b64e86f..056919790 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -41,15 +41,18 @@ foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { } else { push @delete, $i->key; } - } elsif ( $type eq 'text' || $type eq 'select' || $type eq 'select-sub' ) { - if ( $cgi->param($i->key.$n) ne '' ) { - $conf->set($i->key, $cgi->param($i->key.$n), $agentnum); + } elsif ( $type =~ /^(editlist|selectmultiple)$/ + or ( $type =~ /^select(-(sub|part_svc))?$/ || $i->multiple ) + ) + { + if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) { + $conf->set($i->key, join("\n", @{[ $cgi->param($i->key.$n) ]} ), $agentnum); } else { $conf->delete($i->key, $agentnum); } - } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) { - if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) { - $conf->set($i->key, join("\n", @{[ $cgi->param($i->key.$n) ]} ), $agentnum); + } elsif ( $type =~ /^(text|select(-(sub|part_svc))?)$/ ) { + if ( $cgi->param($i->key.$n) ne '' ) { + $conf->set($i->key, $cgi->param($i->key.$n), $agentnum); } else { $conf->delete($i->key, $agentnum); } @@ -101,6 +104,11 @@ $conf->delete($_, $agentnum) foreach @delete; % } elsif ( $type eq 'text' || $type eq 'select' ) { configCell.innerHTML = <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' |js_string %>; +% } elsif ( $type eq 'select-part_svc' && ! $i->multiple ) { + configCell.innerHTML = + <% $conf->config($i->key, $agentnum) |js_string %> +%# + ': ' + +%# <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) |js_string %>; % } elsif ( $type eq 'select-sub' ) { configCell.innerHTML = <% $conf->config($i->key, $agentnum) |js_string %> + ': ' + diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi index 0f6c99232..80a65d09b 100644 --- a/httemplate/config/config-view.cgi +++ b/httemplate/config/config-view.cgi @@ -156,7 +156,9 @@ Click on a configuration value to change it. % } elsif ( $type eq 'textarea' % || $type eq 'editlist' -% || $type eq 'selectmultiple' ) { +% || $type eq 'selectmultiple' +% ) +% { <tr> <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff"> @@ -197,7 +199,7 @@ Click on a configuration value to change it. </td> </tr> -% } elsif ( $type eq 'select-sub' ) { +% } elsif ( $type eq 'select-sub' ) { <tr> <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff"> @@ -206,12 +208,25 @@ Click on a configuration value to change it. </td> </tr> -% } else { +% } elsif ( $type eq 'select-part_svc' ) { +% my @svcparts = $conf->config($i->key, $agentnum); + + <tr> + <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff"> + <% join('<BR>', map { $_ # ': '. $svc + } + @svcparts + ) + %> + </td> + </tr> + +% } else { <tr><td> <font color="#ff0000">unknown type <% $type %></font> </td></tr> -% } +% } % $n++; % } diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi index 8d5b1ae43..4ebedc180 100644 --- a/httemplate/config/config.cgi +++ b/httemplate/config/config.cgi @@ -267,9 +267,24 @@ Setting <b><% $key %></b> <td><input type="button" value="add" onClick="doadd<% "$key$n" %>(this.form)"></td> </tr></table> +% } elsif ( $element_types{$type} ) { +% +% my %opt = ( 'element_name' => "$key$n", +% 'empty_label' => ' ', +% ); +% if ( $config_item->multiple ) { +% $opt{'multiple'} = 1 if $config_item->multiple; +% $opt{'curr_value'} = [ $conf->config($key, $agentnum) ]; +% } else { +% $opt{'curr_value'} = +% $conf->exists($key, $agentnum) ? $conf->config($key, $agentnum) : ''; +% } + + <% include("/elements/$type.html", %opt ) %> + % } else { - <font color="#ff0000">unknown type <% $type %></font> + <font color="#ff0000">unknown type <% $type %></font> % } % $n++; @@ -292,6 +307,10 @@ my $conf = new FS::Conf; my @config_items = $conf->config_items; my %confitems = map { $_->key => $_ } @config_items; +my %element_types = map { $_ => 1 } qw( + select-part_svc +); + </%once> <%init> |