Merge branch 'master' of git@github.com:plainblack/webgui
This commit is contained in:
commit
5a329f8bf3
3 changed files with 143 additions and 29 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
- fixed #11604: scheduled workflows getting deleted
|
- fixed #11604: scheduled workflows getting deleted
|
||||||
- fixed #11613: Thingy: If next action after add is to add more things, previous data remains
|
- fixed #11613: Thingy: If next action after add is to add more things, previous data remains
|
||||||
- added API method commitAsUser allowing developers to commit version tags as other users
|
- added API method commitAsUser allowing developers to commit version tags as other users
|
||||||
|
- fixed: The template form plugin would return an empty string when getValueAsHtml was called. ( Martin Kamerbeek / Oqapi )
|
||||||
|
|
||||||
7.9.6
|
7.9.6
|
||||||
- new checkbox in the asset manager for clearing the package flag on import
|
- new checkbox in the asset manager for clearing the package flag on import
|
||||||
|
|
|
||||||
|
|
@ -78,23 +78,23 @@ If true, this will limit the list of template to only include templates that are
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub definition {
|
sub definition {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
my $definition = shift || [];
|
my $definition = shift || [];
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset_Template');
|
my $i18n = WebGUI::International->new($session, 'Asset_Template');
|
||||||
push(@{$definition}, {
|
push(@{$definition}, {
|
||||||
label=>{
|
label=>{
|
||||||
defaultValue=>$i18n->get("assetName")
|
defaultValue=>$i18n->get("assetName")
|
||||||
},
|
},
|
||||||
name=>{
|
name=>{
|
||||||
defaultValue=>"templateId"
|
defaultValue=>"templateId"
|
||||||
},
|
},
|
||||||
namespace=>{
|
namespace=>{
|
||||||
defaultValue=>undef
|
defaultValue=>undef
|
||||||
},
|
},
|
||||||
onlyCommitted=>{
|
onlyCommitted=>{
|
||||||
defaultValue=>''
|
defaultValue=>''
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return $class->SUPER::definition($session, $definition);
|
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 = WebGUI::Asset::Template->new( $session, $assetId );
|
||||||
|
if ( $asset && !$asset->canView( $userId ) ) {
|
||||||
|
delete $templateList->{ $assetId };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$self->set( 'options', $templateList );
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 toHtml ( )
|
=head2 toHtml ( )
|
||||||
|
|
||||||
Renders a template picker control.
|
Renders a template picker control.
|
||||||
|
|
@ -145,18 +193,11 @@ Renders a template picker control.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub toHtml {
|
sub toHtml {
|
||||||
my $self = shift;
|
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);
|
$self->setOptions;
|
||||||
#Remove entries from template list that the user does not have permission to view.
|
|
||||||
for my $assetId ( keys %{$templateList} ) {
|
return $self->SUPER::toHtml();
|
||||||
my $asset = WebGUI::Asset::Template->new($self->session, $assetId);
|
|
||||||
if (!$asset->canView($self->session->user->userId)) {
|
|
||||||
delete $templateList->{$assetId};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$self->set("options", $templateList);
|
|
||||||
return $self->SUPER::toHtml();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
72
t/Form/Template.t
Normal file
72
t/Form/Template.t
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# Please read the legal notices (docs/legal.txt) and the license
|
||||||
|
# (docs/license.txt) that came with this distribution before using
|
||||||
|
# this software.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# http://www.plainblack.com info@plainblack.com
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
use FindBin;
|
||||||
|
use strict;
|
||||||
|
use lib "$FindBin::Bin/../lib";
|
||||||
|
|
||||||
|
use WebGUI::Test;
|
||||||
|
use WebGUI::Form::Template;
|
||||||
|
use WebGUI::Session;
|
||||||
|
|
||||||
|
use Test::Deep;
|
||||||
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
plan tests => 4;
|
||||||
|
|
||||||
|
my $versionTag = WebGUI::VersionTag->create( $session );
|
||||||
|
$versionTag->setWorking;
|
||||||
|
|
||||||
|
{
|
||||||
|
my $templateList = WebGUI::Asset::Template->getList( $session, 'style' );
|
||||||
|
my $elem = WebGUI::Form::Template->new( $session, {
|
||||||
|
namespace => 'style',
|
||||||
|
onlyCommitted => 0,
|
||||||
|
} );
|
||||||
|
|
||||||
|
$elem->setOptions;
|
||||||
|
cmp_deeply(
|
||||||
|
$templateList,
|
||||||
|
$elem->get('options'),
|
||||||
|
'setOption sets correct templates'
|
||||||
|
);
|
||||||
|
|
||||||
|
my $newTemplate = WebGUI::Asset->getRoot( $session )->addChild( {
|
||||||
|
title => 'Klazam',
|
||||||
|
menuTitle => 'Klazam',
|
||||||
|
template => '',
|
||||||
|
namespace => 'style',
|
||||||
|
className => 'WebGUI::Asset::Template',
|
||||||
|
} );
|
||||||
|
|
||||||
|
$elem->setOptions;
|
||||||
|
cmp_deeply(
|
||||||
|
{ %{$templateList}, $newTemplate->getId => 'Klazam' },
|
||||||
|
$elem->get('options'),
|
||||||
|
'setOption includes uncommitted templates when onlyCommitted is false'
|
||||||
|
);
|
||||||
|
|
||||||
|
$elem->set( onlyCommitted => 1 );
|
||||||
|
$elem->setOptions;
|
||||||
|
cmp_deeply(
|
||||||
|
$templateList,
|
||||||
|
$elem->get('options'),
|
||||||
|
'setOption excludes uncommitted templates when onlyCommitted is true'
|
||||||
|
);
|
||||||
|
|
||||||
|
my ( $id, $name ) = %{ $templateList };
|
||||||
|
$elem->set( 'value', $id );
|
||||||
|
is( $elem->getValueAsHtml, $name, 'getValueAsHtml return template name' );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$versionTag->rollback;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue