Bugzilla – Attachment 147585 Details for
Bug 32983
Use REST API route to retrieve authorised values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32983: Use REST API route to retrieve authorised values
Bug-32983-Use-REST-API-route-to-retrieve-authorise.patch (text/plain), 3.39 KB, created by
Jonathan Druart
on 2023-03-02 10:08:14 UTC
(
hide
)
Description:
Bug 32983: Use REST API route to retrieve authorised values
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-03-02 10:08:14 UTC
Size:
3.39 KB
patch
obsolete
>From b23ac21263baf065d00924449a366e3a8e6acd48 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 23 Feb 2023 12:28:18 +0000 >Subject: [PATCH] Bug 32983: Use REST API route to retrieve authorised values > >Make one API call for all AV categories+values instead of one API call per AV category required > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > .../prog/js/vue/components/ERM/Main.vue | 27 +++++++++++++------ > .../prog/js/vue/fetch/authorised-values.js | 12 ++++++--- > 2 files changed, 27 insertions(+), 12 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >index 563814d0f8c..8aa66d19be4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/Main.vue >@@ -181,15 +181,26 @@ export default { > av_package_content_types: "ERM_PACKAGE_CONTENT_TYPE", > av_title_publication_types: "ERM_TITLE_PUBLICATION_TYPE", > } >- let promises = [] >- Object.entries(authorised_values).forEach(([av_var, av_cat]) => { >- promises.push( >- av_client.values.getAll(av_cat).then(av => { >- this.AVStore[av_var] = av >- }) >- ) >+ >+ let av_cat_array = Object.keys(authorised_values).map(function ( >+ av_cat >+ ) { >+ return '"' + authorised_values[av_cat] + '"' > }) >- Promise.all(promises).then(() => (this.mainStore.is_loading = false)) >+ >+ av_client.values >+ .getCategoriesWithValues(av_cat_array) >+ .then(av_categories => { >+ Object.entries(authorised_values).forEach( >+ ([av_var, av_cat]) => { >+ const av_match = av_categories.find( >+ element => element.category_name == av_cat >+ ) >+ this.AVStore[av_var] = av_match.authorised_values >+ } >+ ) >+ }) >+ .then(() => (this.mainStore.is_loading = false)) > }, > components: { > Breadcrumb, >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/authorised-values.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/authorised-values.js >index 639d8cf99fb..bd3887af534 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/authorised-values.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/authorised-values.js >@@ -3,16 +3,20 @@ import HttpClient from "./http-client"; > export class AVAPIClient extends HttpClient { > constructor() { > super({ >- baseURL: "/api/v1/authorised_value_categories/", >+ baseURL: "/api/v1/authorised_value_categories", > }); > } > > get values() { > return { >- getAll: (category_name, query) => >+ getCategoriesWithValues: (cat_array) => > this.get({ >- endpoint: category_name + "/values?" + (query || "_per_page=-1"), >- }), >+ endpoint: "?q={\"me.category_name\":["+(cat_array.join(", "))+"]}", >+ headers: { >+ "x-koha-embed": >+ "authorised_values", >+ }, >+ }), > }; > } > } >-- >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 32983
:
146732
|
146733
|
147050
|
147081
|
147228
|
147283
|
147348
|
147349
| 147585 |
147959