diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 834587aa6..174ffdcbc 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -18,6 +18,7 @@ - fixed #10550: shipping plugins have no privileges - fixed: Add progress bars for paste and edit branch. - fixed: Add progress bars for promote and demote. + - fixed: Add progress bars for set rank in the Asset Manager. - fixed: SurveyJSON database bloating 7.7.10 diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index da8f3971c..e04853e5e 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -858,7 +858,7 @@ sub setParent { #------------------------------------------------------------------- -=head2 setRank ( newRank ) +=head2 setRank ( newRank, [ $outputSub ] ) Returns 1. Changes rank of Asset. @@ -866,11 +866,17 @@ Returns 1. Changes rank of Asset. Value of new Rank. +=head3 outputSub + +A reference to a subroutine that output messages should be sent to. Typically this would +go to ProgressBar, and it must handle doing sprintf'ed i18n calls. + =cut sub setRank { - my $self = shift; - my $newRank = shift; + my $self = shift; + my $newRank = shift; + my $outputSub = shift || sub {}; my $currentRank = $self->getRank; return 1 if ($newRank == $currentRank); # do nothing if we're moving to ourself my $parentLineage = $self->getParentLineage; @@ -881,13 +887,16 @@ sub setRank { my $temp = substr($self->session->id->generate(),0,6); my $previous = $self->get("lineage"); $self->session->db->beginTransaction; + $outputSub->('moving %s aside', $self->getTitle); $self->cascadeLineage($temp); foreach my $sibling (@{$siblings}) { if (isBetween($sibling->getRank, $newRank, $currentRank)) { + $outputSub->('moving %s', $sibling->getTitle); $sibling->cascadeLineage($previous); $previous = $sibling->get("lineage"); } } + $outputSub->('moving %s back', $self->getTitle); $self->cascadeLineage($previous,$temp); $self->{_properties}{lineage} = $previous; $self->session->db->commit; diff --git a/lib/WebGUI/Content/AssetManager.pm b/lib/WebGUI/Content/AssetManager.pm index c2d3930e1..bfc9da811 100644 --- a/lib/WebGUI/Content/AssetManager.pm +++ b/lib/WebGUI/Content/AssetManager.pm @@ -334,17 +334,17 @@ sub www_manage { ### Do Action my @assetIds = $session->form->get( 'assetId' ); - if ( $session->form->get( 'action_update' ) ) { - for my $assetId ( @assetIds ) { - my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); - next unless $asset; - my $rank = $session->form->get( $assetId . '_rank' ); - next unless $rank; # There's no such thing as zero - - $asset->setRank( $rank ); - } - } - elsif ( $session->form->get( 'action_delete' ) ) { +# if ( $session->form->get( 'action_update' ) ) { +# for my $assetId ( @assetIds ) { +# my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); +# next unless $asset; +# my $rank = $session->form->get( $assetId . '_rank' ); +# next unless $rank; # There's no such thing as zero +# +# $asset->setRank( $rank ); +# } +# } + if ( $session->form->get( 'action_delete' ) ) { for my $assetId ( @assetIds ) { my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId ); next unless $asset; @@ -447,7 +447,7 @@ ENDHTML . q{
} . q{
} . q{

} . $i18n->get( 'with selected' ) - . q{} + . q{} . q{} . q{} . q{} @@ -774,4 +774,42 @@ sub www_search { 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; + $session->asset(getCurrentAsset($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; diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm index 448eb7613..fd2fa7a80 100644 --- a/lib/WebGUI/i18n/English/Asset.pm +++ b/lib/WebGUI/i18n/English/Asset.pm @@ -232,6 +232,30 @@ our $I18N = { context => q|Used in asset context menus.|, }, + 'Set Rank' => { + message => q|Set Rank|, + lastUpdated => 0, + context => q|Set, to assign. Rank, meaning order.|, + }, + + 'moving %s aside' => { + message => q|moving %s aside|, + lastUpdated => 0, + context => q||, + }, + + 'moving %s back' => { + message => q|moving %s back|, + lastUpdated => 0, + context => q||, + }, + + 'moving %s' => { + message => q|moving %s|, + lastUpdated => 0, + context => q||, + }, + 'swap first' => { message => q|swap first|, lastUpdated => 0,