From 81e426fe755eaea508041bc2d7b25ac44c777434 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 25 Sep 2009 10:14:30 +0000 Subject: nomadix, RT#5876 --- httemplate/config/config-process.cgi | 20 ++++++++++++++------ httemplate/config/config-view.cgi | 23 +++++++++++++++++++---- httemplate/config/config.cgi | 21 ++++++++++++++++++++- 3 files changed, 53 insertions(+), 11 deletions(-) (limited to 'httemplate/config') 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' +% ) +% { @@ -197,7 +199,7 @@ Click on a configuration value to change it. -% } elsif ( $type eq 'select-sub' ) { +% } elsif ( $type eq 'select-sub' ) { @@ -206,12 +208,25 @@ Click on a configuration value to change it. -% } else { +% } elsif ( $type eq 'select-part_svc' ) { +% my @svcparts = $conf->config($i->key, $agentnum); + + + + <% join('
', map { $_ # ': '. $svc + } + @svcparts + ) + %> + + + +% } else { unknown type <% $type %> -% } +% } % $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 <% $key %> (this.form)"> +% } 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 { - unknown type <% $type %> + unknown type <% $type %> % } % $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 +); + <%init> -- cgit v1.2.1