Bug 38993: Merge 'fetch' directories

Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2025-01-29 17:04:08 +01:00 committed by Katrin Fischer
parent 8f65d7f2be
commit 8bfb9451bf
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
26 changed files with 265 additions and 373 deletions

View File

@ -99,7 +99,7 @@
function yesimeant() {
var OPACdidyoumean = serialize_plugins("opac");
const client = APIClient.syspref;
const client = APIClient.sysprefs;
client.sysprefs.update("OPACdidyoumean", OPACdidyoumean).then(
success => {
alert(_("Successfully saved configuration"));

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client";
export class AcquisitionAPIClient extends HttpClient {
constructor() {
super({
export class AcquisitionAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/acquisitions/",
});
}
@ -10,7 +8,7 @@ export class AcquisitionAPIClient extends HttpClient {
get vendors() {
return {
getAll: (query, params) =>
this.getAll({
this.httpClient.getAll({
endpoint: "vendors",
query,
params: { _order_by: "name", ...params },

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client";
export class AdditionalFieldsAPIClient extends HttpClient {
constructor() {
super({
export class AdditionalFieldsAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/extended_attribute_types",
});
}
@ -10,7 +8,7 @@ export class AdditionalFieldsAPIClient extends HttpClient {
get additional_fields() {
return {
getAll: resource_type =>
this.get({
this.httpClient.get({
endpoint: "?resource_type=" + resource_type,
}),
};

View File

@ -1,5 +1,7 @@
import HttpClient from "./http-client.js";
import ArticleRequestAPIClient from "./article-request-api-client.js";
import AVAPIClient from "./authorised-value-api-client.js";
import AVAPIClient from "./authorised-values-api-client.js";
import CataloguingAPIClient from "./cataloguing-api-client.js";
import CirculationAPIClient from "./circulation-api-client.js";
import ClubAPIClient from "./club-api-client.js";
@ -11,15 +13,15 @@ import SysprefAPIClient from "./system-preferences-api-client.js";
import TicketAPIClient from "./ticket-api-client.js";
export const APIClient = {
article_request: new ArticleRequestAPIClient(),
authorised_value: new AVAPIClient(),
cataloguing: new CataloguingAPIClient(),
circulation: new CirculationAPIClient(),
club: new ClubAPIClient(),
cover_image: new CoverImageAPIClient(),
localization: new LocalizationAPIClient(),
patron: new PatronAPIClient(),
recall: new RecallAPIClient(),
syspref: new SysprefAPIClient(),
ticket: new TicketAPIClient(),
article_request: new ArticleRequestAPIClient(HttpClient),
authorised_values: new AVAPIClient(HttpClient),
cataloguing: new CataloguingAPIClient(HttpClient),
circulation: new CirculationAPIClient(HttpClient),
club: new ClubAPIClient(HttpClient),
cover_image: new CoverImageAPIClient(HttpClient),
localization: new LocalizationAPIClient(HttpClient),
patron: new PatronAPIClient(HttpClient),
recall: new RecallAPIClient(HttpClient),
sysprefs: new SysprefAPIClient(HttpClient),
ticket: new TicketAPIClient(HttpClient),
};

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client.js";
export class ArticleRequestAPIClient extends HttpClient {
constructor() {
super({
export class ArticleRequestAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/article_request",
headers: {
"Content-Type":
@ -14,22 +12,22 @@ export class ArticleRequestAPIClient extends HttpClient {
get articleRequests() {
return {
process: id =>
this.post({
this.httpClient.post({
endpoint: "",
body: "id=%s&op=%s".format(id, "cud-process"),
}),
complete: id =>
this.post({
this.httpClient.post({
endpoint: "",
body: "id=%s&op=%s".format(id, "cud-complete"),
}),
pending: id =>
this.post({
this.httpClient.post({
endpoint: "",
body: "id=%s&op=%s".format(id, "cud-pending"),
}),
update_urls: (id, urls) =>
this.post({
this.httpClient.post({
endpoint: "",
body: "id=%s&urls=%s&op=%s".format(
id,
@ -38,7 +36,7 @@ export class ArticleRequestAPIClient extends HttpClient {
),
}),
update_library_id: (id, library_id) =>
this.post({
this.httpClient.post({
endpoint: "",
body: "id=%s&library_id=%s&op=%s".format(
id,

View File

@ -1,30 +0,0 @@
import HttpClient from "./http-client.js";
export class AVAPIClient extends HttpClient {
constructor() {
super({
baseURL: "/cgi-bin/koha/svc/authorised_values",
headers: {
"Content-Type":
"application/x-www-form-urlencoded;charset=utf-8",
},
});
}
get values() {
return {
create: value =>
this.post({
endpoint: "",
body: "category=%s&value=%s&description=%s&opac_description=%s".format(
encodeURIComponent(value.category),
encodeURIComponent(value.value),
encodeURIComponent(value.description),
encodeURIComponent(value.opac_description)
),
}),
};
}
}
export default AVAPIClient;

View File

@ -0,0 +1,43 @@
export class AVAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "",
});
}
get values() {
return {
get: category =>
this.httpClient.get({
endpoint: `/api/v1/authorised_value_categories/${category}/authorised_values`,
}),
getCategoriesWithValues: cat_array =>
this.httpClient.get({
endpoint:
"/api/v1/authorised_value_categories" +
'?q={"me.category_name":[' +
cat_array.join(", ") +
"]}",
headers: {
"x-koha-embed": "authorised_values",
},
}),
create: value =>
this.httpClient.post({
endpoint: "/cgi-bin/koha/svc/authorised_values",
body: "category=%s&value=%s&description=%s&opac_description=%s".format(
encodeURIComponent(value.category),
encodeURIComponent(value.value),
encodeURIComponent(value.description),
encodeURIComponent(value.opac_description)
),
headers: {
"Content-Type":
"application/x-www-form-urlencoded;charset=utf-8",
},
}),
};
}
}
export default AVAPIClient;

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client.js";
export class CataloguingAPIClient extends HttpClient {
constructor() {
super({
export class CataloguingAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/",
});
}
@ -10,7 +8,7 @@ export class CataloguingAPIClient extends HttpClient {
get catalog_bib() {
return {
create: bib_info =>
this.post({
this.httpClient.post({
endpoint: "new_bib/?frameworkcode=%s".format(
bib_info.frameworkcode
),
@ -20,7 +18,7 @@ export class CataloguingAPIClient extends HttpClient {
},
}),
update: bib_info =>
this.post({
this.httpClient.post({
endpoint: "bib/%s?frameworkcode=%s".format(
bib_info.id,
bib_info.frameworkcode

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client.js";
export class CirculationAPIClient extends HttpClient {
constructor() {
super({
export class CirculationAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/",
});
}
@ -10,7 +8,7 @@ export class CirculationAPIClient extends HttpClient {
get checkins() {
return {
create: checkin =>
this.post({
this.httpClient.post({
endpoint: "checkin",
body: "itemnumber=%s&borrowernumber=%s&branchcode=%s&exempt_fine=%s&op=%s".format(
checkin.item_id,
@ -30,7 +28,7 @@ export class CirculationAPIClient extends HttpClient {
get checkouts() {
return {
renew: checkout =>
this.post({
this.httpClient.post({
endpoint: "renew",
body:
"itemnumber=%s&borrowernumber=%s&branchcode=%s&override_limit=%s".format(
@ -51,7 +49,7 @@ export class CirculationAPIClient extends HttpClient {
},
}),
mark_as_seen: checkout_id =>
this.post({
this.httpClient.post({
endpoint: "checkout_notes",
body: "issue_id=%s&op=%s".format(checkout_id, "cud-seen"),
headers: {
@ -60,7 +58,7 @@ export class CirculationAPIClient extends HttpClient {
},
}),
mark_as_not_seen: checkout_id =>
this.post({
this.httpClient.post({
endpoint: "checkout_notes",
body: "issue_id=%s&op=%s".format(
checkout_id,

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client.js";
export class ClubAPIClient extends HttpClient {
constructor() {
super({
export class ClubAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/club/",
});
}
@ -10,7 +8,7 @@ export class ClubAPIClient extends HttpClient {
get templates() {
return {
delete: template_id =>
this.post({
this.httpClient.post({
endpoint: "template/delete",
body: "id=%s&op=%s".format(template_id, "cud-delete"),
headers: {
@ -24,7 +22,7 @@ export class ClubAPIClient extends HttpClient {
get clubs() {
return {
delete: club_id =>
this.post({
this.httpClient.post({
endpoint: "delete",
body: "id=%s&op=%s".format(club_id, "cud-delete"),
headers: {
@ -38,7 +36,7 @@ export class ClubAPIClient extends HttpClient {
get enrollments() {
return {
cancel: enrollment_id =>
this.post({
this.httpClient.post({
endpoint: "cancel_enrollment",
body: "id=%s&op=%s".format(enrollment_id, "cud-delete"),
headers: {
@ -48,7 +46,7 @@ export class ClubAPIClient extends HttpClient {
}),
enroll: data =>
this.post({
this.httpClient.post({
endpoint: "enroll",
body: "%s&op=%s".format(
data, // Could do better, but too much work for now!

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client.js";
export class CoverImageAPIClient extends HttpClient {
constructor() {
super({
export class CoverImageAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/cover_images",
});
}
@ -10,7 +8,7 @@ export class CoverImageAPIClient extends HttpClient {
get cover_images() {
return {
delete: image_id =>
this.post({
this.httpClient.post({
endpoint: "",
body: "imagenumber=%s&op=%s".format(image_id, "cud-delete"),
headers: {

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client";
export class ERMAPIClient extends HttpClient {
constructor() {
super({
export class ERMAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/erm/",
});
}
@ -10,7 +8,7 @@ export class ERMAPIClient extends HttpClient {
get config() {
return {
get: () =>
this.get({
this.httpClient.get({
endpoint: "config",
}),
};
@ -19,7 +17,7 @@ export class ERMAPIClient extends HttpClient {
get agreements() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "agreements/" + id,
headers: {
"x-koha-embed":
@ -27,27 +25,27 @@ export class ERMAPIClient extends HttpClient {
},
}),
getAll: (query, params) =>
this.getAll({
this.httpClient.getAll({
endpoint: "agreements",
query,
params,
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "agreements/" + id,
}),
create: agreement =>
this.post({
this.httpClient.post({
endpoint: "agreements",
body: agreement,
}),
update: (agreement, id) =>
this.put({
this.httpClient.put({
endpoint: "agreements/" + id,
body: agreement,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"agreements?" +
new URLSearchParams({
@ -62,7 +60,7 @@ export class ERMAPIClient extends HttpClient {
get licenses() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "licenses/" + id,
headers: {
"x-koha-embed":
@ -70,7 +68,7 @@ export class ERMAPIClient extends HttpClient {
},
}),
getAll: (query, params) =>
this.getAll({
this.httpClient.getAll({
endpoint: "licenses",
query,
params,
@ -79,21 +77,21 @@ export class ERMAPIClient extends HttpClient {
},
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "licenses/" + id,
}),
create: license =>
this.post({
this.httpClient.post({
endpoint: "licenses",
body: license,
}),
update: (license, id) =>
this.put({
this.httpClient.put({
endpoint: "licenses/" + id,
body: license,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"licenses?" +
new URLSearchParams({
@ -108,7 +106,7 @@ export class ERMAPIClient extends HttpClient {
get localPackages() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "eholdings/local/packages/" + id,
headers: {
"x-koha-embed":
@ -116,7 +114,7 @@ export class ERMAPIClient extends HttpClient {
},
}),
getAll: (query, params) =>
this.getAll({
this.httpClient.getAll({
endpoint: "eholdings/local/packages",
query,
params,
@ -125,21 +123,21 @@ export class ERMAPIClient extends HttpClient {
},
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "eholdings/local/packages/" + id,
}),
create: local_package =>
this.post({
this.httpClient.post({
endpoint: "eholdings/local/packages",
body: local_package,
}),
update: (local_package, id) =>
this.put({
this.httpClient.put({
endpoint: "eholdings/local/packages/" + id,
body: local_package,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"eholdings/local/packages?" +
new URLSearchParams({
@ -154,28 +152,28 @@ export class ERMAPIClient extends HttpClient {
get localTitles() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "eholdings/local/titles/" + id,
headers: {
"x-koha-embed": "resources,resources.package",
},
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "eholdings/local/titles/" + id,
}),
create: local_package =>
this.post({
this.httpClient.post({
endpoint: "eholdings/local/titles",
body: local_package,
}),
update: (local_package, id) =>
this.put({
this.httpClient.put({
endpoint: "eholdings/local/titles/" + id,
body: local_package,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"eholdings/local/titles?" +
new URLSearchParams({
@ -185,12 +183,12 @@ export class ERMAPIClient extends HttpClient {
}),
}),
import: body =>
this.post({
this.httpClient.post({
endpoint: "eholdings/local/titles/import",
body,
}),
import_kbart: body =>
this.post({
this.httpClient.post({
endpoint: "eholdings/local/titles/import_kbart",
body,
}),
@ -200,7 +198,7 @@ export class ERMAPIClient extends HttpClient {
get localResources() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "eholdings/local/resources/" + id,
headers: {
"x-koha-embed": "title,package,vendor",
@ -212,7 +210,7 @@ export class ERMAPIClient extends HttpClient {
get EBSCOPackages() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "eholdings/ebsco/packages/" + id,
headers: {
"x-koha-embed":
@ -220,7 +218,7 @@ export class ERMAPIClient extends HttpClient {
},
}),
patch: (id, body) =>
this.patch({
this.httpClient.patch({
endpoint: "eholdings/ebsco/packages/" + id,
body,
}),
@ -230,7 +228,7 @@ export class ERMAPIClient extends HttpClient {
get EBSCOTitles() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "eholdings/ebsco/titles/" + id,
headers: {
"x-koha-embed": "resources,resources.package",
@ -242,14 +240,14 @@ export class ERMAPIClient extends HttpClient {
get EBSCOResources() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "eholdings/ebsco/resources/" + id,
headers: {
"x-koha-embed": "title,package,vendor",
},
}),
patch: (id, body) =>
this.patch({
this.httpClient.patch({
endpoint: "eholdings/ebsco/resources/" + id,
body,
}),
@ -259,31 +257,31 @@ export class ERMAPIClient extends HttpClient {
get usage_data_providers() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "usage_data_providers/" + id,
}),
getAll: query =>
this.getAll({
this.httpClient.getAll({
endpoint: "usage_data_providers",
query,
query,
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "usage_data_providers/" + id,
}),
create: usage_data_provider =>
this.post({
this.httpClient.post({
endpoint: "usage_data_providers",
body: usage_data_provider,
}),
update: (usage_data_provider, id) =>
this.put({
this.httpClient.put({
endpoint: "usage_data_providers/" + id,
body: usage_data_provider,
}),
process_SUSHI_response: (id, body) =>
this.post({
this.httpClient.post({
endpoint:
"usage_data_providers/" +
id +
@ -291,17 +289,17 @@ export class ERMAPIClient extends HttpClient {
body: body,
}),
process_COUNTER_file: (id, body) =>
this.post({
this.httpClient.post({
endpoint:
"usage_data_providers/" + id + "/process_COUNTER_file",
body: body,
}),
test: id =>
this.get({
this.httpClient.get({
endpoint: "usage_data_providers/" + id + "/test_connection",
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"usage_data_providers?" +
new URLSearchParams({
@ -316,11 +314,11 @@ export class ERMAPIClient extends HttpClient {
get counter_files() {
return {
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "counter_files/" + id,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"counter_files?" +
new URLSearchParams({
@ -335,17 +333,17 @@ export class ERMAPIClient extends HttpClient {
get default_usage_reports() {
return {
getAll: query =>
this.get({
this.httpClient.get({
endpoint: "default_usage_reports",
query,
}),
create: default_usage_report =>
this.post({
this.httpClient.post({
endpoint: "default_usage_reports",
body: default_usage_report,
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "default_usage_reports/" + id,
}),
};
@ -354,12 +352,12 @@ export class ERMAPIClient extends HttpClient {
get usage_platforms() {
return {
getAll: query =>
this.getAll({
this.httpClient.getAll({
endpoint: "usage_platforms",
query: query,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"usage_platforms?" +
new URLSearchParams({
@ -374,12 +372,12 @@ export class ERMAPIClient extends HttpClient {
get usage_items() {
return {
getAll: query =>
this.getAll({
this.httpClient.getAll({
endpoint: "usage_items",
query: query,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"usage_items?" +
new URLSearchParams({
@ -394,12 +392,12 @@ export class ERMAPIClient extends HttpClient {
get usage_databases() {
return {
getAll: query =>
this.getAll({
this.httpClient.getAll({
endpoint: "usage_databases",
query: query,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"usage_databases?" +
new URLSearchParams({
@ -414,12 +412,12 @@ export class ERMAPIClient extends HttpClient {
get usage_titles() {
return {
getAll: query =>
this.getAll({
this.httpClient.getAll({
endpoint: "usage_titles",
query: query,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"usage_titles?" +
new URLSearchParams({
@ -434,7 +432,7 @@ export class ERMAPIClient extends HttpClient {
get counter_registry() {
return {
getAll: query =>
this.getAll({
this.httpClient.getAll({
endpoint: "counter_registry",
query,
}),
@ -443,7 +441,7 @@ export class ERMAPIClient extends HttpClient {
get sushi_service() {
return {
getAll: query =>
this.getAll({
this.httpClient.getAll({
endpoint: "sushi_service",
query,
}),

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client";
export class ItemAPIClient extends HttpClient {
constructor() {
super({
export class ItemAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/",
});
}
@ -10,7 +8,7 @@ export class ItemAPIClient extends HttpClient {
get items() {
return {
getAll: (query, params, headers) =>
this.getAll({
this.httpClient.getAll({
endpoint: "items",
query,
params,

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client.js";
export class LocalizationAPIClient extends HttpClient {
constructor() {
super({
export class LocalizationAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/localization",
});
}
@ -10,7 +8,7 @@ export class LocalizationAPIClient extends HttpClient {
get localizations() {
return {
create: localization =>
this.post({
this.httpClient.post({
endpoint: "",
body: "entity=%s&code=%s&lang=%s&translation=%s".format(
encodeURIComponent(localization.entity),
@ -24,7 +22,7 @@ export class LocalizationAPIClient extends HttpClient {
},
}),
update: localization =>
this.put({
this.httpClient.put({
endpoint: "",
body: "id=%s&lang=%s&translation=%s".format(
encodeURIComponent(localization.id),
@ -37,7 +35,7 @@ export class LocalizationAPIClient extends HttpClient {
},
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "/?id=%s".format(id),
headers: {
"Content-Type":

View File

@ -1,28 +1,15 @@
import HttpClient from "./http-client.js";
export class PatronAPIClient extends HttpClient {
constructor() {
super({
baseURL: "/cgi-bin/koha/svc/",
export class PatronAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/",
});
}
get lists() {
get patrons() {
return {
add_patrons: ({ patron_ids, list_id, new_list_name }) =>
this.post({
endpoint: "members/add_to_list",
body: "add_to_patron_list=%s&new_patron_list=%s&%s".format(
list_id,
new_list_name,
patron_ids
.map(id => "borrowernumber=%s".format(id))
.join("&")
),
headers: {
"Content-Type":
"application/x-www-form-urlencoded;charset=utf-8",
},
get: id =>
this.httpClient.get({
endpoint: "patrons/" + id,
}),
};
}

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client";
export class PreservationAPIClient extends HttpClient {
constructor() {
super({
export class PreservationAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/preservation/",
});
}
@ -10,7 +8,7 @@ export class PreservationAPIClient extends HttpClient {
get config() {
return {
get: () =>
this.get({
this.httpClient.get({
endpoint: "config",
}),
};
@ -19,7 +17,7 @@ export class PreservationAPIClient extends HttpClient {
get trains() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "trains/" + id,
headers: {
"x-koha-embed":
@ -27,7 +25,7 @@ export class PreservationAPIClient extends HttpClient {
},
}),
getAll: (query = {}) =>
this.get({
this.httpClient.get({
endpoint:
"trains?" +
new URLSearchParams({
@ -36,21 +34,21 @@ export class PreservationAPIClient extends HttpClient {
}),
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "trains/" + id,
}),
create: train =>
this.post({
this.httpClient.post({
endpoint: "trains",
body: train,
}),
update: (train, id) =>
this.put({
this.httpClient.put({
endpoint: "trains/" + id,
body: train,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"trains?" +
new URLSearchParams({
@ -65,14 +63,14 @@ export class PreservationAPIClient extends HttpClient {
get processings() {
return {
get: id =>
this.get({
this.httpClient.get({
endpoint: "processings/" + id,
headers: {
"x-koha-embed": "attributes",
},
}),
getAll: query =>
this.get({
this.httpClient.get({
endpoint:
"processings?" +
new URLSearchParams({
@ -82,21 +80,21 @@ export class PreservationAPIClient extends HttpClient {
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "processings/" + id,
}),
create: processing =>
this.post({
this.httpClient.post({
endpoint: "processings",
body: processing,
}),
update: (processing, id) =>
this.put({
this.httpClient.put({
endpoint: "processings/" + id,
body: processing,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"processings?" +
new URLSearchParams({
@ -111,7 +109,7 @@ export class PreservationAPIClient extends HttpClient {
get train_items() {
return {
get: (train_id, id) =>
this.get({
this.httpClient.get({
endpoint: "trains/" + train_id + "/items/" + id,
headers: {
"x-koha-embed":
@ -119,31 +117,31 @@ export class PreservationAPIClient extends HttpClient {
},
}),
delete: (train_id, id) =>
this.delete({
this.httpClient.delete({
endpoint: "trains/" + train_id + "/items/" + id,
}),
create: (train_item, train_id) =>
this.post({
this.httpClient.post({
endpoint: "trains/" + train_id + "/items",
body: train_item,
}),
createAll: (train_items, train_id) =>
this.post({
this.httpClient.post({
endpoint: "trains/" + train_id + "/items/batch",
body: train_items,
}),
copy: (new_train_id, train_id, id) =>
this.post({
this.httpClient.post({
endpoint: "trains/" + train_id + "/items/" + id + "/copy",
body: { train_id: new_train_id },
}),
update: (train_item, train_id, id) =>
this.put({
this.httpClient.put({
endpoint: "trains/" + train_id + "/items/" + id,
body: train_item,
}),
count: (train_id, query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"trains/" +
train_id +
@ -169,27 +167,29 @@ export class PreservationAPIClient extends HttpClient {
_per_page: 1,
q: JSON.stringify(q),
};
return this.get({
endpoint:
"waiting-list/items?" + new URLSearchParams(params),
headers: {
"x-koha-embed": "biblio",
},
}).then(response => {
return response.length ? response[0] : undefined;
});
return this.httpClient
.get({
endpoint:
"waiting-list/items?" + new URLSearchParams(params),
headers: {
"x-koha-embed": "biblio",
},
})
.then(response => {
return response.length ? response[0] : undefined;
});
},
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "waiting-list/items/" + id,
}),
createAll: items =>
this.post({
this.httpClient.post({
endpoint: "waiting-list/items",
body: items,
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"waiting-list/items?" +
new URLSearchParams({

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client.js";
export class RecallAPIClient extends HttpClient {
constructor() {
super({
export class RecallAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/recall",
});
}
@ -10,7 +8,7 @@ export class RecallAPIClient extends HttpClient {
get recalls() {
return {
cancel: recall_id =>
this.post({
this.httpClient.post({
endpoint: "",
body: "recall_id=%s&op=%s".format(recall_id, "cud-cancel"),
headers: {
@ -19,7 +17,7 @@ export class RecallAPIClient extends HttpClient {
},
}),
expire: recall_id =>
this.post({
this.httpClient.post({
endpoint: "",
body: "recall_id=%s&op=%s".format(recall_id, "cud-expire"),
headers: {
@ -29,7 +27,7 @@ export class RecallAPIClient extends HttpClient {
}),
revert: recall_id =>
this.post({
this.httpClient.post({
endpoint: "",
body: "recall_id=%s&op=%s".format(recall_id, "cud-revert"),
headers: {
@ -39,7 +37,7 @@ export class RecallAPIClient extends HttpClient {
}),
overdue: recall_id =>
this.post({
this.httpClient.post({
endpoint: "",
body: "recall_id=%s&op=%s".format(recall_id, "cud-overdue"),
headers: {
@ -49,7 +47,7 @@ export class RecallAPIClient extends HttpClient {
}),
transit: recall_id =>
this.post({
this.httpClient.post({
endpoint: "",
body: "recall_id=%s&op=%s".format(recall_id, "cud-transit"),
headers: {

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client";
export class RecordSourcesAPIClient extends HttpClient {
constructor() {
super({
export class RecordSourcesAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/api/v1/record_sources",
});
}
@ -10,32 +8,32 @@ export class RecordSourcesAPIClient extends HttpClient {
get record_sources() {
return {
create: record_source =>
this.post({
this.httpClient.post({
endpoint: "",
body: record_source,
}),
delete: id =>
this.delete({
this.httpClient.delete({
endpoint: "/" + id,
}),
update: (record_source, id) =>
this.put({
this.httpClient.put({
endpoint: "/" + id,
body: record_source,
}),
get: id =>
this.get({
this.httpClient.get({
endpoint: "/" + id,
}),
getAll: (query, params) =>
this.getAll({
this.httpClient.getAll({
endpoint: "/",
query,
params,
headers: {},
}),
count: (query = {}) =>
this.count({
this.httpClient.count({
endpoint:
"?" +
new URLSearchParams({

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client.js";
export class SysprefAPIClient extends HttpClient {
constructor() {
super({
export class SysprefAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/config/systempreferences",
});
}
@ -10,15 +8,16 @@ export class SysprefAPIClient extends HttpClient {
get sysprefs() {
return {
get: variable =>
this.get({
this.httpClient.get({
endpoint: "/?pref=" + variable,
}),
update: (variable, value) =>
this.post({
this.httpClient.post({
endpoint: "",
body: "pref_%s=%s".format(
body: "pref_%s=%s&csrf_token=%s".format(
encodeURIComponent(variable),
encodeURIComponent(value)
encodeURIComponent(value),
csrf_token
),
headers: {
"Content-Type":
@ -26,7 +25,7 @@ export class SysprefAPIClient extends HttpClient {
},
}),
update_all: sysprefs =>
this.post({
this.httpClient.post({
endpoint: "",
body: Object.keys(sysprefs)
.map(variable =>

View File

@ -1,8 +1,6 @@
import HttpClient from "./http-client.js";
export class TicketAPIClient extends HttpClient {
constructor() {
super({
export class TicketAPIClient {
constructor(HttpClient) {
this.httpClient = new HttpClient({
baseURL: "/cgi-bin/koha/svc/",
});
}
@ -10,7 +8,7 @@ export class TicketAPIClient extends HttpClient {
get tickets() {
return {
mark_as_viewed: ticket_id =>
this.post({
this.httpClient.post({
endpoint: "problem_reports",
body: "report_id=%s&op=%s".format(ticket_id, "cud-viewed"),
headers: {
@ -19,7 +17,7 @@ export class TicketAPIClient extends HttpClient {
},
}),
mark_as_closed: ticket_id =>
this.post({
this.httpClient.post({
endpoint: "problem_reports",
body: "report_id=%s&op=%s".format(ticket_id, "cud-closed"),
headers: {
@ -28,7 +26,7 @@ export class TicketAPIClient extends HttpClient {
},
}),
mark_as_new: ticket_id =>
this.post({
this.httpClient.post({
endpoint: "problem_reports",
body: "report_id=%s&op=%s".format(ticket_id, "cud-new"),
headers: {

View File

@ -1,5 +1,4 @@
/* keep tidy */
/* global KOHA CodeMirror to_highlight search_jumped humanMsg themelang */
/* global KOHA CodeMirror to_highlight search_jumped humanMsg dataTablesDefaults themelang */
// We can assume 'KOHA' exists, as we depend on KOHA.AJAX
KOHA.Preferences = {
@ -49,7 +48,7 @@ KOHA.Preferences = {
return;
}
KOHA.AJAX.MarkRunning($(form).find(".save-all"), __("Saving..."));
const client = APIClient.syspref;
const client = APIClient.sysprefs;
client.sysprefs
.update_all(sysprefs)
.then(

View File

@ -1,21 +1,23 @@
import ERMAPIClient from "./erm-api-client";
import PatronAPIClient from "./patron-api-client";
import AcquisitionAPIClient from "./acquisition-api-client";
import AdditionalFieldsAPIClient from "./additional-fields-api-client";
import AVAPIClient from "./authorised-values-api-client";
import ItemAPIClient from "./item-api-client";
import RecordSourcesAPIClient from "./record-sources-api-client";
import SysprefAPIClient from "./system-preferences-api-client";
import PreservationAPIClient from "./preservation-api-client";
import HttpClient from "./http-client";
import ERMAPIClient from "./../../fetch/erm-api-client";
import PatronAPIClient from "./../../fetch/patron-api-client";
import AcquisitionAPIClient from "./../../fetch/acquisition-api-client";
import AdditionalFieldsAPIClient from "./../../fetch/additional-fields-api-client";
import AVAPIClient from "./../../fetch/authorised-values-api-client";
import ItemAPIClient from "./../../fetch/item-api-client";
import RecordSourcesAPIClient from "./../../fetch/record-sources-api-client";
import SysprefAPIClient from "./../../fetch/system-preferences-api-client";
import PreservationAPIClient from "./../../fetch/preservation-api-client";
export const APIClient = {
erm: new ERMAPIClient(),
patron: new PatronAPIClient(),
acquisition: new AcquisitionAPIClient(),
additional_fields: new AdditionalFieldsAPIClient(),
authorised_values: new AVAPIClient(),
item: new ItemAPIClient(),
sysprefs: new SysprefAPIClient(),
preservation: new PreservationAPIClient(),
record_sources: new RecordSourcesAPIClient(),
erm: new ERMAPIClient(HttpClient),
patron: new PatronAPIClient(HttpClient),
acquisition: new AcquisitionAPIClient(HttpClient),
additional_fields: new AdditionalFieldsAPIClient(HttpClient),
authorised_values: new AVAPIClient(HttpClient),
item: new ItemAPIClient(HttpClient),
sysprefs: new SysprefAPIClient(HttpClient),
preservation: new PreservationAPIClient(HttpClient),
record_sources: new RecordSourcesAPIClient(HttpClient),
};

View File

@ -1,30 +0,0 @@
import HttpClient from "./http-client";
export class AVAPIClient extends HttpClient {
constructor() {
super({
baseURL: "/api/v1/authorised_value_categories",
});
}
get values() {
return {
get: category =>
this.get({
endpoint: `/${category}/authorised_values`,
}),
getCategoriesWithValues: cat_array =>
this.get({
endpoint:
'?q={"me.category_name":[' +
cat_array.join(", ") +
"]}",
headers: {
"x-koha-embed": "authorised_values",
},
}),
};
}
}
export default AVAPIClient;

View File

@ -1,20 +0,0 @@
import HttpClient from "./http-client";
export class PatronAPIClient extends HttpClient {
constructor() {
super({
baseURL: "/api/v1/",
});
}
get patrons() {
return {
get: id =>
this.get({
endpoint: "patrons/" + id,
}),
};
}
}
export default PatronAPIClient;

View File

@ -1,33 +0,0 @@
import HttpClient from "./http-client";
export class SysprefAPIClient extends HttpClient {
constructor() {
super({
baseURL: "/cgi-bin/koha/svc/config/systempreferences",
});
}
get sysprefs() {
return {
get: variable =>
this.get({
endpoint: "/?pref=" + variable,
}),
update: (variable, value) =>
this.post({
endpoint: "",
body: "pref_%s=%s&csrf_token=%s".format(
variable,
value,
csrf_token
),
headers: {
"Content-Type":
"application/x-www-form-urlencoded;charset=utf-8",
},
}),
};
}
}
export default SysprefAPIClient;

View File

@ -1,4 +1,3 @@
/* keep tidy */
$(document).ready(function () {
$(".submit-form-link").click(function (e) {
e.preventDefault();