@openmrs/esm-form-entry-app 7.0.2-pre.3932 → 7.0.2-pre.3949
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/.turbo/turbo-build.log +10 -10
- package/dist/13574.8da1a980740c857d.js +1 -0
- package/dist/13574.8da1a980740c857d.js.map +1 -0
- package/dist/{27264.b36257ba265d1fdd.js → 27264.3808a6936d746d78.js} +3 -3
- package/dist/{27264.b36257ba265d1fdd.js.map → 27264.3808a6936d746d78.js.map} +1 -1
- package/dist/{main.ed13f6ac86e7d7d2.js → main.1a29e99eb5cda48b.js} +1 -1
- package/dist/{main.ed13f6ac86e7d7d2.js.map → main.1a29e99eb5cda48b.js.map} +1 -1
- package/dist/openmrs-esm-form-entry-app.js +1 -1
- package/dist/openmrs-esm-form-entry-app.js.buildmanifest.json +14 -14
- package/dist/routes.json +1 -1
- package/package.json +2 -2
- package/src/app/fe-wrapper/fe-wrapper.component.ts +2 -28
- package/src/app/form-submission/form-submission.service.ts +34 -14
- package/src/app/types/index.ts +13 -0
- package/translations/en.json +1 -1
- package/dist/13574.cc880f0562472eee.js +0 -1
- package/dist/13574.cc880f0562472eee.js.map +0 -1
|
@@ -3927,9 +3927,9 @@
|
|
|
3927
3927
|
"initial": false,
|
|
3928
3928
|
"entry": false,
|
|
3929
3929
|
"recorded": false,
|
|
3930
|
-
"size":
|
|
3930
|
+
"size": 2505,
|
|
3931
3931
|
"sizes": {
|
|
3932
|
-
"javascript":
|
|
3932
|
+
"javascript": 2505
|
|
3933
3933
|
},
|
|
3934
3934
|
"names": [],
|
|
3935
3935
|
"idHints": [],
|
|
@@ -3938,12 +3938,12 @@
|
|
|
3938
3938
|
"main"
|
|
3939
3939
|
],
|
|
3940
3940
|
"files": [
|
|
3941
|
-
"13574.
|
|
3941
|
+
"13574.8da1a980740c857d.js"
|
|
3942
3942
|
],
|
|
3943
3943
|
"auxiliaryFiles": [
|
|
3944
|
-
"13574.
|
|
3944
|
+
"13574.8da1a980740c857d.js.map"
|
|
3945
3945
|
],
|
|
3946
|
-
"hash": "
|
|
3946
|
+
"hash": "6c68797f3e688ab5",
|
|
3947
3947
|
"childrenByOrder": {}
|
|
3948
3948
|
},
|
|
3949
3949
|
{
|
|
@@ -8106,9 +8106,9 @@
|
|
|
8106
8106
|
"initial": false,
|
|
8107
8107
|
"entry": false,
|
|
8108
8108
|
"recorded": false,
|
|
8109
|
-
"size":
|
|
8109
|
+
"size": 5539366,
|
|
8110
8110
|
"sizes": {
|
|
8111
|
-
"javascript":
|
|
8111
|
+
"javascript": 5539366
|
|
8112
8112
|
},
|
|
8113
8113
|
"names": [
|
|
8114
8114
|
"bootstrap"
|
|
@@ -8119,12 +8119,12 @@
|
|
|
8119
8119
|
"main"
|
|
8120
8120
|
],
|
|
8121
8121
|
"files": [
|
|
8122
|
-
"27264.
|
|
8122
|
+
"27264.3808a6936d746d78.js"
|
|
8123
8123
|
],
|
|
8124
8124
|
"auxiliaryFiles": [
|
|
8125
|
-
"27264.
|
|
8125
|
+
"27264.3808a6936d746d78.js.map"
|
|
8126
8126
|
],
|
|
8127
|
-
"hash": "
|
|
8127
|
+
"hash": "eb5e1e42d39b7101",
|
|
8128
8128
|
"childrenByOrder": {}
|
|
8129
8129
|
},
|
|
8130
8130
|
{
|
|
@@ -12149,12 +12149,12 @@
|
|
|
12149
12149
|
],
|
|
12150
12150
|
"files": [
|
|
12151
12151
|
"main.c9fedbf76d90aec0.css",
|
|
12152
|
-
"main.
|
|
12152
|
+
"main.1a29e99eb5cda48b.js"
|
|
12153
12153
|
],
|
|
12154
12154
|
"auxiliaryFiles": [
|
|
12155
|
-
"main.
|
|
12155
|
+
"main.1a29e99eb5cda48b.js.map"
|
|
12156
12156
|
],
|
|
12157
|
-
"hash": "
|
|
12157
|
+
"hash": "a022458cff9bdc6b",
|
|
12158
12158
|
"childrenByOrder": {}
|
|
12159
12159
|
},
|
|
12160
12160
|
{
|
|
@@ -26501,7 +26501,7 @@
|
|
|
26501
26501
|
"auxiliaryFiles": [
|
|
26502
26502
|
"openmrs-esm-form-entry-app.js.map"
|
|
26503
26503
|
],
|
|
26504
|
-
"hash": "
|
|
26504
|
+
"hash": "4552f7ab1fbd7622",
|
|
26505
26505
|
"childrenByOrder": {}
|
|
26506
26506
|
},
|
|
26507
26507
|
{
|
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.0","o3forms":"*"},"extensions":[{"name":"form-widget","component":"formWidget","slot":"form-widget-slot","online":true,"offline":true}],"version":"7.0.2-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"webservices.rest":"^2.24.0","o3forms":"*"},"extensions":[{"name":"form-widget","component":"formWidget","slot":"form-widget-slot","online":true,"offline":true}],"version":"7.0.2-pre.3949"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-form-entry-app",
|
|
3
|
-
"version": "7.0.2-pre.
|
|
3
|
+
"version": "7.0.2-pre.3949",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "Form engine entry capabilities for the OpenMRS SPA",
|
|
6
6
|
"browser": "dist/openmrs-esm-form-entry-app.js",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"style-loader": "2.x",
|
|
103
103
|
"webpack": "~5.89.0"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "70fb09c7cf694a6b0127da5a6c5fbf16bfc91178"
|
|
106
106
|
}
|
|
@@ -241,12 +241,9 @@ export class FeWrapperComponent implements OnInit, OnDestroy {
|
|
|
241
241
|
(error: Error) => {
|
|
242
242
|
this.changeState('submissionError');
|
|
243
243
|
showSnackbar({
|
|
244
|
-
isLowContrast:
|
|
244
|
+
isLowContrast: true,
|
|
245
245
|
kind: 'error',
|
|
246
|
-
subtitle: this.translateService
|
|
247
|
-
.instant('formSubmissionFailed')
|
|
248
|
-
.replace('{error}', this.extractErrorMessagesFromResponse(error)),
|
|
249
|
-
|
|
246
|
+
subtitle: this.translateService.instant('formSubmissionFailed').replace('{error}', error.message),
|
|
250
247
|
title: this.form.schema.display ?? this.form.schema.name,
|
|
251
248
|
timeoutInMs: 5000,
|
|
252
249
|
});
|
|
@@ -374,27 +371,4 @@ export class FeWrapperComponent implements OnInit, OnDestroy {
|
|
|
374
371
|
store.setState(obj);
|
|
375
372
|
}
|
|
376
373
|
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Extracts error messages from a given error response object.
|
|
380
|
-
* If fieldErrors are present, it extracts the error messages from each field.
|
|
381
|
-
* Otherwise, it returns the top-level error message.
|
|
382
|
-
*
|
|
383
|
-
* @param {object} errorObject - The error response object.
|
|
384
|
-
* @returns {string[]} An array of error messages.
|
|
385
|
-
*/
|
|
386
|
-
private extractErrorMessagesFromResponse(errorObject) {
|
|
387
|
-
const error = errorObject?.error?.error;
|
|
388
|
-
const fieldErrors = errorObject?.responseBody?.error?.fieldErrors;
|
|
389
|
-
|
|
390
|
-
if (error) {
|
|
391
|
-
return error?.message;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (!fieldErrors) {
|
|
395
|
-
return [errorObject?.responseBody?.error?.message ?? errorObject?.message];
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return Object.values(fieldErrors).flatMap((errors: Array<Error>) => errors.map((error) => error.message));
|
|
399
|
-
}
|
|
400
374
|
}
|
|
@@ -8,7 +8,7 @@ import { EncounterResourceService } from '../openmrs-api/encounter-resource.serv
|
|
|
8
8
|
import { PersonResourceService } from '../openmrs-api/person-resource.service';
|
|
9
9
|
import { FormDataSourceService } from '../form-data-source/form-data-source.service';
|
|
10
10
|
import { HttpErrorResponse } from '@angular/common/http';
|
|
11
|
-
import { Person, PersonUpdate, EncounterCreate, Encounter, IdentifierPayload, Identifier } from '../types';
|
|
11
|
+
import { Person, PersonUpdate, EncounterCreate, Encounter, IdentifierPayload, Identifier, ErrorObject } from '../types';
|
|
12
12
|
import {
|
|
13
13
|
findQueuedPatientFormSyncItemByContentId,
|
|
14
14
|
PatientFormSyncItemContent,
|
|
@@ -22,7 +22,7 @@ import { v4 } from 'uuid';
|
|
|
22
22
|
import { VisitResourceService } from '../openmrs-api/visit-resource.service';
|
|
23
23
|
import { PatientResourceService } from '../openmrs-api/patient-resource.service';
|
|
24
24
|
import { ConfigResourceService } from '../services/config-resource.service';
|
|
25
|
-
|
|
25
|
+
import { TranslateService } from '@ngx-translate/core';
|
|
26
26
|
/**
|
|
27
27
|
* The result of submitting a form via the {@link FormSubmissionService.submitPayload} function.
|
|
28
28
|
*/
|
|
@@ -44,6 +44,7 @@ export class FormSubmissionService {
|
|
|
44
44
|
private readonly visitResourceService: VisitResourceService,
|
|
45
45
|
private readonly patientResourceService: PatientResourceService,
|
|
46
46
|
private readonly configResourceService: ConfigResourceService,
|
|
47
|
+
private readonly translateService: TranslateService,
|
|
47
48
|
) {}
|
|
48
49
|
|
|
49
50
|
public submitPayload(form: Form): Observable<FormSubmissionResult> {
|
|
@@ -249,18 +250,37 @@ export class FormSubmissionService {
|
|
|
249
250
|
|
|
250
251
|
// TODO: Should this function be extracted?
|
|
251
252
|
// This type of general HTTP/REST API error handling is most likely also useful elsewhere.
|
|
252
|
-
private throwUserFriendlyError(error:
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
253
|
+
private throwUserFriendlyError(error: HttpErrorResponse): never {
|
|
254
|
+
const errorMessage = this.extractErrorMessagesFromResponse(error?.error ?? error);
|
|
255
|
+
throw new Error(errorMessage);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Extracts error messages from a given error response object.
|
|
260
|
+
* If fieldErrors are present, it extracts the error messages from each field.
|
|
261
|
+
* If globalErrors are present, it extracts the error messages from each global error.
|
|
262
|
+
* Otherwise, it returns the top-level error message.
|
|
263
|
+
*
|
|
264
|
+
* @param {ErrorObject} errorObject - The error response object.
|
|
265
|
+
* @returns {string[]} An array of error messages.
|
|
266
|
+
*/
|
|
267
|
+
private extractErrorMessagesFromResponse(errorObject: ErrorObject) {
|
|
268
|
+
const {
|
|
269
|
+
error: { fieldErrors, globalErrors, message, code },
|
|
270
|
+
} = errorObject ?? {};
|
|
271
|
+
|
|
272
|
+
if (fieldErrors) {
|
|
273
|
+
return Object.values(fieldErrors)
|
|
274
|
+
.flatMap((errors) => errors.map((error) => error.message))
|
|
275
|
+
.join('\n');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (globalErrors) {
|
|
279
|
+
return Object.values(globalErrors)
|
|
280
|
+
.flatMap((errors) => errors.map((error) => error.message))
|
|
281
|
+
.join('\n');
|
|
264
282
|
}
|
|
283
|
+
|
|
284
|
+
return message ?? code ?? this.translateService.instant('unknownError');
|
|
265
285
|
}
|
|
266
286
|
}
|
package/src/app/types/index.ts
CHANGED
|
@@ -460,3 +460,16 @@ export interface IdentifierPayload {
|
|
|
460
460
|
newIdentifiers: Array<any>;
|
|
461
461
|
currentIdentifiers: Array<any>;
|
|
462
462
|
}
|
|
463
|
+
|
|
464
|
+
type FieldError = {
|
|
465
|
+
[key: string]: Array<{ code: string; message: string }>;
|
|
466
|
+
};
|
|
467
|
+
export type ErrorObject = {
|
|
468
|
+
error: {
|
|
469
|
+
code: string;
|
|
470
|
+
message: string;
|
|
471
|
+
detail: string;
|
|
472
|
+
fieldErrors?: FieldError;
|
|
473
|
+
globalErrors?: FieldError;
|
|
474
|
+
};
|
|
475
|
+
};
|
package/translations/en.json
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"errorLoadingForm": "Error loading form",
|
|
24
24
|
"errorWithForm": "There was an error with this form",
|
|
25
25
|
"fix": "Fix",
|
|
26
|
-
"formSubmissionFailed": "An error
|
|
26
|
+
"formSubmissionFailed": "An error occurred while processing your form submission. Kindly notify the system administrator and reference the following error : {error}",
|
|
27
27
|
"formSubmittedSuccessfully": "The form has been submitted successfully.",
|
|
28
28
|
"from": "From",
|
|
29
29
|
"futureDateRestriction": "Future date is not allowed!",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_openmrs_esm_form_entry_app=self.webpackChunk_openmrs_esm_form_entry_app||[]).push([[13574],{13574:e=>{e.exports=JSON.parse('{"aDayAgo":"a day ago","aFewSecondsAgo":"a few seconds ago","aMinuteAgo":"a minute ago","aMonthAgo":"a month ago","aYearAgo":"a year ago","add":"Add","addHour":"Add a hour","addMinute":"Add a minute","addSecond":"Add a second","anHourAgo":"an hour ago","cancel":"Cancel","changeToMonthView":"Change to month view","chooseMonthAndYear":"Choose month and year","clearEntry":"Are you sure you want to clear this entry?","closeThisPanel":"Close this panel","componentLoadingFailed":"Component Loading failed...","daysAgo":" days ago","deleteEntry":"Are you sure you want to delete this item?","discardButton":"Discard","enterMoreCharacters":"Please enter 2 or more characters","errorFetchingFormData":"There was an error fetching form data. Details: {detail}","errorLoadingForm":"Error loading form","errorWithForm":"There was an error with this form","fix":"Fix","formSubmissionFailed":"An error has occurred while submitting the form. Error: {error}","formSubmittedSuccessfully":"The form has been submitted successfully.","from":"From","futureDateRestriction":"Future date is not allowed!","hoursAgo":" hours ago","invalidDate":"Provided date is invalid!","loading":"Loading...","loadingComponent":"Loading Component...","max":"Max value should be {max}","maxDate":"Max Date should be {maxDate}","maxEntries":"Cannot have more than {max} entries","maxLength":"Max Length should be {maxLength}","min":"Min value should be {min}","minDate":"Min Date should be {minDate}","minLength":"Min Length should be {minLength}","minusHour":"Minus a hour","minusMinute":"Minus a minute","minusSecond":"Minus a second","minutesAgo":" minutes ago","monthsAgo":" months ago","next":"Next","next21Years":"Next 21 years","nextMonth":"Next month","nextYear":"Next year","patientIdentifierDuplication":"Patient identifier duplication","patientIdentifierDuplicationDescription":"The identifier provided is already associated with an existing patient. Please check the identifier and try again.","previous":"Previous","previous21Years":"Previous 21 years","previousMonth":"Previous month","previousValue":"Previous Value","previousYear":"Previous year","remove":"Remove","requiredField":"This field is required!","saveAndCloseButton":"Save and close","selectWeeks":"Select Weeks","set":"Set","submitting":"Submitting","to":"To","tryOpeningAnotherForm":"Try opening another form","useValue":"Use Value","weeks":"Weeks","yearsAgo":" years ago"}')}}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"13574.cc880f0562472eee.js","mappings":"AAAA,aAAa,+GAA+G,UAAU,uBAAuB,0uBAA0uB,OAAO,2LAA2L,MAAM,6SAA6S,IAAI,iCAAiC,QAAQ,uCAAuC,KAAK,4CAA4C,UAAU,8BAA8B,IAAI,iCAAiC,QAAQ,qCAAqC,UAAU,04BAA04B,IAAI","sources":["webpack://_openmrs_esm_form_entry_app/13574.cc880f0562472eee.js"],"names":[],"sourceRoot":""}
|