diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index d34d37356..834587aa6 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -17,6 +17,7 @@ - fixed #10551: paypal (link to section of paypal website to enter in WebGUI information) - 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: SurveyJSON database bloating 7.7.10 diff --git a/lib/WebGUI/AssetBranch.pm b/lib/WebGUI/AssetBranch.pm index d4ebfef10..8465fcbcd 100644 --- a/lib/WebGUI/AssetBranch.pm +++ b/lib/WebGUI/AssetBranch.pm @@ -333,6 +333,8 @@ sub www_editBranchSave { }; delete $self->{_parent}; $self->session->asset($self->getParent); + ##Since this method originally returned the user to the AssetManager, we don't need + ##to use $pb->finish to redirect back there. return $self->getParent->www_manageAssets; } diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index af6388660..da8f3971c 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -138,14 +138,20 @@ Swaps lineage with sister below. Returns 1 if there is a sister to swap. Otherwi This will update the lineage of $self, but not the sister. +=head3 outputSub + +A reference to a subroutine that output messages should be sent to. Typically this would +go to ProgressBar. + =cut sub demote { - my $self = shift; + my $self = shift; + my $outputSub = shift || sub {}; my ($sisterLineage) = $self->session->db->quickArray("select min(lineage) from asset where parentId=? and state='published' and lineage>?",[$self->get('parentId'), $self->get('lineage')]); if (defined $sisterLineage) { - $self->swapRank($sisterLineage); + $self->swapRank($sisterLineage, undef, $outputSub); $self->{_properties}{lineage} = $sisterLineage; return 1; } @@ -789,20 +795,26 @@ sub newByLineage { #------------------------------------------------------------------- -=head2 promote ( ) +=head2 promote ( [ $outputSub ] ) Keeps the same rank of lineage, swaps with sister above. Returns 1 if there is a sister to swap. Otherwise returns 0. This will update the lineage of $self, but not the sister. +=head3 outputSub + +A reference to a subroutine that output messages should be sent to. Typically this would +go to ProgressBar. + =cut sub promote { - my $self = shift; + my $self = shift; + my $outputSub = shift || sub {}; my ($sisterLineage) = $self->session->db->quickArray("select max(lineage) from asset where parentId=? and state='published' and lineageget("parentId"), $self->get("lineage")]); if (defined $sisterLineage) { - $self->swapRank($sisterLineage); + $self->swapRank($sisterLineage, undef, $outputSub); $self->{_properties}{lineage} = $sisterLineage; return 1; } @@ -898,13 +910,16 @@ no in the objects. =cut sub swapRank { - my $self = shift; - my $second = shift; - my $first = shift || $self->get("lineage"); + my $self = shift; + my $second = shift; + my $first = shift || $self->get("lineage"); + my $outputSub = shift || sub {}; my $temp = substr($self->session->id->generate(),0,6); # need a temp in order to do the swap $self->session->db->beginTransaction; + $outputSub->('swap first'); ##Note, i18n call passed in from caller-1 $self->cascadeLineage($temp,$first); $self->cascadeLineage($first,$second); + $outputSub->('swap second'); $self->cascadeLineage($second,$temp); $self->session->db->commit; $self->updateHistory("swapped lineage between ".$first." and ".$second); @@ -921,10 +936,15 @@ Demotes self and returns www_view method of getContainer of self if canEdit, oth =cut sub www_demote { - my $self = shift; - return $self->session->privilege->insufficient() unless $self->canEdit; - $self->demote; - return $self->session->asset($self->getContainer)->www_view; + my $self = shift; + my $session = $self->session; + return $self->session->privilege->insufficient() unless $self->canEdit; + my $i18n = WebGUI::International->new($session, 'Asset'); + my $pb = WebGUI::ProgressBar->new($session); + $pb->start($i18n->get('demote'), $session->url->extras('adminConsole/assets.gif')); + $pb->update(sprintf $i18n->get('demote %s'), $self->getTitle); + $self->demote(sub{ $pb->update($i18n->get(shift))}); + $pb->finish($self->getContainer->getUrl); } @@ -937,10 +957,15 @@ Returns www_view method of getContainer of self. Promotes self. If canEdit is Fa =cut sub www_promote { - my $self = shift; - return $self->session->privilege->insufficient() unless $self->canEdit; - $self->promote; - return $self->session->asset($self->getContainer)->www_view; + my $self = shift; + my $session = $self->session; + return $self->session->privilege->insufficient() unless $self->canEdit; + my $i18n = WebGUI::International->new($session, 'Asset'); + my $pb = WebGUI::ProgressBar->new($session); + $pb->start($i18n->get('promote'), $session->url->extras('adminConsole/assets.gif')); + $pb->update(sprintf $i18n->get('promote %s'), $self->getTitle); + $self->promote(sub{ $pb->update($i18n->get(shift))}); + $pb->finish($self->getContainer->getUrl); } diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm index 8444a98ef..448eb7613 100644 --- a/lib/WebGUI/i18n/English/Asset.pm +++ b/lib/WebGUI/i18n/English/Asset.pm @@ -217,13 +217,31 @@ our $I18N = { 'restore' => { message => q|Restore|, lastUpdated => 0, - context => q|Used in asset context menus.| + context => q|Used in asset context menus.|, }, 'promote' => { message => q|Promote|, lastUpdated => 0, - context => q|Used in asset context menus.| + context => q|Used in asset context menus.|, + }, + + 'promote %s' => { + message => q|promote %s|, + lastUpdated => 0, + context => q|Used in asset context menus.|, + }, + + 'swap first' => { + message => q|swap first|, + lastUpdated => 0, + context => q|swap, to exchange places|, + }, + + 'swap second' => { + message => q|swap second|, + lastUpdated => 0, + context => q|swap, to exchange places|, }, 'promote help' => { @@ -242,6 +260,12 @@ our $I18N = { lastUpdated => 0, }, + 'demote %s' => { + message => q|demote %s|, + lastUpdated => 0, + context => q|Used in asset context menus.|, + }, + 'cut' => { message => q|Cut|, lastUpdated => 0,