Bugzilla – Attachment 147041 Details for
Bug 32939
Have generic fetch functions in vue modules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32939: Use APIClient to fetch EBSCO eHoldings
Bug-32939-Use-APIClient-to-fetch-EBSCO-eHoldings.patch (text/plain), 10.16 KB, created by
Jonathan Druart
on 2023-02-21 13:50:25 UTC
(
hide
)
Description:
Bug 32939: Use APIClient to fetch EBSCO eHoldings
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-02-21 13:50:25 UTC
Size:
10.16 KB
patch
obsolete
>From 1ded66fde7f424eee255e4d93431b111875d6208 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 21 Feb 2023 12:42:15 +0100 >Subject: [PATCH] Bug 32939: Use APIClient to fetch EBSCO eHoldings > >--- > .../ERM/EHoldingsEBSCOPackageAgreements.vue | 11 +++- > .../ERM/EHoldingsEBSCOPackagesList.vue | 10 ++-- > .../ERM/EHoldingsEBSCOPackagesShow.vue | 17 +++--- > .../ERM/EHoldingsEBSCOResourcesShow.vue | 17 +++--- > .../ERM/EHoldingsEBSCOTitlesShow.vue | 16 ++++-- > .../prog/js/vue/fetch/erm-api-client.js | 53 +++++++++++++++++++ > 6 files changed, 102 insertions(+), 22 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageAgreements.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageAgreements.vue >index d82d7e380c9..734db3e5946 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageAgreements.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackageAgreements.vue >@@ -58,6 +58,10 @@ export default { > erm_package.provider = "ebsco" > erm_package.package_id = erm_package.koha_internal_id > delete erm_package.koha_internal_id >+ delete erm_package.resources >+ delete erm_package.vendor >+ delete erm_package.resources_count >+ delete erm_package.is_selected > return erm_package > }, > addAgreement(agreement_id) { >@@ -72,7 +76,10 @@ export default { > ) { > erm_package.package_agreements.push({ agreement_id }) > const client = APIClient.erm >+ > if (this.erm_package.koha_internal_id) { >+ let package_id = erm_package.package_id >+ delete erm_package.package_id > client.localPackages.update(erm_package, package_id).then( > success => { > this.$emit("refresh-agreements") >@@ -97,8 +104,10 @@ export default { > }, > deleteAgreement(counter) { > let erm_package = this.serializeAgreement() >- const client = APIClient.erm > erm_package.package_agreements.splice(counter, 1) >+ let package_id = erm_package.package_id >+ delete erm_package.package_id >+ const client = APIClient.erm > client.localPackages.update(erm_package, package_id).then( > success => { > this.$emit("refresh-agreements") >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue >index 900c459bfb4..27d54c59311 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesList.vue >@@ -137,11 +137,13 @@ export default { > .draw() > if (this.erm_providers.includes("local")) { > const client = APIClient.erm >- const query = filters >+ const query = this.filters > ? { >- "me.name": { like: "%" + filters.package_name + "%" }, >- ...(filters.content_type >- ? { "me.content_type": filters.content_type } >+ "me.name": { >+ like: "%" + this.filters.package_name + "%", >+ }, >+ ...(this.filters.content_type >+ ? { "me.content_type": this.filters.content_type } > : {}), > } > : {} >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesShow.vue >index 7809cdfe741..abb80afccc3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesShow.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOPackagesShow.vue >@@ -116,7 +116,7 @@ > import { inject } from "vue" > import EHoldingsPackageAgreements from "./EHoldingsEBSCOPackageAgreements.vue" > import EHoldingsPackageTitlesList from "./EHoldingsEBSCOPackageTitlesList.vue" >-import { fetchEBSCOPackage, checkError } from "../../fetch/erm.js" >+import { APIClient } from "../../fetch/api-client.js" > > export default { > setup() { >@@ -157,11 +157,16 @@ export default { > this.erm_package = this.getPackage(to.params.package_id) > }, > methods: { >- async getPackage(package_id) { >- const erm_package = await fetchEBSCOPackage(package_id) >- this.erm_package = erm_package >- this.initialized = true >- this.updating_is_selected = false >+ getPackage(package_id) { >+ const client = APIClient.erm >+ client.EBSCOPackages.get(package_id).then( >+ erm_package => { >+ this.erm_package = erm_package >+ this.initialized = true >+ this.updating_is_selected = false >+ }, >+ error => {} >+ ) > }, > edit_selected(is_selected) { > this.updating_is_selected = true >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOResourcesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOResourcesShow.vue >index fc4a9fbf37c..e764194e937 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOResourcesShow.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOResourcesShow.vue >@@ -115,9 +115,9 @@ > > <script> > import { inject } from "vue" >-import { fetchEBSCOResource } from "../../fetch/erm.js" > import { storeToRefs } from "pinia" > import { checkError } from "../../fetch/erm.js" >+import { APIClient } from "../../fetch/api-client.js" > > export default { > setup() { >@@ -156,11 +156,16 @@ export default { > this.resource = this.getResource(to.params.resource_id) > }, > methods: { >- async getResource(resource_id) { >- const resource = await fetchEBSCOResource(resource_id) >- this.resource = resource >- this.initialized = true >- this.updating_is_selected = false >+ getResource(resource_id) { >+ const client = APIClient.erm >+ client.EBSCOResources.get(resource_id).then( >+ resource => { >+ this.resource = resource >+ this.initialized = true >+ this.updating_is_selected = false >+ }, >+ error => {} >+ ) > }, > edit_selected(is_selected) { > this.updating_is_selected = true >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesShow.vue >index 137f3d8f22f..8ea3ef6fde5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesShow.vue >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsEBSCOTitlesShow.vue >@@ -245,7 +245,8 @@ > <script> > import { inject } from "vue" > import EHoldingsTitlePackagesList from "./EHoldingsEBSCOTitlePackagesList.vue" >-import { fetchEBSCOTitle } from "../../fetch/erm.js" >+import { APIClient } from "../../fetch/api-client.js" >+ > export default { > setup() { > const AVStore = inject("AVStore") >@@ -298,10 +299,15 @@ export default { > this.title = this.getTitle(to.params.title_id) > }, > methods: { >- async getTitle(title_id) { >- const title = await fetchEBSCOTitle(title_id) >- this.title = title >- this.initialized = true >+ getTitle(title_id) { >+ const client = APIClient.erm >+ client.EBSCOTitles.get(title_id).then( >+ title => { >+ this.title = title >+ this.initialized = true >+ }, >+ error => {} >+ ) > }, > }, > components: { >diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >index bfe0c6eb3b9..18cdf4b2751 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js >@@ -169,6 +169,59 @@ export class ERMAPIClient extends HttpClient { > }), > }; > } >+ >+ >+ get EBSCOPackages() { >+ return { >+ get: (id) => >+ this.get({ >+ endpoint: "eholdings/ebsco/packages/" + id, >+ headers: { >+ "x-koha-embed": >+ "package_agreements,package_agreements.agreement,resources+count,vendor", >+ }, >+ }), >+ getAll: (query) => >+ this.get({ >+ endpoint: >+ "eholdings/ebsco/packages/" + >+ id + >+ (query || "_per_page=-1"), >+ headers: { >+ "x-koha-embed": "resources+count,vendor.name", >+ }, >+ }), >+ }; >+ } >+ >+ get EBSCOTitles() { >+ return { >+ get: (id) => >+ this.get({ >+ endpoint: "eholdings/ebsco/titles/" + id, >+ headers: { >+ "x-koha-embed": "resources,resources.package", >+ }, >+ }), >+ getAll: (query) => >+ this.get({ >+ endpoint: >+ "eholdings/local/ebsco/titles" + (query || "_per_page=-1"), >+ }), >+ }; >+ } >+ >+ get EBSCOResources() { >+ return { >+ get: (id) => >+ this.get({ >+ endpoint: "eholdings/ebsco/resources/" + id, >+ headers: { >+ "x-koha-embed": "title,package,vendor", >+ }, >+ }), >+ }; >+ } > } > > export default ERMAPIClient; >-- >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 32939
:
146470
|
146509
|
146642
|
146644
|
146645
|
146668
|
146669
|
146670
|
146671
|
146672
|
146674
|
146675
|
146676
|
146677
|
146678
|
146679
|
146680
|
146681
|
146682
|
147029
|
147030
|
147031
|
147032
|
147033
|
147034
|
147035
|
147036
|
147037
|
147038
|
147039
|
147040
|
147041
|
147042
|
147043
|
147044
|
147056
|
147057
|
147059
|
147060
|
147061
|
147062
|
147063
|
147064
|
147065
|
147066
|
147067
|
147068
|
147069
|
147070
|
147071
|
147072
|
147073
|
147306
|
147307
|
147308
|
147309
|
147310
|
147311
|
147312
|
147313
|
147314
|
147315
|
147316
|
147317
|
147318
|
147319
|
147320
|
147321
|
147322
|
147332
|
149441