From dc9324d98ddc99380f71390f0d18b2b9d8022d56 Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Thu, 15 Dec 2022 07:58:36 +0100
Subject: [PATCH] Bug 32468: ERM - Populate dropdown list with all entries

The REST API routes is configured to return the 20 first results if
_per_page is not provided. Here we want to display all the
vendors/agreements/licenses/packages in the dropdown lists.

Ideally we should implement an infinite scroll to not load all the data
at once (https://vue-select.org/guide/infinite-scroll.html)

Test plan:
Create more than 20 vendors and confirm that, with this patch, all the
vendors are display in the dropdown list displayed on the add agreement
form
Same for agreements, licenses and local packages

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
---
 koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js
index 228e7841413..39ff7c9f7e1 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch.js
@@ -23,7 +23,7 @@ export const fetchAgreement = async function (agreement_id) {
 };
 
 export const fetchAgreements = async function () {
-    const apiUrl = "/api/v1/erm/agreements";
+    const apiUrl = "/api/v1/erm/agreements?_per_page=-1";
     let agreements;
     await fetch(apiUrl)
         .then(checkError)
@@ -60,7 +60,7 @@ export const fetchLicense = async function (license_id) {
 };
 
 export const fetchLicenses = async function () {
-    const apiUrl = "/api/v1/erm/licenses";
+    const apiUrl = "/api/v1/erm/licenses?_per_page=-1";
     let licenses;
     await fetch(apiUrl, {
         headers: {
@@ -97,7 +97,7 @@ export const fetchPatron = async function (patron_id) {
 };
 
 export const fetchVendors = async function () {
-    const apiUrl = "/api/v1/acquisitions/vendors";
+    const apiUrl = "/api/v1/acquisitions/vendors?_per_page=-1";
     let vendors;
     await fetch(apiUrl)
         .then(checkError)
@@ -207,7 +207,7 @@ export const _fetchPackages = async function (apiUrl) {
     return packages;
 };
 export const fetchLocalPackages = function () {
-    const apiUrl = "/api/v1/erm/eholdings/local/packages";
+    const apiUrl = "/api/v1/erm/eholdings/local/packages?_per_page=-1";
     return _fetchPackages(apiUrl);
 };
 export const fetchEBSCOPackages = function () {
-- 
2.30.2