summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/config/config-process.cgi20
-rw-r--r--httemplate/config/config-view.cgi23
-rw-r--r--httemplate/config/config.cgi21
-rw-r--r--httemplate/elements/select-part_svc.html18
-rw-r--r--httemplate/elements/select-table.html11
-rw-r--r--httemplate/elements/tr-select-part_svc.html7
6 files changed, 82 insertions, 18 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>
diff --git a/httemplate/elements/select-part_svc.html b/httemplate/elements/select-part_svc.html
new file mode 100644
index 000000000..72ab7f6b0
--- /dev/null
+++ b/httemplate/elements/select-part_svc.html
@@ -0,0 +1,18 @@
+<% include( '/elements/select-table.html',
+ 'table' => 'part_svc',
+ 'name_col' => 'svc',
+ 'label_showkey' => 1,
+ #N/A 'empty_label' => '(none)',
+ %opt,
+ )
+%>
+<%init>
+
+my( %opt ) = @_;
+
+$opt{'records'} = delete $opt{'part_svc'}
+ if $opt{'part_svc'};
+
+$opt{'records'} ||= [ qsearch( 'part_svc', {} ) ]; # { disabled=>'' } )
+
+</%init>
diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html
index 1a440f07e..10a8b2741 100644
--- a/httemplate/elements/select-table.html
+++ b/httemplate/elements/select-table.html
@@ -34,6 +34,7 @@ Example:
'empty_label' => '', #better specify it though, the default might change
'multiple' => 0, # bool
'disable_empty' => 0, # bool (implied by multiple)
+ 'label_showkey' => 0, # bool
'label_callback' => sub { my $record = shift; return "label"; },
#more params controlling HTML stuff about the <SELECT>
@@ -77,13 +78,19 @@ Example:
<OPTION VALUE=""><% $opt{'empty_label'} || 'all' %>
% }
-% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col() } @records ) {
+% foreach my $record ( sort { $a->$name_col() cmp $b->$name_col()
+% || $a->$key() <=> $b->$key()
+% }
+% @records
+% )
+% {
% my $recvalue = $record->$key();
<OPTION VALUE="<% $recvalue %>"
<% ref($value) && $value->{$recvalue} || $value == $recvalue
? ' SELECTED' : ''
%>
- ><% $opt{'label_callback'}
+ ><% $opt{'label_showkey'} ? "$recvalue: " : '' %>
+ <% $opt{'label_callback'}
? &{ $opt{'label_callback'} }( $record )
: $record->$name_col()
%>
diff --git a/httemplate/elements/tr-select-part_svc.html b/httemplate/elements/tr-select-part_svc.html
index 0274ef12a..af5148749 100644
--- a/httemplate/elements/tr-select-part_svc.html
+++ b/httemplate/elements/tr-select-part_svc.html
@@ -7,11 +7,8 @@
<TR>
<TD ALIGN="right"><% $opt{'label'} || 'Package definition' %></TD>
<TD>
- <% include( '/elements/select-table.html',
- 'table' => 'part_svc',
- 'name_col' => 'svc',
- 'multiple' => 1,
- #N/A 'empty_label' => '(none)',
+ <% include( '/elements/select-part_svc.html',
+ 'multiple' => 1,
%opt,
)
%>