diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 90fbf42c0..a35138c23 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,4 +1,6 @@ 6.7.0 + - Added the ability to override the UI Level of any field in the edit form of + any asset in the WebGUI config file. - fix [ 1229042 ] crumbtrail should show full path... - Added asset versioning. - fix [ 1229188 ] typo in Help: Collaboration, Post List Template Variables diff --git a/etc/WebGUI.conf.original b/etc/WebGUI.conf.original index 66a454d09..fa111c429 100644 --- a/etc/WebGUI.conf.original +++ b/etc/WebGUI.conf.original @@ -137,6 +137,15 @@ utilityAssets = WebGUI::Asset::Template, \ #assetAddPrivilege = WebGUI::Asset::Wobject::SQLReport => 3, \ # WebGUI:::Asset::Template => 4 +# You can override the UI Levels of any field in the edit form of +# any asset using the following variables. Basically just take the +# class name of the asset seperated by underscores, and append +# _uiLevel to the end of it, then you can start specifying field +# names and associated UI Level. + +#WebGUI_Asset_Wobject_Article = menuTitle => 9, url => 8 +#WebGUI_Asset_RichEdit = askAboutRichEdit => 7, preformatted => 3 + # If exportPath is defined, an "Export" toolbar icon will appear # which allows you to export assets to static html. This folder # needs to be writable by your web server. diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 2673e9512..29a5ab900 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -960,7 +960,9 @@ Creates and returns a tabform to edit parameters of an Asset. sub getEditForm { my $self = shift; - my $tabform = WebGUI::TabForm->new(undef,undef,$self->getUrl()); + my $uiLevelOverride = $self->get("className"); + $uiLevelOverride =~ s/\:\:/_/g; + my $tabform = WebGUI::TabForm->new(undef,undef,$self->getUrl(),$uiLevelOverride); $tabform->hidden({ name=>"func", value=>"editSave" diff --git a/lib/WebGUI/Form/Control.pm b/lib/WebGUI/Form/Control.pm index 78b5aa24d..5bf701b46 100644 --- a/lib/WebGUI/Form/Control.pm +++ b/lib/WebGUI/Form/Control.pm @@ -362,10 +362,8 @@ Renders the form field to HTML as a table row complete with labels, subtext, hov sub toHtmlWithWrapper { my $self = shift; - if ($self->{uiLevel} <= $session{user}{uiLevel} - || ( $session{config}{$self->{uiLevelOverride}}{$self->{name}} - && $session{config}{$self->{uiLevelOverride}}{$self->{name}} <= $session{user}{uiLevel})) - { +WebGUI::ErrorHandler::debug($session{config}{$self->{uiLevelOverride}."_uiLevel"}{$self->{name}}); + if ($self->{uiLevel} <= $session{user}{uiLevel} && $session{config}{$self->{uiLevelOverride}."_uiLevel"}{$self->{name}} <= $session{user}{uiLevel}) { my $rowClass = $self->{rowClass}; $rowClass = qq| class="$rowClass" | if($self->{rowClass}); my $labelClass = $self->{labelClass}; diff --git a/lib/WebGUI/Form/button.pm b/lib/WebGUI/Form/button.pm index 69fee4df9..e0f25206a 100644 --- a/lib/WebGUI/Form/button.pm +++ b/lib/WebGUI/Form/button.pm @@ -59,6 +59,9 @@ sub definition { push(@{$definition}, { defaultValue=>{ defaultValue=>WebGUI::International::get(62,"WebGUI") + }, + label=>{ + defaultValue=>"" } }); return $class->SUPER::definition($definition); diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index af2915b4c..4bdf233ac 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -120,7 +120,8 @@ sub AUTOLOAD { our $AUTOLOAD; my $self = shift; my $name = (split /::/, $AUTOLOAD)[-1]; - my @params = @_; + my %params = @_; + $params{uiLevelOverride} ||= $self->{_uiLevelOverride}; my $cmd = "use WebGUI::Form::".$name; eval ($cmd); if ($@) { @@ -128,7 +129,7 @@ sub AUTOLOAD { return undef; } my $class = "WebGUI::Form::".$name; - $self->{_data} .= $class->new(@params)->toHtmlWithWrapper; + $self->{_data} .= $class->new(%params)->toHtmlWithWrapper; } #------------------------------------------------------------------- @@ -227,20 +228,19 @@ If you want to add anything special to the form's table like a name or styleshee sub new { my ($header, $footer); - my ($self, @p) = @_; - my ($noTable, $action, $method, $extras, $enctype, $tableExtras) = - rearrange([qw(noTable action method extras enctype tableExtras)], @p); - $noTable = $noTable || 0; + my $class = shift; + my %param = @_; + $param{noTable} ||= 0; $header = "\n\n".WebGUI::Form::formHeader({ - "action"=>$action, - "extras"=>$extras, - "method"=>$method, - "enctype"=>$enctype + action=>$param{action}, + extras=>$param{extras}, + method=>$param{method}, + enctype=>$param{enctype} }); - $header .= "\n' unless ($noTable); - $footer = "
\n" unless ($noTable); + $header .= "\n' unless ($param{noTable}); + $footer = "
\n" unless ($param{noTable}); $footer .= WebGUI::Form::formFooter(); - bless {_noTable => $noTable, _header => $header, _footer => $footer, _data => ''}, $self; + bless {_uiLevelOverride=>$param{uiLevelOverride}, _noTable => $param{noTable}, _header => $header, _footer => $footer, _data => ''}, $class; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Operation/User.pm b/lib/WebGUI/Operation/User.pm index 2a0b010a7..ea9353efc 100644 --- a/lib/WebGUI/Operation/User.pm +++ b/lib/WebGUI/Operation/User.pm @@ -121,6 +121,7 @@ sub getUserSearchForm { $f->selectList( -name=>"modifier", -value=>([$session{scratch}{userSearchModifier} || "contains"]), + -label=>"", -options=>{ startsWith=>WebGUI::International::get("starts with"), contains=>WebGUI::International::get("contains"), @@ -129,11 +130,13 @@ sub getUserSearchForm { ); $f->text( -name=>"keyword", + -label=>"", -value=>$session{scratch}{userSearchKeyword}, -size=>15 ); $f->selectList( -name => "status", + -label=>"", -value => [$session{scratch}{userSearchStatus} || "users.status like '%'"], -options=> { "" => WebGUI::International::get(821), @@ -142,7 +145,7 @@ sub getUserSearchForm { Selfdestructed => WebGUI::International::get(819) } ); - $f->submit(WebGUI::International::get(170)); + $f->submit(value=>WebGUI::International::get(170)); $output .= $f->print; $output .= ''; return $output; diff --git a/lib/WebGUI/TabForm.pm b/lib/WebGUI/TabForm.pm index 8b98070a8..6214e9cd5 100644 --- a/lib/WebGUI/TabForm.pm +++ b/lib/WebGUI/TabForm.pm @@ -98,7 +98,7 @@ sub addTab { my $name = shift; my $label = shift; my $uiLevel = shift || 0; - $self->{_tab}{$name}{form} = WebGUI::HTMLForm->new; + $self->{_tab}{$name}{form} = WebGUI::HTMLForm->new(uiLevelOverride=>$self->{_uiLevelOverride}); $self->{_tab}{$name}{label} = $label; $self->{_tab}{$name}{uiLevel} = $uiLevel; } @@ -197,10 +197,11 @@ sub new { my $startingTabs = shift; my $css = shift || $session{config}{extrasURL}.'/tabs/tabs.css'; my $cancelUrl = shift || WebGUI::URL::page(); + my $uiLevelOverride = shift; my %tabs; tie %tabs, 'Tie::IxHash'; foreach my $key (keys %{$startingTabs}) { - $tabs{$key}{form} = WebGUI::HTMLForm->new; + $tabs{$key}{form} = WebGUI::HTMLForm->new(uiLevelOverride=>$uiLevelOverride); $tabs{$key}{label} = $startingTabs->{$key}->{label}; $tabs{$key}{uiLevel} = $startingTabs->{$key}->{uiLevel}; } @@ -208,7 +209,7 @@ sub new { value=>WebGUI::International::get('cancel'), extras=>q|onClick="location.href='|.$cancelUrl.q|'"| }); - bless { _cancel=>$cancel, _submit=>WebGUI::Form::submit(), _form=>WebGUI::Form::formHeader(), _hidden=>"", _tab=>\%tabs, _css=>$css }, $class; + bless { _uiLevelOverride=>$uiLevelOverride, _cancel=>$cancel, _submit=>WebGUI::Form::submit(), _form=>WebGUI::Form::formHeader(), _hidden=>"", _tab=>\%tabs, _css=>$css }, $class; }