From 1d23b6ff36bf50c14928c40dbacb6a6ff33fcf67 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 21 Mar 2023 09:00:10 +0100 Subject: [PATCH] Bug 33289: Add API client class to interact with svc/config/systempreferences On bug 30708 we will need to modify sysprefs from the UI (Vue app), it could be useful for other developments as well and so it is moved on its own bug report. Test plan: It can be tested independently of bug 30708 using the following code: const client = APIClient.sysprefs client.sysprefs .update( "CardnumberLength", "42" ) Sponsored-by: BULAC - http://www.bulac.fr/ Signed-off-by: Pedro Amorim Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 9597b88ed259470f2dc5d0a2be206cad6e0f3605) Signed-off-by: Matt Blenkinsop --- .../prog/js/vue/fetch/api-client.js | 2 ++ .../fetch/system-preferences-api-client.js | 25 +++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js index 5c3f8535e2..2c17ef443f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/api-client.js @@ -2,10 +2,12 @@ import ERMAPIClient from "./erm-api-client"; import PatronAPIClient from "./patron-api-client"; import AcquisitionAPIClient from "./acquisition-api-client"; import AVAPIClient from "./authorised-values"; +import SysprefAPIClient from "./system-preferences-api-client"; export const APIClient = { erm: new ERMAPIClient(), patron: new PatronAPIClient(), acquisition: new AcquisitionAPIClient(), authorised_values: new AVAPIClient(), + sysprefs: new SysprefAPIClient(), }; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js new file mode 100644 index 0000000000..1e4cd3f7a7 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/system-preferences-api-client.js @@ -0,0 +1,25 @@ +import HttpClient from "./http-client"; + +export class SysprefAPIClient extends HttpClient { + constructor() { + super({ + baseURL: "/cgi-bin/koha/svc/config/systempreferences", + }); + } + + get sysprefs() { + return { + update: (variable, value) => + this.post({ + endpoint: "", + body: "pref_%s=%s".format(variable, value), + headers: { + "Content-Type": + "application/x-www-form-urlencoded;charset=utf-8", + }, + }), + }; + } +} + +export default SysprefAPIClient; -- 2.39.5