Bugzilla – Attachment 161132 Details for
Bug 34431
Distinguish between status and status alias in ILL UI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34431: Add a status_alias filter input, if any status_alias exist
Bug-34431-Add-a-statusalias-filter-input-if-any-st.patch (text/plain), 9.35 KB, created by
Tomás Cohen Arazi (tcohen)
on 2024-01-18 12:58:58 UTC
(
hide
)
Description:
Bug 34431: Add a status_alias filter input, if any status_alias exist
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2024-01-18 12:58:58 UTC
Size:
9.35 KB
patch
obsolete
>From c4b206546b9d37eb961857fa42d889d33b211b1a Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Fri, 4 Aug 2023 16:06:11 +0000 >Subject: [PATCH] Bug 34431: Add a status_alias filter input, if any > status_alias exist > >This patch also makes it so that the status input filter is enabled by default, and shows all existing statuses by default, or all existing statuses for a specific backend, if and when selected. > >Signed-off-by: Stephen Graham <s.graham4@herts.ac.uk> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../en/includes/ill-list-table-strings.inc | 2 + > .../intranet-tmpl/prog/js/ill-list-table.js | 140 ++++++++++++------ > 2 files changed, 97 insertions(+), 45 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table-strings.inc >index bf1ef077f9c..c3cbf09df1b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table-strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-list-table-strings.inc >@@ -4,5 +4,7 @@ > var ill_manage = _("Manage request"); > var ill_manage_select_backend_first = _("Select a backend first"); > var ill_all_statuses = _("All statuses"); >+ var ill_all_status_aliases = _("All status aliases"); >+ var ill_status_aliases = _("Status aliases"); > </script> > <!-- / ill-list-table-strings.inc --> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >index db08be878cb..21339ef9913 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >@@ -98,11 +98,12 @@ $(document).ready(function() { > "-or": function(){ > let patron = $("#illfilter_patron").val(); > let status = $("#illfilter_status").val(); >+ let status_alias = $("#illfilter_status_alias").val(); > let filters = []; > let status_sub_or = []; > let subquery_and = []; > >- if (!patron && !status) return ""; >+ if (!patron && !status && !status_alias) return ""; > > if(patron){ > let patronquery = buildPatronSearchQuery( >@@ -115,13 +116,10 @@ $(document).ready(function() { > } > > if(status){ >- const status_search_fields = "me.status,me.status_av"; >- status_search_fields.split(',').forEach(function(attr){ >- status_sub_or.push({ >- [attr]:{"=": status } >- }); >- }); >- subquery_and.push(status_sub_or); >+ subquery_and.push( {"me.status":{"=": status }}); >+ } >+ if(status_alias){ >+ subquery_and.push({"me.status_alias":{"=": status_alias }}); > } > > filters.push({"-and": subquery_and}); >@@ -455,37 +453,71 @@ $(document).ready(function() { > $('#illfilter_form > fieldset > ol > li:nth-child(6) > span > a').click(); > $('#illfilter_form > fieldset > ol > li:nth-child(7) > span > a').click(); > >- disableStatusFilter(); >- > redrawTable(); > } > >- function populateStatusFilter(backend) { >- $.ajax({ >- type: "GET", >- url: "/api/v1/ill/backends/"+backend, >- headers: { >- 'x-koha-embed': 'statuses+strings' >- }, >- success: function(response){ >- let statuses = response.statuses >- $('#illfilter_status').append( >- '<option value="">'+ill_all_statuses+'</option>' >+ function addStatusOptions(statuses){ >+ $('#illfilter_status').children().remove(); >+ $('#illfilter_status').append( >+ '<option value="">'+ill_all_statuses+'</option>' >+ ); >+ statuses.sort((a, b) => a.str.localeCompare(b.str)).forEach(function(status) { >+ $('#illfilter_status').append( >+ '<option value="' + status.code + >+ '">' + status.str + '</option>' >+ ); >+ }); >+ } >+ >+ function addStatusAliasOptions(status_aliases){ >+ $('#illfilter_status_alias').parent().remove(); >+ if (status_aliases.length !== 0) { >+ $('#illfilter_status').parent().after(function() { >+ return '<li><label for="illfilter_status_alias">'+ill_status_aliases+':</label> <select name="illfilter_status_alias" id="illfilter_status_alias"></select></li>'; >+ }); >+ $('#illfilter_status_alias').append( >+ '<option value="">'+ill_all_status_aliases+'</option>' >+ ); >+ status_aliases.sort((a, b) => a.str.localeCompare(b.str)).forEach(function (status_alias) { >+ $('#illfilter_status_alias').append( >+ '<option value="' + status_alias.code + >+ '">' + status_alias.str + '</option>' > ); >- statuses.sort((a, b) => a.str.localeCompare(b.str)).forEach(function(status) { >- $('#illfilter_status').append( >- '<option value="' + status.code + >- '">' + status.str + '</option>' >- ); >- }); >+ }); >+ } >+ } >+ >+ function populateStatusFilter(params) { >+ if(params.backend_statuses){ >+ if(params.backend_statuses.statuses){ >+ addStatusOptions(params.backend_statuses.statuses); > } >- }); >+ if(params.backend_statuses.status_aliases){ >+ addStatusAliasOptions(params.backend_statuses.status_aliases); >+ } >+ }else if(params.backend){ >+ let backend_id = params.backend || ""; >+ $.ajax({ >+ type: "GET", >+ url: "/api/v1/ill/backends/"+backend_id, >+ headers: { >+ 'x-koha-embed': 'statuses+strings' >+ }, >+ success: function(response){ >+ addStatusOptions(response.statuses.filter(status => status.type == 'ill_status')); >+ addStatusAliasOptions(response.statuses.filter(status => status.type == 'av')); >+ } >+ }); >+ } > } > > function populateBackendFilter() { > $.ajax({ > type: "GET", > url: "/api/v1/ill/backends", >+ headers: { >+ 'x-koha-embed': 'statuses+strings' >+ }, > success: function(backends){ > backends.sort((a, b) => a.ill_backend_id.localeCompare(b.ill_backend_id)).forEach(function(backend) { > $('#illfilter_backend').append( >@@ -493,33 +525,51 @@ $(document).ready(function() { > '">' + backend.ill_backend_id + '</option>' > ); > }); >- } >- }); >- } > >- function disableStatusFilter() { >- $('#illfilter_status').children().remove(); >- $("#illfilter_status").attr('title', ill_manage_select_backend_first); >- $('#illfilter_status').prop("disabled", true); >- } >+ let all_existing_statuses = []; >+ backends.forEach((backend) => { >+ let existing_statuses = backend.statuses; >+ existing_statuses.filter(status => status.type == 'ill_status').forEach((existing_status) => { >+ let index = all_existing_statuses.map(function(e) { return e.code; }).indexOf(existing_status.code) || false; >+ if(index == -1){ >+ all_existing_statuses.push(existing_status); >+ } >+ }); >+ }); > >- function enableStatusFilter() { >- $('#illfilter_status').children().remove(); >- $("#illfilter_status").attr('title', ''); >- $('#illfilter_status').prop("disabled", false); >+ let all_existing_status_aliases = []; >+ backends.forEach((backend) => { >+ let existing_status_aliases = backend.statuses; >+ existing_status_aliases.filter(status => status.type == 'av').forEach((existing_status_aliases) => { >+ let index = all_existing_status_aliases.map(function(e) { return e.code; }).indexOf(existing_status_aliases.code) || false; >+ if(index == -1){ >+ all_existing_status_aliases.push(existing_status_aliases); >+ } >+ }); >+ }); >+ >+ populateStatusFilter( >+ { backend_statuses: >+ { >+ statuses : all_existing_statuses, >+ status_aliases: all_existing_status_aliases >+ } >+ } >+ ) >+ >+ } >+ }); > } > > $('#illfilter_backend').change(function() { > var selected_backend = $('#illfilter_backend option:selected').val(); > if (selected_backend && selected_backend.length > 0) { >- populateStatusFilter(selected_backend); >- enableStatusFilter(); >- } else { >- disableStatusFilter(); >+ populateStatusFilter( { backend : selected_backend } ); >+ } else{ >+ populateBackendFilter(); > } > }); > >- disableStatusFilter(); > populateBackendFilter(); > > // Clear all filters >-- >2.43.0
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 34431
:
154034
|
154035
|
154036
|
154037
|
154289
|
154290
|
154291
|
154292
|
154301
|
154405
|
154406
|
154407
|
154408
|
154409
|
154410
|
154999
|
161104
|
161105
|
161106
|
161107
|
161108
|
161109
|
161110
|
161129
|
161130
|
161131
| 161132 |
161133
|
161134
|
161135