@osimatic/helpers-js 1.1.54 → 1.1.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/form_helper.js +4 -4
- package/http_client.js +28 -19
- package/import_from_csv.js +1 -1
- package/package.json +1 -1
package/form_helper.js
CHANGED
|
@@ -264,18 +264,18 @@ class FormHelper {
|
|
|
264
264
|
}
|
|
265
265
|
|
|
266
266
|
static getFormErrorText(errors) {
|
|
267
|
-
let errorLabels =
|
|
267
|
+
let errorLabels = [];
|
|
268
268
|
for (let property in errors) {
|
|
269
269
|
// console.log(property);
|
|
270
270
|
if (typeof errors[property] != 'function') {
|
|
271
271
|
if (typeof errors[property]['error_description'] === 'undefined') {
|
|
272
|
-
errorLabels
|
|
272
|
+
errorLabels.push(errors[property]);
|
|
273
273
|
} else {
|
|
274
|
-
errorLabels
|
|
274
|
+
errorLabels.push(errors[property]['error_description']);
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
|
-
return errorLabels;
|
|
278
|
+
return errorLabels.removeEmptyValues().map(errorLabel => '<span>' + errorLabel + '</span>').join('<br/>');
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
static displayFormErrors(form, btnSubmit, errors, errorWrapperDiv) {
|
package/http_client.js
CHANGED
|
@@ -156,6 +156,10 @@ class HTTPClient {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
static logRequestFailure(response, json) {
|
|
159
|
+
if (null == response) {
|
|
160
|
+
console.error('Request failure : network error.');
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
159
163
|
console.error('Request failure. Status: '+response.statusText+' ; HTTP Code : '+response.status, json);
|
|
160
164
|
}
|
|
161
165
|
static logJqueryRequestFailure(jqxhr, status, errorThrown) {
|
|
@@ -222,18 +226,20 @@ class HTTPClient {
|
|
|
222
226
|
data = null;
|
|
223
227
|
}
|
|
224
228
|
|
|
225
|
-
|
|
226
|
-
method: method,
|
|
227
|
-
headers: headers,
|
|
228
|
-
body: body,
|
|
229
|
-
mode: 'cors',
|
|
230
|
-
cache: 'no-cache'
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
const response = await fetch(url, requestOptions);
|
|
234
|
-
|
|
229
|
+
let response = null;
|
|
235
230
|
let jsonData = {};
|
|
236
231
|
try {
|
|
232
|
+
const requestOptions = {
|
|
233
|
+
method: method,
|
|
234
|
+
headers: headers,
|
|
235
|
+
body: body,
|
|
236
|
+
mode: 'cors',
|
|
237
|
+
cache: 'no-cache'
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// On met le fetch dans un try catch pour détecter les erreurs de connexion réseau (si pas de connexion, une exception est déclenchée par fetch)
|
|
241
|
+
response = await fetch(url, requestOptions);
|
|
242
|
+
|
|
237
243
|
if (response.status !== 204 && response.statusText !== 'No Content') {
|
|
238
244
|
jsonData = await response.json();
|
|
239
245
|
}
|
|
@@ -309,16 +315,19 @@ class HTTPClient {
|
|
|
309
315
|
data = null;
|
|
310
316
|
}
|
|
311
317
|
|
|
312
|
-
|
|
313
|
-
method: method,
|
|
314
|
-
headers: headers,
|
|
315
|
-
body: body,
|
|
316
|
-
mode: 'cors',
|
|
317
|
-
cache: 'no-cache'
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const response = await fetch(url, requestOptions);
|
|
318
|
+
let response = null;
|
|
321
319
|
try {
|
|
320
|
+
const requestOptions = {
|
|
321
|
+
method: method,
|
|
322
|
+
headers: headers,
|
|
323
|
+
body: body,
|
|
324
|
+
mode: 'cors',
|
|
325
|
+
cache: 'no-cache'
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// On met le fetch dans un try catch pour détecter les erreurs de connexion réseau (si pas de connexion, une exception est déclenchée par fetch)
|
|
329
|
+
response = await fetch(url, requestOptions);
|
|
330
|
+
|
|
322
331
|
if (response.status === 401 && response.statusText === 'Expired JWT Token') {
|
|
323
332
|
HTTPClient.refreshToken(() => HTTPClient.requestBlob(method, url, data, successCallback, errorCallback, completeCallback, additionalHeaders), errorCallback);
|
|
324
333
|
return;
|
package/import_from_csv.js
CHANGED
|
@@ -162,7 +162,7 @@ class ImportFromCsv {
|
|
|
162
162
|
tableContent += '<tbody>';
|
|
163
163
|
$.each(data, function (index, line) {
|
|
164
164
|
tableContent += '<tr data-line="'+(index+1)+'">';
|
|
165
|
-
tableContent += '<td class="
|
|
165
|
+
tableContent += '<td class="text-bold text-end select_line_checkbox"><input type="checkbox" class="import_line_checkbox pull-left" checked="checked" /> '+(index+1)+'.</td>';
|
|
166
166
|
$.each(line, function (key, value) {
|
|
167
167
|
tableContent += '<td data-key="'+key+'">'+(value!==null?value:'')+'</td>';
|
|
168
168
|
});
|