allow asset helper-type responses
This should probably be refactored into a WebGUI::ProgressBar::Admin subclass to get rid of all these if statements
This commit is contained in:
parent
05a551d960
commit
e7bfd6db48
1 changed files with 28 additions and 8 deletions
|
|
@ -64,7 +64,7 @@ sub new {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 finish ( $url )
|
=head2 finish ( $url|$helper )
|
||||||
|
|
||||||
Redirects the user out of the status page.
|
Redirects the user out of the status page.
|
||||||
|
|
||||||
|
|
@ -72,11 +72,25 @@ Redirects the user out of the status page.
|
||||||
|
|
||||||
The URL to send the user to.
|
The URL to send the user to.
|
||||||
|
|
||||||
|
=head3 $helper
|
||||||
|
|
||||||
|
A hashref response for an Asset Helper to be processed by the Admin Console
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub finish {
|
sub finish {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $url = shift;
|
my $arg = shift;
|
||||||
|
|
||||||
|
# We may have been passed a URL to go to, or an Asset Helper response hash
|
||||||
|
my ( $url, $helper );
|
||||||
|
if ( !ref $arg ) {
|
||||||
|
$url = $arg;
|
||||||
|
}
|
||||||
|
elsif ( ref $arg eq "HASH" ) {
|
||||||
|
$helper = $arg;
|
||||||
|
}
|
||||||
|
|
||||||
local $| = 1;
|
local $| = 1;
|
||||||
if ( $url ) {
|
if ( $url ) {
|
||||||
my $text = sprintf(<<EOJS, $url);
|
my $text = sprintf(<<EOJS, $url);
|
||||||
|
|
@ -89,11 +103,17 @@ EOJS
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# We're in admin mode, close the dialog
|
# We're in admin mode, close the dialog
|
||||||
my $text = sprintf(<<EOJS );
|
my $text = '<script type="text/javascript">';
|
||||||
<script>
|
|
||||||
parent.admin.closeModalDialog();
|
if ( ref $helper eq 'HASH' ) {
|
||||||
</script>
|
# Process the output as JSON
|
||||||
EOJS
|
$text .= sprintf 'parent.admin.processHelper( %s );', JSON->new->encode( $helper );
|
||||||
|
}
|
||||||
|
|
||||||
|
# Close dialog last so that script above runs!
|
||||||
|
$text .= 'parent.admin.closeModalDialog();'
|
||||||
|
. '</script>';
|
||||||
|
|
||||||
$self->session->output->print( $text, 1); # skipMacros
|
$self->session->output->print( $text, 1); # skipMacros
|
||||||
return 'chunked';
|
return 'chunked';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue