+sub init_models {
+ SL::Controller::Helper::GetModels->new(
+ controller => $_[0],
+ filtered => 0,
+ sorted => {
+ package_name => t8('Package name'),
+ type => t8('Execution type'),
+ active => t8('Active'),
+ cron_spec => t8('Execution schedule'),
+ last_run_at => t8('Last run at'),
+ next_run_at => t8('Next run at'),
+ },
+ query => [
+ package_name => [ SL::BackgroundJob::Base->get_known_job_classes ],
+ ],
+ );
+}
+
+sub setup_list_action_bar {
+ my ($self) = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ link => [
+ t8('Add'),
+ link => $self->url_for(action => 'new'),
+ accesskey => 'enter',
+ ],
+ link => [
+ t8('Server control'),
+ link => $self->url_for(controller => 'TaskServer', action => 'show'),
+ ],
+ link => [
+ t8('Job history'),
+ link => $self->url_for(controller => 'BackgroundJobHistory', action => 'list'),
+ ],
+ );
+ }
+}
+
+sub setup_form_action_bar {
+ my ($self) = @_;
+
+ my $is_new = !$self->background_job->id;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ combobox => [
+ action => [
+ t8('Save'),
+ submit => [ '#form', { action => 'BackgroundJob/' . ($is_new ? 'create' : 'update') } ],
+ accesskey => 'enter',
+ ],
+ action => [
+ t8('Save and execute'),
+ submit => [ '#form', { action => 'BackgroundJob/save_and_execute' } ],
+ ],
+ action => [
+ t8('Use as new'),
+ submit => [ '#form', { action => 'BackgroundJob/edit_as_new' } ],
+ disabled => $is_new ? t8('The object has not been saved yet.') : undef,
+ ],
+ ], # end of combobox "Save"
+
+ action => [
+ t8('Delete'),
+ submit => [ '#form', { action => 'BackgroundJob/destroy' } ],
+ confirm => t8('Do you really want to delete this object?'),
+ disabled => $is_new ? t8('This object has not been saved yet.') : undef,
+ ],
+
+ link => [
+ t8('Abort'),
+ link => $self->url_for(action => 'list'),
+ ],
+
+ link => [
+ t8('Job history'),
+ link => $self->url_for(controller => 'BackgroundJobHistory', action => 'list', 'filter.package_name:substr::ilike' => $self->background_job->package_name),
+ disabled => $is_new ? t8('This object has not been saved yet.') : undef,
+ ],
+ );
+ }
+}
+