diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 97c242fda..c5d958803 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -12,6 +12,8 @@ Default' ( Martin Kamerbeek / Oqapi ) - fixed: In the Asset Manager, if you pasted an asset if returned you to the page instead the manager. - fixed: In the Asset Manager, only display a Select All button if there is more than one asset. + - fixed: Add a progress indicator for long running functions so the user knows something is happening. + - fixed: In the Asset Manager, if you pasted an package or prototype if returned you to the page instead the manager. 7.7.10 - Made a change to LDAP auth that adds an OR to that query so that it also searches for a row with fieldData REGEXP '^uid=(value-from-ldap-directory-server),'. (Wes Morgan) diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 3d71043b9..ab1a7694a 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -36,6 +36,7 @@ use WebGUI::Form; use WebGUI::HTML; use WebGUI::HTMLForm; use WebGUI::Keyword; +use WebGUI::ProgressBar; use WebGUI::Search::Index; use WebGUI::TabForm; use WebGUI::Utility; diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index 3d35ada51..80b84d72f 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -35,9 +35,6 @@ These methods are available from this class: =cut - - - #------------------------------------------------------------------- =head2 canPaste ( ) @@ -183,8 +180,8 @@ Alphanumeric ID tag of Asset. =cut sub paste { - my $self = shift; - my $assetId = shift; + my $self = shift; + my $assetId = shift; my $pastedAsset = WebGUI::Asset->newByDynamicClass($self->session,$assetId); return 0 unless ($self->get("state") eq "published"); return 0 unless ($pastedAsset->canPaste()); ##Allow pasted assets to have a say about pasting. @@ -508,17 +505,53 @@ sub www_pasteList { my $session = $self->session; return $session->privilege->insufficient() unless $self->canEdit; my $form = $session->form; - ASSET: foreach my $clipId ($form->param("assetId")) { - my $pasteAsset = WebGUI::Asset->newPending($session, $clipId); - next ASSET unless $pasteAsset->canEdit; - $self->paste($clipId); - } - if ($form->param("proceed") eq 'manageAssets') { - return $self->www_manageAssets(); + my $pb = WebGUI::ProgressBar->new($session); + ##Need to store the list of assetIds for the status subroutine + my @assetIds = $form->param('assetId'); + $session->scratch->set('assetPasteList', JSON::to_json(\@assetIds)); + if ($form->param('proceed') eq 'manageAssets') { + $session->scratch->set('assetPasteReturnUrl', $self->getUrl('op=manageAssets')); } else { - return ""; + $session->scratch->set('assetPasteReturnUrl', $self->getUrl); } + $session->scratch->set('assetPasteList', JSON::to_json(\@assetIds)); + ##Need to set the URL that should be displayed when it is done + my $i18n = WebGUI::International->new($session, 'Asset'); + $pb->setIcon($session->url->extras('adminConsole/assets.gif')); + return $pb->render({ + title => $i18n->get('Paste Assets'), + statusUrl => $self->getUrl('func=pasteListStatus'), + }); +} + +#------------------------------------------------------------------- + +=head2 www_pasteListStatus ( ) + +Pastes a selection of assets. If canEdit is False, returns an insufficient privileges page. +Returns the user to the manageAssets screen. + +=cut + +sub www_pasteListStatus { + my $self = shift; + my $session = $self->session; + my $pb = WebGUI::ProgressBar->new($session); + if (! $self->canEdit ) { + return $session->privilege->insufficient('no style')."return to site"; + } + my $assetIds = $session->scratch->get('assetPasteList') || '[]'; + my @assetIds = @{ JSON::from_json($assetIds) }; + my $i18n = WebGUI::International->new($session, 'Asset'); + ASSET: foreach my $clipId (@assetIds) { + my $pasteAsset = WebGUI::Asset->newPending($session, $clipId); + next ASSET unless $pasteAsset && $pasteAsset->canEdit; + $pb->print(sprintf $i18n->get("Pasting %s"), $pasteAsset->getTitle); + $self->paste($clipId); + } + $pb->redirect( $session->scratch->get('assetPasteReturnUrl') ); + return ""; } diff --git a/lib/WebGUI/Content/AssetManager.pm b/lib/WebGUI/Content/AssetManager.pm index aa44b7426..c2d3930e1 100644 --- a/lib/WebGUI/Content/AssetManager.pm +++ b/lib/WebGUI/Content/AssetManager.pm @@ -474,6 +474,7 @@ ENDHTML $output .= '
'.$i18n->get(1082).'' .WebGUI::Form::formHeader($session, {action=>$currentAsset->getUrl}) .WebGUI::Form::hidden($session,{name=>"func",value=>"pasteList"}) + .WebGUI::Form::hidden($session,{name=>"proceed",value=>"manageAssets"}) .( $clipNum > 1 ? WebGUI::Form::checkbox($session,{extras=>'onclick="toggleClipboardSelectAll(this.form);"'}).' '.$i18n->get("select all").'
' : '' diff --git a/lib/WebGUI/Macro/AdminBar.pm b/lib/WebGUI/Macro/AdminBar.pm index cb5cfe065..b7388acf5 100644 --- a/lib/WebGUI/Macro/AdminBar.pm +++ b/lib/WebGUI/Macro/AdminBar.pm @@ -87,14 +87,14 @@ sub process { # stuff to do if we're on a page with an asset if ($asset) { - my $inAssetManager = $session->form->get('op') eq 'assetManager'; + my $proceed = $session->form->get('op') eq 'assetManager' ? ';proceed=manageAssets' : ''; # clipboard my $clipboardItems = $session->asset->getAssetsInClipboard(1); if (scalar (@$clipboardItems)) { $out .= q{
}.$i18n->get("1082").q{
}; foreach my $item (@{$clipboardItems}) { my $title = $asset->getTitle; - $out .= q{getId).q{">} + $out .= q{getId.$proceed).q{">} .q{icon } .$item->getTitle.q{}; } @@ -119,7 +119,6 @@ sub process { # assets my %assetList = %{$config->get('assets')}; - my $proceed = $inAssetManager ? ';proceed=manageAssets' : ''; foreach my $assetClass (keys %assetList) { my $dummy = WebGUI::Asset->newByPropertyHashRef($session,{dummy=>1, className=>$assetClass}); next unless defined $dummy; @@ -136,7 +135,7 @@ sub process { foreach my $package (@{$session->asset->getPackageList}) { next unless ($package->canView && $package->canAdd($session) && $package->getUiLevel <= $userUiLevel); $categories{packages}{items}{$package->getTitle} = { - url => $asset->getUrl("func=deployPackage;assetId=".$package->getId), + url => $asset->getUrl("func=deployPackage;assetId=".$package->getId.$proceed), icon => $package->getIcon(1), }; } @@ -149,7 +148,7 @@ sub process { foreach my $prototype (@{ $session->asset->getPrototypeList }) { next unless ($prototype->canView && $prototype->canAdd($session) && $prototype->getUiLevel <= $userUiLevel); $categories{prototypes}{items}{$prototype->getTitle} = { - url => $asset->getUrl("func=add;class=".$prototype->get('className').";prototype=".$prototype->getId), + url => $asset->getUrl("func=add;class=".$prototype->get('className').";prototype=".$prototype->getId.$proceed), icon => $prototype->getIcon(1), }; } diff --git a/lib/WebGUI/ProgressBar.pm b/lib/WebGUI/ProgressBar.pm new file mode 100644 index 000000000..aae1450ba --- /dev/null +++ b/lib/WebGUI/ProgressBar.pm @@ -0,0 +1,175 @@ +package WebGUI::ProgressBar; + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2009 Plain Black Corporation. + ------------------------------------------------------------------- + Please read the legal notices (docs/legal.txt) and the license + (docs/license.txt) that came with this distribution before using + this software. + ------------------------------------------------------------------- + http://www.plainblack.com info@plainblack.com + ------------------------------------------------------------------- + +=cut + +use strict; + +=head1 NAME + +Package WebGUI::ProgressBar + +=head1 DESCRIPTION + +Render a progress bar for the user inside a nice style. + +=head1 SYNOPSIS + + use WebGUI::ProgressBar; + +=head1 METHODS + +These methods are available from this class: + +=cut + +#------------------------------------------------------------------- + +=head2 new ( session ) + +Constructor. + +=head3 session + +A reference to the current session. + +=cut + +sub new { + my $class = shift; + my $session = shift; + my $self = {}; + $self->{_session} = $session; + $self->{_counter} = 1; + bless $self, $class; + return $self; +} + +#------------------------------------------------------------------- + +=head2 print ( $message ) + +Sends a message and increments the status bar. + +=head3 $message + +A message to be displayed in the status bar. + +=cut + +sub print { + my $self = shift; + my $message = shift; ##JS string escaping? + $self->{_counter} += 1; + my $text = sprintf(<{_counter}, $message); + +EOJS + $self->session->output->print($text); + return ''; +} + +#------------------------------------------------------------------- + +=head2 redirect ( $url ) + +Redirects the user out of the status page. + +=head3 $url + +The URL to send the user to. + +=cut + +sub redirect { + my $self = shift; + my $url = shift; + my $text = sprintf(< +parent.location.href='%s'; + +EOJS + $self->session->output->print($text); + return ''; +} + +#------------------------------------------------------------------- + +=head2 render ( $options ) + +Returns a templated progress bar implemented in CSS and JS. + +=head3 options + +A hashref of options to configure the progress bar + +=head3 title + +A title to display above the progress bar. + +=head3 statusUrl + +The URL that the progress bar should use to get status information. + +=cut + +sub render { + my $self = shift; + my $options = shift; + $self->session->http->setCacheControl("none"); + my %var = %{ $options }; + $var{"icon"} = $self->{_icon}; + my $template = WebGUI::Asset::Template->new($self->session, 'YP9WaMPJHvCJl-YwrLVcPw'); + my $output = $template->process(\%var); + return $self->session->style->process($output,"PBtmpl0000000000000137"); +} + +#------------------------------------------------------------------- + +=head2 session ( ) + +Returns a reference to the current session. + +=cut + +sub session { + my $self = shift; + return $self->{_session}; +} + +#------------------------------------------------------------------- + +=head2 setIcon ( icon ) + +Sets the _function icon to parameter. + +=head3 icon + +A string representing the location of the icon. + +=cut + +sub setIcon { + my $self = shift; + my $icon = shift; + if ($icon) { + $self->{_icon} = $icon; + } +} + + +1; + diff --git a/lib/WebGUI/i18n/English/Asset.pm b/lib/WebGUI/i18n/English/Asset.pm index 134821678..9792837f9 100644 --- a/lib/WebGUI/i18n/English/Asset.pm +++ b/lib/WebGUI/i18n/English/Asset.pm @@ -272,6 +272,17 @@ our $I18N = { context => q|To remove an item from the clipboard, and put it on the current page.| }, + 'Paste Assets' => { + message => q|Paste Assets|, + lastUpdated => 1245342798, + }, + + 'Pasting %s' => { + message => q|Pasting %s|, + lastUpdated => 1245343280, + context => q|short for "I am pasting this asset onto the page."| + }, + 'this asset only' => { message => q|This Asset Only|, lastUpdated => 0, diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 63078aa59..9e68cde90 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -4470,6 +4470,11 @@ Users may override this setting in their profile. lastUpdated => 0, }, + 'Working...' => { + message => 'Working...', + lastUpdated => 0, + }, + }; 1;