Listenansicht in BackgroundJobHistory-Controller sortierbar gemacht
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 31 Aug 2012 14:15:17 +0000 (16:15 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 31 Aug 2012 14:15:17 +0000 (16:15 +0200)
SL/Controller/BackgroundJobHistory.pm
templates/webpages/background_job_history/list.html

index 54d7338..0629edf 100644 (file)
@@ -4,6 +4,8 @@ use strict;
 
 use parent qw(SL::Controller::Base);
 
+use SL::Controller::Helper::GetModels;
+use SL::Controller::Helper::Sorted;
 use SL::DB::BackgroundJobHistory;
 use SL::Helper::Flash;
 use SL::System::TaskServer;
@@ -18,6 +20,20 @@ __PACKAGE__->run_before('check_auth');
 __PACKAGE__->run_before('add_stylesheet');
 __PACKAGE__->run_before('check_task_server');
 
+__PACKAGE__->make_sorted(
+  DEFAULT_BY   => 'run_at',
+  DEFAULT_DIR  => 1,
+  MODEL        => 'BackgroundJobHistory',
+  FORM_PARAMS  => [ qw(sort_by sort_dir) ],
+  ONLY         => [ qw(list) ],
+
+  package_name => $::locale->text('Package name'),
+  run_at       => $::locale->text('Run at'),
+  status       => $::locale->text('Execution status'),
+  result       => $::locale->text('Result'),
+  error        => $::locale->text('Error'),
+);
+
 #
 # actions
 #
@@ -27,7 +43,7 @@ sub action_list {
 
   $self->render('background_job_history/list',
                 title   => $::locale->text('Background job history'),
-                ENTRIES => SL::DB::Manager::BackgroundJobHistory->get_all_sorted);
+                ENTRIES => $self->get_models);
 }
 
 sub action_show {
index 83c8dae..6086776 100644 (file)
    <table id="background_job_history_list" class="background_job_list" width="100%">
     <thead>
      <tr class="listheading">
-      <th>[%- LxERP.t8('Package name') %]</th>
-      <th>[%- LxERP.t8('Run at') %]</th>
-      <th>[%- LxERP.t8('Execution status') %]</th>
-      <th>[%- LxERP.t8('Result') %]</th>
-      <th>[%- LxERP.t8('Error') %]</th>
+      <th>[% L.sortable_table_header('package_name') %]</th>
+      <th>[% L.sortable_table_header('run_at') %]</th>
+      <th>[% L.sortable_table_header('status') %]</th>
+      <th>[% L.sortable_table_header('result') %]</th>
+      <th>[% L.sortable_table_header('error') %]</th>
      </tr>
     </thead>
 
@@ -27,7 +27,7 @@
     [%- FOREACH entry = ENTRIES %]
     <tr class="listrow[% loop.count % 2 %]" id="background_job_history_id_[% entry.id %]">
      <td>
-      <a href="[% SELF.url_for(action => 'show', id => entry.id) %]">
+      <a href="[% SELF.url_for(action => 'show', id => entry.id, back_to => SELF.get_callback) %]">
        [%- HTML.escape(entry.package_name) %]
       </a>
      </td>