Make the AssetManager use Asset*.pm for cut, copy, paste, rank and duplicate.
This commit is contained in:
parent
44bc4abcdb
commit
8bcfa301b3
2 changed files with 56 additions and 85 deletions
|
|
@ -1015,6 +1015,43 @@ sub www_setRank {
|
||||||
return $self->getParent->www_manageAssets();
|
return $self->getParent->www_manageAssets();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 www_setRanks ( )
|
||||||
|
|
||||||
|
Utility method for the AssetManager. Reorders 1 pagefull of assets via rank.
|
||||||
|
|
||||||
|
If the current user cannot edit the current asset, it returns the insufficient privileges page.
|
||||||
|
|
||||||
|
Returns the user to the manage assets screen.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub www_setRanks {
|
||||||
|
my $self = shift;
|
||||||
|
my $session = $self->session;
|
||||||
|
return $session->privilege->insufficient() unless $session->asset->canEdit;
|
||||||
|
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||||
|
my $pb = WebGUI::ProgressBar->new($session);
|
||||||
|
my $form = $session->form;
|
||||||
|
|
||||||
|
$pb->start($i18n->get('Set Rank'), $session->url->extras('adminConsole/assets.gif'));
|
||||||
|
my @assetIds = $form->get( 'assetId' );
|
||||||
|
ASSET: for my $assetId ( @assetIds ) {
|
||||||
|
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
||||||
|
next ASSET unless $asset;
|
||||||
|
my $rank = $form->get( $assetId . '_rank' );
|
||||||
|
next ASSET unless $rank; # There's no such thing as zero
|
||||||
|
|
||||||
|
$asset->setRank( $rank, sub { $pb->update(sprintf $i18n->get(shift), shift); } );
|
||||||
|
}
|
||||||
|
|
||||||
|
$pb->finish($session->asset->getManagerUrl);
|
||||||
|
return "redirect";
|
||||||
|
#return $www_manageAssets();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -334,37 +334,6 @@ sub www_manage {
|
||||||
### Do Action
|
### Do Action
|
||||||
my @assetIds = $session->form->get( 'assetId' );
|
my @assetIds = $session->form->get( 'assetId' );
|
||||||
|
|
||||||
if ( $session->form->get( 'action_delete' ) ) {
|
|
||||||
for my $assetId ( @assetIds ) {
|
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
|
||||||
next unless $asset;
|
|
||||||
$asset->trash;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif ( $session->form->get( 'action_cut' ) ) {
|
|
||||||
for my $assetId ( @assetIds ) {
|
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
|
||||||
next unless $asset;
|
|
||||||
$asset->cut;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif ( $session->form->get( 'action_copy' ) ) {
|
|
||||||
for my $assetId ( @assetIds ) {
|
|
||||||
# Copy == Duplicate + Cut
|
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId);
|
|
||||||
my $newAsset = $asset->duplicate( { skipAutoCommitWorkflows => 1 } );
|
|
||||||
$newAsset->update( { title => $newAsset->getTitle . ' (copy)' } );
|
|
||||||
$newAsset->cut;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elsif ( $session->form->get( 'action_duplicate' ) ) {
|
|
||||||
for my $assetId ( @assetIds ) {
|
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
|
||||||
next unless $asset;
|
|
||||||
$asset->duplicate( { skipAutoCommitWorkflows => 1 } );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Handle autocommit workflows
|
# Handle autocommit workflows
|
||||||
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, {
|
if (WebGUI::VersionTag->autoCommitWorkingIfEnabled($session, {
|
||||||
allowComments => 1,
|
allowComments => 1,
|
||||||
|
|
@ -428,24 +397,25 @@ ENDHTML
|
||||||
$output .= '</ol>';
|
$output .= '</ol>';
|
||||||
|
|
||||||
### The page of assets
|
### The page of assets
|
||||||
$output .= q{<div>}
|
$output .= sprintf <<EOHTML, $session->asset->getUrl, $i18n->get( 'with selected' ), $i18n->get( "update" ), $i18n->get( "delete" ), $i18n->get( '43' ), $i18n->get( 'cut' ), $i18n->get( "Copy" ), $i18n->get( "duplicate" );
|
||||||
. q{<form method="post" enctype="multipart/form-data">}
|
<div>
|
||||||
. q{<input type="hidden" name="op" value="assetManager" />}
|
<form method="post" enctype="multipart/form-data" action="%s">
|
||||||
. q{<input type="hidden" name="method" value="manage" />}
|
<input type="hidden" name="func" value="manageAssets" />
|
||||||
. q{<div id="dataTableContainer">}
|
<input type="hidden" name="proceed" value="manageAssets" />
|
||||||
. q{</div>}
|
<div id="dataTableContainer">
|
||||||
. q{<p class="actions">} . $i18n->get( 'with selected' )
|
</div>
|
||||||
. q{<input type="submit" name="action_update" value="} . $i18n->get( "update" ) . q{" onclick="this.form.method.value='setRanks'; this.form.submit();" />}
|
<p class="actions"> %s
|
||||||
. q{<input type="submit" name="action_delete" value="} . $i18n->get( "delete" ) . q{" onclick="return confirm('} . $i18n->get( 43 ) . q{')" />}
|
<input type="submit" name="action_update" value="%s" onclick="this.form.func.value='setRanks'; this.form.submit();" />
|
||||||
. q{<input type="submit" name="action_cut" value="} . $i18n->get( 'cut' ) . q{" />}
|
<input type="submit" name="action_delete" value="%s" onclick="if( confirm('%s')){ alert('true'); this.form.func.value='deleteList'; alert(this.form.func.value); this.form.submit(); }{ return false; }" />
|
||||||
. q{<input type="submit" name="action_copy" value="} . $i18n->get( "Copy" ) . q{" />}
|
<input type="submit" name="action_cut" value="%s" onclick="this.form.func.value='cutList'; this.form.submit();"/>
|
||||||
. q{<input type="submit" name="action_duplicate" value="} . $i18n->get( "duplicate" ) . q{" />}
|
<input type="submit" name="action_copy" value="%s" onclick="this.form.func.value='copyList'; this.form.submit();"/>
|
||||||
. q{</p>}
|
<input type="submit" name="action_duplicate" value="%s" onclick="this.form.func.value='duplicateList'; this.form.submit();"/>
|
||||||
. q{</form>}
|
</p>
|
||||||
. q{<div id="pagination"> }
|
</form>
|
||||||
. q{</div>}
|
<div id="pagination">
|
||||||
. q{</div>}
|
</div>
|
||||||
;
|
</div>
|
||||||
|
EOHTML
|
||||||
|
|
||||||
### Clearing div
|
### Clearing div
|
||||||
$output .= q{<div style="clear: both;"> </div>};
|
$output .= q{<div style="clear: both;"> </div>};
|
||||||
|
|
@ -762,41 +732,5 @@ sub www_search {
|
||||||
return $ac->render( $output );
|
return $ac->render( $output );
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_setRanks ( )
|
|
||||||
|
|
||||||
Utility method for the AssetManager. Reorders 1 pagefull of assets via rank.
|
|
||||||
|
|
||||||
If the current user cannot edit the current asset, it returns the insufficient privileges page.
|
|
||||||
|
|
||||||
Returns the user to the manage assets screen.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_setRanks {
|
|
||||||
my $session = shift;
|
|
||||||
return $session->privilege->insufficient() unless $session->asset->canEdit;
|
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset');
|
|
||||||
my $pb = WebGUI::ProgressBar->new($session);
|
|
||||||
my $form = $session->form;
|
|
||||||
|
|
||||||
$pb->start($i18n->get('Set Rank'), $session->url->extras('adminConsole/assets.gif'));
|
|
||||||
my @assetIds = $form->get( 'assetId' );
|
|
||||||
ASSET: for my $assetId ( @assetIds ) {
|
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
|
||||||
next ASSET unless $asset;
|
|
||||||
my $rank = $form->get( $assetId . '_rank' );
|
|
||||||
next ASSET unless $rank; # There's no such thing as zero
|
|
||||||
|
|
||||||
$asset->setRank( $rank, sub { $pb->update(sprintf $i18n->get(shift), shift); } );
|
|
||||||
}
|
|
||||||
|
|
||||||
$pb->finish($session->asset->getManagerUrl);
|
|
||||||
return "redirect";
|
|
||||||
#return $www_manageAssets();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue