From 37a16e69c7ef65bb396eec703631bcf3ff650cfc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 21 Mar 2024 09:07:18 +0100 Subject: [PATCH] Bug 36374: Keep tidy files from 'fetch' directory And tidy them Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Pedro Amorim Signed-off-by: Katrin Fischer --- .../intranet-tmpl/prog/js/fetch/api-client.js | 1 + .../prog/js/fetch/article-request-api-client.js | 1 + .../js/fetch/authorised-value-api-client.js | 3 ++- .../prog/js/fetch/cataloguing-api-client.js | 1 + .../prog/js/fetch/circulation-api-client.js | 17 +++++++++++++---- .../prog/js/fetch/club-api-client.js | 1 + .../prog/js/fetch/cover-image-api-client.js | 1 + .../intranet-tmpl/prog/js/fetch/http-client.js | 13 ++++++++----- .../prog/js/fetch/localization-api-client.js | 1 + .../prog/js/fetch/patron-api-client.js | 1 + .../prog/js/fetch/recall-api-client.js | 1 + .../js/fetch/system-preferences-api-client.js | 6 +++++- .../prog/js/fetch/ticket-api-client.js | 5 +++-- 13 files changed, 39 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js index 760e0d4ea8..2551709c0c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import ArticleRequestAPIClient from "./article-request-api-client.js"; import AVAPIClient from "./authorised-value-api-client.js"; import CataloguingAPIClient from "./cataloguing-api-client.js"; diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/article-request-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/article-request-api-client.js index 59e984b122..3afc9a3cf8 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/article-request-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/article-request-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class ArticleRequestAPIClient extends HttpClient { diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/authorised-value-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/authorised-value-api-client.js index 091947a4fa..c646541948 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/authorised-value-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/authorised-value-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class AVAPIClient extends HttpClient { @@ -20,7 +21,7 @@ export class AVAPIClient extends HttpClient { encodeURIComponent(value.category), encodeURIComponent(value.value), encodeURIComponent(value.description), - encodeURIComponent(value.opac_description), + encodeURIComponent(value.opac_description) ), }), }; diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js index 8f3f4748e2..00959be93c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/cataloguing-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class CataloguingAPIClient extends HttpClient { diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/circulation-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/circulation-api-client.js index 106c8e6614..1eeb06824c 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/circulation-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/circulation-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class CirculationAPIClient extends HttpClient { @@ -32,7 +33,12 @@ export class CirculationAPIClient extends HttpClient { renew: checkout => this.post({ endpoint: "renew", - body: "itemnumber=%s&borrowernumber=%s&branchcode=%s&override_limit=%s".format(checkout.item_id, checkout.patron_id, checkout.library_id, checkout.override_limit), + body: "itemnumber=%s&borrowernumber=%s&branchcode=%s&override_limit=%s".format( + checkout.item_id, + checkout.patron_id, + checkout.library_id, + checkout.override_limit + ), //+ ( checkout.seen !== undefined ? "&seen=%s".format(checkout.seen) : "" ) + (checkout.date_due !== undefined ? "&date_due=%s".format(checkout.date_due) : ""), headers: { "Content-Type": @@ -51,13 +57,16 @@ export class CirculationAPIClient extends HttpClient { mark_as_not_seen: checkout_id => this.post({ endpoint: "checkout_notes", - body: "issue_id=%s&op=%s".format(checkout_id, "cud-notseen"), + body: "issue_id=%s&op=%s".format( + checkout_id, + "cud-notseen" + ), headers: { "Content-Type": "application/x-www-form-urlencoded;charset=utf-8", }, - }) - } + }), + }; } } diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/club-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/club-api-client.js index 102a01c8ec..a238da5a6b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/club-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/club-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class ClubAPIClient extends HttpClient { diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/cover-image-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/cover-image-api-client.js index 2d6c0a03cd..6e1d73e42b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/cover-image-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/cover-image-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class CoverImageAPIClient extends HttpClient { diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js index a379a1f867..385d0e11a9 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/http-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ class Dialog { constructor(options = {}) {} @@ -17,9 +18,10 @@ class Dialog { class HttpClient { constructor(options = {}) { this._baseURL = options.baseURL || ""; - this._headers = options.headers || { // FIXME we actually need to merge the headers + this._headers = options.headers || { + // FIXME we actually need to merge the headers "Content-Type": "application/json;charset=utf-8", - "X-Requested-With": "XMLHttpRequest" + "X-Requested-With": "XMLHttpRequest", }; this.csrf_token = $('meta[name="csrf-token"]').attr("content"); } @@ -38,7 +40,9 @@ class HttpClient { headers: { ...this._headers, ...headers }, }) .then(response => { - const is_json = response.headers.get("content-type")?.includes("application/json"); + const is_json = response.headers + .get("content-type") + ?.includes("application/json"); if (!response.ok) { return response.text().then(text => { let message; @@ -54,7 +58,7 @@ class HttpClient { throw new Error(message); }); } - if ( return_response || !is_json ) { + if (return_response || !is_json) { return response; } return response.json(); @@ -133,7 +137,6 @@ class HttpClient { true ); } - } export default HttpClient; diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/localization-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/localization-api-client.js index 1a22dfbd3a..4fbede4c67 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/localization-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/localization-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class LocalizationAPIClient extends HttpClient { diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js index da8a510711..a6825bd6bf 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/patron-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class PatronAPIClient extends HttpClient { diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/recall-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/recall-api-client.js index d7f04eb8ae..3a413fe597 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/recall-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/recall-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class RecallAPIClient extends HttpClient { diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js index e2b9bcbac8..11d30a4156 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/system-preferences-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class SysprefAPIClient extends HttpClient { @@ -32,7 +33,10 @@ export class SysprefAPIClient extends HttpClient { .map(variable => sysprefs[variable].length ? sysprefs[variable].map(value => - "%s=%s".format(variable, encodeURIComponent(value)) + "%s=%s".format( + variable, + encodeURIComponent(value) + ) ) : "%s=".format(variable) ) diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/ticket-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/ticket-api-client.js index 6c6a5c6099..267f65b1e1 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/ticket-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/ticket-api-client.js @@ -1,3 +1,4 @@ +/* keep tidy */ import HttpClient from "./http-client.js"; export class TicketAPIClient extends HttpClient { @@ -7,7 +8,7 @@ export class TicketAPIClient extends HttpClient { }); } - get tickets () { + get tickets() { return { mark_as_viewed: ticket_id => this.post({ @@ -36,7 +37,7 @@ export class TicketAPIClient extends HttpClient { "application/x-www-form-urlencoded;charset=utf-8", }, }), - } + }; } } -- 2.39.5