<%doc> Example: In misc/something.html:
<% include( '/elements/progress-init.html', 'MyForm', [ 'recordnum', 'what_to_do' ], $p.'misc/process_something.html', { url => $p.'where_to_go_next.html' }, #or { message => 'Finished!' }, #or { url => $p.'where_to_go.html', message => 'Finished' }, # which recirects to the URL and displays the message as a status #or { popup_url => $p.'popup_contents.html' } # which loads that URL into the popup after completion #or { url => $p.'where_to_go.html', error_url => $p.'where_we_just_were.html' } # to redirect somewhere different on error ) %>
<%init> my( $formname, $fields, $action, $url_or_message, $key ) = @_; $key = '' unless defined $key; my %dest_info; if ( ref($url_or_message) ) { #its a message or something %dest_info = map { $_ => $url_or_message->{$_} } grep { $url_or_message->{$_} } qw( message url popup_url error_url reload_with_error ); } else { # it can also just be a url %dest_info = ( 'url' => $url_or_message ); } my $progress_url = URI->new($fsurl.'misc/progress-popup.html'); $progress_url->query_form( 'jobnum' => '_JOBNUM_', 'formname' => $formname, %dest_info, ); my $all_fields = 0; my %copy_fields; if (grep '/^ALL$/', @$fields) { $all_fields = 1; } else { %copy_fields = map { $_ => 1 } @$fields; } #stupid safari is caching the "location" of popup iframs, and submitting them #instead of displaying them. this should prevent that. my $popup_name = 'popup-'.random_id();