From 50c29e4db154a9efd430fe5178026b057b749484 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 5 May 2020 18:55:49 -0300 Subject: [PATCH] Bug 25279: (QA follow-up) Original behaviour This patch does the following things: - Uses a call to Koha::Cities->search(*)->count to display the same message we displayed before when no city was found/defined (datatable not rendered at all). - Restores the main search box functionality, the passed param is used to query on the city name with wildcards on both sides, for (a) counting results and for (b) apending to the API call with the same behaviour. The only missing bit from QA is HTML/URI escaping values from cells, but this is going to happen at DT level most sure. Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- admin/cities.pl | 15 ++++-- .../prog/en/modules/admin/cities.tt | 47 ++++++++++++------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/admin/cities.pl b/admin/cities.pl index f25ec18571..03bce54d24 100755 --- a/admin/cities.pl +++ b/admin/cities.pl @@ -27,7 +27,7 @@ use C4::Output; use Koha::Cities; my $input = new CGI; -my $searchfield = $input->param('city_name') // q||; +my $city_name = $input->param('city_name') // q||; my $cityid = $input->param('cityid'); my $op = $input->param('op') || 'list'; my @messages; @@ -84,8 +84,8 @@ if ( $op eq 'add_form' ) { push @messages, { type => 'message', code => 'success_on_insert' }; } } - $searchfield = q||; - $op = 'list'; + $city_name = q||; + $op = 'list'; } elsif ( $op eq 'delete_confirm' ) { my $city = Koha::Cities->find($cityid); $template->param( city => $city, ); @@ -101,9 +101,16 @@ if ( $op eq 'add_form' ) { $op = 'list'; } +if ( $op eq 'list' ) { + my $filter = {}; + $filter->{city_name} = { -like => '%'.$city_name.'%' } + if $city_name; + $template->param( cities_count => Koha::Cities->search($filter)->count ); +} + $template->param( cityid => $cityid, - searchfield => $searchfield, + city_name_filter => $city_name, messages => \@messages, op => $op, ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt index bce24c5fd3..445d839e59 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt @@ -129,22 +129,28 @@

Cities

- [% IF searchfield %] - Searching: [% searchfield | html %] + [% IF city_name_filter %] + Searching: [% city_name_filter | html %] [% END %] - - - - - - - - - - - -
City IDCityStateZIP/Postal codeCountryActions
+ [% IF cities_count > 0 %] + + + + + + + + + + + +
City IDCityStateZIP/Postal codeCountryActions
+ [% ELSE %] +
+ There are no cities defined. Create a new city. +
+ [% END %] [% END %] @@ -162,12 +168,21 @@ [% INCLUDE 'datatables.inc' %]