Bugzilla – Attachment 132742 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: Be more flexible for filters
Bug-30063-Be-more-flexible-for-filters.patch (text/plain), 5.07 KB, created by
Jonathan Druart
on 2022-03-31 12:47:34 UTC
(
hide
)
Description:
Bug 30063: Be more flexible for filters
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-03-31 12:47:34 UTC
Size:
5.07 KB
patch
obsolete
>From a8d9b42047857358d71952fd469b752ae8177805 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 23 Mar 2022 17:36:50 +0100 >Subject: [PATCH] Bug 30063: Be more flexible for filters >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >On later follow-ups (ERM) we need to filter columns that contain AVs, >and so be more flexible. Here we are expecting a _id and _str keys we >are gonna use to build the select's options > >Signed-off-by: Séverine Queune <severine.queune@bulac.fr> >--- > .../prog/en/includes/patron-search.inc | 20 +++++++--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 40 ++++++------------- > 2 files changed, 26 insertions(+), 34 deletions(-) > >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 88e6d893049..7b68a5940c0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -209,14 +209,22 @@ > <script>console.log("Wrong call of patron_searh_js - missing redirect_url");</script> > [% END %] > <script> >- let categories = [% To.json(categories) | $raw %]; >- let categories_map = categories.reduce((map, c) => { >- map[c.categorycode] = c; >+ let categories = [% To.json(categories) | $raw %].map(e => { >+ e['_id'] = e.categorycode; >+ e['_str'] = e.description; >+ return e; >+ }); >+ let categories_map = categories.reduce((map, e) => { >+ map[e._id] = e; > return map; > }, {}); >- let libraries = [% To.json(libraries) | $raw %]; >- let libraries_map = libraries.reduce((map, l) => { >- map[l.branchcode] = l; >+ let libraries = [% To.json(libraries) | $raw %].map(e => { >+ e['_id'] = e.branchcode; >+ e['_str'] = e.branchname; >+ return e; >+ }); >+ let libraries_map = libraries.reduce((map, e) => { >+ map[e._id] = e; > return map; > }, {}); > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index ebc267f85d6..3baa6b21664 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -819,34 +819,18 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > if ( $(this).data('filter') ) { > input_type = 'select' > let filter_type = $(this).data('filter'); >- if ( filter_type == 'libraries' ) { >- var existing_search = table_dt.column(i).search(); >- let select = $('<select><option value=""></option></select'); >- >- $(libraries).each(function(){ >- let o = $('<option value="%s">%s</option>'.format(this.branchcode, this.branchname)); >- if ( existing_search == this.branchcode ) { >- o.prop("selected", "selected"); >- } >- o.appendTo(select); >- }); >- $(this).html( select ); >- } else if ( filter_type == 'categories' ) { >- var existing_search = table_dt.column(i).search(); >- let select = $('<select><option value=""></option></select'); >- >- $(categories).each(function(){ >- let o = $('<option value="%s">%s</option>'.format(this.categorycode, this.description)); >- if ( existing_search == this.categorycode ) { >- o.prop("selected", "selected"); >- } >- o.appendTo(select); >- }); >- $(this).html( select ); >- } else { >- console.log("Unknown filter " + filter_type); >- return; >- } >+ var existing_search = table_dt.column(i).search(); >+ let select = $('<select><option value=""></option></select'); >+ >+ // FIXME eval here is bad and dangerous, how do we workaround that? >+ $(eval(filter_type)).each(function(){ >+ let o = $('<option value="%s">%s</option>'.format(this._id, this._str)); >+ if ( existing_search == this._id ) { >+ o.prop("selected", "selected"); >+ } >+ o.appendTo(select); >+ }); >+ $(this).html( select ); > } else { > var title = $(this).text(); > var existing_search = table_dt.column(i).search(); >-- >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