Bugzilla – Attachment 189169 Details for
Bug 38262
Add additional fields to Vendors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38262: (bug 38446 follow-up) Use a dedicated endpoint
Bug-38262-bug-38446-follow-up-Use-a-dedicated-endp.patch (text/plain), 7.08 KB, created by
Biblibre Sandboxes
on 2025-11-06 13:16:15 UTC
(
hide
)
Description:
Bug 38262: (bug 38446 follow-up) Use a dedicated endpoint
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2025-11-06 13:16:15 UTC
Size:
7.08 KB
patch
obsolete
>From f2214a322d769c6f38b52322299c51ea0c40e894 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 6 Nov 2025 12:36:08 +0100 >Subject: [PATCH] Bug 38262: (bug 38446 follow-up) Use a dedicated endpoint > >Following what has been done on bug 38262 we need a separate endpoint to >retrieve additional fields for vendors. > >We add another proxy for acquisition in acquisition-api-client: we do >not want to retrieve all the fields for acquisition as we have more >granular permissions than ERM. > >Signed-off-by: Michaela <michaela.sieber@kit.edu> >--- > Koha/REST/V1/ExtendedAttributeTypes.pm | 22 ++++++++ > ...ions_vendors_extended_attribute_types.yaml | 54 +++++++++++++++++++ > api/v1/swagger/swagger.yaml | 2 + > .../prog/js/fetch/acquisition-api-client.js | 19 +++++++ > .../js/fetch/additional-fields-api-client.js | 3 ++ > 5 files changed, 100 insertions(+) > create mode 100644 api/v1/swagger/paths/acquisitions_vendors_extended_attribute_types.yaml > >diff --git a/Koha/REST/V1/ExtendedAttributeTypes.pm b/Koha/REST/V1/ExtendedAttributeTypes.pm >index e46395c577..3608017814 100644 >--- a/Koha/REST/V1/ExtendedAttributeTypes.pm >+++ b/Koha/REST/V1/ExtendedAttributeTypes.pm >@@ -112,4 +112,26 @@ sub list_erm { > }; > } > >+=head3 list_acq_vendors >+ >+List the vendors-related additional fields, can be filtered using the resource_type parameter. >+ >+=cut >+ >+sub list_acq_vendors { >+ my ($self) = @_; >+ my $c = shift->openapi->valid_input or return; >+ my @resource_types = qw(vendor); >+ >+ return try { >+ my $additional_fields_set = $self->_list(@resource_types); >+ return $c->render( >+ status => 200, >+ openapi => $c->objects->search($additional_fields_set) >+ ); >+ } catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ > 1; >diff --git a/api/v1/swagger/paths/acquisitions_vendors_extended_attribute_types.yaml b/api/v1/swagger/paths/acquisitions_vendors_extended_attribute_types.yaml >new file mode 100644 >index 0000000000..ceb2ba4466 >--- /dev/null >+++ b/api/v1/swagger/paths/acquisitions_vendors_extended_attribute_types.yaml >@@ -0,0 +1,54 @@ >+--- >+/acquisitions/vendors/extended_attribute_types: >+ get: >+ x-mojo-to: ExtendedAttributeTypes#list_acq_vendors >+ operationId: listAcquisitionVendorsAdditionalFields >+ tags: >+ - additional_fields >+ summary: List acquisition vendors extended attribute types >+ produces: >+ - application/json >+ parameters: >+ - description: filter by resource type >+ in: query >+ name: resource_type >+ type: string >+ enum: >+ - vendor >+ - $ref: "../swagger.yaml#/parameters/match" >+ - $ref: "../swagger.yaml#/parameters/order_by" >+ - $ref: "../swagger.yaml#/parameters/page" >+ - $ref: "../swagger.yaml#/parameters/per_page" >+ - $ref: "../swagger.yaml#/parameters/q_param" >+ - $ref: "../swagger.yaml#/parameters/q_body" >+ responses: >+ 200: >+ description: A list of extended attribute types for acquisition vendors >+ schema: >+ items: >+ $ref: "../swagger.yaml#/definitions/extended_attribute_type" >+ type: array >+ "400": >+ description: | >+ Bad request. Possible `error_code` attribute values: >+ >+ * `invalid_query` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ 403: >+ description: Access forbidden >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ 500: >+ description: |- >+ Internal server error. Possible `error_code` attribute values: >+ * `internal_server_error` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ 503: >+ description: Under maintenance >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ x-koha-authorization: >+ permissions: >+ - acquisition: vendors_manage >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index cc2f7b359a..23026d0a2e 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -221,6 +221,8 @@ paths: > $ref: "./paths/acquisitions_orders.yaml#/~1acquisitions~1orders~1{order_id}" > /acquisitions/vendors: > $ref: ./paths/acquisitions_vendors.yaml#/~1acquisitions~1vendors >+ /acquisitions/vendors/extended_attribute_types: >+ $ref: ./paths/acquisitions_vendors_extended_attribute_types.yaml#/~1acquisitions~1vendors~1extended_attribute_types > /acquisitions/vendors/config: > $ref: ./paths/acquisitions_vendors_config.yaml#/~1acquisitions~1vendors~1config > "/acquisitions/vendors/{vendor_id}": >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js >index f0f1a482df..df0533d7b6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js >@@ -57,6 +57,11 @@ export class AcquisitionAPIClient { > ...(query && { q: JSON.stringify(query) }), > }), > }), >+ additional_fields: resource_type => >+ this.httpClient.getAll({ >+ endpoint: "vendors/extended_attribute_types", >+ params: { resource_type }, >+ }), > }; > } > >@@ -74,6 +79,20 @@ export class AcquisitionAPIClient { > }), > }; > } >+ >+ get additional_fields() { >+ return { >+ getAll: resource_type => { >+ if (resource_type == "vendor") { >+ return this.vendors.additional_fields(resource_type); >+ } >+ // Use fetch/additional-fields-api-client.js instead >+ throw new Error( >+ "resource_type %s does not have a dedicated endpoint to fetch additional fields." >+ ); >+ }, >+ }; >+ } > } > > export default AcquisitionAPIClient; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/additional-fields-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/additional-fields-api-client.js >index 8d359ec0e2..10958ff8ae 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/fetch/additional-fields-api-client.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/additional-fields-api-client.js >@@ -1,4 +1,5 @@ > import ERMAPIClient from "@fetch/erm-api-client"; >+import AcquisitionAPIClient from "@fetch/acquisition-api-client.js"; > > export class AdditionalFieldsAPIClient { > constructor(HttpClient) { >@@ -23,6 +24,7 @@ export class AdditionalFieldsAPIClientWrapper { > this.clients = { > admin: new AdditionalFieldsAPIClient(HttpClient), > erm: new ERMAPIClient(HttpClient), >+ acquisition: new AcquisitionAPIClient(HttpClient), > }; > } > >@@ -40,6 +42,7 @@ export class AdditionalFieldsAPIClientWrapper { > getModuleName(resource_type) { > const moduleMappings = { > erm: ["agreement", "license", "package"], >+ acquisition: ["vendor"], > }; > > for (const [module, resourceTypes] of Object.entries(moduleMappings)) { >-- >2.39.5
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 38262
:
175147
|
175148
|
175149
|
175712
|
175713
|
175714
|
180558
|
180559
|
180560
|
182602
|
182603
|
182604
|
183026
|
183027
|
183028
|
183029
|
183030
|
183031
|
188213
|
188214
|
188215
|
188364
|
188366
|
188377
|
188384
|
188385
|
188386
|
188388
|
188754
|
188755
|
188756
|
189024
|
189025
|
189026
|
189157
|
189166
|
189167
|
189168
| 189169