Bugzilla – Attachment 104431 Details for
Bug 25279
Make the cities list use the API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25279: (QA follow-up) Original behaviour
Bug-25279-QA-follow-up-Original-behaviour.patch (text/plain), 5.49 KB, created by
Jonathan Druart
on 2020-05-06 14:13:00 UTC
(
hide
)
Description:
Bug 25279: (QA follow-up) Original behaviour
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-05-06 14:13:00 UTC
Size:
5.49 KB
patch
obsolete
>From 50c29e4db154a9efd430fe5178026b057b749484 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >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 <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > 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 @@ > </div> > > <h2>Cities</h2> >- [% IF searchfield %] >- Searching: [% searchfield | html %] >+ [% IF city_name_filter %] >+ Searching: [% city_name_filter | html %] > [% END %] > >- <table id="table_cities"> >- <thead> >- <tr> >- <th>City ID</th> >- <th>City</th> >- <th>State</th> >- <th>ZIP/Postal code</th> >- <th>Country</th> >- <th>Actions</th> >- </tr> >- </thead> >- </table> >+ [% IF cities_count > 0 %] >+ <table id="table_cities"> >+ <thead> >+ <tr> >+ <th>City ID</th> >+ <th>City</th> >+ <th>State</th> >+ <th>ZIP/Postal code</th> >+ <th>Country</th> >+ <th data-class-name="actions">Actions</th> >+ </tr> >+ </thead> >+ </table> >+ [% ELSE %] >+ <div class="dialog message"> >+ There are no cities defined. <a href="/cgi-bin/koha/admin/cities.pl?op=add_form">Create a new city</a>. >+ </div> >+ [% END %] > [% END %] > > </main> >@@ -162,12 +168,21 @@ > [% INCLUDE 'datatables.inc' %] > <script> > $(document).ready(function() { >- var cities_table_url = '/api/v1/cities'; >+ var cities_table_url = '/api/v1/cities?'; >+ [% IF city_name_filter %] >+ var city_name_filter = { >+ 'name': { >+ "like": '%[%- city_name_filter | html -%]%' >+ } >+ }; >+ cities_table_url += 'q='+ encodeURI(JSON.stringify(city_name_filter)); >+ [% END %] > var cities_table = $("#table_cities").api({ > "ajax": { > "url": cities_table_url > }, > 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', >+ "order": [[ 1, "asc" ]], > "columns": [ > { > "data": "city_id", >@@ -197,7 +212,7 @@ > { > "data": function( row, type, val, meta ) { > >- var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/cities.pl?op=add_form&cityid='+ row.city_id +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'; >+ var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/cities.pl?op=add_form&cityid='+ row.city_id +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n"; > result += '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/cities.pl?op=delete_confirm&cityid='+ row.city_id +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</a>'; > return result; > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25279
:
103693
|
103694
|
103802
|
103803
|
103804
|
104065
|
104072
|
104359
|
104387
|
104416
|
104417
|
104420
|
104421
|
104423
|
104427
|
104428
|
104429
|
104430
| 104431 |
104432
|
104433
|
104434
|
104435
|
104510