From 693997feeaaf4a6db25873de52c74fe99c184ea8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Feb 2023 12:02:31 +0100 Subject: [PATCH] Bug 32925: Handle submission notification at fetch level This is done in a single place now! --- .../prog/js/vue/fetch/http-client.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js index 84311cb0c27..1bbfa44c999 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/http-client.js @@ -1,4 +1,4 @@ -import { setError } from "../messages"; +import { setError, isSubmitting, submitted } from "../messages"; class HttpClient { constructor(options = {}) { @@ -12,9 +12,11 @@ class HttpClient { endpoint, headers = {}, options = {}, - return_response = false + return_response = false, + mark_submitting = false, ) { let res, error; + if ( mark_submitting) isSubmitting() await fetch(this._baseURL + endpoint, { ...options, headers: { ...this._headers, ...headers }, @@ -32,7 +34,9 @@ class HttpClient { .catch((err) => { error = err; setError(err); - }); + }).then(() => { + if (mark_submitting) submitted()}) + ; if (error) throw Error(error); @@ -51,7 +55,7 @@ class HttpClient { ...params.options, body: params.body ? JSON.stringify(params.body) : undefined, method: "POST", - }); + }, false, true); } put(params = {}) { @@ -59,7 +63,7 @@ class HttpClient { ...params.options, body: params.body ? JSON.stringify(params.body) : undefined, method: "PUT", - }); + }, false, true); } delete(params = {}) { @@ -67,7 +71,7 @@ class HttpClient { parseResponse: false, ...params.options, method: "DELETE", - }, true); + }, true, true); } count(params = {}) { -- 2.25.1