change AssetHelpers to have short IDs instead of class names
This will make better code reuse: The Asset Manager will instead call the AssetHelper with the id of "cut" or "copy" to get the correct operation.
This commit is contained in:
parent
f249070c50
commit
b9e879b7aa
22 changed files with 156 additions and 115 deletions
|
|
@ -656,10 +656,13 @@ sub www_processAssetHelper {
|
||||||
my ( $form ) = $session->quick(qw{ form });
|
my ( $form ) = $session->quick(qw{ form });
|
||||||
|
|
||||||
my $assetId = $form->get('assetId');
|
my $assetId = $form->get('assetId');
|
||||||
my $class = $form->get('className');
|
my $helperId = $form->get('helperId');
|
||||||
WebGUI::Pluggable::load( $class );
|
|
||||||
my $asset = WebGUI::Asset->newById( $session, $assetId );
|
my $asset = WebGUI::Asset->newById( $session, $assetId );
|
||||||
return JSON->new->encode( $class->process( $asset ) );
|
|
||||||
|
my $class = $asset->getHelpers->{ $helperId }->{ className };
|
||||||
|
WebGUI::Pluggable::load( $class );
|
||||||
|
my $helper = $class->new( id => $helperId, session => $self->session );
|
||||||
|
return JSON->new->encode( $helper->process( $asset ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1191,61 +1191,56 @@ sub getHelpers {
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
my ( $conf ) = $session->quick(qw{ config });
|
my ( $conf ) = $session->quick(qw{ config });
|
||||||
|
|
||||||
my $default = [
|
my $default = {
|
||||||
{
|
change_url => {
|
||||||
class => 'WebGUI::AssetHelper::ChangeUrl',
|
className => 'WebGUI::AssetHelper::ChangeUrl',
|
||||||
label => 'Change URL',
|
label => 'Change URL',
|
||||||
},
|
},
|
||||||
{
|
copy => {
|
||||||
class => 'WebGUI::AssetHelper::Copy',
|
className => 'WebGUI::AssetHelper::Copy',
|
||||||
label => 'Copy',
|
label => 'Copy',
|
||||||
},
|
},
|
||||||
{
|
copy_branch => {
|
||||||
class => 'WebGUI::AssetHelper::CopyBranch',
|
className => 'WebGUI::AssetHelper::CopyBranch',
|
||||||
label => 'Copy Branch',
|
label => 'Copy Branch',
|
||||||
},
|
},
|
||||||
{
|
shortcut => {
|
||||||
class => 'WebGUI::AssetHelper::CreateShortcut',
|
className => 'WebGUI::AssetHelper::CreateShortcut',
|
||||||
label => 'Create Shortcut',
|
label => 'Create Shortcut',
|
||||||
},
|
},
|
||||||
{
|
cut => {
|
||||||
class => 'WebGUI::AssetHelper::Cut',
|
className => 'WebGUI::AssetHelper::Cut',
|
||||||
label => 'Cut',
|
label => 'Cut',
|
||||||
},
|
},
|
||||||
{
|
edit => {
|
||||||
url => $self->getUrl( 'func=edit' ),
|
url => $self->getUrl( 'func=edit' ),
|
||||||
label => 'Edit',
|
label => 'Edit',
|
||||||
},
|
},
|
||||||
{
|
edit_branch => {
|
||||||
class => 'WebGUI::AssetHelper::EditBranch',
|
className => 'WebGUI::AssetHelper::EditBranch',
|
||||||
label => 'Edit Branch',
|
label => 'Edit Branch',
|
||||||
},
|
},
|
||||||
{
|
export_html => {
|
||||||
class => 'WebGUI::AssetHelper::ExportHtml',
|
className => 'WebGUI::AssetHelper::ExportHtml',
|
||||||
label => 'Export As HTML',
|
label => 'Export As HTML',
|
||||||
},
|
},
|
||||||
{
|
view => {
|
||||||
url => $self->getUrl( 'func=view' ),
|
url => $self->getUrl( 'func=view' ),
|
||||||
label => 'View',
|
label => 'View',
|
||||||
},
|
},
|
||||||
{
|
lock => {
|
||||||
class => 'WebGUI::AssetHelper::Lock',
|
className => 'WebGUI::AssetHelper::Lock',
|
||||||
label => 'Lock',
|
label => 'Lock',
|
||||||
},
|
},
|
||||||
];
|
};
|
||||||
|
|
||||||
|
# Merge additional helpers for this class from config
|
||||||
|
my $confHelpers = $conf->get('assets/' . $self->className . '/helpers') || {};
|
||||||
|
$default = { %$default, %$confHelpers };
|
||||||
|
|
||||||
# Get additional helpers for this class from config
|
# Process macros in labels
|
||||||
my $confHelpers = $conf->get('assets/' . $self->className . '/helpers');
|
for my $helper ( values %$default ) {
|
||||||
# Merge on label
|
|
||||||
for my $helper ( @$confHelpers ) {
|
|
||||||
WebGUI::Macro::process( \$helper->{label} );
|
WebGUI::Macro::process( \$helper->{label} );
|
||||||
if ( my $replace = first { $_->{label} eq $helper->{label} } @$default ) {
|
|
||||||
$replace = $helper; # replace in the default arrayref
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
push @$default, $helper;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $default;
|
return $default;
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,38 @@ the Admin Console.
|
||||||
|
|
||||||
=head1 SYNOPSIS
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
Despite using OO style methods, there are no AssetHelper objects. This is simply to provide inheritance.
|
package MyHelper;
|
||||||
|
use base 'WebGUI::AssetHelper';
|
||||||
|
|
||||||
|
sub process {
|
||||||
|
my ( $self, $asset ) = @_;
|
||||||
|
# Do stuff
|
||||||
|
return { message => 'Done stuff!' };
|
||||||
|
}
|
||||||
|
|
||||||
|
sub www_doOtherStuff {
|
||||||
|
my ( $self, $asset ) = @_;
|
||||||
|
# Do other stuff
|
||||||
|
}
|
||||||
|
|
||||||
|
=head1 ATTRIBUTES
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
use WebGUI::BestPractices;
|
||||||
|
use Moose;
|
||||||
|
|
||||||
|
has 'session' => (
|
||||||
|
is => 'ro',
|
||||||
|
required => 1,
|
||||||
|
isa => 'WebGUI::Session',
|
||||||
|
);
|
||||||
|
|
||||||
|
has 'id' => (
|
||||||
|
is => 'ro',
|
||||||
|
required => 1,
|
||||||
|
isa => 'Str',
|
||||||
|
);
|
||||||
|
|
||||||
=head1 METHODS
|
=head1 METHODS
|
||||||
|
|
||||||
|
|
@ -33,16 +64,12 @@ These methods are available from this class:
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 process ( $class, $asset )
|
=head2 process ( $asset )
|
||||||
|
|
||||||
This is a class method. Process is the default method called by the Asset Helper content handler.
|
Process is the default method called by the Admin Console.
|
||||||
It returns a hashref, that is converted by the content handler to JSON to be passed back to the
|
It returns a hashref, that is converted by the content handler to JSON to be passed back to the
|
||||||
Admin Console.
|
Admin Console.
|
||||||
|
|
||||||
=head3 $class
|
|
||||||
|
|
||||||
The name of the class this method was called as.
|
|
||||||
|
|
||||||
=head3 $asset
|
=head3 $asset
|
||||||
|
|
||||||
A WebGUI::Asset object.
|
A WebGUI::Asset object.
|
||||||
|
|
@ -82,14 +109,14 @@ An array reference of arguments that, when used with C<scriptMethod>, will be pa
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
|
|
||||||
##This method can do work, or it can delegate out to other methods.
|
##This method can do work, or it can delegate out to other methods.
|
||||||
|
|
||||||
return {
|
return {
|
||||||
error => q{User, we have a problem.},
|
error => q{User, we have a problem.},
|
||||||
message => q{A friendly informational method},
|
message => q{A friendly informational method},
|
||||||
open_tab => '?op=assetHelper;className=WebGUI::AssetHelper;method=editBranch',
|
open_tab => '?op=assetHelper;helperId=' . $self->id . ';method=editBranch',
|
||||||
redirect => '/home',
|
redirect => '/home',
|
||||||
scriptFile => q{URL},
|
scriptFile => q{URL},
|
||||||
scriptMethod => q{methodName},
|
scriptMethod => q{methodName},
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,14 @@ These methods are available from this class:
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 process ( $class, $asset )
|
=head2 process ( $asset )
|
||||||
|
|
||||||
Opens a new tab for displaying the form to change the Asset's URL.
|
Opens a new tab for displaying the form to change the Asset's URL.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
my $i18n = WebGUI::International->new($session, "Asset");
|
my $i18n = WebGUI::International->new($session, "Asset");
|
||||||
if (! $asset->canEdit) {
|
if (! $asset->canEdit) {
|
||||||
|
|
@ -51,20 +51,20 @@ sub process {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
openDialog => $asset->getUrl('op=assetHelper;className=WebGUI::AssetHelper::ChangeUrl;method=changeUrl;assetId=' . $asset->getId ),
|
openDialog => $asset->getUrl('op=assetHelper;helperId=' . $self->id . ';method=changeUrl;assetId=' . $asset->getId ),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_changeUrl ( $class, $asset )
|
=head2 www_changeUrl ( $asset )
|
||||||
|
|
||||||
Displays a form to change the URL for this asset.
|
Displays a form to change the URL for this asset.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_changeUrl {
|
sub www_changeUrl {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
my $i18n = WebGUI::International->new($session, "Asset");
|
my $i18n = WebGUI::International->new($session, "Asset");
|
||||||
if (! $asset->canEdit) {
|
if (! $asset->canEdit) {
|
||||||
|
|
@ -74,7 +74,7 @@ sub www_changeUrl {
|
||||||
}
|
}
|
||||||
my $f = WebGUI::FormBuilder->new($session, method => 'POST', action => $asset->getUrl );
|
my $f = WebGUI::FormBuilder->new($session, method => 'POST', action => $asset->getUrl );
|
||||||
$f->addField( "hidden", name => 'op', value => 'assetHelper' );
|
$f->addField( "hidden", name => 'op', value => 'assetHelper' );
|
||||||
$f->addField( "hidden", name => 'className', value => $class );
|
$f->addField( "hidden", name => 'helperId', value => $self->id );
|
||||||
$f->addField( "hidden", name => "method", value=>"changeUrlSave" );
|
$f->addField( "hidden", name => "method", value=>"changeUrlSave" );
|
||||||
$f->addField( "hidden", name => 'assetId', value => $asset->getId );
|
$f->addField( "hidden", name => 'assetId', value => $asset->getId );
|
||||||
$f->addField( "text",
|
$f->addField( "text",
|
||||||
|
|
@ -103,7 +103,7 @@ This actually does the change url of the www_changeUrl() function.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_changeUrlSave {
|
sub www_changeUrlSave {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
my $i18n = WebGUI::International->new($session, "Asset");
|
my $i18n = WebGUI::International->new($session, "Asset");
|
||||||
if (! $asset->canEdit) {
|
if (! $asset->canEdit) {
|
||||||
|
|
|
||||||
|
|
@ -32,30 +32,30 @@ These methods are available from this class:
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 process ( $class, $asset )
|
=head2 process ( $asset )
|
||||||
|
|
||||||
Open a progress dialog for the copy operation
|
Open a progress dialog for the copy operation
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
openDialog => '?op=assetHelper;className=' . $class . ';method=copy;assetId=' . $asset->getId,
|
openDialog => '?op=assetHelper;helperId=' . $self->id . ';method=copy;assetId=' . $asset->getId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_copy ( $class, $asset )
|
=head2 www_copy ( $asset )
|
||||||
|
|
||||||
Perform the copy operation, showing the progress.
|
Perform the copy operation, showing the progress.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_copy {
|
sub www_copy {
|
||||||
my ( $class, $asset ) = @_;
|
my ( $self, $asset ) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,36 +32,36 @@ These methods are available from this class:
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 process ( $class, $asset )
|
=head2 process ( $asset )
|
||||||
|
|
||||||
Open a progress dialog for the copy operation
|
Open a progress dialog for the copy operation
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
openDialog => '?op=assetHelper;className=' . $class . ';method=getWith;assetId=' . $asset->getId
|
openDialog => '?op=assetHelper;helperId=' . $self->id . ';method=getWith;assetId=' . $asset->getId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_getWith ( $class, $asset )
|
=head2 www_getWith ( $asset )
|
||||||
|
|
||||||
Get the "with" configuration. "Descendants" or "Children".
|
Get the "with" configuration. "Descendants" or "Children".
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_getWith {
|
sub www_getWith {
|
||||||
my ( $class, $asset ) = @_;
|
my ( $self, $asset ) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||||
|
|
||||||
return '<form style="text-align: center">'
|
return '<form style="text-align: center">'
|
||||||
. '<input type="hidden" name="op" value="assetHelper" />'
|
. '<input type="hidden" name="op" value="assetHelper" />'
|
||||||
. '<input type="hidden" name="className" value="' . $class . '" />'
|
. '<input type="hidden" name="helperId" value="' . $self->id . '" />'
|
||||||
. '<input type="hidden" name="assetId" value="' . $asset->getId . '" />'
|
. '<input type="hidden" name="assetId" value="' . $asset->getId . '" />'
|
||||||
. '<input type="hidden" name="method" value="copy" />'
|
. '<input type="hidden" name="method" value="copy" />'
|
||||||
. '<input type="submit" name="with" value="Children" />'
|
. '<input type="submit" name="with" value="Children" />'
|
||||||
|
|
@ -73,14 +73,14 @@ sub www_getWith {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_copy ( $class, $asset )
|
=head2 www_copy ( $asset )
|
||||||
|
|
||||||
Perform the copy operation, showing the progress.
|
Perform the copy operation, showing the progress.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_copy {
|
sub www_copy {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
|
|
||||||
$asset->forkWithStatusPage({
|
$asset->forkWithStatusPage({
|
||||||
|
|
|
||||||
|
|
@ -32,14 +32,14 @@ These methods are available from this class:
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 process ( $class, $asset )
|
=head2 process ( $asset )
|
||||||
|
|
||||||
Create a shortcut to the asset on the clipboard.
|
Create a shortcut to the asset on the clipboard.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
my $i18n = WebGUI::International->new( $session, 'WebGUI' );
|
my $i18n = WebGUI::International->new( $session, 'WebGUI' );
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ These methods are available from this class:
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 process ( $class, $asset )
|
=head2 process ( $asset )
|
||||||
|
|
||||||
Cuts the asset to the clipboard. If the user cannot edit the asset, or the asset is a
|
Cuts the asset to the clipboard. If the user cannot edit the asset, or the asset is a
|
||||||
system asset, it returns an error message.
|
system asset, it returns an error message.
|
||||||
|
|
@ -40,7 +40,7 @@ system asset, it returns an error message.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
|
|
||||||
my $i18n = WebGUI::International->new($session, 'WebGUI');
|
my $i18n = WebGUI::International->new($session, 'WebGUI');
|
||||||
|
|
@ -52,20 +52,20 @@ sub process {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
openDialog => '?op=assetHelper;className=' . $class . ';method=cut;assetId=' . $asset->getId,
|
openDialog => '?op=assetHelper;helperId=' . $self->id . ';method=cut;assetId=' . $asset->getId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 www_cut ( $class, $asset )
|
=head2 www_cut ( $asset )
|
||||||
|
|
||||||
Show the progress bar while cutting the asset.
|
Show the progress bar while cutting the asset.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_cut {
|
sub www_cut {
|
||||||
my ( $class, $asset ) = @_;
|
my ( $self, $asset ) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ Creates a tabform to edit the Asset Tree. If canEdit returns False, returns insu
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_editBranch {
|
sub www_editBranch {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
my ( $style, $url ) = $session->quick( qw( style url ) );
|
my ( $style, $url ) = $session->quick( qw( style url ) );
|
||||||
$style->setCss( $url->extras('hoverhelp.css'));
|
$style->setCss( $url->extras('hoverhelp.css'));
|
||||||
|
|
@ -84,7 +84,7 @@ ENDHTML
|
||||||
my $change = '<br />'.$i18n->get("change") . ' ';
|
my $change = '<br />'.$i18n->get("change") . ' ';
|
||||||
my $tabform = WebGUI::TabForm->new($session);
|
my $tabform = WebGUI::TabForm->new($session);
|
||||||
$tabform->hidden({name=>"op",value=>"assetHelper"});
|
$tabform->hidden({name=>"op",value=>"assetHelper"});
|
||||||
$tabform->hidden({name=>"className",value=>$class});
|
$tabform->hidden({name=>"helperId",value=>$self->id});
|
||||||
$tabform->hidden({name=>"method",value=>"editBranchSave"});
|
$tabform->hidden({name=>"method",value=>"editBranchSave"});
|
||||||
$tabform->hidden({name=>"assetId",value=>$asset->getId});
|
$tabform->hidden({name=>"assetId",value=>$asset->getId});
|
||||||
$tabform->addTab("properties",$i18n->get("properties"),9);
|
$tabform->addTab("properties",$i18n->get("properties"),9);
|
||||||
|
|
@ -312,7 +312,7 @@ Verifies proper inputs in the Asset Tree and saves them. Returns ManageAssets me
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_editBranchSave {
|
sub www_editBranchSave {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
return $session->privilege->insufficient() unless ($asset->canEdit && $session->user->isInGroup('4'));
|
return $session->privilege->insufficient() unless ($asset->canEdit && $session->user->isInGroup('4'));
|
||||||
my $form = $session->form;
|
my $form = $session->form;
|
||||||
|
|
|
||||||
|
|
@ -34,14 +34,14 @@ These methods are available from this class:
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 process ( $class, $asset )
|
=head2 process ( $asset )
|
||||||
|
|
||||||
Opens a new tab for displaying the form and the output for exporting a branch.
|
Opens a new tab for displaying the form and the output for exporting a branch.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
my $i18n = WebGUI::International->new($session, "Asset");
|
my $i18n = WebGUI::International->new($session, "Asset");
|
||||||
if (! $asset->canEdit) {
|
if (! $asset->canEdit) {
|
||||||
|
|
@ -51,7 +51,7 @@ sub process {
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
openDialog => '?op=assetHelper;className=' . $class . ';method=export;assetId=' . $asset->getId,
|
openDialog => '?op=assetHelper;helperId=' . $self->id . ';method=export;assetId=' . $asset->getId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ Displays the export page administrative interface
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_export {
|
sub www_export {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
return $session->privilege->insufficient() unless ($session->user->isInGroup(13));
|
return $session->privilege->insufficient() unless ($session->user->isInGroup(13));
|
||||||
my ( $style, $url ) = $session->quick(qw{ style url });
|
my ( $style, $url ) = $session->quick(qw{ style url });
|
||||||
|
|
@ -81,7 +81,7 @@ ENDHTML
|
||||||
my $i18n = WebGUI::International->new($session, "Asset");
|
my $i18n = WebGUI::International->new($session, "Asset");
|
||||||
my $f = WebGUI::FormBuilder->new($session, action => $asset->getUrl);
|
my $f = WebGUI::FormBuilder->new($session, action => $asset->getUrl);
|
||||||
$f->addField( "hidden", name => 'op', value => 'assetHelper' );
|
$f->addField( "hidden", name => 'op', value => 'assetHelper' );
|
||||||
$f->addField( "hidden", name => 'className', value => $class );
|
$f->addField( "hidden", name => 'helperId', value => $self->id );
|
||||||
$f->addField( "hidden", name => 'assetId', value => $asset->getId );
|
$f->addField( "hidden", name => 'assetId', value => $asset->getId );
|
||||||
$f->addField( "hidden",
|
$f->addField( "hidden",
|
||||||
name => "method",
|
name => "method",
|
||||||
|
|
@ -155,7 +155,7 @@ Displays the export status page
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_exportStatus {
|
sub www_exportStatus {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
return $session->privilege->insufficient
|
return $session->privilege->insufficient
|
||||||
unless $session->user->isInGroup(13);
|
unless $session->user->isInGroup(13);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ These methods are available from this class:
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 process ( $class, $asset )
|
=head2 process ( $asset )
|
||||||
|
|
||||||
Locks the asset with a version tag. If the user cannot edit the asset, or the asset is
|
Locks the asset with a version tag. If the user cannot edit the asset, or the asset is
|
||||||
already locked, it returns an error message.
|
already locked, it returns an error message.
|
||||||
|
|
@ -41,7 +41,7 @@ already locked, it returns an error message.
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($class, $asset) = @_;
|
my ($self, $asset) = @_;
|
||||||
my $session = $asset->session;
|
my $session = $asset->session;
|
||||||
|
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||||
|
|
|
||||||
|
|
@ -83,14 +83,20 @@ sub handler {
|
||||||
|
|
||||||
if ( $session->form->get("op") eq "assetHelper" ) {
|
if ( $session->form->get("op") eq "assetHelper" ) {
|
||||||
# Load and run the requested asset helper www_ method
|
# Load and run the requested asset helper www_ method
|
||||||
my $class = $session->form->get('className');
|
|
||||||
WebGUI::Pluggable::load( $class );
|
|
||||||
my $method = $session->form->get('method') || "view";
|
|
||||||
my $assetId = $session->form->get('assetId');
|
my $assetId = $session->form->get('assetId');
|
||||||
my $asset = WebGUI::Asset->newById( $session, $assetId );
|
my $asset = WebGUI::Asset->newById( $session, $assetId );
|
||||||
|
|
||||||
if ( $class->can( "www_" . $method ) ) {
|
my $helperId = $session->form->get('helperId');
|
||||||
return $class->can( "www_" . $method )->( $class, $asset );
|
my $class = $asset->getHelpers->{ $helperId }->{ className };
|
||||||
|
WebGUI::Pluggable::load( $class );
|
||||||
|
my $helper = $class->new( id => $helperId, session => $session );
|
||||||
|
|
||||||
|
my $method = $session->form->get('method') || "view";
|
||||||
|
if ( $helper->can( "www_" . $method ) ) {
|
||||||
|
return $helper->can( "www_" . $method )->( $helper, $asset );
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$session->log->error( sprintf 'Invalid asset helper "%s" calling method "%s"', $helperId, $method );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,10 +81,10 @@ $mech->get('/'); # Start a session
|
||||||
$mech->session->user({ userId => '3' });
|
$mech->session->user({ userId => '3' });
|
||||||
|
|
||||||
# www_processAssetHelper
|
# www_processAssetHelper
|
||||||
$mech->get_ok( '/?op=admin;method=processAssetHelper;className=WebGUI::AssetHelper::Cut;assetId=' . $snip->getId );
|
$mech->get_ok( '/?op=admin;method=processAssetHelper;helperId=cut;assetId=' . $snip->getId );
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
JSON->new->decode( $mech->content ),
|
JSON->new->decode( $mech->content ),
|
||||||
WebGUI::AssetHelper::Cut->process( $snip ),
|
WebGUI::AssetHelper::Cut->new( id => 'cut', session => $session )->process( $snip ),
|
||||||
'www_processAssetHelper',
|
'www_processAssetHelper',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,9 +35,10 @@ my $asset = WebGUI::Test->asset->addChild( {
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Check permissions
|
# Check permissions
|
||||||
|
my $helper = WebGUI::AssetHelper::ChangeUrl->new( id => 'change_url', session => $session );
|
||||||
|
|
||||||
$session->user({ userId => 1 });
|
$session->user({ userId => 1 });
|
||||||
my $output = WebGUI::AssetHelper::ChangeUrl->process( $asset );
|
my $output = $helper->process( $asset );
|
||||||
ok( $output->{error}, "Errors on bad permissions" );
|
ok( $output->{error}, "Errors on bad permissions" );
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -45,7 +46,7 @@ ok( $output->{error}, "Errors on bad permissions" );
|
||||||
# Change URL!
|
# Change URL!
|
||||||
|
|
||||||
$session->user({ userId => 3 }); # By the power of grayskull!
|
$session->user({ userId => 3 }); # By the power of grayskull!
|
||||||
my $output = WebGUI::AssetHelper::ChangeUrl->process( $asset );
|
my $output = $helper->process( $asset );
|
||||||
cmp_deeply( $output, {
|
cmp_deeply( $output, {
|
||||||
openDialog => all(
|
openDialog => all(
|
||||||
re( 'method=changeUrl' ),
|
re( 'method=changeUrl' ),
|
||||||
|
|
|
||||||
|
|
@ -36,16 +36,18 @@ plan tests => 3; # Increment this number for each test you create
|
||||||
# put your tests here
|
# put your tests here
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
|
my $helper = WebGUI::AssetHelper::Copy->new( id => 'copy', session => $session );
|
||||||
my $home = WebGUI::Asset->getDefault($session);
|
my $home = WebGUI::Asset->getDefault($session);
|
||||||
my $root = WebGUI::Asset->getRoot($session);
|
my $root = WebGUI::Asset->getRoot($session);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$output = WebGUI::AssetHelper::Copy->process($home);
|
$output = $helper->process($home);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
openDialog => all(
|
openDialog => all(
|
||||||
|
re('helperId=copy'),
|
||||||
re('method=copy'),
|
re('method=copy'),
|
||||||
re('assetId=' . $home->getId ),
|
re('assetId=' . $home->getId ),
|
||||||
),
|
),
|
||||||
|
|
@ -55,7 +57,7 @@ my $root = WebGUI::Asset->getRoot($session);
|
||||||
}
|
}
|
||||||
|
|
||||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::Copy;method=copy;assetId=' . $home->getId );
|
$mech->get_ok( '/?op=assetHelper;helperId=copy;method=copy;assetId=' . $home->getId );
|
||||||
|
|
||||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||||
is @{ $clippies }, 1, '... only copied 1 asset to the clipboard, no children';
|
is @{ $clippies }, 1, '... only copied 1 asset to the clipboard, no children';
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ plan tests => 5; # Increment this number for each test you create
|
||||||
# put your tests here
|
# put your tests here
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
|
my $helper = WebGUI::AssetHelper::CopyBranch->new( id => 'copy_branch', session => $session );
|
||||||
my $node = WebGUI::Asset->getImportNode($session);
|
my $node = WebGUI::Asset->getImportNode($session);
|
||||||
my $root = WebGUI::Asset->getRoot( $session );
|
my $root = WebGUI::Asset->getRoot( $session );
|
||||||
my $tag = WebGUI::VersionTag->getWorking( $session );
|
my $tag = WebGUI::VersionTag->getWorking( $session );
|
||||||
|
|
@ -60,11 +61,12 @@ addToCleanup( $tag );
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$output = WebGUI::AssetHelper::CopyBranch->process($top);
|
$output = $helper->process($top);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
openDialog => all(
|
openDialog => all(
|
||||||
|
re('helperId=copy_branch'),
|
||||||
re('method=getWith'),
|
re('method=getWith'),
|
||||||
re('assetId=' . $top->getId ),
|
re('assetId=' . $top->getId ),
|
||||||
),
|
),
|
||||||
|
|
@ -74,7 +76,7 @@ addToCleanup( $tag );
|
||||||
}
|
}
|
||||||
|
|
||||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::CopyBranch;method=copy;with=children;assetId=' . $top->getId );
|
$mech->get_ok( '/?op=assetHelper;helperId=copy_branch;method=copy;with=children;assetId=' . $top->getId );
|
||||||
WebGUI::Test->waitForAllForks;
|
WebGUI::Test->waitForAllForks;
|
||||||
|
|
||||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||||
|
|
@ -83,7 +85,7 @@ for my $asset ( @$clippies ) {
|
||||||
$asset->purge;
|
$asset->purge;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::CopyBranch;method=copy;with=descendants;assetId=' . $top->getId );
|
$mech->get_ok( '/?op=assetHelper;helperId=copy_branch;method=copy;with=descendants;assetId=' . $top->getId );
|
||||||
WebGUI::Test->waitForAllForks;
|
WebGUI::Test->waitForAllForks;
|
||||||
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
my $clippies = $root->getLineage(["descendants"], {statesToInclude => [qw{clipboard clipboard-limbo}], returnObjects => 1,});
|
||||||
is @{ $clippies }, 3, '... copied 3 asset to the clipboard';
|
is @{ $clippies }, 3, '... copied 3 asset to the clipboard';
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,12 @@ my $session = WebGUI::Test->session;
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
|
my $helper = WebGUI::AssetHelper::CreateShortcut->new( id => 'shortcut', session => $session );
|
||||||
my $import = WebGUI::Asset->getImportNode($session);
|
my $import = WebGUI::Asset->getImportNode($session);
|
||||||
|
|
||||||
my $priv_page = WebGUI::Test->asset( groupIdView => '3' );
|
my $priv_page = WebGUI::Test->asset( groupIdView => '3' );
|
||||||
$session->user({userId => 1});
|
$session->user({userId => 1});
|
||||||
$output = WebGUI::AssetHelper::CreateShortcut->process($priv_page);
|
$output = $helper->process($priv_page);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
@ -48,7 +49,7 @@ $session->setting->set( versionTagMode => 'autoCommit' );
|
||||||
$session->setting->set( skipCommitComments => '1' );
|
$session->setting->set( skipCommitComments => '1' );
|
||||||
$session->user({userId => 3});
|
$session->user({userId => 3});
|
||||||
my $safe_page = WebGUI::Test->asset;
|
my $safe_page = WebGUI::Test->asset;
|
||||||
$output = WebGUI::AssetHelper::CreateShortcut->process($safe_page);
|
$output = $helper->process($safe_page);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,10 +31,11 @@ my $session = WebGUI::Test->session;
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
|
my $helper = WebGUI::AssetHelper::Cut->new( id => 'cut', session => $session );
|
||||||
my $import = WebGUI::Asset->getImportNode($session);
|
my $import = WebGUI::Asset->getImportNode($session);
|
||||||
|
|
||||||
$session->user({userId => 1});
|
$session->user({userId => 1});
|
||||||
$output = WebGUI::AssetHelper::Cut->process($import);
|
$output = $helper->process($import);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
@ -44,7 +45,7 @@ cmp_deeply(
|
||||||
);
|
);
|
||||||
|
|
||||||
$session->user({userId => 3});
|
$session->user({userId => 3});
|
||||||
$output = WebGUI::AssetHelper::Cut->process($import);
|
$output = $helper->process($import);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
@ -54,7 +55,7 @@ cmp_deeply(
|
||||||
);
|
);
|
||||||
|
|
||||||
my $safe_page = $import->getFirstChild;
|
my $safe_page = $import->getFirstChild;
|
||||||
$output = WebGUI::AssetHelper::Cut->process($safe_page);
|
$output = $helper->process($safe_page);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ my $session = WebGUI::Test->session;
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
|
my $helper = WebGUI::AssetHelper::EditBranch->new( id => 'edit_branch', session => $session );
|
||||||
my $node = WebGUI::Asset->getImportNode($session);
|
my $node = WebGUI::Asset->getImportNode($session);
|
||||||
my $root = WebGUI::Asset->getRoot( $session );
|
my $root = WebGUI::Asset->getRoot( $session );
|
||||||
my $top = $node->addChild({
|
my $top = $node->addChild({
|
||||||
|
|
@ -54,7 +55,7 @@ WebGUI::Test->addToCleanup( $top, $child, $grand );
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$output = WebGUI::AssetHelper::EditBranch->process($top);
|
$output = $helper->process($top);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +71,7 @@ WebGUI::Test->addToCleanup( $top, $child, $grand );
|
||||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||||
$mech->get('/');
|
$mech->get('/');
|
||||||
$mech->session->user({ userId => 3 });
|
$mech->session->user({ userId => 3 });
|
||||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::EditBranch;method=editBranch;assetId=' . $top->getId );
|
$mech->get_ok( '/?op=assetHelper;helperId=edit_branch;method=editBranch;assetId=' . $top->getId );
|
||||||
$mech->submit_form_ok({
|
$mech->submit_form_ok({
|
||||||
fields => {
|
fields => {
|
||||||
ownerUserId => '3',
|
ownerUserId => '3',
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ my $session = WebGUI::Test->session;
|
||||||
$session->user({ userId => 3 });
|
$session->user({ userId => 3 });
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
|
my $helper = WebGUI::AssetHelper::ExportHtml->new( id => 'export_html', session => $session );
|
||||||
my $node = WebGUI::Asset->getImportNode($session);
|
my $node = WebGUI::Asset->getImportNode($session);
|
||||||
my $root = WebGUI::Asset->getRoot( $session );
|
my $root = WebGUI::Asset->getRoot( $session );
|
||||||
my $top = $node->addChild({
|
my $top = $node->addChild({
|
||||||
|
|
@ -62,7 +63,7 @@ WebGUI::Test->config->set( "exportPath" => $dir->dirname );
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
$output = WebGUI::AssetHelper::ExportHtml->process($top);
|
$output = $helper->process($top);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +79,7 @@ WebGUI::Test->config->set( "exportPath" => $dir->dirname );
|
||||||
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||||
$mech->get('/');
|
$mech->get('/');
|
||||||
$mech->session->user({ userId => 3 });
|
$mech->session->user({ userId => 3 });
|
||||||
$mech->get_ok( '/?op=assetHelper;className=WebGUI::AssetHelper::ExportHtml;method=export;assetId=' . $top->getId );
|
$mech->get_ok( '/?op=assetHelper;helperId=export_html;method=export;assetId=' . $top->getId );
|
||||||
$mech->submit_form_ok({
|
$mech->submit_form_ok({
|
||||||
fields => {
|
fields => {
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,9 @@ my $newPage = $home->addChild({
|
||||||
|
|
||||||
$newPage = WebGUI::Asset->newById($session, $newPage->assetId);
|
$newPage = WebGUI::Asset->newById($session, $newPage->assetId);
|
||||||
|
|
||||||
|
my $helper = WebGUI::AssetHelper::Lock->new( id => 'lock', session => $session );
|
||||||
$session->user({userId => 1});
|
$session->user({userId => 1});
|
||||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
$output = $helper->process($newPage);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
@ -56,7 +57,7 @@ cmp_deeply(
|
||||||
);
|
);
|
||||||
|
|
||||||
$session->user({userId => 3});
|
$session->user({userId => 3});
|
||||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
$output = $helper->process($newPage);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +71,7 @@ ok $newPage->isLocked, 'Asset is locked, and ready for next test';
|
||||||
is $newPage->getRevisionCount, 2, 'new revision added';
|
is $newPage->getRevisionCount, 2, 'new revision added';
|
||||||
|
|
||||||
$session->user({userId => $editor->getId});
|
$session->user({userId => $editor->getId});
|
||||||
$output = WebGUI::AssetHelper::Lock->process($newPage);
|
$output = $helper->process($newPage);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -454,28 +454,28 @@ WebGUI.Admin.prototype.updateAssetHelpers
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add new ones
|
// Add new ones
|
||||||
for ( var i = 0; i < assetDef.helpers.length; i++ ) {
|
for ( var helperId in assetDef.helpers ) {
|
||||||
var helper = assetDef.helpers[i];
|
var helper = assetDef.helpers[helperId];
|
||||||
var li = document.createElement('li');
|
var li = document.createElement('li');
|
||||||
li.className = "clickable with_icon";
|
li.className = "clickable with_icon";
|
||||||
li.appendChild( document.createTextNode( helper.label ) );
|
li.appendChild( document.createTextNode( helper.label ) );
|
||||||
this.addHelperHandler( li, helper );
|
this.addHelperHandler( li, helperId, helper );
|
||||||
helperEl.appendChild( li );
|
helperEl.appendChild( li );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* addHelperHandler( elem, helper )
|
* addHelperHandler( elem, helperId, helper )
|
||||||
* Add the click handler to activate the given helper
|
* Add the click handler to activate the given helper
|
||||||
*/
|
*/
|
||||||
WebGUI.Admin.prototype.addHelperHandler
|
WebGUI.Admin.prototype.addHelperHandler
|
||||||
= function ( elem, helper ) {
|
= function ( elem, helperId, helper ) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if ( helper.url ) {
|
if ( helper.url ) {
|
||||||
YAHOO.util.Event.on( elem, "click", function(){ self.gotoAsset( helper.url ) }, self, true );
|
YAHOO.util.Event.on( elem, "click", function(){ self.gotoAsset( helper.url ) }, self, true );
|
||||||
}
|
}
|
||||||
else if ( helper['class'] ) {
|
else {
|
||||||
YAHOO.util.Event.on( elem, "click", function(){ self.requestHelper( helper['class'], self.currentAssetDef.assetId ) }, self, true );
|
YAHOO.util.Event.on( elem, "click", function(){ self.requestHelper( helperId, self.currentAssetDef.assetId ) }, self, true );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -535,7 +535,7 @@ WebGUI.Admin.prototype.requestUpdateCurrentVersionTag
|
||||||
* Request the Asset Helper for the given assetId
|
* Request the Asset Helper for the given assetId
|
||||||
*/
|
*/
|
||||||
WebGUI.Admin.prototype.requestHelper
|
WebGUI.Admin.prototype.requestHelper
|
||||||
= function ( helperClass, assetId ) {
|
= function ( helperId, assetId ) {
|
||||||
var callback = {
|
var callback = {
|
||||||
success : function (o) {
|
success : function (o) {
|
||||||
var resp = YAHOO.lang.JSON.parse( o.responseText );
|
var resp = YAHOO.lang.JSON.parse( o.responseText );
|
||||||
|
|
@ -547,7 +547,7 @@ WebGUI.Admin.prototype.requestHelper
|
||||||
scope: this
|
scope: this
|
||||||
};
|
};
|
||||||
|
|
||||||
var url = '?op=admin;method=processAssetHelper;className=' + helperClass + ';assetId=' + assetId;
|
var url = '?op=admin;method=processAssetHelper;helperId=' + helperId + ';assetId=' + assetId;
|
||||||
var ajax = YAHOO.util.Connect.asyncRequest( 'GET', url, callback );
|
var ajax = YAHOO.util.Connect.asyncRequest( 'GET', url, callback );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue