From c082dd1a35a2e25b97f28ee137ec2c5b3b8052ca Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 22 Sep 2007 21:31:13 +0000 Subject: [PATCH] improve config UI, especially for textareas --- httemplate/config/config-view.cgi | 33 ++++++++++++++++++++++++-------- httemplate/config/config.cgi | 40 ++++++++++++++++++++++++++------------- 2 files changed, 52 insertions(+), 21 deletions(-) diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi index bca1f1603..f5cead575 100644 --- a/httemplate/config/config-view.cgi +++ b/httemplate/config/config-view.cgi @@ -1,12 +1,14 @@ <% include("/elements/header.html", $title, menubar( - 'Main Menu' => $p, 'View all agents' => $p.'browse/agent.cgi', ) ) %> +Click on a configuration value to change it. +

+ @@ -38,20 +40,31 @@ % }
- <% include('/elements/table.html', '#cccccc' ) %> + % foreach my $i (grep $_->section eq $section, @config_items) { +% my @types = ref($i->type) ? @{$i->type} : ($i->type); +% my( $width, $height ) = ( 522, 336 ); +% if ( grep $_ eq 'textarea', @types ) { +% #800x600 +% $width = 763; +% $height = 408; +% #1024x768 +% #$width = +% #$height = +% } - +% unless ( $description_printed ) { + +% } + +
<% ucfirst($section || 'unclassified') %> configuration options
- <% $i->key %> - <% $i->description %> + +%# <% $i->key %> - <% $i->description %> + <% $i->key %>: <% $i->description %> -% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { +% foreach my $type (@types) { % my $n = 0; % if ( $type eq '' ) { @@ -72,9 +85,13 @@ % } elsif ( $type eq 'checkbox' ) { diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi index 485565e80..b32f654d4 100644 --- a/httemplate/config/config.cgi +++ b/httemplate/config/config.cgi @@ -29,12 +29,20 @@ function SafeOnsubmit() { -Setting <% $key %> +Setting <% $key %> + +% my $description_printed = 0; +% if ( grep $_ eq 'textarea', @types ) { +% $description_printed = 1; + + - <% $description %> + +% }
-
-<% encode_entities(join("\n", $conf->config($i->key, $agentnum) ) ) %>
-
+
+<% encode_entities(join("\n",
+     map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
+         $conf->config($i->key, $agentnum)
+   ) )
+%>
+
% my $n = 0; -% foreach my $type ( ref($config_item->type) ? @{$config_item->type} : $config_item->type ) { +% foreach my $type (@types) { % if ( $type eq '' ) { no type @@ -45,7 +53,7 @@ Setting <% $key %> % } elsif ( $type eq 'textarea' ) { - + % } elsif ( $type eq 'checkbox' ) { @@ -260,7 +268,12 @@ Setting <% $key %> % $n++; % } - <% $description %>
+
<% $description %>
@@ -279,15 +292,15 @@ my %confitems = map { $_->key => $_ } @config_items; die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my($agentnum, $agent, $title, $action, $key, $value, $config_item, - $description, $type); - -$action = 'Set'; +my $action = 'Set'; +my $agentnum = ''; if ($cgi->param('agentnum') =~ /(\d+)$/) { $agentnum=$1; } +my $agent = ''; +my $title; if ($agentnum) { $agent = qsearchs('agent', { 'agentnum' => $1 } ); die "Agent $agentnum not found!" unless $agent; @@ -298,11 +311,12 @@ if ($agentnum) { } $cgi->param('key') =~ /^([-.\w]+)$/ or die "illegal configuration item"; -$key=$1; -$value = $conf->config($key); -$config_item = $confitems{$key}; +my $key = $1; +my $value = $conf->config($key); +my $config_item = $confitems{$key}; -$description = $config_item->description; -$type = $config_item->type; +my $description = $config_item->description; +my $config_type = $config_item->type; +my @types = ref($config_type) ? @$config_type : ($config_type); -- 2.11.0