Bugzilla – Attachment 130608 Details for
Bug 30063
Make the main patron search use the /patrons REST API route
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30063: Number of checkouts
Bug-30063-Number-of-checkouts.patch (text/plain), 8.99 KB, created by
Jonathan Druart
on 2022-02-15 10:31:11 UTC
(
hide
)
Description:
Bug 30063: Number of checkouts
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-02-15 10:31:11 UTC
Size:
8.99 KB
patch
obsolete
>From bde12bca89b945586235f9e5fd0afb352b76d006 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 11 Feb 2022 09:39:12 +0100 >Subject: [PATCH] Bug 30063: Number of checkouts > >--- > api/v1/swagger/definitions/patron.yaml | 5 ++ > api/v1/swagger/paths/patrons.yaml | 1 + > .../prog/en/includes/patron-search.inc | 47 ++++++++++++++----- > .../prog/en/modules/members/search.tt | 2 +- > 4 files changed, 41 insertions(+), 14 deletions(-) > >diff --git a/api/v1/swagger/definitions/patron.yaml b/api/v1/swagger/definitions/patron.yaml >index cda77629cea..d23129b1add 100644 >--- a/api/v1/swagger/definitions/patron.yaml >+++ b/api/v1/swagger/definitions/patron.yaml >@@ -328,6 +328,11 @@ properties: > description: patron's extended attributes > items: > $ref: patron_extended_attribute.yaml >+ checkouts_count: >+ type: >+ - integer >+ - "null" >+ description: Number of checkouts > additionalProperties: false > required: > - surname >diff --git a/api/v1/swagger/paths/patrons.yaml b/api/v1/swagger/paths/patrons.yaml >index 1fbf3677a2f..17fe506fffb 100644 >--- a/api/v1/swagger/paths/patrons.yaml >+++ b/api/v1/swagger/paths/patrons.yaml >@@ -385,6 +385,7 @@ > - acquisition: "order_manage" > x-koha-embed: > - extended_attributes >+ - checkouts+count > post: > x-mojo-to: Patrons#add > operationId: addPatron >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 90e0d9ff895..3f8e6752eee 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -78,7 +78,7 @@ > [% END %] > </div> > >- <div id="[% table_id %]_search_results" style="display:none;"> >+ <div id="[% table_id | html %]_search_results" style="display:none;"> > > <div id="info" class="dialog message" style="display: none;"></div> > <div id="error" class="dialog alert" style="dispay: none;"></div> >@@ -86,9 +86,9 @@ > > <input type="hidden" id="firstletter_filter" value="" /> > [% IF open_on_row_click %] >- <table id="[% table_id %]" class="selections-table"> >+ <table id="[% table_id | html %]" class="selections-table"> > [% ELSE %] >- <table id="[% table_id %]"> >+ <table id="[% table_id | html %]"> > [% END %] > <thead> > <tr> >@@ -105,6 +105,7 @@ > [% CASE 'dateexpiry' %]<th>Expires on</td> > [% CASE 'borrowernotes' %]<th>Notes</th> > [% CASE 'phone' %]<th>Phone</th> >+ [% CASE 'checkouts' %]<th>Checkouts</th> > [% CASE 'action' %]<th> </th> > [% END %] > [% END %] >@@ -153,8 +154,8 @@ > return map; > }, {}); > >- [% IF Koha.Preference('ExtendedPatronAttributes') %] >- let extended_attribute_types = [% To.json(attribute_type_codes || []) | $raw %]; >+ [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %] >+ let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; > [% END %] > > </script> >@@ -187,9 +188,9 @@ > [% SET search_fields = Koha.Preference('DefaultPatronSearchFields') || 'surname,firstname,othernames,cardnumber,userid' %] > return [ > [% FOR search_field IN search_fields.split(',') %] >- {"me.[% search_field %]":{"like":"%"+filter+"%"}}, >+ {"me.[% search_field | html %]":{"like":"%"+filter+"%"}}, > [% END %] >- [% IF Koha.Preference('ExtendedPatronAttributes') %] >+ [% IF Koha.Preference('ExtendedPatronAttributes') && extended_attribute_types %] > { > "extended_attributes.value": { "like": "%" + filter + "%" }, > "extended_attributes.code": extended_attribute_types >@@ -198,7 +199,7 @@ > ]; > } > }; >- patrons_table = $("#[% table_id %]").kohaTable({ >+ patrons_table = $("#[% table_id | html %]").kohaTable({ > "ajax": { > [% SWITCH filter %] > [% CASE 'suggestions_managers' %] >@@ -216,7 +217,7 @@ > [% IF redirect_if_one_result %] > // redirect if there is only 1 result. > if ( first_draw && json.recordsFiltered == 1 ) { >- document.location.href = '[% redirect_url %]&borrowernumber=' + json.data[0].patron_id; >+ document.location.href = '[% redirect_url | html %]&borrowernumber=' + json.data[0].patron_id; > return false; > } > first_draw = 0; >@@ -224,7 +225,7 @@ > return json.data; > } > }, >- embed: ['extended_attributes'], >+ embed: ['extended_attributes', 'checkouts+count'], > "drawCallback": function( settings ) { > var api = this.api(); > var data = api.data(); >@@ -232,7 +233,7 @@ > > [% IF open_on_row_click %] > $.each($(this).find("tbody tr"), function(index, tr) { >- let url = "[% on_click_url %]&borrowernumber=" + data[index].patron_id; >+ let url = "[% on_click_url | html %]&borrowernumber=" + data[index].patron_id; > $(tr).off('click').on('click', function() { > document.location.href = url; > }).addClass('clickable'); >@@ -249,6 +250,17 @@ > "columns": [ > [% FOR column IN columns %] > [% SWITCH column %] >+ [% CASE 'checkbox' %] >+ { >+ "data": "borrowernumber", >+ "searchable": true, >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ return "<input type=\"checkbox\" name="data ? escape_str($date(data) + " (" + _("%s years").format($get_age(data)) + ")") : ""; >+ >+ return "<label for='check" + data + "' class='content_hidden'>" + _("Select patron") + "</label><input type='checkbox' id='check" + data + "' class='selection' name='borrowernumber' value='" + data + "' />", >+ } >+ } > [% CASE 'cardnumber' %] > { > "data": "cardnumber", >@@ -367,6 +379,15 @@ > return escape_str(data); > } > } >+ [% CASE 'checkouts' %] >+ { >+ "data": "", >+ "searchable": false, >+ "orderable": false, >+ "render": function( data, type, row, meta ) { >+ return escape_str(row.checkouts_count); >+ } >+ } > [% CASE 'action' %] > { > "data": function( row, type, val, meta ) { >@@ -426,7 +447,7 @@ > > function filter() { > $("#firstletter_filter").val(''); >- $("#[% table_id %]_search_results").show(); >+ $("#[% table_id | html %]_search_results").show(); > > let table_dt = patrons_table.DataTable(); > [% FOR c IN columns %] >@@ -450,7 +471,7 @@ > // User has clicked on a letter > function filterByFirstLetterSurname(letter) { > $("#firstletter_filter").val(letter); >- $("#[% table_id %]_search_results").show(); >+ $("#[% table_id | html %]_search_results").show(); > patrons_table.DataTable().draw(); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >index 620a9d73db6..9e404c9efbb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt >@@ -32,7 +32,7 @@ > table_id => 'memberresultst', > categories => categories, > libraries => libraries, >- extended_attribute_types => extended_attribute_types, >+ extended_attribute_types => attribute_type_codes, > columns => columns, > filter => filter, > selection_type => selection_type, >-- >2.25.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 30063
:
130608
|
130609
|
130610
|
130611
|
130612
|
130613
|
130614
|
130615
|
132387
|
132552
|
132731
|
132732
|
132733
|
132734
|
132735
|
132736
|
132737
|
132738
|
132739
|
132740
|
132741
|
132742
|
132743
|
132744
|
132745
|
132746
|
132747
|
132748
|
132749
|
132759
|
132760
|
132761
|
132762
|
132763
|
132764
|
132765
|
132766
|
132767
|
132768
|
132769
|
132770
|
132771
|
132772
|
132773
|
132774
|
132775
|
132776
|
132777
|
132958