Add a progress bar to Delete in the AssetManager.
This commit is contained in:
parent
45a6428887
commit
299442662a
3 changed files with 61 additions and 27 deletions
|
|
@ -9,6 +9,7 @@
|
||||||
- fixed #10549: EMS import
|
- fixed #10549: EMS import
|
||||||
- fixed #10561: pb: purge
|
- fixed #10561: pb: purge
|
||||||
- fixed #10563: pb: rollback version tag
|
- fixed #10563: pb: rollback version tag
|
||||||
|
- fixed #10562: pb: delete
|
||||||
|
|
||||||
7.7.11
|
7.7.11
|
||||||
- Fixed a bug where empty version tags were not deleted. (Martin Kamerbeek / Oqapi)
|
- Fixed a bug where empty version tags were not deleted. (Martin Kamerbeek / Oqapi)
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ sub purge {
|
||||||
|
|
||||||
# can't delete if it's one of these things
|
# can't delete if it's one of these things
|
||||||
if ($self->getId eq $session->setting->get("defaultPage") || $self->getId eq $session->setting->get("notFoundPage") || $self->get("isSystem")) {
|
if ($self->getId eq $session->setting->get("defaultPage") || $self->getId eq $session->setting->get("notFoundPage") || $self->get("isSystem")) {
|
||||||
$outputSub->(sprintf $i18n->get('Trying to delete system page %s. Aborting purge'), $self->getTitle);
|
$outputSub->(sprintf $i18n->get('Trying to delete system page %s. Aborting'), $self->getTitle);
|
||||||
$session->errorHandler->security("delete a system protected page (".$self->getId.")");
|
$session->errorHandler->security("delete a system protected page (".$self->getId.")");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -174,7 +174,7 @@ sub purge {
|
||||||
# gotta delete stuff we've exported
|
# gotta delete stuff we've exported
|
||||||
unless ($options->{skipExported}) {
|
unless ($options->{skipExported}) {
|
||||||
$outputSub->($i18n->get('Deleting exported files'));
|
$outputSub->($i18n->get('Deleting exported files'));
|
||||||
$self->_invokeWorkflowOnExportedFiles($self->session->setting->get('purgeWorkflow'), 1);
|
$self->_invokeWorkflowOnExportedFiles($session->setting->get('purgeWorkflow'), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
# gonna need this at the end
|
# gonna need this at the end
|
||||||
|
|
@ -218,36 +218,59 @@ sub purge {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 trash ( )
|
=head2 trash ( $options )
|
||||||
|
|
||||||
Removes asset from lineage, places it in trash state. The "gap" in the
|
Removes asset from lineage, places it in trash state. The "gap" in the
|
||||||
lineage is changed in state to trash-limbo.
|
lineage is changed in state to trash-limbo.
|
||||||
|
|
||||||
|
=head3 $options
|
||||||
|
|
||||||
|
An optional hashref of options
|
||||||
|
|
||||||
|
=head4 outputSub
|
||||||
|
|
||||||
|
A subroutine used to report the status of the purge, most likely used by WebGUI::ProgressBar->update.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub trash {
|
sub trash {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
return undef if ($self->getId eq $self->session->setting->get("defaultPage") || $self->getId eq $self->session->setting->get("notFoundPage") || $self->get('isSystem'));
|
my $options = shift;
|
||||||
|
my $session = $self->session;
|
||||||
|
my $outputSub = $options->{outputSub} || sub {};
|
||||||
|
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||||
|
|
||||||
|
if ($self->getId eq $session->setting->get("defaultPage") || $self->getId eq $session->setting->get("notFoundPage") || $self->get('isSystem')) {
|
||||||
|
$outputSub->(sprintf $i18n->get('Trying to delete system page %s. Aborting'), $self->getTitle);
|
||||||
|
$session->errorHandler->security("delete a system protected page (".$self->getId.")");
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
$outputSub->($i18n->get('Deleting exported files'));
|
||||||
foreach my $asset ($self, @{$self->getLineage(['descendants'], {returnObjects => 1})}) {
|
foreach my $asset ($self, @{$self->getLineage(['descendants'], {returnObjects => 1})}) {
|
||||||
$asset->_invokeWorkflowOnExportedFiles($self->session->setting->get('trashWorkflow'), 1);
|
$asset->_invokeWorkflowOnExportedFiles($session->setting->get('trashWorkflow'), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Trash any shortcuts to this asset
|
# Trash any shortcuts to this asset
|
||||||
my $shortcuts
|
my $shortcuts
|
||||||
= WebGUI::Asset::Shortcut->getShortcutsForAssetId($self->session, $self->getId, { returnObjects => 1});
|
= WebGUI::Asset::Shortcut->getShortcutsForAssetId($session, $self->getId, { returnObjects => 1});
|
||||||
|
$outputSub->($i18n->get('Purging shortcuts'));
|
||||||
for my $shortcut ( @$shortcuts ) {
|
for my $shortcut ( @$shortcuts ) {
|
||||||
$shortcut->trash;
|
$shortcut->trash({ outputSub => $outputSub, });
|
||||||
}
|
}
|
||||||
|
|
||||||
# Raw database work is more efficient than $asset->update
|
# Raw database work is more efficient than $asset->update
|
||||||
my $db = $self->session->db;
|
my $db = $session->db;
|
||||||
$db->beginTransaction;
|
$db->beginTransaction;
|
||||||
my $sth = $db->read("select assetId from asset where lineage like ?",[$self->get("lineage").'%']);
|
my $sth = $db->read("select assetId from asset where lineage like ?",[$self->get("lineage").'%']);
|
||||||
|
$outputSub->($i18n->get('Clearing search index'));
|
||||||
while (my ($id) = $sth->array) {
|
while (my ($id) = $sth->array) {
|
||||||
$db->write("delete from assetIndex where assetId=?",[$id]);
|
$db->write("delete from assetIndex where assetId=?",[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$outputSub->($i18n->get('Clearing asset tables'));
|
||||||
$db->write("update asset set state='trash-limbo' where lineage like ?",[$self->get("lineage").'%']);
|
$db->write("update asset set state='trash-limbo' where lineage like ?",[$self->get("lineage").'%']);
|
||||||
$db->write("update asset set state='trash', stateChangedBy=?, stateChanged=? where assetId=?",[$self->session->user->userId, $self->session->datetime->time(), $self->getId]);
|
$db->write("update asset set state='trash', stateChangedBy=?, stateChanged=? where assetId=?",[$session->user->userId, $session->datetime->time(), $self->getId]);
|
||||||
$db->commit;
|
$db->commit;
|
||||||
|
|
||||||
# Update ourselves since we didn't use update()
|
# Update ourselves since we didn't use update()
|
||||||
|
|
@ -303,18 +326,28 @@ Moves list of assets to trash, returns www_manageAssets() method of self if canE
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_deleteList {
|
sub www_deleteList {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
foreach my $assetId ($self->session->form->param("assetId")) {
|
my $session = $self->session;
|
||||||
my $asset = WebGUI::Asset->newPending($self->session,$assetId);
|
my $pb = WebGUI::ProgressBar->new($session);
|
||||||
if ($asset->canEdit && $asset->canEditIfLocked) {
|
my $i18n = WebGUI::International->new($session, 'Asset');
|
||||||
$asset->trash;
|
my $form = $session->form;
|
||||||
}
|
my @assetIds = $form->param('assetId');
|
||||||
}
|
$pb->start($i18n->get('Delete Assets'), $session->url->extras('adminConsole/assets.gif'));
|
||||||
if ($self->session->form->process("proceed") ne "") {
|
ASSETID: foreach my $assetId (@assetIds) {
|
||||||
my $method = "www_".$self->session->form->process("proceed");
|
my $asset = eval { WebGUI::Asset->newPending($session,$assetId); };
|
||||||
return $self->$method();
|
if ($@) {
|
||||||
|
$pb->update(sprintf $i18n->get('Error getting asset with assetId %s'), $assetId);
|
||||||
|
next ASSETID;
|
||||||
}
|
}
|
||||||
return $self->www_manageAssets();
|
if (! ($asset->canEdit && $asset->canEditIfLocked) ) {
|
||||||
|
$pb->update(sprintf $i18n->get('You cannot edit the asset %s, skipping'), $asset->getTitle);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$asset->trash({outputSub => sub { $pb->update(@_); } });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
my $method = ($session->form->process("proceed")) ? $session->form->process('proceed') : 'manageTrash';
|
||||||
|
$pb->finish($self->getUrl('func='.$method));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -410,7 +443,7 @@ sub www_purgeList {
|
||||||
next ASSETID;
|
next ASSETID;
|
||||||
}
|
}
|
||||||
if (! $asset->canEdit) {
|
if (! $asset->canEdit) {
|
||||||
$pb->update(sprintf $i18n->get('You cannot edit the asset %s, skipping purge'), $asset->getTitle);
|
$pb->update(sprintf $i18n->get('You cannot edit the asset %s, skipping'), $asset->getTitle);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$asset->purge({outputSub => sub { $pb->update(@_); } });
|
$asset->purge({outputSub => sub { $pb->update(@_); } });
|
||||||
|
|
|
||||||
|
|
@ -1304,10 +1304,10 @@ Couldn't open %-s because %-s <br />
|
||||||
context => q{Generic error when an asset cannot be looked up by assetId},
|
context => q{Generic error when an asset cannot be looked up by assetId},
|
||||||
},
|
},
|
||||||
|
|
||||||
'You cannot edit the asset %s, skipping purge' => {
|
'You cannot edit the asset %s, skipping' => {
|
||||||
message => q{You cannot edit the asset %s, skipping purge},
|
message => q{You cannot edit the asset %s, skipping},
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
context => q{Generic error when an asset cannot be deleted},
|
context => q{Generic error when an asset cannot be edited},
|
||||||
},
|
},
|
||||||
|
|
||||||
'Purging %s' => {
|
'Purging %s' => {
|
||||||
|
|
@ -1316,8 +1316,8 @@ Couldn't open %-s because %-s <br />
|
||||||
context => q{},
|
context => q{},
|
||||||
},
|
},
|
||||||
|
|
||||||
'Trying to delete system page %s. Aborting purge' => {
|
'Trying to delete system page %s. Aborting' => {
|
||||||
message => q{Trying to delete system page %s. Aborting purge},
|
message => q{Trying to delete system page %s. Aborting},
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
context => q{},
|
context => q{},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue