Add a progress bar for reordering rank in the Asset Manager.
This commit is contained in:
parent
385e3ee259
commit
35749ff8c6
4 changed files with 87 additions and 15 deletions
|
|
@ -18,6 +18,7 @@
|
||||||
- fixed #10550: shipping plugins have no privileges
|
- fixed #10550: shipping plugins have no privileges
|
||||||
- fixed: Add progress bars for paste and edit branch.
|
- fixed: Add progress bars for paste and edit branch.
|
||||||
- fixed: Add progress bars for promote and demote.
|
- fixed: Add progress bars for promote and demote.
|
||||||
|
- fixed: Add progress bars for set rank in the Asset Manager.
|
||||||
- fixed: SurveyJSON database bloating
|
- fixed: SurveyJSON database bloating
|
||||||
|
|
||||||
7.7.10
|
7.7.10
|
||||||
|
|
|
||||||
|
|
@ -858,7 +858,7 @@ sub setParent {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 setRank ( newRank )
|
=head2 setRank ( newRank, [ $outputSub ] )
|
||||||
|
|
||||||
Returns 1. Changes rank of Asset.
|
Returns 1. Changes rank of Asset.
|
||||||
|
|
||||||
|
|
@ -866,11 +866,17 @@ Returns 1. Changes rank of Asset.
|
||||||
|
|
||||||
Value of new Rank.
|
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
|
=cut
|
||||||
|
|
||||||
sub setRank {
|
sub setRank {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $newRank = shift;
|
my $newRank = shift;
|
||||||
|
my $outputSub = shift || sub {};
|
||||||
my $currentRank = $self->getRank;
|
my $currentRank = $self->getRank;
|
||||||
return 1 if ($newRank == $currentRank); # do nothing if we're moving to ourself
|
return 1 if ($newRank == $currentRank); # do nothing if we're moving to ourself
|
||||||
my $parentLineage = $self->getParentLineage;
|
my $parentLineage = $self->getParentLineage;
|
||||||
|
|
@ -881,13 +887,16 @@ sub setRank {
|
||||||
my $temp = substr($self->session->id->generate(),0,6);
|
my $temp = substr($self->session->id->generate(),0,6);
|
||||||
my $previous = $self->get("lineage");
|
my $previous = $self->get("lineage");
|
||||||
$self->session->db->beginTransaction;
|
$self->session->db->beginTransaction;
|
||||||
|
$outputSub->('moving %s aside', $self->getTitle);
|
||||||
$self->cascadeLineage($temp);
|
$self->cascadeLineage($temp);
|
||||||
foreach my $sibling (@{$siblings}) {
|
foreach my $sibling (@{$siblings}) {
|
||||||
if (isBetween($sibling->getRank, $newRank, $currentRank)) {
|
if (isBetween($sibling->getRank, $newRank, $currentRank)) {
|
||||||
|
$outputSub->('moving %s', $sibling->getTitle);
|
||||||
$sibling->cascadeLineage($previous);
|
$sibling->cascadeLineage($previous);
|
||||||
$previous = $sibling->get("lineage");
|
$previous = $sibling->get("lineage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$outputSub->('moving %s back', $self->getTitle);
|
||||||
$self->cascadeLineage($previous,$temp);
|
$self->cascadeLineage($previous,$temp);
|
||||||
$self->{_properties}{lineage} = $previous;
|
$self->{_properties}{lineage} = $previous;
|
||||||
$self->session->db->commit;
|
$self->session->db->commit;
|
||||||
|
|
|
||||||
|
|
@ -334,17 +334,17 @@ sub www_manage {
|
||||||
### Do Action
|
### Do Action
|
||||||
my @assetIds = $session->form->get( 'assetId' );
|
my @assetIds = $session->form->get( 'assetId' );
|
||||||
|
|
||||||
if ( $session->form->get( 'action_update' ) ) {
|
# if ( $session->form->get( 'action_update' ) ) {
|
||||||
for my $assetId ( @assetIds ) {
|
# for my $assetId ( @assetIds ) {
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
# my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
||||||
next unless $asset;
|
# next unless $asset;
|
||||||
my $rank = $session->form->get( $assetId . '_rank' );
|
# my $rank = $session->form->get( $assetId . '_rank' );
|
||||||
next unless $rank; # There's no such thing as zero
|
# next unless $rank; # There's no such thing as zero
|
||||||
|
#
|
||||||
$asset->setRank( $rank );
|
# $asset->setRank( $rank );
|
||||||
}
|
# }
|
||||||
}
|
# }
|
||||||
elsif ( $session->form->get( 'action_delete' ) ) {
|
if ( $session->form->get( 'action_delete' ) ) {
|
||||||
for my $assetId ( @assetIds ) {
|
for my $assetId ( @assetIds ) {
|
||||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
||||||
next unless $asset;
|
next unless $asset;
|
||||||
|
|
@ -447,7 +447,7 @@ ENDHTML
|
||||||
. q{<div id="dataTableContainer">}
|
. q{<div id="dataTableContainer">}
|
||||||
. q{</div>}
|
. q{</div>}
|
||||||
. q{<p class="actions">} . $i18n->get( 'with selected' )
|
. q{<p class="actions">} . $i18n->get( 'with selected' )
|
||||||
. q{<input type="submit" name="action_update" value="} . $i18n->get( "update" ) . q{" />}
|
. q{<input type="submit" name="action_update" value="} . $i18n->get( "update" ) . q{" onclick="this.form.method.value='setRanks'; this.form.submit();" />}
|
||||||
. q{<input type="submit" name="action_delete" value="} . $i18n->get( "delete" ) . q{" onclick="return confirm('} . $i18n->get( 43 ) . q{')" />}
|
. q{<input type="submit" name="action_delete" value="} . $i18n->get( "delete" ) . q{" onclick="return confirm('} . $i18n->get( 43 ) . q{')" />}
|
||||||
. q{<input type="submit" name="action_cut" value="} . $i18n->get( 'cut' ) . q{" />}
|
. q{<input type="submit" name="action_cut" value="} . $i18n->get( 'cut' ) . q{" />}
|
||||||
. q{<input type="submit" name="action_copy" value="} . $i18n->get( "Copy" ) . q{" />}
|
. q{<input type="submit" name="action_copy" value="} . $i18n->get( "Copy" ) . q{" />}
|
||||||
|
|
@ -774,4 +774,42 @@ 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;
|
||||||
|
$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;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,30 @@ our $I18N = {
|
||||||
context => q|Used in asset context menus.|,
|
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' => {
|
'swap first' => {
|
||||||
message => q|swap first|,
|
message => q|swap first|,
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue