From 6c5cdbebb76503232d7aabafd7c86e353ef2b73d Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 5 Aug 2013 10:26:32 +0200 Subject: [PATCH] Backgroundjob-History-Liste: Filterfunktion --- SL/Controller/BackgroundJobHistory.pm | 34 +++++- locale/de/all | 1 + .../background_job_history/_filter.html | 47 ++++++++ .../webpages/background_job_history/list.html | 100 +++++++++--------- 4 files changed, 131 insertions(+), 51 deletions(-) create mode 100644 templates/webpages/background_job_history/_filter.html diff --git a/SL/Controller/BackgroundJobHistory.pm b/SL/Controller/BackgroundJobHistory.pm index 29f2bc79a..5b0cd8fae 100644 --- a/SL/Controller/BackgroundJobHistory.pm +++ b/SL/Controller/BackgroundJobHistory.pm @@ -4,6 +4,7 @@ use strict; use parent qw(SL::Controller::Base); +use SL::Controller::Helper::Filtered; use SL::Controller::Helper::GetModels; use SL::Controller::Helper::Paginated; use SL::Controller::Helper::Sorted; @@ -14,7 +15,7 @@ use SL::System::TaskServer; use Rose::Object::MakeMethods::Generic ( - scalar => [ qw(history) ], + scalar => [ qw(history db_args flat_filter filter_summary) ], 'scalar --get_set_init' => [ qw(task_server) ], ); @@ -22,6 +23,10 @@ __PACKAGE__->run_before('check_auth'); __PACKAGE__->run_before('add_stylesheet'); __PACKAGE__->run_before('check_task_server'); +__PACKAGE__->make_filtered( + MODEL => 'BackgroundJobHistory', + LAUNDER_TO => 'filter' +); __PACKAGE__->make_paginated(ONLY => [ qw(list) ]); __PACKAGE__->make_sorted( @@ -41,6 +46,8 @@ __PACKAGE__->make_sorted( sub action_list { my ($self) = @_; + $self->make_filter_summary; + $self->render('background_job_history/list', title => $::locale->text('Background job history'), ENTRIES => $self->get_models); @@ -82,4 +89,29 @@ sub add_stylesheet { $::request->{layout}->use_stylesheet('lx-office-erp/background_jobs.css'); } +sub make_filter_summary { + my ($self) = @_; + + my $filter = $::form->{filter} || {}; + my @filters = ( + [ "package_name:substr::ilike", $::locale->text('Package name') ], + [ "result:substr::ilike", $::locale->text('Result') ], + [ "error:substr::ilike", $::locale->text('Error') ], + [ "run_at:date::ge", $::locale->text('Run at') . " " . $::locale->text('From Date') ], + [ "run_at:date::le", $::locale->text('Run at') . " " . $::locale->text('To Date') ], + ); + + my @filter_strings = grep { $_ } + map { $filter->{ $_->[0] } ? $_->[1] . ' ' . $filter->{ $_->[0] } : undef } + @filters; + + my %status = ( + failed => $::locale->text('failed'), + success => $::locale->text('succeeded'), + ); + push @filter_strings, $status{ $filter->{'status:eq_ignore_empty'} } if $filter->{'status:eq_ignore_empty'}; + + $self->filter_summary(join(', ', @filter_strings)); +} + 1; diff --git a/locale/de/all b/locale/de/all index ba78f2306..dabbeb6ae 100755 --- a/locale/de/all +++ b/locale/de/all @@ -556,6 +556,7 @@ $self->{texts} = { 'Current / Next Level' => 'Aktuelles / Nächstes Mahnlevel', 'Current Earnings' => 'Gewinn', 'Current assets account' => 'Konto für Umlaufvermögen', + 'Current filter' => 'Aktueller Filter', 'Current profile' => 'Aktuelles Profil', 'Current status' => 'Aktueller Status', 'Current value:' => 'Aktueller Wert:', diff --git a/templates/webpages/background_job_history/_filter.html b/templates/webpages/background_job_history/_filter.html new file mode 100644 index 000000000..f7e49fdd7 --- /dev/null +++ b/templates/webpages/background_job_history/_filter.html @@ -0,0 +1,47 @@ +[%- USE L %][%- USE LxERP %][%- USE HTML %] +
+
+ [% LxERP.t8('Show Filter') %] + [% IF SELF.filter_summary %]([% LxERP.t8("Current filter") %]: [% SELF.filter_summary %])[% END %] +
+ + + +
diff --git a/templates/webpages/background_job_history/list.html b/templates/webpages/background_job_history/list.html index e044a7ad3..1a2b94887 100644 --- a/templates/webpages/background_job_history/list.html +++ b/templates/webpages/background_job_history/list.html @@ -1,60 +1,60 @@ [% USE HTML %][% USE L %][% USE LxERP %] -

[% FORM.title %]

+

[% FORM.title %]

[%- INCLUDE 'common/flash.html' %] -
- [% IF !ENTRIES.size %] -

- [%- LxERP.t8('There are no entries in the background job history.') %] -

- - [%- ELSE %] - - - - - - - - - - - - - [%- FOREACH entry = ENTRIES %] - - - - - - - +[%- PROCESS 'background_job_history/_filter.html' filter=SELF.filter %] + +[% IF !ENTRIES.size %] +

+ [%- LxERP.t8('There are no entries in the background job history.') %] +

+ +[%- ELSE %] +
[% L.sortable_table_header('package_name') %][% L.sortable_table_header('run_at') %][% L.sortable_table_header('status') %][% L.sortable_table_header('result') %][% L.sortable_table_header('error') %]
- - [%- HTML.escape(entry.package_name) %] - - [%- HTML.escape(entry.run_at.to_lxoffice('precision' => 'second')) %] - [%- IF entry.status == 'success' %] - [%- LxERP.t8('succeeded') %] - [%- ELSIF entry.status == 'failure' %] - [%- LxERP.t8('failed') %] - [%- ELSE %] - [%- HTML.escape(entry.status) %] - [%- END %] - [%- HTML.escape(entry.result) %][% IF entry.error_col %]
[%- HTML.escape(L.truncate(entry.error_col)) %]
[%- END %]
+ + + + + + + + + + + + [%- FOREACH entry = ENTRIES %] + + + + -
[% L.sortable_table_header('package_name') %][% L.sortable_table_header('run_at') %][% L.sortable_table_header('status') %][% L.sortable_table_header('result') %][% L.sortable_table_header('error') %]
+ + [%- HTML.escape(entry.package_name) %] + + [%- HTML.escape(entry.run_at.to_lxoffice('precision' => 'second')) %] + [%- IF entry.status == 'success' %] + [%- LxERP.t8('succeeded') %] + [%- ELSIF entry.status == 'failure' %] + [%- LxERP.t8('failed') %] + [%- ELSE %] + [%- HTML.escape(entry.status) %] [%- END %] -
+ + [%- HTML.escape(entry.result) %] + [% IF entry.error_col %]
[%- HTML.escape(L.truncate(entry.error_col)) %]
[%- END %] + [%- END %] + + +[%- END %] - [% L.paginate_controls %] +[% L.paginate_controls %] -
+
-

- [%- LxERP.t8('View background jobs') %] - | - [%- LxERP.t8('Task server control') %] -

-
+

+ [%- LxERP.t8('View background jobs') %] + | + [%- LxERP.t8('Task server control') %] +

-- 2.20.1