Merge commit '17ce3572bf' into WebGUI8. All tests passing.
This commit is contained in:
commit
5e502fee53
117 changed files with 2012 additions and 1027 deletions
|
|
@ -297,7 +297,7 @@ JS
|
|||
$output .= '<div class="crumbTrail">'.join(" > ", @crumb)."</div>\n<ul>";
|
||||
|
||||
my $useAssetUrls = $session->config->get("richEditorsUseAssetUrls");
|
||||
my $children = $base->getLineage(["children"]);
|
||||
my $children = $base->getLineageIterator(["children"]);
|
||||
while ( my $child = $children->() ) {
|
||||
next unless $child->canView;
|
||||
$output .= '<li>';
|
||||
|
|
|
|||
|
|
@ -78,23 +78,23 @@ If true, this will limit the list of template to only include templates that are
|
|||
=cut
|
||||
|
||||
sub definition {
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Template');
|
||||
push(@{$definition}, {
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("assetName")
|
||||
},
|
||||
name=>{
|
||||
defaultValue=>"templateId"
|
||||
},
|
||||
namespace=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
onlyCommitted=>{
|
||||
defaultValue=>''
|
||||
},
|
||||
my $class = shift;
|
||||
my $session = shift;
|
||||
my $definition = shift || [];
|
||||
my $i18n = WebGUI::International->new($session, 'Asset_Template');
|
||||
push(@{$definition}, {
|
||||
label=>{
|
||||
defaultValue=>$i18n->get("assetName")
|
||||
},
|
||||
name=>{
|
||||
defaultValue=>"templateId"
|
||||
},
|
||||
namespace=>{
|
||||
defaultValue=>undef
|
||||
},
|
||||
onlyCommitted=>{
|
||||
defaultValue=>''
|
||||
},
|
||||
});
|
||||
return $class->SUPER::definition($session, $definition);
|
||||
}
|
||||
|
|
@ -138,6 +138,54 @@ sub isDynamicCompatible {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Returns the tempalte name of the selected template.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
|
||||
$self->setOptions;
|
||||
|
||||
return $self->SUPER::getValueAsHtml;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 setOptions
|
||||
|
||||
Fills the options of the select list with the appropriate templates.
|
||||
|
||||
=cut
|
||||
|
||||
sub setOptions {
|
||||
my $self = shift;
|
||||
my $session = $self->session;
|
||||
my $userId = $session->user->userId;
|
||||
|
||||
my $onlyCommitted = $self->get( 'onlyCommitted' )
|
||||
? q{assetData.status='approved'}
|
||||
: $self->get( 'onlyCommitted' )
|
||||
;
|
||||
my $templateList = WebGUI::Asset::Template->getList( $session, $self->get( 'namespace' ), $onlyCommitted );
|
||||
|
||||
#Remove entries from template list that the user does not have permission to view.
|
||||
for my $assetId ( keys %{$templateList} ) {
|
||||
my $asset = eval { WebGUI::Asset->newById($session, $assetId); };
|
||||
if (!Exception::Class->caught() && !$asset->canView($self->session->user->userId)) {
|
||||
delete $templateList->{$assetId};
|
||||
}
|
||||
}
|
||||
|
||||
$self->set( 'options', $templateList );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a template picker control.
|
||||
|
|
@ -145,18 +193,11 @@ Renders a template picker control.
|
|||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $onlyCommitted = $self->get('onlyCommitted') ? "assetData.status='approved'" : $self->get('onlyCommitted');
|
||||
my $templateList = WebGUI::Asset::Template->getList($self->session, $self->get("namespace"), $onlyCommitted);
|
||||
#Remove entries from template list that the user does not have permission to view.
|
||||
for my $assetId ( keys %{$templateList} ) {
|
||||
my $asset = WebGUI::Asset::Template->newById($self->session, $assetId);
|
||||
if (!$asset->canView($self->session->user->userId)) {
|
||||
delete $templateList->{$assetId};
|
||||
}
|
||||
}
|
||||
$self->set("options", $templateList);
|
||||
return $self->SUPER::toHtml();
|
||||
my $self = shift;
|
||||
|
||||
$self->setOptions;
|
||||
|
||||
return $self->SUPER::toHtml();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -36,6 +36,31 @@ The following methods are specifically available from this class. Check the supe
|
|||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'WebGUI')->get('user');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
Since this Form field requires a thingId to work it is not dynamic compatible.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
=head2 www_getThingFields ($session)
|
||||
|
|
|
|||
|
|
@ -58,6 +58,19 @@ Defaults to the setting textBoxSize or 30 if that's not set. Specifies how big o
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub getName {
|
||||
my ($self, $session) = @_;
|
||||
return WebGUI::International->new($session, 'Form_Username')->get('username');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [ value ] )
|
||||
|
||||
Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. Strip newlines/carriage returns from the value.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue