Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 5be585d1

Von Moritz Bunkus vor etwa 12 Jahren hinzugefügt

  • ID 5be585d1151e2a92655cc2220d0d51947be686e1
  • Vorgänger 261cfce2
  • Nachfolger aae0ac79

Sortierung im BackgroundJob-Controller

Unterschiede anzeigen:

SL/Controller/BackgroundJob.pm
4 4

  
5 5
use parent qw(SL::Controller::Base);
6 6

  
7
use SL::Controller::Helper::GetModels;
8
use SL::Controller::Helper::Sorted;
7 9
use SL::DB::BackgroundJob;
8 10
use SL::Helper::Flash;
9 11
use SL::System::TaskServer;
......
11 13
use Rose::Object::MakeMethods::Generic
12 14
(
13 15
  scalar                  => [ qw(background_job) ],
14
  'scalar --get_set_init' => [ qw(task_server) ],
16
  'scalar --get_set_init' => [ qw(task_server back_to) ],
15 17
);
16 18

  
17 19
__PACKAGE__->run_before('check_auth');
18 20
__PACKAGE__->run_before('check_task_server');
19 21
__PACKAGE__->run_before('load_background_job', only => [ qw(edit update destroy execute) ]);
20 22

  
23
__PACKAGE__->make_sorted(
24
  ONLY         => [ qw(list) ],
25

  
26
  package_name => $::locale->text('Package name'),
27
  type         => $::locale->text('Execution type'),
28
  active       => $::locale->text('Active'),
29
  cron_spec    => $::locale->text('Execution schedule'),
30
  last_run_at  => $::locale->text('Last run at'),
31
  next_run_at  => $::locale->text('Next run at'),
32
);
33

  
21 34
#
22 35
# actions
23 36
#
......
27 40

  
28 41
  $self->render('background_job/list',
29 42
                title           => $::locale->text('Background jobs'),
30
                BACKGROUND_JOBS => SL::DB::Manager::BackgroundJob->get_all_sorted);
43
                BACKGROUND_JOBS => $self->get_models);
31 44
}
32 45

  
33 46
sub action_new {
......
63 76
    flash_later('error', $::locale->text('The background job could not be destroyed.'));
64 77
  }
65 78

  
66
  $self->redirect_to(action => 'list');
79
  $self->redirect_to($self->back_to);
67 80
}
68 81

  
69 82
sub action_save_and_execute {
......
123 136
  flash_later('info', $is_new ? $::locale->text('The background job has been created.') : $::locale->text('The background job has been saved.'));
124 137
  return if $return;
125 138

  
126
  $self->redirect_to(action => 'list');
139
  $self->redirect_to($self->back_to);
127 140
}
128 141

  
129 142
sub load_background_job {
......
140 153
  flash('warning', $::locale->text('The task server does not appear to be running.')) if !$self->task_server->is_running;
141 154
}
142 155

  
156
sub init_back_to {
157
  my ($self) = @_;
158
  return $::form->{back_to} || $self->url_for(action => 'list');
159
}
160

  
143 161
1;
templates/webpages/background_job/form.html
37 37

  
38 38
  <p>
39 39
   [% L.hidden_tag("id", SELF.background_job.id) %]
40
   [% L.hidden_tag("back_to", SELF.back_to) %]
40 41
   [% L.hidden_tag("action", "BackgroundJob/dispatch") %]
41 42
   [% L.submit_tag("action_" _  (SELF.background_job.id ? "update" : "create"), LxERP.t8('Save')) %]
42 43
   [%- IF SELF.background_job.id %]
templates/webpages/background_job/list.html
15 15
   <table id="background_job_list" width="100%">
16 16
    <thead>
17 17
     <tr class="listheading">
18
      <th>[%- LxERP.t8('Package name') %]</th>
19
      <th>[%- LxERP.t8('Execution type') %]</th>
20
      <th>[%- LxERP.t8('Active') %]</th>
21
      <th>[%- LxERP.t8('Execution schedule') %]</th>
22
      <th>[%- LxERP.t8('Last run at') %]</th>
23
      <th>[%- LxERP.t8('Next run at') %]</th>
18
      <th>[% L.sortable_table_header('package_name') %]</th>
19
      <th>[% L.sortable_table_header('type') %]</th>
20
      <th>[% L.sortable_table_header('active') %]</th>
21
      <th>[% L.sortable_table_header('cron_spec') %]</th>
22
      <th>[% L.sortable_table_header('last_run_at') %]</th>
23
      <th>[% L.sortable_table_header('next_run_at') %]</th>
24 24
     </tr>
25 25
    </thead>
26 26

  
......
28 28
    [%- FOREACH background_job = BACKGROUND_JOBS %]
29 29
    <tr class="listrow[% loop.count % 2 %]" id="background_job_id_[% background_job.id %]">
30 30
     <td>
31
      <a href="[% SELF.url_for(action => 'edit', id => background_job.id) %]">
31
      <a href="[% SELF.url_for(action => 'edit', id => background_job.id, back_to => SELF.get_callback) %]">
32 32
       [%- HTML.escape(background_job.package_name) %]
33 33
      </a>
34 34
     </td>
......
67 67
  <hr size="3" noshade>
68 68

  
69 69
  <p>
70
   <a href="[% SELF.url_for(action => 'new') %]">[%- LxERP.t8('Create new background job') %]</a>
70
   <a href="[% SELF.url_for(action => 'new', back_to => SELF.get_callback) %]">[%- LxERP.t8('Create new background job') %]</a>
71 71
   |
72 72
   <a href="[% SELF.url_for(controller => 'BackgroundJobHistory', action => 'list') %]">[%- LxERP.t8('View background job history') %]</a>
73 73
   |

Auch abrufbar als: Unified diff