@beinformed/ui 1.17.3 → 1.17.4
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/CHANGELOG.md +7 -0
- package/esm/hooks/useForm.js +1 -11
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/i18n/Locale.js +2 -1
- package/esm/i18n/Locale.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js +5 -11
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/hooks/useForm.js +2 -15
- package/lib/hooks/useForm.js.flow +0 -14
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/i18n/Locale.js +2 -1
- package/lib/i18n/Locale.js.flow +4 -2
- package/lib/i18n/Locale.js.map +1 -1
- package/lib/i18n/__tests__/Locale.spec.js.flow +3 -2
- package/lib/redux/actions/FormAttributeSet.js +6 -15
- package/lib/redux/actions/FormAttributeSet.js.flow +3 -16
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/package.json +8 -7
- package/src/hooks/useForm.js +0 -14
- package/src/i18n/Locale.js +4 -2
- package/src/i18n/__tests__/Locale.spec.js +3 -2
- package/src/redux/actions/FormAttributeSet.js +3 -16
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.17.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.17.3...v1.17.4) (2022-04-22)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **console:** set log about missing translation to debug ([7f679a8](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/7f679a8002032e6105cd7234c716eea373852d6a))
|
|
10
|
+
- **validation:** remove useAttributeValidate hook ([918bd9a](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/918bd9aeaeaefb8309eac2d1aeb99f471fdc678d))
|
|
11
|
+
|
|
5
12
|
### [1.17.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.17.2...v1.17.3) (2022-04-13)
|
|
6
13
|
|
|
7
14
|
### Bug Fixes
|
package/esm/hooks/useForm.js
CHANGED
|
@@ -3,7 +3,7 @@ import Href from "../models/href/Href";
|
|
|
3
3
|
import { getSetting, HTTP_METHODS } from "../constants";
|
|
4
4
|
import { loadModularUI, removeModelByKey } from "../redux/_modularui";
|
|
5
5
|
import { useModularUI } from "./useModularUI";
|
|
6
|
-
import { addRepeatableAttributeSet, cancelForm, cancelRepeatableAttributeSet, previousObject, removeRepeatableAttributeSet, showFormNotification, updateFormAttribute
|
|
6
|
+
import { addRepeatableAttributeSet, cancelForm, cancelRepeatableAttributeSet, previousObject, removeRepeatableAttributeSet, showFormNotification, updateFormAttribute } from "../redux/actions";
|
|
7
7
|
import FormModel from "../models/form/FormModel";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -76,16 +76,6 @@ export var useAttributeUpdate = function useAttributeUpdate(form, object) {
|
|
|
76
76
|
return dispatch(updateFormAttribute(form, object, attribute, value, options));
|
|
77
77
|
};
|
|
78
78
|
};
|
|
79
|
-
/**
|
|
80
|
-
* Validate attributes of a form
|
|
81
|
-
*/
|
|
82
|
-
|
|
83
|
-
export var useAttributeValidate = function useAttributeValidate(form) {
|
|
84
|
-
var dispatch = useDispatch();
|
|
85
|
-
return function () {
|
|
86
|
-
return dispatch(validateFormAttribute(form));
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
79
|
/**
|
|
90
80
|
* Attributeset actions
|
|
91
81
|
*/
|
package/esm/hooks/useForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useForm.js"],"names":["useDispatch","Href","getSetting","HTTP_METHODS","loadModularUI","removeModelByKey","useModularUI","addRepeatableAttributeSet","cancelForm","cancelRepeatableAttributeSet","previousObject","removeRepeatableAttributeSet","showFormNotification","updateFormAttribute","
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useForm.js"],"names":["useDispatch","Href","getSetting","HTTP_METHODS","loadModularUI","removeModelByKey","useModularUI","addRepeatableAttributeSet","cancelForm","cancelRepeatableAttributeSet","previousObject","removeRepeatableAttributeSet","showFormNotification","updateFormAttribute","FormModel","useForm","href","formHref","addParameter","form","method","POST","targetModel","removeOnUnmount","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","data","formdata","updateModel","remove","showFormNotificationAction","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"mappings":"AACA,SAASA,WAAT,QAA4B,aAA5B;AAEA,OAAOC,IAAP,MAAiB,qBAAjB;AAEA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,cAAzC;AAEA,SAASC,aAAT,EAAwBC,gBAAxB,QAAgD,qBAAhD;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA,SACEC,yBADF,EAEEC,UAFF,EAGEC,4BAHF,EAIEC,cAJF,EAKEC,4BALF,EAMEC,oBANF,EAOEC,mBAPF,QAQO,kBARP;AAUA,OAAOC,SAAP,MAAsB,0BAAtB;;AA6BA;AACA;AACA;AACA,OAAO,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAqC;AAC1D,MAAMC,QAAQ,GAAG,IAAIhB,IAAJ,CAASe,IAAT,CAAjB;;AAEA,MAAI,CAACd,UAAU,CAAC,oBAAD,CAAf,EAAuC;AACrCe,IAAAA,QAAQ,CAACC,YAAT,CAAsB,QAAtB,EAAgC,OAAhC;AACD;;AAED,MAAMC,IAAI,GAAGb,YAAY,CAAC,MAAD,EAASW,QAAT,EAAmB;AAC1CG,IAAAA,MAAM,EAAEjB,YAAY,CAACkB,IADqB;AAE1CC,IAAAA,WAAW,EAAER,SAF6B;AAG1CS,IAAAA,eAAe,EAAE;AAHyB,GAAnB,CAAzB;;AAMA,MAAIJ,IAAJ,aAAIA,IAAJ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ALjB,GAAP;AAOD,CA9BM;AAgCP;AACA;AACA;;AACA,OAAO,IAAMC,kBAAkB,GAAG,SAArBA,kBAAqB,CAChClB,IADgC,EAEhCmB,MAFgC,EAGR;AACxB,MAAMZ,QAAQ,GAAG1B,WAAW,EAA5B;AAEA,SAAO,UACLuC,SADK,EAELC,KAFK,EAGLC,OAHK;AAAA,WAIFf,QAAQ,CAACb,mBAAmB,CAACM,IAAD,EAAOmB,MAAP,EAAeC,SAAf,EAA0BC,KAA1B,EAAiCC,OAAjC,CAApB,CAJN;AAAA,GAAP;AAKD,CAXM;AAaP;AACA;AACA;;AACA,OAAO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACvB,IAAD,EAAuC;AACpE,MAAMO,QAAQ,GAAG1B,WAAW,EAA5B;AAEA,SAAO;AACL2C,IAAAA,IAAI,EAAE;AAAA,aAAMjB,QAAQ,CAACnB,yBAAyB,CAACY,IAAD,CAA1B,CAAd;AAAA,KADD;AAELS,IAAAA,MAAM,EAAE,gBAACU,MAAD;AAAA,aACNZ,QAAQ,CAACjB,4BAA4B,CAACU,IAAD,EAAOmB,MAAP,CAA7B,CADF;AAAA,KAFH;AAILH,IAAAA,MAAM,EAAE,gBAACG,MAAD;AAAA,aACNZ,QAAQ,CAACf,4BAA4B,CAACQ,IAAD,EAAOmB,MAAP,CAA7B,CADF;AAAA;AAJH,GAAP;AAOD,CAVM","sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel, AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\nimport type {\n RemoveModelByKeyAction,\n UpdateModelAction,\n} from \"../redux/_modularui\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateModelAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateModelAction,\n cancel: (object: FormObjectModel) => UpdateModelAction,\n remove: (object: FormObjectModel) => UpdateModelAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateModel: form,\n targetModel: FormModel,\n })\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Update attributes of a form\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"file":"useForm.js"}
|
package/esm/i18n/Locale.js
CHANGED
|
@@ -135,7 +135,8 @@ var Locale = /*#__PURE__*/function () {
|
|
|
135
135
|
if ((typeof process === "undefined" || process.env.NODE_ENV !== "production") && !messageFromLocale && id && getSetting("DEBUG_I18N_MESSAGE_NOT_FOUND")) {
|
|
136
136
|
var _context;
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
// eslint-disable-next-line no-console
|
|
139
|
+
console.debug(_concatInstanceProperty(_context = "Message with id ".concat(id, " not found for locale ")).call(_context, this.code, " in layout translations"));
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;
|
package/esm/i18n/Locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i18n/Locale.js"],"names":["formatMessage","languages","IllegalStateException","getSetting","Locale","locale","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","setup","missingTranslation","aLocale","split","length","language","lang","toUpperCase","message","replace","JSON","parse","id","defaultMessage","messageFromLocale","process","env","NODE_ENV","console","
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/Locale.js"],"names":["formatMessage","languages","IllegalStateException","getSetting","Locale","locale","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","setup","missingTranslation","aLocale","split","length","language","lang","toUpperCase","message","replace","JSON","parse","id","defaultMessage","messageFromLocale","process","env","NODE_ENV","console","debug","fixPlaceHolders","parameters","getBaseMessage"],"mappings":";;;;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,oBACEI,EADF,EAEEC,cAFF,EAGEQ,UAHF,EAIU;AACR,UAAMb,OAAO,GAAG,KAAKc,cAAL,CAAoBV,EAApB,EAAwBC,cAAxB,CAAhB;AACA,aAAO,KAAK5B,aAAL,CAAmBuB,OAAnB,EAA4Ba,UAA5B,CAAP;AACD;AAED;AACF;AACA;;;;WACE,kBAAmD;AAAA,UAA5C1B,QAA4C,uEAAzB,EAAyB;AAAA,UAArBE,MAAqB,uEAAJ,EAAI;AACjD,WAAKJ,SAAL,mCACK,KAAKA,SADV,GAEK,KAAKC,uBAAL,CAA6BC,QAA7B,CAFL;AAKA,WAAKC,OAAL,mCACK,KAAKA,OADV,GAEK,KAAKF,uBAAL,CAA6BG,MAA7B,CAFL;AAID;;;;;;AAGH,eAAeR,MAAf","sourcesContent":["// @flow\nimport formatMessage from \"format-message\";\n\nimport languages from \"./languages\";\nimport { IllegalStateException } from \"../exceptions\";\n\nimport { getSetting } from \"../constants\";\n\nimport type { LocaleConfiguration, MessageParameters } from \"./types\";\n\n/**\n * Create a locale\n */\nclass Locale {\n _code: string;\n _messages: { [string]: string };\n _errors: { [string]: string };\n _nativeName: ?string;\n\n constructor(locale: LocaleConfiguration) {\n this._code = locale.code;\n\n this._messages = this.fixPlaceHoldersInObject(locale.messages);\n this._errors = this.fixPlaceHoldersInObject(locale.errors);\n\n this._nativeName = locale.nativeName;\n\n formatMessage.setup({\n missingTranslation: \"ignore\",\n });\n }\n\n /**\n * Retrieve locale code\n */\n get code(): string {\n return this._code;\n }\n\n /**\n * Retrieve nativeName\n */\n get nativeName(): string {\n if (this._nativeName) {\n return this._nativeName;\n }\n\n const aLocale = this.code.split(\"-\");\n\n if (aLocale.length > 0) {\n const language = languages.lang[aLocale[0]];\n\n if (language) {\n return (\n language[1] + (aLocale[1] ? ` (${aLocale[1].toUpperCase()})` : \"\")\n );\n }\n }\n\n throw new IllegalStateException(\n `Can not find language name based on locale: ${this.code}`\n );\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHolders(message: ?string): null | string {\n if (typeof message === \"string\") {\n return message\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\");\n }\n\n return null;\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHoldersInObject(messages: Object = {}): Object {\n return JSON.parse(\n JSON.stringify(messages)\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\")\n );\n }\n\n /**\n * Retrieve message by id\n */\n getBaseMessage(id: string, defaultMessage?: string): string {\n if (!id && !defaultMessage) {\n return \"[message: id or defaultMessage missing]\";\n }\n\n const messageFromLocale = this._messages[id] || this._errors[id];\n\n if (\n (typeof process === \"undefined\" ||\n process.env.NODE_ENV !== \"production\") &&\n !messageFromLocale &&\n id &&\n getSetting(\"DEBUG_I18N_MESSAGE_NOT_FOUND\")\n ) {\n // eslint-disable-next-line no-console\n console.debug(\n `Message with id ${id} not found for locale ${this.code} in layout translations`\n );\n }\n return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;\n }\n\n /**\n * Format message using formatMessage library\n */\n formatMessage(message: string, parameters?: MessageParameters): string {\n if (parameters) {\n return formatMessage(message, parameters);\n }\n\n return message;\n }\n\n /**\n * Retrieve a messages with replaced parameters\n */\n getMessage(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters\n ): string {\n const message = this.getBaseMessage(id, defaultMessage);\n return this.formatMessage(message, parameters);\n }\n\n /**\n * Add or change messages for this locale. It is not possible to remove messages.\n */\n update(messages: Object = {}, errors: Object = {}) {\n this._messages = {\n ...this._messages,\n ...this.fixPlaceHoldersInObject(messages),\n };\n\n this._errors = {\n ...this._errors,\n ...this.fixPlaceHoldersInObject(errors),\n };\n }\n}\n\nexport default Locale;\n"],"file":"Locale.js"}
|
|
@@ -15,13 +15,15 @@ export var updateFormAttribute = function updateFormAttribute(form, formObject,
|
|
|
15
15
|
validate: true
|
|
16
16
|
};
|
|
17
17
|
return function (dispatch) {
|
|
18
|
+
var _newForm$currentFormO, _newForm$currentFormO2;
|
|
19
|
+
|
|
18
20
|
var newForm = form.clone();
|
|
19
21
|
|
|
20
22
|
if (options.validate === undefined) {
|
|
21
23
|
options.validate = true;
|
|
22
24
|
}
|
|
23
25
|
|
|
24
|
-
if (newForm.currentFormObject &&
|
|
26
|
+
if ((_newForm$currentFormO = newForm.currentFormObject) !== null && _newForm$currentFormO !== void 0 && _newForm$currentFormO.equals(formObject)) {
|
|
25
27
|
newForm.currentFormObject.updateAttribute(attribute, inputvalue);
|
|
26
28
|
} else {
|
|
27
29
|
newForm.completedFormObjects.forEach(function (completeObject) {
|
|
@@ -43,20 +45,12 @@ export var updateFormAttribute = function updateFormAttribute(form, formObject,
|
|
|
43
45
|
dispatch(autosaveFormObject(newForm));
|
|
44
46
|
}
|
|
45
47
|
|
|
46
|
-
if (newForm.currentFormObject &&
|
|
48
|
+
if (options.validate && (_newForm$currentFormO2 = newForm.currentFormObject) !== null && _newForm$currentFormO2 !== void 0 && _newForm$currentFormO2.hasDynamicValidations && getSetting("USE_INSTANT_SERVER_VALIDATION")) {
|
|
49
|
+
// server form validations happens async, don't wait for the form to return
|
|
47
50
|
dispatch(validateFormObject(newForm));
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
return dispatch(updateModel(newForm));
|
|
51
54
|
};
|
|
52
55
|
};
|
|
53
|
-
/**
|
|
54
|
-
* Validate an attribute on a form
|
|
55
|
-
*/
|
|
56
|
-
|
|
57
|
-
export var validateFormAttribute = function validateFormAttribute(form) {
|
|
58
|
-
return function (dispatch) {
|
|
59
|
-
return dispatch(validateFormObject(form));
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
56
|
//# sourceMappingURL=FormAttributeSet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateModel","getSetting","validateFormObject","autosaveFormObject","autosubmitFormObject","updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"
|
|
1
|
+
{"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateModel","getSetting","validateFormObject","autosaveFormObject","autosubmitFormObject","updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"mappings":"AACA,SAASA,WAAT,QAA4B,uBAA5B;AAEA,SAASC,UAAT,QAA2B,0BAA3B;AAEA,SAASC,kBAAT,QAAmC,mBAAnC;AACA,SAASC,kBAAT,QAAmC,gBAAnC;AACA,SAASC,oBAAT,QAAqC,kBAArC;;AAOA;AACA;AACA;AACA,OAAO,IAAMC,mBAAmB,GAC9B,SADWA,mBACX,CACEC,IADF,EAEEC,UAFF,EAGEC,SAHF,EAIEC,UAJF;AAAA,MAKEC,OALF,uEAK+B;AAC3BC,IAAAA,UAAU,EAAE,KADe;AAE3BC,IAAAA,QAAQ,EAAE,KAFiB;AAG3BC,IAAAA,WAAW,EAAE,KAHc;AAI3BC,IAAAA,QAAQ,EAAE;AAJiB,GAL/B;AAAA,SAYA,UAACC,QAAD,EAAwB;AAAA;;AACtB,QAAMC,OAAO,GAAGV,IAAI,CAACW,KAAL,EAAhB;;AAEA,QAAIP,OAAO,CAACI,QAAR,KAAqBI,SAAzB,EAAoC;AAClCR,MAAAA,OAAO,CAACI,QAAR,GAAmB,IAAnB;AACD;;AAED,iCAAIE,OAAO,CAACG,iBAAZ,kDAAI,sBAA2BC,MAA3B,CAAkCb,UAAlC,CAAJ,EAAmD;AACjDS,MAAAA,OAAO,CAACG,iBAAR,CAA0BE,eAA1B,CAA0Cb,SAA1C,EAAqDC,UAArD;AACD,KAFD,MAEO;AACLO,MAAAA,OAAO,CAACM,oBAAR,CAA6BC,OAA7B,CAAqC,UAACC,cAAD,EAAoB;AACvD,YAAIA,cAAc,CAACJ,MAAf,CAAsBb,UAAtB,CAAJ,EAAuC;AACrCiB,UAAAA,cAAc,CAACH,eAAf,CAA+Bb,SAA/B,EAA0CC,UAA1C;AACD;AACF,OAJD;AAKD;;AAED,QAAIC,OAAO,CAACC,UAAR,IAAsBK,OAAO,CAACS,OAAlC,EAA2C;AACzC,UAAMC,gBAAgB,GAAGtB,oBAAoB,CAC3CY,OAD2C,EAE3CR,SAF2C,EAG3CE,OAAO,CAACG,WAHmC,CAA7C;;AAKA,UAAIa,gBAAJ,EAAsB;AACpB,eAAOX,QAAQ,CAACW,gBAAD,CAAf;AACD;AACF;;AAED,QAAIhB,OAAO,CAACE,QAAR,IAAoBI,OAAO,CAACS,OAA5B,IAAuCT,OAAO,CAACW,SAAR,EAA3C,EAAgE;AAC9DZ,MAAAA,QAAQ,CAACZ,kBAAkB,CAACa,OAAD,CAAnB,CAAR;AACD;;AAED,QACEN,OAAO,CAACI,QAAR,8BACAE,OAAO,CAACG,iBADR,mDACA,uBAA2BS,qBAD3B,IAEA3B,UAAU,CAAC,+BAAD,CAHZ,EAIE;AACA;AACAc,MAAAA,QAAQ,CAACb,kBAAkB,CAACc,OAAD,CAAnB,CAAR;AACD;;AACD,WAAOD,QAAQ,CAACf,WAAW,CAACgB,OAAD,CAAZ,CAAf;AACD,GArDD;AAAA,CADK","sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/actions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\n\nimport type { Dispatch, ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\n\n/**\n * Update an attribute on a form\n */\nexport const updateFormAttribute =\n (\n form: FormModel,\n formObject: FormObjectModel,\n attribute: AttributeType,\n inputvalue: string,\n options: UpdateFormOptions = {\n autosubmit: false,\n autosave: false,\n forceUpdate: false,\n validate: true,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (options.validate === undefined) {\n options.validate = true;\n }\n\n if (newForm.currentFormObject?.equals(formObject)) {\n newForm.currentFormObject.updateAttribute(attribute, inputvalue);\n } else {\n newForm.completedFormObjects.forEach((completeObject) => {\n if (completeObject.equals(formObject)) {\n completeObject.updateAttribute(attribute, inputvalue);\n }\n });\n }\n\n if (options.autosubmit && newForm.isValid) {\n const autosubmitAction = autosubmitFormObject(\n newForm,\n attribute,\n options.forceUpdate\n );\n if (autosubmitAction) {\n return dispatch(autosubmitAction);\n }\n }\n\n if (options.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n options.validate &&\n newForm.currentFormObject?.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n // server form validations happens async, don't wait for the form to return\n dispatch(validateFormObject(newForm));\n }\n return dispatch(updateModel(newForm));\n };\n"],"file":"FormAttributeSet.js"}
|
package/lib/hooks/useForm.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.useFormNavigation = exports.useForm = exports.
|
|
8
|
+
exports.useFormNavigation = exports.useForm = exports.useAttributeUpdate = exports.useAttributeSet = void 0;
|
|
9
9
|
|
|
10
10
|
var _reactRedux = require("react-redux");
|
|
11
11
|
|
|
@@ -97,25 +97,12 @@ var useAttributeUpdate = function useAttributeUpdate(form, object) {
|
|
|
97
97
|
return dispatch((0, _actions.updateFormAttribute)(form, object, attribute, value, options));
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
|
-
/**
|
|
101
|
-
* Validate attributes of a form
|
|
102
|
-
*/
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
exports.useAttributeUpdate = useAttributeUpdate;
|
|
106
|
-
|
|
107
|
-
var useAttributeValidate = function useAttributeValidate(form) {
|
|
108
|
-
var dispatch = (0, _reactRedux.useDispatch)();
|
|
109
|
-
return function () {
|
|
110
|
-
return dispatch((0, _actions.validateFormAttribute)(form));
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
100
|
/**
|
|
114
101
|
* Attributeset actions
|
|
115
102
|
*/
|
|
116
103
|
|
|
117
104
|
|
|
118
|
-
exports.
|
|
105
|
+
exports.useAttributeUpdate = useAttributeUpdate;
|
|
119
106
|
|
|
120
107
|
var useAttributeSet = function useAttributeSet(form) {
|
|
121
108
|
var dispatch = (0, _reactRedux.useDispatch)();
|
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
removeRepeatableAttributeSet,
|
|
17
17
|
showFormNotification,
|
|
18
18
|
updateFormAttribute,
|
|
19
|
-
validateFormAttribute,
|
|
20
19
|
} from "../redux/actions";
|
|
21
20
|
|
|
22
21
|
import FormModel from "../models/form/FormModel";
|
|
@@ -48,8 +47,6 @@ type AttributeUpdateHook = (
|
|
|
48
47
|
options: UpdateFormOptions
|
|
49
48
|
) => void;
|
|
50
49
|
|
|
51
|
-
type AttributeValidateHook = () => void;
|
|
52
|
-
|
|
53
50
|
/**
|
|
54
51
|
* Load a form by href
|
|
55
52
|
*/
|
|
@@ -122,17 +119,6 @@ export const useAttributeUpdate = (
|
|
|
122
119
|
) => dispatch(updateFormAttribute(form, object, attribute, value, options));
|
|
123
120
|
};
|
|
124
121
|
|
|
125
|
-
/**
|
|
126
|
-
* Validate attributes of a form
|
|
127
|
-
*/
|
|
128
|
-
export const useAttributeValidate = (
|
|
129
|
-
form: FormModel
|
|
130
|
-
): AttributeValidateHook => {
|
|
131
|
-
const dispatch = useDispatch();
|
|
132
|
-
|
|
133
|
-
return () => dispatch(validateFormAttribute(form));
|
|
134
|
-
};
|
|
135
|
-
|
|
136
122
|
/**
|
|
137
123
|
* Attributeset actions
|
|
138
124
|
*/
|
package/lib/hooks/useForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useForm.js"],"names":["useForm","href","formHref","Href","addParameter","form","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","data","formdata","updateModel","remove","showFormNotificationAction","showFormNotification","useAttributeUpdate","object","attribute","value","options","
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useForm.js"],"names":["useForm","href","formHref","Href","addParameter","form","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","data","formdata","updateModel","remove","showFormNotificationAction","showFormNotification","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"mappings":";;;;;;;;;AACA;;AAEA;;AAEA;;AAEA;;AACA;;AAEA;;AAUA;;AA6BA;AACA;AACA;AACO,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,IAAD,EAAqC;AAC1D,MAAMC,QAAQ,GAAG,IAAIC,aAAJ,CAASF,IAAT,CAAjB;;AAEA,MAAI,CAAC,2BAAW,oBAAX,CAAL,EAAuC;AACrCC,IAAAA,QAAQ,CAACE,YAAT,CAAsB,QAAtB,EAAgC,OAAhC;AACD;;AAED,MAAMC,IAAI,GAAG,gCAAa,MAAb,EAAqBH,QAArB,EAA+B;AAC1CI,IAAAA,MAAM,EAAEC,wBAAaC,IADqB;AAE1CC,IAAAA,WAAW,EA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AAA,MAAM,EAANA,MAJK;AAKLE,IAAAA,oBAAoB,EAAED;AALjB,GAAP;AAOD,CA9BM;AAgCP;AACA;AACA;;;;;AACO,IAAME,kBAAkB,GAAG,SAArBA,kBAAqB,CAChCrB,IADgC,EAEhCsB,MAFgC,EAGR;AACxB,MAAMb,QAAQ,GAAG,8BAAjB;AAEA,SAAO,UACLc,SADK,EAELC,KAFK,EAGLC,OAHK;AAAA,WAIFhB,QAAQ,CAAC,kCAAoBT,IAApB,EAA0BsB,MAA1B,EAAkCC,SAAlC,EAA6CC,KAA7C,EAAoDC,OAApD,CAAD,CAJN;AAAA,GAAP;AAKD,CAXM;AAaP;AACA;AACA;;;;;AACO,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAAC1B,IAAD,EAAuC;AACpE,MAAMS,QAAQ,GAAG,8BAAjB;AAEA,SAAO;AACLkB,IAAAA,IAAI,EAAE;AAAA,aAAMlB,QAAQ,CAAC,wCAA0BT,IAA1B,CAAD,CAAd;AAAA,KADD;AAELW,IAAAA,MAAM,EAAE,gBAACW,MAAD;AAAA,aACNb,QAAQ,CAAC,2CAA6BT,IAA7B,EAAmCsB,MAAnC,CAAD,CADF;AAAA,KAFH;AAILJ,IAAAA,MAAM,EAAE,gBAACI,MAAD;AAAA,aACNb,QAAQ,CAAC,2CAA6BT,IAA7B,EAAmCsB,MAAnC,CAAD,CADF;AAAA;AAJH,GAAP;AAOD,CAVM","sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { FormObjectModel, AttributeType } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\nimport type {\n RemoveModelByKeyAction,\n UpdateModelAction,\n} from \"../redux/_modularui\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateModelAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateModelAction,\n cancel: (object: FormObjectModel) => UpdateModelAction,\n remove: (object: FormObjectModel) => UpdateModelAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateModel: form,\n targetModel: FormModel,\n })\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Update attributes of a form\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"file":"useForm.js"}
|
package/lib/i18n/Locale.js
CHANGED
|
@@ -156,7 +156,8 @@ var Locale = /*#__PURE__*/function () {
|
|
|
156
156
|
if ((typeof process === "undefined" || process.env.NODE_ENV !== "production") && !messageFromLocale && id && (0, _constants.getSetting)("DEBUG_I18N_MESSAGE_NOT_FOUND")) {
|
|
157
157
|
var _context;
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
// eslint-disable-next-line no-console
|
|
160
|
+
console.debug((0, _concat.default)(_context = "Message with id ".concat(id, " not found for locale ")).call(_context, this.code, " in layout translations"));
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;
|
package/lib/i18n/Locale.js.flow
CHANGED
|
@@ -107,9 +107,11 @@ class Locale {
|
|
|
107
107
|
id &&
|
|
108
108
|
getSetting("DEBUG_I18N_MESSAGE_NOT_FOUND")
|
|
109
109
|
) {
|
|
110
|
-
|
|
110
|
+
// eslint-disable-next-line no-console
|
|
111
|
+
console.debug(
|
|
112
|
+
`Message with id ${id} not found for locale ${this.code} in layout translations`
|
|
113
|
+
);
|
|
111
114
|
}
|
|
112
|
-
|
|
113
115
|
return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;
|
|
114
116
|
}
|
|
115
117
|
|
package/lib/i18n/Locale.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/i18n/Locale.js"],"names":["Locale","locale","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","formatMessage","setup","missingTranslation","aLocale","split","length","language","languages","lang","toUpperCase","IllegalStateException","message","replace","JSON","parse","id","defaultMessage","messageFromLocale","process","env","NODE_ENV","console","
|
|
1
|
+
{"version":3,"sources":["../../src/i18n/Locale.js"],"names":["Locale","locale","_code","code","_messages","fixPlaceHoldersInObject","messages","_errors","errors","_nativeName","nativeName","formatMessage","setup","missingTranslation","aLocale","split","length","language","languages","lang","toUpperCase","IllegalStateException","message","replace","JSON","parse","id","defaultMessage","messageFromLocale","process","env","NODE_ENV","console","debug","fixPlaceHolders","parameters","getBaseMessage"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAEA;;;;;;;;AAIA;AACA;AACA;IACMA,M;AAMJ,kBAAYC,MAAZ,EAAyC;AAAA;AAAA;AAAA;AAAA;AAAA;AACvC,SAAKC,KAAL,GAAaD,MAAM,CAACE,IAApB;AAEA,SAAKC,SAAL,GAAiB,KAAKC,uBAAL,CAA6BJ,MAAM,CAACK,QAApC,CAAjB;AACA,SAAKC,OAAL,GAAe,KAAKF,uBAAL,CAA6BJ,MAAM,CAACO,MAApC,CAAf;AAEA,SAAKC,WAAL,GAAmBR,MAAM,CAACS,UAA1B;;AAEAC,4BAAcC,KAAd,CAAoB;AAClBC,MAAAA,kBAAkB,EAAE;AADF,KAApB;AAGD;AAED;AACF;AACA;;;;;SACE,eAAmB;AACjB,aAAO,KAAKX,KAAZ;AACD;AAED;AACF;AACA;;;;SACE,eAAyB;AACvB,UAAI,KAAKO,WAAT,EAAsB;AACpB,eAAO,KAAKA,WAAZ;AACD;;AAED,UAAMK,OAAO,GAAG,KAAKX,IAAL,CAAUY,KAAV,CAAgB,GAAhB,CAAhB;;AAEA,UAAID,OAAO,CAACE,MAAR,GAAiB,CAArB,EAAwB;AACtB,YAAMC,QAAQ,GAAGC,mBAAUC,IAAV,CAAeL,OAAO,CAAC,CAAD,CAAtB,CAAjB;;AAEA,Y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ACD,aAAOyB,iBAAiB,IAAI,KAAKM,eAAL,CAAqBP,cAArB,CAArB,IAA6DD,EAApE;AACD;AAED;AACF;AACA;;;;WACE,uBAAcJ,OAAd,EAA+Ba,UAA/B,EAAuE;AACrE,UAAIA,UAAJ,EAAgB;AACd,eAAO,6BAAcb,OAAd,EAAuBa,UAAvB,CAAP;AACD;;AAED,aAAOb,OAAP;AACD;AAED;AACF;AACA;;;;WACE,oBACEI,EADF,EAEEC,cAFF,EAGEQ,UAHF,EAIU;AACR,UAAMb,OAAO,GAAG,KAAKc,cAAL,CAAoBV,EAApB,EAAwBC,cAAxB,CAAhB;AACA,aAAO,KAAKhB,aAAL,CAAmBW,OAAnB,EAA4Ba,UAA5B,CAAP;AACD;AAED;AACF;AACA;;;;WACE,kBAAmD;AAAA,UAA5C7B,QAA4C,uEAAzB,EAAyB;AAAA,UAArBE,MAAqB,uEAAJ,EAAI;AACjD,WAAKJ,SAAL,mCACK,KAAKA,SADV,GAEK,KAAKC,uBAAL,CAA6BC,QAA7B,CAFL;AAKA,WAAKC,OAAL,mCACK,KAAKA,OADV,GAEK,KAAKF,uBAAL,CAA6BG,MAA7B,CAFL;AAID;;;;;eAGYR,M","sourcesContent":["// @flow\nimport formatMessage from \"format-message\";\n\nimport languages from \"./languages\";\nimport { IllegalStateException } from \"../exceptions\";\n\nimport { getSetting } from \"../constants\";\n\nimport type { LocaleConfiguration, MessageParameters } from \"./types\";\n\n/**\n * Create a locale\n */\nclass Locale {\n _code: string;\n _messages: { [string]: string };\n _errors: { [string]: string };\n _nativeName: ?string;\n\n constructor(locale: LocaleConfiguration) {\n this._code = locale.code;\n\n this._messages = this.fixPlaceHoldersInObject(locale.messages);\n this._errors = this.fixPlaceHoldersInObject(locale.errors);\n\n this._nativeName = locale.nativeName;\n\n formatMessage.setup({\n missingTranslation: \"ignore\",\n });\n }\n\n /**\n * Retrieve locale code\n */\n get code(): string {\n return this._code;\n }\n\n /**\n * Retrieve nativeName\n */\n get nativeName(): string {\n if (this._nativeName) {\n return this._nativeName;\n }\n\n const aLocale = this.code.split(\"-\");\n\n if (aLocale.length > 0) {\n const language = languages.lang[aLocale[0]];\n\n if (language) {\n return (\n language[1] + (aLocale[1] ? ` (${aLocale[1].toUpperCase()})` : \"\")\n );\n }\n }\n\n throw new IllegalStateException(\n `Can not find language name based on locale: ${this.code}`\n );\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHolders(message: ?string): null | string {\n if (typeof message === \"string\") {\n return message\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\");\n }\n\n return null;\n }\n\n /**\n * Exported messages from Be Informed have placeholders in the syntax ${placeholder_name}\n * where the ICU messageformat module uses {placeholder_name}.\n * This method converts the ${} to {}\n */\n fixPlaceHoldersInObject(messages: Object = {}): Object {\n return JSON.parse(\n JSON.stringify(messages)\n .replace(/'\\$\\{(?<key>.*?)}'/g, \"''{$<key>}''\")\n .replace(/\\$\\{(?<key>.*?)}/g, \"{$<key>}\")\n );\n }\n\n /**\n * Retrieve message by id\n */\n getBaseMessage(id: string, defaultMessage?: string): string {\n if (!id && !defaultMessage) {\n return \"[message: id or defaultMessage missing]\";\n }\n\n const messageFromLocale = this._messages[id] || this._errors[id];\n\n if (\n (typeof process === \"undefined\" ||\n process.env.NODE_ENV !== \"production\") &&\n !messageFromLocale &&\n id &&\n getSetting(\"DEBUG_I18N_MESSAGE_NOT_FOUND\")\n ) {\n // eslint-disable-next-line no-console\n console.debug(\n `Message with id ${id} not found for locale ${this.code} in layout translations`\n );\n }\n return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;\n }\n\n /**\n * Format message using formatMessage library\n */\n formatMessage(message: string, parameters?: MessageParameters): string {\n if (parameters) {\n return formatMessage(message, parameters);\n }\n\n return message;\n }\n\n /**\n * Retrieve a messages with replaced parameters\n */\n getMessage(\n id: string,\n defaultMessage?: string,\n parameters?: MessageParameters\n ): string {\n const message = this.getBaseMessage(id, defaultMessage);\n return this.formatMessage(message, parameters);\n }\n\n /**\n * Add or change messages for this locale. It is not possible to remove messages.\n */\n update(messages: Object = {}, errors: Object = {}) {\n this._messages = {\n ...this._messages,\n ...this.fixPlaceHoldersInObject(messages),\n };\n\n this._errors = {\n ...this._errors,\n ...this.fixPlaceHoldersInObject(errors),\n };\n }\n}\n\nexport default Locale;\n"],"file":"Locale.js"}
|
|
@@ -6,6 +6,7 @@ import { setSetting } from "../../constants";
|
|
|
6
6
|
|
|
7
7
|
global.console = {
|
|
8
8
|
warn: jest.fn(),
|
|
9
|
+
debug: jest.fn(),
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
jest.mock(
|
|
@@ -89,8 +90,8 @@ describe("locale", () => {
|
|
|
89
90
|
|
|
90
91
|
const msg = locale.getMessage("non-existing");
|
|
91
92
|
expect(msg).toBe("non-existing");
|
|
92
|
-
expect(global.console.
|
|
93
|
-
"Message with id non-existing not found for locale de"
|
|
93
|
+
expect(global.console.debug).toHaveBeenCalledWith(
|
|
94
|
+
"Message with id non-existing not found for locale de in layout translations"
|
|
94
95
|
);
|
|
95
96
|
|
|
96
97
|
const msgWithDefault = locale.getMessage("non-existing", "Default");
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.updateFormAttribute = void 0;
|
|
7
7
|
|
|
8
8
|
var _actions = require("../_modularui/actions");
|
|
9
9
|
|
|
@@ -26,13 +26,15 @@ var updateFormAttribute = function updateFormAttribute(form, formObject, attribu
|
|
|
26
26
|
validate: true
|
|
27
27
|
};
|
|
28
28
|
return function (dispatch) {
|
|
29
|
+
var _newForm$currentFormO, _newForm$currentFormO2;
|
|
30
|
+
|
|
29
31
|
var newForm = form.clone();
|
|
30
32
|
|
|
31
33
|
if (options.validate === undefined) {
|
|
32
34
|
options.validate = true;
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
if (newForm.currentFormObject &&
|
|
37
|
+
if ((_newForm$currentFormO = newForm.currentFormObject) !== null && _newForm$currentFormO !== void 0 && _newForm$currentFormO.equals(formObject)) {
|
|
36
38
|
newForm.currentFormObject.updateAttribute(attribute, inputvalue);
|
|
37
39
|
} else {
|
|
38
40
|
newForm.completedFormObjects.forEach(function (completeObject) {
|
|
@@ -54,25 +56,14 @@ var updateFormAttribute = function updateFormAttribute(form, formObject, attribu
|
|
|
54
56
|
dispatch((0, _FormAutosave.autosaveFormObject)(newForm));
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
if (newForm.currentFormObject &&
|
|
59
|
+
if (options.validate && (_newForm$currentFormO2 = newForm.currentFormObject) !== null && _newForm$currentFormO2 !== void 0 && _newForm$currentFormO2.hasDynamicValidations && (0, _Settings.getSetting)("USE_INSTANT_SERVER_VALIDATION")) {
|
|
60
|
+
// server form validations happens async, don't wait for the form to return
|
|
58
61
|
dispatch((0, _FormValidations.validateFormObject)(newForm));
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
return dispatch((0, _actions.updateModel)(newForm));
|
|
62
65
|
};
|
|
63
66
|
};
|
|
64
|
-
/**
|
|
65
|
-
* Validate an attribute on a form
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
67
|
|
|
69
68
|
exports.updateFormAttribute = updateFormAttribute;
|
|
70
|
-
|
|
71
|
-
var validateFormAttribute = function validateFormAttribute(form) {
|
|
72
|
-
return function (dispatch) {
|
|
73
|
-
return dispatch((0, _FormValidations.validateFormObject)(form));
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
exports.validateFormAttribute = validateFormAttribute;
|
|
78
69
|
//# sourceMappingURL=FormAttributeSet.js.map
|
|
@@ -35,10 +35,7 @@ export const updateFormAttribute =
|
|
|
35
35
|
options.validate = true;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (
|
|
39
|
-
newForm.currentFormObject &&
|
|
40
|
-
newForm.currentFormObject.equals(formObject)
|
|
41
|
-
) {
|
|
38
|
+
if (newForm.currentFormObject?.equals(formObject)) {
|
|
42
39
|
newForm.currentFormObject.updateAttribute(attribute, inputvalue);
|
|
43
40
|
} else {
|
|
44
41
|
newForm.completedFormObjects.forEach((completeObject) => {
|
|
@@ -64,22 +61,12 @@ export const updateFormAttribute =
|
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
if (
|
|
67
|
-
newForm.currentFormObject &&
|
|
68
64
|
options.validate &&
|
|
69
|
-
newForm.currentFormObject
|
|
65
|
+
newForm.currentFormObject?.hasDynamicValidations &&
|
|
70
66
|
getSetting("USE_INSTANT_SERVER_VALIDATION")
|
|
71
67
|
) {
|
|
68
|
+
// server form validations happens async, don't wait for the form to return
|
|
72
69
|
dispatch(validateFormObject(newForm));
|
|
73
70
|
}
|
|
74
|
-
|
|
75
71
|
return dispatch(updateModel(newForm));
|
|
76
72
|
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Validate an attribute on a form
|
|
80
|
-
*/
|
|
81
|
-
export const validateFormAttribute =
|
|
82
|
-
(form: FormModel): ThunkAction =>
|
|
83
|
-
(dispatch: Dispatch) => {
|
|
84
|
-
return dispatch(validateFormObject(form));
|
|
85
|
-
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"
|
|
1
|
+
{"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"mappings":";;;;;;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAOA;AACA;AACA;AACO,IAAMA,mBAAmB,GAC9B,SADWA,mBACX,CACEC,IADF,EAEEC,UAFF,EAGEC,SAHF,EAIEC,UAJF;AAAA,MAKEC,OALF,uEAK+B;AAC3BC,IAAAA,UAAU,EAAE,KADe;AAE3BC,IAAAA,QAAQ,EAAE,KAFiB;AAG3BC,IAAAA,WAAW,EAAE,KAHc;AAI3BC,IAAAA,QAAQ,EAAE;AAJiB,GAL/B;AAAA,SAYA,UAACC,QAAD,EAAwB;AAAA;;AACtB,QAAMC,OAAO,GAAGV,IAAI,CAACW,KAAL,EAAhB;;AAEA,QAAIP,OAAO,CAACI,QAAR,KAAqBI,SAAzB,EAAoC;AAClCR,MAAAA,OAAO,CAACI,QAAR,GAAmB,IAAnB;AACD;;AAED,iCAAIE,OAAO,CAACG,iBAAZ,kDAAI,sBAA2BC,MAA3B,CAAkCb,UAAlC,CAAJ,EAAmD;AACjDS,MAAAA,OAAO,CAACG,iBAAR,CAA0BE,eAA1B,CAA0Cb,SAA1C,EAAqDC,UAArD;AACD,KAFD,MAEO;AACLO,MAAAA,OAAO,CAACM,oBAAR,CAA6BC,OAA7B,CAAqC,UAACC,cAAD,EAAoB;AACvD,YAAIA,cAAc,CAACJ,MAAf,CAAsBb,UAAtB,CAAJ,EAAuC;AACrCiB,UAAAA,cAAc,CAACH,eAAf,CAA+Bb,SAA/B,EAA0CC,UAA1C;AACD;AACF,OAJD;AAKD;;AAED,QAAIC,OAAO,CAACC,UAAR,IAAsBK,OAAO,CAACS,OAAlC,EAA2C;AACzC,UAAMC,gBAAgB,GAAG,0CACvBV,OADuB,EAEvBR,SAFuB,EAGvBE,OAAO,CAACG,WAHe,CAAzB;;AAKA,UAAIa,gBAAJ,EAAsB;AACpB,eAAOX,QAAQ,CAACW,gBAAD,CAAf;AACD;AACF;;AAED,QAAIhB,OAAO,CAACE,QAAR,IAAoBI,OAAO,CAACS,OAA5B,IAAuCT,OAAO,CAACW,SAAR,EAA3C,EAAgE;AAC9DZ,MAAAA,QAAQ,CAAC,sCAAmBC,OAAnB,CAAD,CAAR;AACD;;AAED,QACEN,OAAO,CAACI,QAAR,8BACAE,OAAO,CAACG,iBADR,mDACA,uBAA2BS,qBAD3B,IAEA,0BAAW,+BAAX,CAHF,EAIE;AACA;AACAb,MAAAA,QAAQ,CAAC,yCAAmBC,OAAnB,CAAD,CAAR;AACD;;AACD,WAAOD,QAAQ,CAAC,0BAAYC,OAAZ,CAAD,CAAf;AACD,GArDD;AAAA,CADK","sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/actions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\n\nimport type { Dispatch, ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\n\n/**\n * Update an attribute on a form\n */\nexport const updateFormAttribute =\n (\n form: FormModel,\n formObject: FormObjectModel,\n attribute: AttributeType,\n inputvalue: string,\n options: UpdateFormOptions = {\n autosubmit: false,\n autosave: false,\n forceUpdate: false,\n validate: true,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (options.validate === undefined) {\n options.validate = true;\n }\n\n if (newForm.currentFormObject?.equals(formObject)) {\n newForm.currentFormObject.updateAttribute(attribute, inputvalue);\n } else {\n newForm.completedFormObjects.forEach((completeObject) => {\n if (completeObject.equals(formObject)) {\n completeObject.updateAttribute(attribute, inputvalue);\n }\n });\n }\n\n if (options.autosubmit && newForm.isValid) {\n const autosubmitAction = autosubmitFormObject(\n newForm,\n attribute,\n options.forceUpdate\n );\n if (autosubmitAction) {\n return dispatch(autosubmitAction);\n }\n }\n\n if (options.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n options.validate &&\n newForm.currentFormObject?.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n // server form validations happens async, don't wait for the form to return\n dispatch(validateFormObject(newForm));\n }\n return dispatch(updateModel(newForm));\n };\n"],"file":"FormAttributeSet.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.4",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "http://support.beinformed.com",
|
|
@@ -99,6 +99,7 @@
|
|
|
99
99
|
"@babel/core": "^7.17.9",
|
|
100
100
|
"@babel/eslint-parser": "^7.17.0",
|
|
101
101
|
"@babel/eslint-plugin": "^7.16.5",
|
|
102
|
+
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
102
103
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
103
104
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
|
104
105
|
"@babel/preset-env": "^7.16.11",
|
|
@@ -107,7 +108,7 @@
|
|
|
107
108
|
"@commitlint/cli": "^16.2.3",
|
|
108
109
|
"@commitlint/config-conventional": "^16.2.1",
|
|
109
110
|
"@testing-library/react-hooks": "^8.0.0",
|
|
110
|
-
"auditjs": "^4.0.
|
|
111
|
+
"auditjs": "^4.0.37",
|
|
111
112
|
"babel-jest": "^27.5.1",
|
|
112
113
|
"babel-plugin-styled-components": "^2.0.7",
|
|
113
114
|
"cherry-pick": "^0.5.0",
|
|
@@ -119,20 +120,20 @@
|
|
|
119
120
|
"eslint-plugin-ft-flow": "^2.0.1",
|
|
120
121
|
"eslint-plugin-import": "^2.26.0",
|
|
121
122
|
"eslint-plugin-jest": "^26.1.4",
|
|
122
|
-
"eslint-plugin-jsdoc": "^39.2.
|
|
123
|
+
"eslint-plugin-jsdoc": "^39.2.7",
|
|
123
124
|
"eslint-plugin-react": "^7.28.0",
|
|
124
125
|
"eslint-plugin-react-hooks": "^4.4.0",
|
|
125
|
-
"flow-bin": "^0.176.
|
|
126
|
+
"flow-bin": "^0.176.2",
|
|
126
127
|
"flow-copy-source": "^2.0.9",
|
|
127
128
|
"flow-typed": "^3.6.1",
|
|
128
129
|
"glob": "^8.0.1",
|
|
129
130
|
"history": "^4.0.0",
|
|
130
131
|
"husky": "^7.0.4",
|
|
131
132
|
"jest": "^27.5.1",
|
|
132
|
-
"jest-junit": "^13.
|
|
133
|
+
"jest-junit": "^13.2.0",
|
|
133
134
|
"jest-sonar-reporter": "^2.0.0",
|
|
134
135
|
"jscodeshift": "^0.13.1",
|
|
135
|
-
"lint-staged": "^12.
|
|
136
|
+
"lint-staged": "^12.4.0",
|
|
136
137
|
"polished": "^4.2.2",
|
|
137
138
|
"prettier": "^2.6.2",
|
|
138
139
|
"react": "^17.0.2",
|
|
@@ -141,7 +142,7 @@
|
|
|
141
142
|
"react-redux": "^7.2.8",
|
|
142
143
|
"react-router": "^5.2.0",
|
|
143
144
|
"react-test-renderer": "^17.0.2",
|
|
144
|
-
"redux": "^4.
|
|
145
|
+
"redux": "^4.2.0",
|
|
145
146
|
"redux-mock-store": "^1.5.4",
|
|
146
147
|
"redux-thunk": "^2.4.1",
|
|
147
148
|
"rimraf": "^3.0.2",
|
package/src/hooks/useForm.js
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
removeRepeatableAttributeSet,
|
|
17
17
|
showFormNotification,
|
|
18
18
|
updateFormAttribute,
|
|
19
|
-
validateFormAttribute,
|
|
20
19
|
} from "../redux/actions";
|
|
21
20
|
|
|
22
21
|
import FormModel from "../models/form/FormModel";
|
|
@@ -48,8 +47,6 @@ type AttributeUpdateHook = (
|
|
|
48
47
|
options: UpdateFormOptions
|
|
49
48
|
) => void;
|
|
50
49
|
|
|
51
|
-
type AttributeValidateHook = () => void;
|
|
52
|
-
|
|
53
50
|
/**
|
|
54
51
|
* Load a form by href
|
|
55
52
|
*/
|
|
@@ -122,17 +119,6 @@ export const useAttributeUpdate = (
|
|
|
122
119
|
) => dispatch(updateFormAttribute(form, object, attribute, value, options));
|
|
123
120
|
};
|
|
124
121
|
|
|
125
|
-
/**
|
|
126
|
-
* Validate attributes of a form
|
|
127
|
-
*/
|
|
128
|
-
export const useAttributeValidate = (
|
|
129
|
-
form: FormModel
|
|
130
|
-
): AttributeValidateHook => {
|
|
131
|
-
const dispatch = useDispatch();
|
|
132
|
-
|
|
133
|
-
return () => dispatch(validateFormAttribute(form));
|
|
134
|
-
};
|
|
135
|
-
|
|
136
122
|
/**
|
|
137
123
|
* Attributeset actions
|
|
138
124
|
*/
|
package/src/i18n/Locale.js
CHANGED
|
@@ -107,9 +107,11 @@ class Locale {
|
|
|
107
107
|
id &&
|
|
108
108
|
getSetting("DEBUG_I18N_MESSAGE_NOT_FOUND")
|
|
109
109
|
) {
|
|
110
|
-
|
|
110
|
+
// eslint-disable-next-line no-console
|
|
111
|
+
console.debug(
|
|
112
|
+
`Message with id ${id} not found for locale ${this.code} in layout translations`
|
|
113
|
+
);
|
|
111
114
|
}
|
|
112
|
-
|
|
113
115
|
return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;
|
|
114
116
|
}
|
|
115
117
|
|
|
@@ -6,6 +6,7 @@ import { setSetting } from "../../constants";
|
|
|
6
6
|
|
|
7
7
|
global.console = {
|
|
8
8
|
warn: jest.fn(),
|
|
9
|
+
debug: jest.fn(),
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
jest.mock(
|
|
@@ -89,8 +90,8 @@ describe("locale", () => {
|
|
|
89
90
|
|
|
90
91
|
const msg = locale.getMessage("non-existing");
|
|
91
92
|
expect(msg).toBe("non-existing");
|
|
92
|
-
expect(global.console.
|
|
93
|
-
"Message with id non-existing not found for locale de"
|
|
93
|
+
expect(global.console.debug).toHaveBeenCalledWith(
|
|
94
|
+
"Message with id non-existing not found for locale de in layout translations"
|
|
94
95
|
);
|
|
95
96
|
|
|
96
97
|
const msgWithDefault = locale.getMessage("non-existing", "Default");
|
|
@@ -35,10 +35,7 @@ export const updateFormAttribute =
|
|
|
35
35
|
options.validate = true;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (
|
|
39
|
-
newForm.currentFormObject &&
|
|
40
|
-
newForm.currentFormObject.equals(formObject)
|
|
41
|
-
) {
|
|
38
|
+
if (newForm.currentFormObject?.equals(formObject)) {
|
|
42
39
|
newForm.currentFormObject.updateAttribute(attribute, inputvalue);
|
|
43
40
|
} else {
|
|
44
41
|
newForm.completedFormObjects.forEach((completeObject) => {
|
|
@@ -64,22 +61,12 @@ export const updateFormAttribute =
|
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
if (
|
|
67
|
-
newForm.currentFormObject &&
|
|
68
64
|
options.validate &&
|
|
69
|
-
newForm.currentFormObject
|
|
65
|
+
newForm.currentFormObject?.hasDynamicValidations &&
|
|
70
66
|
getSetting("USE_INSTANT_SERVER_VALIDATION")
|
|
71
67
|
) {
|
|
68
|
+
// server form validations happens async, don't wait for the form to return
|
|
72
69
|
dispatch(validateFormObject(newForm));
|
|
73
70
|
}
|
|
74
|
-
|
|
75
71
|
return dispatch(updateModel(newForm));
|
|
76
72
|
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Validate an attribute on a form
|
|
80
|
-
*/
|
|
81
|
-
export const validateFormAttribute =
|
|
82
|
-
(form: FormModel): ThunkAction =>
|
|
83
|
-
(dispatch: Dispatch) => {
|
|
84
|
-
return dispatch(validateFormObject(form));
|
|
85
|
-
};
|