paginating für test_import
authorSven Schöling <s.schoeling@linet-services.de>
Fri, 16 Nov 2012 16:38:25 +0000 (17:38 +0100)
committerSven Schöling <s.schoeling@linet-services.de>
Fri, 11 Jan 2013 12:57:53 +0000 (13:57 +0100)
SL/Controller/CsvImport.pm
templates/webpages/csv_import/_deferred_report.html [new file with mode: 0644]
templates/webpages/csv_import/report.html

index 24c76ab..9d068c3 100644 (file)
@@ -96,7 +96,7 @@ sub action_result {
   }
 
   if ($data->{progress}{finished} || $data->{errors}) {
-    $self->action_report(report_id => $data->{report_id}, no_layout => 1);
+    $self->render('csv_import/_deferred_report', { no_layout => 1 });
   } else {
     $self->render('csv_import/_deferred_results', { no_layout => 1 });
   }
@@ -165,10 +165,9 @@ sub action_report {
   $self->{report_rows}   = $self->{report}->folded_rows(rows => $rows);
   $self->{report_status} = $self->{report}->folded_status(status => $status);
   $self->{pages} = $pages;
+  $self->{base_url} = $self->url_for(action => 'report', id => $report_id, no_layout => $params{no_layout} || $::form->{no_layout} );
 
-  my $base_url = $self->url_for(action => 'report', id => $report_id);
-
-  $self->render('csv_import/report', { no_layout => $params{no_layout} }, base_url => $base_url);
+  $self->render('csv_import/report', { no_layout => $params{no_layout} || $::form->{no_layout} });
 }
 
 
diff --git a/templates/webpages/csv_import/_deferred_report.html b/templates/webpages/csv_import/_deferred_report.html
new file mode 100644 (file)
index 0000000..ae65747
--- /dev/null
@@ -0,0 +1,26 @@
+<div id='csv_import_report'></div>
+
+<script type='text/javascript'>
+  function get_report(target, source, data){
+    $.ajax({
+      url:        source,
+      success:    function (rsp) {
+        $(target).html(rsp);
+        $(target).find('.paginate').find('a').click(function(event){ redirect_event(event, target) });
+      },
+      data:       data,
+    });
+  };
+
+  function redirect_event(event, target){
+    event.preventDefault();
+    get_report(target, event.target + '', {});
+  }
+
+  $(document).ready(function(){
+    get_report('#csv_import_report', 'controller.pl', { action: 'CsvImport/report', 'no_layout': 1, 'id': [% SELF.background_job.data_as_hash.report_id %] });
+  });
+
+
+</script>
+
index 96fb0a5..7154e75 100644 (file)
@@ -1,9 +1,9 @@
 [% USE HTML %]
 [% USE LxERP %]
 [% USE L %]
-
  <h3>[%- LxERP.t8('Import result') %]</h3>
 
+[%- PROCESS 'common/paginate.html' pages=SELF.pages, base_url = SELF.base_url %]
  <table>
 [%- FOREACH rownum = SELF.display_rows %]
  [%- IF loop.first %]
@@ -29,7 +29,7 @@
 
  </table>
 
-[%- PROCESS 'common/paginate.html' pages=SELF.pages %]
+[%- PROCESS 'common/paginate.html' pages=SELF.pages, base_url = SELF.base_url %]
 
 <script type='text/javascript'>
   $(function(){ $('#action_import').show() });