@beinformed/ui 1.60.5 → 1.61.0
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 +19 -0
- package/esm/hooks/__tests__/useForm.spec.js.flow +1 -1
- package/esm/hooks/useForm.js +15 -20
- package/esm/hooks/useForm.js.flow +5 -14
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useModularUI.d.ts +0 -1
- package/esm/hooks/useModularUI.js +3 -11
- package/esm/hooks/useModularUI.js.flow +4 -23
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/models/attributes/AttributeCollection.js +2 -2
- package/esm/models/attributes/AttributeCollection.js.map +1 -1
- package/esm/models/attributes/AttributeContent.js +1 -1
- package/esm/models/attributes/AttributeContent.js.flow +1 -1
- package/esm/models/attributes/AttributeContent.js.map +1 -1
- package/esm/models/attributes/CompositeAttributeChildCollection.js +4 -4
- package/esm/models/attributes/CompositeAttributeChildCollection.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +9 -9
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/content/ContentTOCModel.d.ts +7 -0
- package/esm/models/content/ContentTOCModel.js +35 -8
- package/esm/models/content/ContentTOCModel.js.flow +36 -9
- package/esm/models/content/ContentTOCModel.js.map +1 -1
- package/esm/models/content/SectionModel.d.ts +3 -0
- package/esm/models/content/SectionModel.js +11 -2
- package/esm/models/content/SectionModel.js.flow +11 -0
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/content/SubSectionModel.d.ts +1 -1
- package/esm/models/content/SubSectionModel.js.flow +1 -1
- package/esm/models/content/SubSectionModel.js.map +1 -1
- package/esm/models/content/__tests__/Formalsource.spec.js.flow +91 -0
- package/esm/models/form/FormModel.js +33 -33
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/form/FormObjectModel.d.ts +13 -12
- package/esm/models/form/FormObjectModel.js +10 -9
- package/esm/models/form/FormObjectModel.js.flow +41 -27
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/models/form/__tests__/FormValidation.spec.js.flow +79 -0
- package/esm/models/href/Href.js +6 -6
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/links/LinkCollection.js +4 -4
- package/esm/models/links/LinkCollection.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.d.ts +2 -2
- package/esm/redux/_modularui/ModularUIActions.js +27 -10
- package/esm/redux/_modularui/ModularUIActions.js.flow +24 -5
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js.flow +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +4 -2
- package/esm/redux/_modularui/ModularUIReducer.js.flow +10 -1
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/ModularUISelectors.js +2 -2
- package/esm/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/esm/redux/_modularui/__tests__/actions.spec.js.flow +5 -1
- package/esm/redux/_modularui/types.d.ts +1 -0
- package/esm/redux/_modularui/types.js.flow +2 -0
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/utils/helpers/text.d.ts +1 -1
- package/esm/utils/helpers/text.js +1 -1
- package/esm/utils/helpers/text.js.flow +2 -2
- package/esm/utils/helpers/text.js.map +1 -1
- package/lib/hooks/useDeepCompareEffect.js +1 -2
- package/lib/hooks/useDeepCompareEffect.js.map +1 -1
- package/lib/hooks/useForm.js +14 -19
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useModularUI.d.ts +0 -1
- package/lib/hooks/useModularUI.js +4 -13
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/i18n/index.js +1 -2
- package/lib/i18n/index.js.map +1 -1
- package/lib/models/attributes/AttributeCollection.js +2 -2
- package/lib/models/attributes/AttributeCollection.js.map +1 -1
- package/lib/models/attributes/AttributeContent.js +1 -1
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/attributes/CompositeAttributeChildCollection.js +4 -4
- package/lib/models/attributes/CompositeAttributeChildCollection.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +9 -9
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/content/ContentTOCModel.d.ts +7 -0
- package/lib/models/content/ContentTOCModel.js +35 -8
- package/lib/models/content/ContentTOCModel.js.map +1 -1
- package/lib/models/content/SectionModel.d.ts +3 -0
- package/lib/models/content/SectionModel.js +11 -2
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/content/SubSectionModel.d.ts +1 -1
- package/lib/models/content/SubSectionModel.js.map +1 -1
- package/lib/models/form/FormModel.js +33 -33
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/form/FormObjectModel.d.ts +13 -12
- package/lib/models/form/FormObjectModel.js +10 -9
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/href/Href.js +6 -6
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/index.js +1 -2
- package/lib/models/index.js.map +1 -1
- package/lib/models/links/LinkCollection.js +4 -4
- package/lib/models/links/LinkCollection.js.map +1 -1
- package/lib/react-server/serverUtil.js +1 -2
- package/lib/react-server/serverUtil.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.d.ts +2 -2
- package/lib/redux/_modularui/ModularUIActions.js +27 -10
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +4 -2
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/ModularUISelectors.js +2 -2
- package/lib/redux/_modularui/ModularUISelectors.js.map +1 -1
- package/lib/redux/_modularui/types.d.ts +1 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/utils/helpers/text.d.ts +1 -1
- package/lib/utils/helpers/text.js +1 -1
- package/lib/utils/helpers/text.js.map +1 -1
- package/package.json +17 -17
- package/src/hooks/__tests__/useForm.spec.js +1 -1
- package/src/hooks/useForm.js +5 -14
- package/src/hooks/useModularUI.js +4 -23
- package/src/models/attributes/AttributeContent.js +1 -1
- package/src/models/content/ContentTOCModel.js +36 -9
- package/src/models/content/SectionModel.js +11 -0
- package/src/models/content/SubSectionModel.js +1 -1
- package/src/models/content/__tests__/Formalsource.spec.js +91 -0
- package/src/models/content/__tests__/formalsource-complete.json +234 -0
- package/src/models/content/__tests__/formalsource-contributions.json +110 -0
- package/src/models/content/__tests__/formalsource-section-contributions.json +84 -0
- package/src/models/content/__tests__/formalsource-section.json +60 -0
- package/src/models/content/__tests__/formalsource-toc.json +119 -0
- package/src/models/form/FormObjectModel.js +41 -27
- package/src/models/form/__tests__/FormValidation.spec.js +79 -0
- package/src/models/form/__tests__/FormValidationContributions.json +45 -0
- package/src/models/form/__tests__/FormValidationDataInitial.json +33 -0
- package/src/models/form/__tests__/FormValidationDataUpdate1.json +25 -0
- package/src/models/form/__tests__/FormValidationDataUpdate2.json +33 -0
- package/src/redux/_modularui/ModularUIActions.js +24 -5
- package/src/redux/_modularui/ModularUIMiddleware.js +1 -1
- package/src/redux/_modularui/ModularUIReducer.js +10 -1
- package/src/redux/_modularui/__tests__/actions.spec.js +5 -1
- package/src/redux/_modularui/types.js +2 -0
- package/src/utils/helpers/text.js +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeepCompareEffect.js","names":["React","_interopRequireWildcard","require","_lite","
|
|
1
|
+
{"version":3,"file":"useDeepCompareEffect.js","names":["React","_interopRequireWildcard","require","_lite","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor","useDeepCompareMemoize","value","ref","useRef","signalRef","deepEqual","current","useDeepCompareEffect","callback","dependencies","useEffect","_default","exports"],"sources":["../../src/hooks/useDeepCompareEffect.js"],"sourcesContent":["// @flow\nimport * as React from \"react\";\nimport { dequal as deepEqual } from \"dequal/lite\";\n\ntype Callback = () => void | (() => void);\ntype DependencyList = Array<mixed>;\n\n/**\n * As copied from https://github.com/kentcdodds/use-deep-compare-effect/\n * Need to copy this, because the dependency on dequal breaks in ie11\n */\nconst useDeepCompareMemoize = (value: DependencyList) => {\n const ref = React.useRef<DependencyList | null>(null); // NOSONAR\n const signalRef = React.useRef<number>(0);\n\n if (!deepEqual(value, ref.current)) {\n ref.current = value;\n signalRef.current += 1;\n }\n\n return [signalRef.current];\n};\n\n/**\n */\nexport function useDeepCompareEffect(\n callback: Callback,\n dependencies: DependencyList,\n): void {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useEffect(callback, useDeepCompareMemoize(dependencies));\n}\n\nexport default useDeepCompareEffect;\n"],"mappings":";;;;;;;;;AACA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAkD,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,QAAA,MAAAC,CAAA,OAAAD,QAAA,IAAAE,CAAA,OAAAF,QAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAC,gCAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAKlD;AACA;AACA;AACA;AACA,MAAMkB,qBAAqB,GAAIC,KAAqB,IAAK;EACvD,MAAMC,GAAG,GAAGzB,KAAK,CAAC0B,MAAM,CAAwB,IAAI,CAAC,CAAC,CAAC;EACvD,MAAMC,SAAS,GAAG3B,KAAK,CAAC0B,MAAM,CAAS,CAAC,CAAC;EAEzC,IAAI,CAAC,IAAAE,YAAS,EAACJ,KAAK,EAAEC,GAAG,CAACI,OAAO,CAAC,EAAE;IAClCJ,GAAG,CAACI,OAAO,GAAGL,KAAK;IACnBG,SAAS,CAACE,OAAO,IAAI,CAAC;EACxB;EAEA,OAAO,CAACF,SAAS,CAACE,OAAO,CAAC;AAC5B,CAAC;;AAED;AACA;AACO,SAASC,oBAAoBA,CAClCC,QAAkB,EAClBC,YAA4B,EACtB;EACN;EACA,OAAOhC,KAAK,CAACiC,SAAS,CAACF,QAAQ,EAAER,qBAAqB,CAACS,YAAY,CAAC,CAAC;AACvE;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAArB,OAAA,GAEcgB,oBAAoB","ignoreList":[]}
|
package/lib/hooks/useForm.js
CHANGED
|
@@ -12,8 +12,6 @@ var _modularui = require("../redux/_modularui");
|
|
|
12
12
|
var _useModularUI = require("./useModularUI");
|
|
13
13
|
var _actions = require("../redux/actions");
|
|
14
14
|
var _FormModel = _interopRequireDefault(require("../models/form/FormModel"));
|
|
15
|
-
const FORM_MODEL_KEY = "form";
|
|
16
|
-
|
|
17
15
|
/**
|
|
18
16
|
* Load a form by href
|
|
19
17
|
*/
|
|
@@ -22,7 +20,7 @@ const useForm = (href, data) => {
|
|
|
22
20
|
if (!(0, _constants.getSetting)("ALWAYS_COMMIT_FORM")) {
|
|
23
21
|
formHref.addParameter("commit", "false");
|
|
24
22
|
}
|
|
25
|
-
const form = (0, _useModularUI.useModularUI)(
|
|
23
|
+
const form = (0, _useModularUI.useModularUI)("form", formHref, {
|
|
26
24
|
method: _constants.HTTP_METHODS.POST,
|
|
27
25
|
targetModel: _FormModel.default,
|
|
28
26
|
removeOnUnmount: true,
|
|
@@ -43,22 +41,19 @@ const useFormNavigation = () => {
|
|
|
43
41
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
44
42
|
const previous = form => dispatch((0, _actions.previousObject)(form));
|
|
45
43
|
const cancel = form => dispatch((0, _actions.cancelForm)(form));
|
|
46
|
-
const submit = form => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
targetModel: _FormModel.default
|
|
60
|
-
}));
|
|
61
|
-
};
|
|
44
|
+
const submit = form => dispatch((0, _modularui.loadModularUI)(form.connectKey, form.selfhref, {
|
|
45
|
+
method: _constants.HTTP_METHODS.POST,
|
|
46
|
+
data: form.formdata,
|
|
47
|
+
updateHandler: newModel => {
|
|
48
|
+
if (newModel instanceof _FormModel.default) {
|
|
49
|
+
const clonedModel = form.clone();
|
|
50
|
+
clonedModel.update(newModel);
|
|
51
|
+
return clonedModel;
|
|
52
|
+
}
|
|
53
|
+
return newModel;
|
|
54
|
+
},
|
|
55
|
+
targetModel: _FormModel.default
|
|
56
|
+
}));
|
|
62
57
|
const remove = form => dispatch((0, _modularui.removeModelByKey)(form.connectKey));
|
|
63
58
|
const showFormNotificationAction = form => dispatch((0, _actions.showFormNotification)(form));
|
|
64
59
|
return {
|
package/lib/hooks/useForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.js","names":["_reactRedux","require","_Href","_interopRequireDefault","_constants","_modularui","_useModularUI","_actions","_FormModel","
|
|
1
|
+
{"version":3,"file":"useForm.js","names":["_reactRedux","require","_Href","_interopRequireDefault","_constants","_modularui","_useModularUI","_actions","_FormModel","useForm","href","data","formHref","Href","getSetting","addParameter","form","useModularUI","method","HTTP_METHODS","POST","targetModel","FormModel","removeOnUnmount","origin","contextPath","model","exports","useFormNavigation","dispatch","useDispatch","previous","previousObject","cancel","cancelForm","submit","loadModularUI","connectKey","selfhref","formdata","updateHandler","newModel","clonedModel","clone","update","remove","removeModelByKey","showFormNotificationAction","showFormNotification","useAttributeUpdate","object","attribute","value","options","updateFormAttribute","useAttributeSet","save","addRepeatableAttributeSet","cancelRepeatableAttributeSet","removeRepeatableAttributeSet"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport type {\n RemoveModelByKeyAction,\n UpdateFormAction,\n} from \"../redux/_modularui\";\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 { AttributeType, FormObjectModel, ModularUIModel } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateFormAction,\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: () => UpdateFormAction,\n cancel: (object: FormObjectModel) => UpdateFormAction,\n remove: (object: FormObjectModel) => UpdateFormAction,\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, data?: Object): ?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 data,\n origin: formHref.origin,\n contextPath: formHref.contextPath,\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 updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n const clonedModel: FormModel = form.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\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 * Hook that returns a function to update attributes of a form object.\n * <br >\n * The returned function accepts the following options:\n *\n * - autosubmit: Automatically submit the form after a change\n * - autosav: Automatically save the form (in the background) after a change\n * - autoupdate: Automatically update the current form object after a change\n * - forceUpdate: Force the update even if conditions are not met.\n * - validate: Activate/deactivate the form object validation by an update.\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"],"mappings":";;;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AAMA,IAAAI,UAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AAEA,IAAAM,QAAA,GAAAN,OAAA;AAUA,IAAAO,UAAA,GAAAL,sBAAA,CAAAF,OAAA;AAyBA;AACA;AACA;AACO,MAAMQ,OAAO,GAAGA,CAACC,IAAmB,EAAEC,IAAa,KAAiB;EACzE,MAAMC,QAAQ,GAAG,IAAIC,aAAI,CAACH,IAAI,CAAC;EAE/B,IAAI,CAAC,IAAAI,qBAAU,EAAC,oBAAoB,CAAC,EAAE;IACrCF,QAAQ,CAACG,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC1C;EAEA,MAAMC,IAAI,GAAG,IAAAC,0BAAY,EAAC,MAAM,EAAEL,QAAQ,EAAE;IAC1CM,MAAM,EAAEC,uBAAY,CAACC,IAAI;IACzBC,WAAW,EAAEC,kBAAS;IACtBC,eAAe,EAAE,IAAI;IACrBZ,IAAI;IACJa,MAAM,EAAEZ,QAAQ,CAACY,MAAM;IACvBC,WAAW,EAAEb,QAAQ,CAACa;EACxB,CAAC,CAAC;EAEF,IAAIT,IAAI,EAAEU,KAAK,EAAE;IACf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;AACA;AACA;AACA;AACA;AACA;AACA;AAVApB,OAAA,CAAAC,iBAAA,GAAAA,iBAAA;AAWO,MAAMqB,kBAAkB,GAAGA,CAChCjC,IAAe,EACfkC,MAAuB,KACC;EACxB,MAAMrB,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAE9B,OAAO,CACLqB,SAAwB,EACxBC,KAAa,EACbC,OAA0B,KACvBxB,QAAQ,CAAC,IAAAyB,4BAAmB,EAACtC,IAAI,EAAEkC,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAAC;AAC7E,CAAC;;AAED;AACA;AACA;AAFA1B,OAAA,CAAAsB,kBAAA,GAAAA,kBAAA;AAGO,MAAMM,eAAe,GAAIvC,IAAe,IAAuB;EACpE,MAAMa,QAAQ,GAAG,IAAAC,uBAAW,EAAC,CAAC;EAE9B,OAAO;IACL0B,IAAI,EAAEA,CAAA,KAAM3B,QAAQ,CAAC,IAAA4B,kCAAyB,EAACzC,IAAI,CAAC,CAAC;IACrDiB,MAAM,EAAGiB,MAAuB,IAC9BrB,QAAQ,CAAC,IAAA6B,qCAA4B,EAAC1C,IAAI,EAAEkC,MAAM,CAAC,CAAC;IACtDL,MAAM,EAAGK,MAAuB,IAC9BrB,QAAQ,CAAC,IAAA8B,qCAA4B,EAAC3C,IAAI,EAAEkC,MAAM,CAAC;EACvD,CAAC;AACH,CAAC;AAACvB,OAAA,CAAA4B,eAAA,GAAAA,eAAA","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export function createKeyForModularUIStore(modelKey: string, url: string, locale: string): string;
|
|
2
1
|
export function useModularUI(modelKey: string, url: string | Href, options?: RequestModularUIOptions): any;
|
|
3
2
|
import Href from "../models/href/Href";
|
|
4
3
|
import { RequestModularUIOptions } from "../utils";
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.useModularUI =
|
|
7
|
+
exports.useModularUI = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _reactRedux = require("react-redux");
|
|
10
10
|
var _reactRouter = require("react-router");
|
|
@@ -15,18 +15,9 @@ var _useI18n = require("./useI18n");
|
|
|
15
15
|
var _Href = _interopRequireDefault(require("../models/href/Href"));
|
|
16
16
|
/**
|
|
17
17
|
*/
|
|
18
|
-
const
|
|
19
|
-
return `${modelKey}(${url})(${locale})`;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*/
|
|
24
|
-
exports.createKeyForModularUIStore = createKeyForModularUIStore;
|
|
25
|
-
const useKeyForHook = function (modelKey, url) {
|
|
26
|
-
let removeQuerystringFromKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
18
|
+
const useKeyForHook = (modelKey, url) => {
|
|
27
19
|
const locale = (0, _useI18n.useLocale)();
|
|
28
|
-
|
|
29
|
-
return (0, _react.useMemo)(() => createKeyForModularUIStore(modelKey, href, locale), [modelKey, href, locale]);
|
|
20
|
+
return (0, _react.useMemo)(() => `${modelKey}(${url.split("?")[0]})(${locale})`, [modelKey, url, locale]);
|
|
30
21
|
};
|
|
31
22
|
|
|
32
23
|
/**
|
|
@@ -39,7 +30,7 @@ const useModularUI = function (modelKey, url) {
|
|
|
39
30
|
};
|
|
40
31
|
const dispatch = (0, _reactRedux.useDispatch)();
|
|
41
32
|
const href = (0, _react.useMemo)(() => url?.toString() || "", [url]);
|
|
42
|
-
const key = useKeyForHook(modelKey, href
|
|
33
|
+
const key = useKeyForHook(modelKey, href);
|
|
43
34
|
const modelSelector = (0, _react.useMemo)(() => state => state.modularui[key], [key]);
|
|
44
35
|
const model = (0, _reactRedux.useSelector)(modelSelector);
|
|
45
36
|
if (url instanceof _Href.default) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUI.js","names":["_react","require","_reactRedux","_reactRouter","_constants","_ModularUIActions","_useDeepCompareEffect","_interopRequireDefault","_useI18n","_Href","
|
|
1
|
+
{"version":3,"file":"useModularUI.js","names":["_react","require","_reactRedux","_reactRouter","_constants","_ModularUIActions","_useDeepCompareEffect","_interopRequireDefault","_useI18n","_Href","useKeyForHook","modelKey","url","locale","useLocale","useMemo","split","useModularUI","options","arguments","length","undefined","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","modelSelector","state","modularui","model","useSelector","Href","origin","contextPath","location","useLocation","redirectLocation","forceLoad","equals","prevOptions","useRef","prevHref","prevForceLoad","useDeepCompareEffect","isOldReload","current","isReload","doForceLoad","loadModularUI","useEffect","removeModelByKey","exports"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef, useMemo } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\nimport { useLocation } from \"react-router\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\nimport Href from \"../models/href/Href\";\n\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return useMemo(\n () => `${modelKey}(${url.split(\"?\")[0]})(${locale})`,\n [modelKey, url, locale],\n );\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = useMemo(() => url?.toString() || \"\", [url]);\n const key = useKeyForHook(modelKey, href);\n\n const modelSelector = useMemo(() => (state) => state.modularui[key], [key]);\n const model = useSelector(modelSelector);\n\n if (url instanceof Href) {\n options.origin = options.origin ?? url.origin;\n options.contextPath = options.contextPath ?? url.contextPath;\n }\n\n const location = useLocation();\n const redirectLocation = location.state?.redirectLocation;\n const forceLoad =\n model == null ||\n (redirectLocation instanceof Href ? redirectLocation?.equals(href) : false);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n const prevForceLoad = useRef(forceLoad);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n const doForceLoad = forceLoad && !prevForceLoad.current;\n\n if (href !== \"\" && (doForceLoad || !isOldReload)) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n prevForceLoad.current = forceLoad;\n }, [key, href, options, forceLoad]);\n\n useEffect(() => {\n if (options.removeOnUnmount) {\n return () => {\n dispatch(removeModelByKey(key));\n };\n }\n }, [dispatch, key, options.removeOnUnmount]);\n\n return model;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AAKA,IAAAK,qBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAEA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAF,sBAAA,CAAAN,OAAA;AAIA;AACA;AACA,MAAMS,aAAa,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KAAK;EACvD,MAAMC,MAAM,GAAG,IAAAC,kBAAS,EAAC,CAAC;EAC1B,OAAO,IAAAC,cAAO,EACZ,MAAM,GAAGJ,QAAQ,IAAIC,GAAG,CAACI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAKH,MAAM,GAAG,EACpD,CAACF,QAAQ,EAAEC,GAAG,EAAEC,MAAM,CACxB,CAAC;AACH,CAAC;;AA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QAAQ,GAAG,IAAAD,aAAM,EAACjB,IAAI,CAAC;EAC7B,MAAMmB,aAAa,GAAG,IAAAF,aAAM,EAACH,SAAS,CAAC;;EAEvC;EACA,IAAAM,6BAAoB,EAAC,MAAM;IACzB;IACA,MAAMC,WAAW,GACfH,QAAQ,CAACI,OAAO,KAAKtB,IAAI,IACzBgB,WAAW,CAACM,OAAO,CAACC,QAAQ,IAC5B,CAACjC,OAAO,CAACiC,QAAQ;IAEnB,MAAMC,WAAW,GAAGV,SAAS,IAAI,CAACK,aAAa,CAACG,OAAO;IAEvD,IAAItB,IAAI,KAAK,EAAE,KAAKwB,WAAW,IAAI,CAACH,WAAW,CAAC,EAAE;MAChDvB,QAAQ,CAAC,IAAA2B,+BAAa,EAACvB,GAAG,EAAEF,IAAI,EAAEV,OAAO,CAAC,CAAC;IAC7C;IAEA0B,WAAW,CAACM,OAAO,GAAGhC,OAAO;IAC7B4B,QAAQ,CAACI,OAAO,GAAGtB,IAAI;IACvBmB,aAAa,CAACG,OAAO,GAAGR,SAAS;EACnC,CAAC,EAAE,CAACZ,GAAG,EAAEF,IAAI,EAAEV,OAAO,EAAEwB,SAAS,CAAC,CAAC;EAEnC,IAAAY,gBAAS,EAAC,MAAM;IACd,IAAIpC,OAAO,CAACO,eAAe,EAAE;MAC3B,OAAO,MAAM;QACXC,QAAQ,CAAC,IAAA6B,kCAAgB,EAACzB,GAAG,CAAC,CAAC;MACjC,CAAC;IACH;EACF,CAAC,EAAE,CAACJ,QAAQ,EAAEI,GAAG,EAAEZ,OAAO,CAACO,eAAe,CAAC,CAAC;EAE5C,OAAOS,KAAK;AACd,CAAC;AAACsB,OAAA,CAAAvC,YAAA,GAAAA,YAAA","ignoreList":[]}
|
package/lib/i18n/index.js
CHANGED
|
@@ -52,6 +52,5 @@ var _Locales = _interopRequireWildcard(require("./Locales"));
|
|
|
52
52
|
var _Message = _interopRequireDefault(require("./Message"));
|
|
53
53
|
var _withMessage = _interopRequireDefault(require("./withMessage"));
|
|
54
54
|
var _useI18n = require("../hooks/useI18n");
|
|
55
|
-
function
|
|
56
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && _Object$getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? _Object$getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
55
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof _WeakMap) var r = new _WeakMap(), n = new _WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && _Object$getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
57
56
|
//# sourceMappingURL=index.js.map
|
package/lib/i18n/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_Locales","_interopRequireWildcard","require","_Message","_interopRequireDefault","_withMessage","_useI18n","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Locales","_interopRequireWildcard","require","_Message","_interopRequireDefault","_withMessage","_useI18n","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor"],"sources":["../../src/i18n/index.js"],"sourcesContent":["// @flow\nexport {\n default as Locales,\n availableLocales,\n createLocalesWithConfiguredErrors,\n} from \"./Locales\";\n\nexport { default as Message } from \"./Message\";\nexport { default as withMessage } from \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AAC,CAAA","ignoreList":[]}
|
|
@@ -257,9 +257,9 @@ class AttributeCollection extends _ResourceCollection.default {
|
|
|
257
257
|
/**
|
|
258
258
|
*/
|
|
259
259
|
getFormData() {
|
|
260
|
-
var _context9,
|
|
260
|
+
var _context9, _context0;
|
|
261
261
|
let validationData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
262
|
-
const attributesFormData = (0, _map.default)(_context9 = (0, _filter.default)(
|
|
262
|
+
const attributesFormData = (0, _map.default)(_context9 = (0, _filter.default)(_context0 = this.attributes).call(_context0, attribute => attribute.formdata !== null && !attribute.readonly && (!validationData || attribute.hasDynamicValidationData))).call(_context9, attribute => {
|
|
263
263
|
// make attribute empty when it is not (or no longer) visible
|
|
264
264
|
if (attribute.isVisible) {
|
|
265
265
|
return attribute.formdata;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeCollection.js","names":["_objects","require","_ResourceCollection","_interopRequireDefault","_createAttribute","_ChoiceAttributeModel","_CompositeAttributeModel","_ContentConfiguration","_exceptions","AttributeCollection","ResourceCollection","constructor","data","arguments","length","undefined","contributions","modelOptions","forEach","contribution","key","_keys","default","attribute","createAttribute","origin","contextPath","isReadonly","has","readonly","collection","push","processLayoutHintRules","attributes","all","visible","_context","_filter","call","isHidden","questions","_context2","isResult","results","_context3","getAttributeByAttribute","_context4","_find","attr","equals","CompositeAttributeModel","getChildByAttribute","getAttributeByKey","_context5","getChildByKey","hasAttributeByKey","getAttributeByLayoutHint","_context6","_len","hints","Array","_key","layouthint","getChoiceAttributeByLayoutHint","layoutHint","ChoiceAttributeModel","getAttributesByLayoutHint","_context7","_len2","_key2","replace","oldAttribute","newAttribute","replaceByKey","index","setReferenceDate","date","clone","referenceDate","hasServerErrors","some","addServerError","error","elementid","anchor","ConfigurationException","hasErrors","updateValidations","errors","_context8","hasDynamicValidationData","attributeErrors","compositeChildErrors","elementId","_startsWith","children","indicateContentConfiguration","contentConfiguration","formdata","getFormData","_context9","_context10","validationData","attributesFormData","_map","isVisible","getEmptyFormData","attributeFormData","_default","exports"],"sources":["../../../src/models/attributes/AttributeCollection.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceCollection from \"../base/ResourceCollection\";\n\nimport createAttribute from \"./_createAttribute\";\nimport ChoiceAttributeModel from \"./ChoiceAttributeModel\";\nimport CompositeAttributeModel from \"./CompositeAttributeModel\";\n\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\n\nimport { ConfigurationException } from \"../../exceptions\";\n\nimport type { AttributeType, FormErrorAnchor, ModelOptions } from \"../types\";\n\ntype AttributeCollectionOptions = {\n ...ModelOptions,\n isReadonly: boolean,\n};\n\n/**\n * Collection of attributes\n */\nclass AttributeCollection extends ResourceCollection<AttributeType> {\n constructor(\n data: Object | Array<Object> = {},\n contributions: Array<Object> = [],\n modelOptions?: AttributeCollectionOptions,\n ) {\n super();\n\n if (contributions) {\n contributions.forEach((contribution) => {\n const [key] = Object.keys(contribution);\n\n const attribute = createAttribute(key, data, contribution[key], {\n origin: modelOptions?.origin,\n contextPath: modelOptions?.contextPath,\n });\n\n if (attribute !== null) {\n // when readonly is not explicitly set in the contributions, follow argument\n if (modelOptions?.isReadonly && !has(contribution[key], \"readonly\")) {\n attribute.readonly = true;\n }\n\n this.collection.push(attribute);\n }\n });\n\n this.processLayoutHintRules();\n }\n }\n\n /**\n * Retrieve all attributes in this collection<br>\n * This getter processes layout hints, this is different from the standard {@link BaseCollection#all} property\n * @returns {Array<AttributeType>}\n */\n get attributes(): Array<AttributeType> {\n this.processLayoutHintRules();\n return this.all;\n }\n\n /**\n * Replace attributes with a new array of attributes\n */\n set attributes(attributes: Array<AttributeType>) {\n this.collection = attributes;\n }\n\n /**\n */\n processLayoutHintRules(): void {\n this.all.forEach((attribute) => {\n attribute.processLayoutHintRules(this);\n });\n }\n\n /**\n * Retrieve only visible attributes from the collection\n */\n get visible(): Array<AttributeType> {\n // Let flow know that this is a AttributeCollection\n if (this instanceof AttributeCollection) {\n return this.attributes.filter((attribute) => !attribute.isHidden);\n }\n\n return [];\n }\n\n /**\n */\n get questions(): Array<AttributeType> {\n return this.visible.filter((attribute) => !attribute.isResult);\n }\n\n /**\n */\n get results(): Array<AttributeType> {\n return this.visible.filter((attribute) => attribute.isResult);\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.find((attr) => {\n if (attr.equals(attribute)) {\n return true;\n } else if (attribute instanceof CompositeAttributeModel) {\n return attribute.getChildByAttribute(attribute);\n }\n\n return false;\n });\n }\n\n /**\n * Get a single attribute by it's key\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.find((attribute) => {\n if (attribute.key === key) {\n return true;\n } else if (attribute instanceof CompositeAttributeModel) {\n return attribute.getChildByKey(key);\n }\n\n return false;\n });\n }\n\n /**\n * Indicates if attribute with key exists in collection\n */\n hasAttributeByKey(key: string): boolean {\n return this.getAttributeByKey(key) !== null;\n }\n\n /**\n * Getting the first attribute having the supplied layout hint\n */\n getAttributeByLayoutHint(...hints: Array<string>): AttributeType | null {\n return this.find((attribute) => attribute.layouthint.has(...hints)) || null;\n }\n\n /**\n * Getting a choice attribute by layouthint, returns null when not found or not a choice attribute\n */\n getChoiceAttributeByLayoutHint(\n layoutHint: string,\n ): ChoiceAttributeModel | null {\n const attribute = this.getAttributeByLayoutHint(layoutHint);\n\n return attribute instanceof ChoiceAttributeModel ? attribute : null;\n }\n\n /**\n * Getting all attributes having the supplied layout hint\n */\n getAttributesByLayoutHint(...hints: Array<string>): Array<AttributeType> {\n return this.filter((attribute) => attribute.layouthint.has(...hints));\n }\n\n /**\n * Replace an attribute instance in the collection with a new attribute instance\n */\n replace(oldAttribute: AttributeType, newAttribute: AttributeType): void {\n this.replaceByKey(oldAttribute.key, newAttribute);\n }\n\n /**\n * Replace an attribute by the key of the attribute\n */\n replaceByKey(key: string, newAttribute: AttributeType): void {\n this.forEach((attribute, index) => {\n if (attribute.key === key) {\n this.collection[index] = newAttribute;\n }\n });\n }\n\n /**\n * Set reference date by replacing an old attribute with a new attribute with a reference Date\n * Date is a string in ISO format yyyy-MM-dd\n */\n setReferenceDate(date: string): void {\n this.forEach((attribute) => {\n const newAttribute = attribute.clone();\n\n newAttribute.referenceDate = date;\n\n this.replace(attribute, newAttribute);\n });\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return this.collection.some((attribute) => attribute.hasServerErrors());\n }\n\n /**\n */\n addServerError(error: FormErrorAnchor): void {\n const elementid = error?.anchor?.elementid;\n\n if (elementid) {\n const attribute = this.getAttributeByKey(elementid);\n if (attribute) {\n attribute.addServerError(error);\n } else {\n throw new ConfigurationException(\n `Could not add error to missing attribute with id ${elementid}`,\n );\n }\n }\n }\n\n /**\n */\n hasErrors(): boolean {\n return this.visible.some((attribute) => attribute.hasErrors());\n }\n\n /**\n */\n updateValidations(errors: Array<Object>): AttributeCollection {\n this.all\n .filter((attribute) => attribute.hasDynamicValidationData)\n .forEach((attribute) => {\n const attributeErrors = errors.filter(\n (error) => error.anchor?.elementid === attribute.key,\n );\n attribute.updateValidations(attributeErrors);\n\n if (attribute instanceof CompositeAttributeModel) {\n const compositeChildErrors = errors.filter((error) => {\n const elementId = error.anchor?.elementid;\n return elementId && elementId.startsWith(`${attribute.key}.`);\n });\n\n attribute.children.updateValidations(\n `${attribute.key}.`,\n compositeChildErrors,\n );\n }\n });\n\n return this;\n }\n\n /**\n */\n indicateContentConfiguration(\n contentConfiguration: ContentConfiguration,\n ): void {\n if (contentConfiguration) {\n this.all.forEach((attribute) => {\n attribute.indicateContentConfiguration(contentConfiguration);\n });\n }\n }\n\n /**\n * Generate formdata object for current collection based on formdata of attributes\n * Skip attributes that are readonly, the confirmation password or null\n */\n get formdata(): { [string]: any } | null {\n return this.getFormData(false);\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n const attributesFormData = this.attributes\n .filter(\n (attribute) =>\n attribute.formdata !== null &&\n !attribute.readonly &&\n (!validationData || attribute.hasDynamicValidationData),\n )\n .map((attribute) => {\n // make attribute empty when it is not (or no longer) visible\n if (attribute.isVisible) {\n return attribute.formdata;\n }\n\n return attribute.getEmptyFormData();\n });\n\n let data = {};\n attributesFormData.forEach((attributeFormData) => {\n // $FlowIgnore[cannot-spread-indexer]\n // $FlowIgnore[exponential-spread]\n data = {\n ...data,\n ...attributeFormData,\n };\n });\n\n return data;\n }\n}\n\nexport default AttributeCollection;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,qBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,wBAAA,GAAAH,sBAAA,CAAAF,OAAA;AAEA,IAAAM,qBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAEA,IAAAO,WAAA,GAAAP,OAAA;AASA;AACA;AACA;AACA,MAAMQ,mBAAmB,SAASC,2BAAkB,CAAgB;EAClEC,WAAWA,CAAA,EAIT;IAAA,IAHAC,IAA4B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAA,IACjCG,aAA4B,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;IAAA,IACjCI,YAAyC,GAAAJ,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;IAEzC,KAAK,CAAC,CAAC;IAEP,IAAIC,aAAa,EAAE;MACjBA,aAAa,CAACE,OAAO,CAAEC,YAAY,IAAK;QACtC,MAAM,CAACC,GAAG,CAAC,GAAG,IAAAC,KAAA,CAAAC,OAAA,EAAYH,YAAY,CAAC;QAEvC,MAAMI,SAAS,GAAG,IAAAC,wBAAe,EAACJ,GAAG,EAAER,IAAI,EAAEO,YAAY,CAACC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,CAAC,CAAC;IACJ;EACF;;EAEA;AACF;AACA;AACA;EACE,IAAIC,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAACC,WAAW,CAAC,KAAK,CAAC;EAChC;;EAEA;AACF;EACEA,WAAWA,CAAA,EAA4D;IAAA,IAAAC,SAAA,EAAAC,UAAA;IAAA,IAA3DC,cAAuB,GAAAzF,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,KAAK;IACzC,MAAM0F,kBAAkB,GAAG,IAAAC,IAAA,CAAAlF,OAAA,EAAA8E,SAAA,OAAA/D,OAAA,CAAAf,OAAA,EAAA+E,UAAA,OAAI,CAACpE,UAAU,EAAAK,IAAA,CAAA+D,UAAA,EAErC9E,SAAS,IACRA,SAAS,CAAC2E,QAAQ,KAAK,IAAI,IAC3B,CAAC3E,SAAS,CAACM,QAAQ,KAClB,CAACyE,cAAc,IAAI/E,SAAS,CAACmE,wBAAwB,CAC1D,CAAC,EAAApD,IAAA,CAAA8D,SAAA,EACK7E,SAAS,IAAK;MAClB;MACA,IAAIA,SAAS,CAACkF,SAAS,EAAE;QACvB,OAAOlF,SAAS,CAAC2E,QAAQ;MAC3B;MAEA,OAAO3E,SAAS,CAACmF,gBAAgB,CAAC,CAAC;IACrC,CAAC,CAAC;IAEJ,IAAI9F,IAAI,GAAG,CAAC,CAAC;IACb2F,kBAAkB,CAACrF,OAAO,CAAEyF,iBAAiB,IAAK;MAChD;MACA;MACA/F,IAAI,GAAG;QACL,GAAGA,IAAI;QACP,GAAG+F;MACL,CAAC;IACH,CAAC,CAAC;IAEF,OAAO/F,IAAI;EACb;AACF;AAAC,IAAAgG,QAAA,GAAAC,OAAA,CAAAvF,OAAA,GAEcb,mBAAmB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"AttributeCollection.js","names":["_objects","require","_ResourceCollection","_interopRequireDefault","_createAttribute","_ChoiceAttributeModel","_CompositeAttributeModel","_ContentConfiguration","_exceptions","AttributeCollection","ResourceCollection","constructor","data","arguments","length","undefined","contributions","modelOptions","forEach","contribution","key","_keys","default","attribute","createAttribute","origin","contextPath","isReadonly","has","readonly","collection","push","processLayoutHintRules","attributes","all","visible","_context","_filter","call","isHidden","questions","_context2","isResult","results","_context3","getAttributeByAttribute","_context4","_find","attr","equals","CompositeAttributeModel","getChildByAttribute","getAttributeByKey","_context5","getChildByKey","hasAttributeByKey","getAttributeByLayoutHint","_context6","_len","hints","Array","_key","layouthint","getChoiceAttributeByLayoutHint","layoutHint","ChoiceAttributeModel","getAttributesByLayoutHint","_context7","_len2","_key2","replace","oldAttribute","newAttribute","replaceByKey","index","setReferenceDate","date","clone","referenceDate","hasServerErrors","some","addServerError","error","elementid","anchor","ConfigurationException","hasErrors","updateValidations","errors","_context8","hasDynamicValidationData","attributeErrors","compositeChildErrors","elementId","_startsWith","children","indicateContentConfiguration","contentConfiguration","formdata","getFormData","_context9","_context0","validationData","attributesFormData","_map","isVisible","getEmptyFormData","attributeFormData","_default","exports"],"sources":["../../../src/models/attributes/AttributeCollection.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ResourceCollection from \"../base/ResourceCollection\";\n\nimport createAttribute from \"./_createAttribute\";\nimport ChoiceAttributeModel from \"./ChoiceAttributeModel\";\nimport CompositeAttributeModel from \"./CompositeAttributeModel\";\n\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\n\nimport { ConfigurationException } from \"../../exceptions\";\n\nimport type { AttributeType, FormErrorAnchor, ModelOptions } from \"../types\";\n\ntype AttributeCollectionOptions = {\n ...ModelOptions,\n isReadonly: boolean,\n};\n\n/**\n * Collection of attributes\n */\nclass AttributeCollection extends ResourceCollection<AttributeType> {\n constructor(\n data: Object | Array<Object> = {},\n contributions: Array<Object> = [],\n modelOptions?: AttributeCollectionOptions,\n ) {\n super();\n\n if (contributions) {\n contributions.forEach((contribution) => {\n const [key] = Object.keys(contribution);\n\n const attribute = createAttribute(key, data, contribution[key], {\n origin: modelOptions?.origin,\n contextPath: modelOptions?.contextPath,\n });\n\n if (attribute !== null) {\n // when readonly is not explicitly set in the contributions, follow argument\n if (modelOptions?.isReadonly && !has(contribution[key], \"readonly\")) {\n attribute.readonly = true;\n }\n\n this.collection.push(attribute);\n }\n });\n\n this.processLayoutHintRules();\n }\n }\n\n /**\n * Retrieve all attributes in this collection<br>\n * This getter processes layout hints, this is different from the standard {@link BaseCollection#all} property\n * @returns {Array<AttributeType>}\n */\n get attributes(): Array<AttributeType> {\n this.processLayoutHintRules();\n return this.all;\n }\n\n /**\n * Replace attributes with a new array of attributes\n */\n set attributes(attributes: Array<AttributeType>) {\n this.collection = attributes;\n }\n\n /**\n */\n processLayoutHintRules(): void {\n this.all.forEach((attribute) => {\n attribute.processLayoutHintRules(this);\n });\n }\n\n /**\n * Retrieve only visible attributes from the collection\n */\n get visible(): Array<AttributeType> {\n // Let flow know that this is a AttributeCollection\n if (this instanceof AttributeCollection) {\n return this.attributes.filter((attribute) => !attribute.isHidden);\n }\n\n return [];\n }\n\n /**\n */\n get questions(): Array<AttributeType> {\n return this.visible.filter((attribute) => !attribute.isResult);\n }\n\n /**\n */\n get results(): Array<AttributeType> {\n return this.visible.filter((attribute) => attribute.isResult);\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.find((attr) => {\n if (attr.equals(attribute)) {\n return true;\n } else if (attribute instanceof CompositeAttributeModel) {\n return attribute.getChildByAttribute(attribute);\n }\n\n return false;\n });\n }\n\n /**\n * Get a single attribute by it's key\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.find((attribute) => {\n if (attribute.key === key) {\n return true;\n } else if (attribute instanceof CompositeAttributeModel) {\n return attribute.getChildByKey(key);\n }\n\n return false;\n });\n }\n\n /**\n * Indicates if attribute with key exists in collection\n */\n hasAttributeByKey(key: string): boolean {\n return this.getAttributeByKey(key) !== null;\n }\n\n /**\n * Getting the first attribute having the supplied layout hint\n */\n getAttributeByLayoutHint(...hints: Array<string>): AttributeType | null {\n return this.find((attribute) => attribute.layouthint.has(...hints)) || null;\n }\n\n /**\n * Getting a choice attribute by layouthint, returns null when not found or not a choice attribute\n */\n getChoiceAttributeByLayoutHint(\n layoutHint: string,\n ): ChoiceAttributeModel | null {\n const attribute = this.getAttributeByLayoutHint(layoutHint);\n\n return attribute instanceof ChoiceAttributeModel ? attribute : null;\n }\n\n /**\n * Getting all attributes having the supplied layout hint\n */\n getAttributesByLayoutHint(...hints: Array<string>): Array<AttributeType> {\n return this.filter((attribute) => attribute.layouthint.has(...hints));\n }\n\n /**\n * Replace an attribute instance in the collection with a new attribute instance\n */\n replace(oldAttribute: AttributeType, newAttribute: AttributeType): void {\n this.replaceByKey(oldAttribute.key, newAttribute);\n }\n\n /**\n * Replace an attribute by the key of the attribute\n */\n replaceByKey(key: string, newAttribute: AttributeType): void {\n this.forEach((attribute, index) => {\n if (attribute.key === key) {\n this.collection[index] = newAttribute;\n }\n });\n }\n\n /**\n * Set reference date by replacing an old attribute with a new attribute with a reference Date\n * Date is a string in ISO format yyyy-MM-dd\n */\n setReferenceDate(date: string): void {\n this.forEach((attribute) => {\n const newAttribute = attribute.clone();\n\n newAttribute.referenceDate = date;\n\n this.replace(attribute, newAttribute);\n });\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return this.collection.some((attribute) => attribute.hasServerErrors());\n }\n\n /**\n */\n addServerError(error: FormErrorAnchor): void {\n const elementid = error?.anchor?.elementid;\n\n if (elementid) {\n const attribute = this.getAttributeByKey(elementid);\n if (attribute) {\n attribute.addServerError(error);\n } else {\n throw new ConfigurationException(\n `Could not add error to missing attribute with id ${elementid}`,\n );\n }\n }\n }\n\n /**\n */\n hasErrors(): boolean {\n return this.visible.some((attribute) => attribute.hasErrors());\n }\n\n /**\n */\n updateValidations(errors: Array<Object>): AttributeCollection {\n this.all\n .filter((attribute) => attribute.hasDynamicValidationData)\n .forEach((attribute) => {\n const attributeErrors = errors.filter(\n (error) => error.anchor?.elementid === attribute.key,\n );\n attribute.updateValidations(attributeErrors);\n\n if (attribute instanceof CompositeAttributeModel) {\n const compositeChildErrors = errors.filter((error) => {\n const elementId = error.anchor?.elementid;\n return elementId && elementId.startsWith(`${attribute.key}.`);\n });\n\n attribute.children.updateValidations(\n `${attribute.key}.`,\n compositeChildErrors,\n );\n }\n });\n\n return this;\n }\n\n /**\n */\n indicateContentConfiguration(\n contentConfiguration: ContentConfiguration,\n ): void {\n if (contentConfiguration) {\n this.all.forEach((attribute) => {\n attribute.indicateContentConfiguration(contentConfiguration);\n });\n }\n }\n\n /**\n * Generate formdata object for current collection based on formdata of attributes\n * Skip attributes that are readonly, the confirmation password or null\n */\n get formdata(): { [string]: any } | null {\n return this.getFormData(false);\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n const attributesFormData = this.attributes\n .filter(\n (attribute) =>\n attribute.formdata !== null &&\n !attribute.readonly &&\n (!validationData || attribute.hasDynamicValidationData),\n )\n .map((attribute) => {\n // make attribute empty when it is not (or no longer) visible\n if (attribute.isVisible) {\n return attribute.formdata;\n }\n\n return attribute.getEmptyFormData();\n });\n\n let data = {};\n attributesFormData.forEach((attributeFormData) => {\n // $FlowIgnore[cannot-spread-indexer]\n // $FlowIgnore[exponential-spread]\n data = {\n ...data,\n ...attributeFormData,\n };\n });\n\n return data;\n }\n}\n\nexport default AttributeCollection;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,mBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,gBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,qBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,wBAAA,GAAAH,sBAAA,CAAAF,OAAA;AAEA,IAAAM,qBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AAEA,IAAAO,WAAA,GAAAP,OAAA;AASA;AACA;AACA;AACA,MAAMQ,mBAAmB,SAASC,2BAAkB,C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K;MAClB;MACA,IAAIA,SAAS,CAACkF,SAAS,EAAE;QACvB,OAAOlF,SAAS,CAAC2E,QAAQ;MAC3B;MAEA,OAAO3E,SAAS,CAACmF,gBAAgB,CAAC,CAAC;IACrC,CAAC,CAAC;IAEJ,IAAI9F,IAAI,GAAG,CAAC,CAAC;IACb2F,kBAAkB,CAACrF,OAAO,CAAEyF,iBAAiB,IAAK;MAChD;MACA;MACA/F,IAAI,GAAG;QACL,GAAGA,IAAI;QACP,GAAG+F;MACL,CAAC;IACH,CAAC,CAAC;IAEF,OAAO/F,IAAI;EACb;AACF;AAAC,IAAAgG,QAAA,GAAAC,OAAA,CAAAvF,OAAA,GAEcb,mBAAmB","ignoreList":[]}
|
|
@@ -84,7 +84,7 @@ class AttributeContent {
|
|
|
84
84
|
layouthint: new _LayoutHintCollection.default(layouthint),
|
|
85
85
|
textfragments: (0, _map.default)(textfragments).call(textfragments, textfragment => ({
|
|
86
86
|
...textfragment,
|
|
87
|
-
text: (0, _text.retrieveText)(textfragment.text)
|
|
87
|
+
text: (0, _text.retrieveText)(textfragment.text) || ""
|
|
88
88
|
}))
|
|
89
89
|
}
|
|
90
90
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeContent.js","names":["_text","require","_Settings","_SectionModel","_interopRequireDefault","_LayoutHintCollection","_utils","AttributeContent","constructor","content","_defineProperty2","default","_content","fromData","hasAllContentInData","header","headerLabel","headerDescription","label","description","isPlainObject","message","elements","_context","_context2","_map","_filter","call","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","retrieveText","contentElement","sections","section","SectionModel","getContentElements","elementName","_context3","getContentElementCollections","collectionName","_context4","_context5","_flat","getContentElementCollectionByLabels","labels","_context6","_context7","_context8","_includes","getConceptPropertiesByLabels","getTextFragmentsByLabels","getSectionsByType","types","_context9","type","getSectionsByLabels","getReferredSections","referredSections","push","_default","exports"],"sources":["../../../src/models/attributes/AttributeContent.js"],"sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\n/**\n */\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements\n .filter((element) => element !== null)\n .map((element) => {\n if (element.propertyElement) {\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (element.textFragmentElement) {\n const { label, layouthint, textfragments } =\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (element.contentElement) {\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null),\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string,\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>,\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\",\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData,\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\",\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData,\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\",\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel,\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,qBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAaA;AACA;AACA,MAAMM,gBAAgB,CAAC;EAGrBC,WAAWA,CAACC,OAAqB,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IACjC,IAAI,CAACC,QAAQ,GAAGH,OAAO;EACzB;;EAEA;AACF;EACE,IAAII,QAAQA,CAAA,EAAY;IACtB,OAAO,IAAAC,6BAAmB,EAAC,CAAC;EAC9B;;EAEA;AACF;EACE,IAAIC,MAAMA,CAAA,EAGR;IACA,IAAIC,WAAW,GAAG,IAAI;IACtB,IAAIC,iBAAiB,GAAG,IAAI;IAE5B,MAAMC,KAAK,GAAG,IAAI,CAACN,QAAQ,EAAEG,MAAM,EAAEG,KAAK;IAC1C,IAAIA,KAAK,EAAE;MACTF,WAAW,GAAGE,KAAK;IACrB;IAEA,MAAMC,WAAW,GAAG,IAAI,CAACP,QAAQ,EAAEG,MAAM,EAAEI,WAAW;IACtD,IAAIA,WAAW,EAAE;MACf,IAAI,IAAAC,oBAAa,EAACD,WAAW,CAAC,IAAI,SAAS,IAAIA,WAAW,EAAE;QAC1DF,iBAAiB,GAAGE,WAAW,CAACE,OAAO;MACzC,CAAC,MAAM,IAAI,OAAOF,WAAW,KAAK,QAAQ,EAAE;QAC1CF,iBAAiB,GAAGE,WAAW;MACjC;IACF;IAEA,OAAO;MAAED,KAAK,EAAEF,WAAW;MAAEG,WAAW,EAAEF;IAAkB,CAAC;EAC/D;;EAEA;AACF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C,IAAA,CAALgC,KAAK,EAAUnB,OAAO,CAACqB,IAAI,CAAC,CAAC;EACxE;;EAEA;AACF;AACA;EACEC,mBAAmBA,CAACX,MAAqB,EAAuB;IAC9D,OAAO,IAAI,CAACD,mCAAmC,CAG7C,gBAAgB,EAAE,UAAU,EAAEC,MAAM,CAAC;EACzC;;EAEA;AACF;EACEY,mBAAmBA,CAAA,EAA0C;IAC3D,MAAMC,gBAAgB,GAAG,EAAE;IAE3B,KAAK,MAAMxB,OAAO,IAAI,IAAI,CAACD,QAAQ,EAAE;MACnCyB,gBAAgB,CAACC,IAAI,CAAC,GAAGzB,OAAO,CAACuB,mBAAmB,CAAC,CAAC,CAAC;IACzD;IAEA,OAAOC,gBAAgB;EACzB;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAxD,OAAA,GAEcJ,gBAAgB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"AttributeContent.js","names":["_text","require","_Settings","_SectionModel","_interopRequireDefault","_LayoutHintCollection","_utils","AttributeContent","constructor","content","_defineProperty2","default","_content","fromData","hasAllContentInData","header","headerLabel","headerDescription","label","description","isPlainObject","message","elements","_context","_context2","_map","_filter","call","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","retrieveText","contentElement","sections","section","SectionModel","getContentElements","elementName","_context3","getContentElementCollections","collectionName","_context4","_context5","_flat","getContentElementCollectionByLabels","labels","_context6","_context7","_context8","_includes","getConceptPropertiesByLabels","getTextFragmentsByLabels","getSectionsByType","types","_context9","type","getSectionsByLabels","getReferredSections","referredSections","push","_default","exports"],"sources":["../../../src/models/attributes/AttributeContent.js"],"sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nimport type {\n ContentData,\n ContentElementMapped,\n PropertyData,\n PropertyElementMapped,\n TextFragmentData,\n TextFragmentElementMapped,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\n\n/**\n */\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements\n .filter((element) => element !== null)\n .map((element) => {\n if (element.propertyElement) {\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (element.textFragmentElement) {\n const { label, layouthint, textfragments } =\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text) || \"\",\n })),\n },\n };\n }\n\n if (element.contentElement) {\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null),\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string): Array<T> {\n // $FlowIssue incompatible-return\n return this.elements.filter((element) => elementName in element);\n }\n\n /**\n */\n getContentElementCollections<T>(\n elementName: string,\n collectionName: string,\n ): Array<T> {\n return this.getContentElements(elementName)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n getContentElementCollectionByLabels<T, U>(\n elementName: string,\n collectionName: string,\n labels: Array<string>,\n ): Array<U> {\n return (\n this.getContentElements<T>(elementName)\n // $FlowIssue incompatible-use\n .filter((element) => labels.includes(element[elementName].label))\n // $FlowIssue incompatible-use\n .map((element) => element[elementName][collectionName])\n .flat()\n );\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElementCollections<PropertyData>(\n \"propertyElement\",\n \"properties\",\n );\n }\n\n /**\n * Get concept properties by property element label\n */\n getConceptPropertiesByLabels(labels: Array<string>): Array<PropertyData> {\n return this.getContentElementCollectionByLabels<\n PropertyElementMapped,\n PropertyData,\n >(\"propertyElement\", \"properties\", labels);\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElementCollections<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\",\n );\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getTextFragmentsByLabels(labels: Array<string>): Array<TextFragmentData> {\n return this.getContentElementCollectionByLabels<\n TextFragmentElementMapped,\n TextFragmentData,\n >(\"textFragmentElement\", \"textfragments\", labels);\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElementCollections<SectionModel>(\n \"contentElement\",\n \"sections\",\n );\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n * Get concept text fragments by text fragment element label\n */\n getSectionsByLabels(labels: Array<string>): Array<SectionModel> {\n return this.getContentElementCollectionByLabels<\n ContentElementMapped,\n SectionModel,\n >(\"contentElement\", \"sections\", labels);\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA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EC,MAAM,CAAC;EACzC;;EAEA;AACF;EACEY,mBAAmBA,CAAA,EAA0C;IAC3D,MAAMC,gBAAgB,GAAG,EAAE;IAE3B,KAAK,MAAMxB,OAAO,IAAI,IAAI,CAACD,QAAQ,EAAE;MACnCyB,gBAAgB,CAACC,IAAI,CAAC,GAAGzB,OAAO,CAACuB,mBAAmB,CAAC,CAAC,CAAC;IACzD;IAEA,OAAOC,gBAAgB;EACzB;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAxD,OAAA,GAEcJ,gBAAgB","ignoreList":[]}
|
|
@@ -162,12 +162,12 @@ class CompositeAttributeChildCollection extends _ResourceCollection.default {
|
|
|
162
162
|
/**
|
|
163
163
|
*/
|
|
164
164
|
get readonlyvalue() {
|
|
165
|
-
var
|
|
165
|
+
var _context1, _context10;
|
|
166
166
|
if (this.first instanceof CompositeAttributeChildCollection) {
|
|
167
|
-
var
|
|
168
|
-
return (0, _map.default)(
|
|
167
|
+
var _context0;
|
|
168
|
+
return (0, _map.default)(_context0 = this.collection).call(_context0, collection => collection.readonlyvalue).join(" | ");
|
|
169
169
|
}
|
|
170
|
-
return (0, _map.default)(
|
|
170
|
+
return (0, _map.default)(_context1 = (0, _filter.default)(_context10 = this.collection).call(_context10, child => child.value !== null)).call(_context1, child => child.readonlyvalue).join(", ");
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeAttributeChildCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ErrorCollection","_createAttribute","CompositeAttributeChildCollection","ResourceCollection","create","data","contributions","modelOptions","Array","isArray","children","isMultipleTableRows","createMultiData","createStandard","_context","_context2","compositeChildCollection","collection","_filter","default","_map","call","contribution","_context3","_context4","key","_keys","attributeData","_find","attr","attributeContribution","_includes","type","replace","attribute","createAttribute","dynamicschema","readonly","parentKey","_context5","childData","getInputValue","_context6","child","inputvalue","join","validate","every","isValid","errorCollection","ErrorCollection","hasServerErrors","serverErrors","length","some","hasErrors","hasItems","reset","forEach","initvalue","_context8","first","_context7","value","_context9","formdata","readonlyvalue","_context11","_context12","_context10","updateValidations","prefix","errors","attributeErrors","error","anchor","elementid","hasValue","_default","exports"],"sources":["../../../src/models/attributes/CompositeAttributeChildCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ErrorCollection from \"../error/ErrorCollection\";\n\nimport createAttribute from \"./_createAttribute\";\n\nimport type { AttributeType, ModelOptions } from \"../types\";\n\n/**\n * Collection of choice attribute options\n */\nclass CompositeAttributeChildCollection extends ResourceCollection<AttributeType> {\n /**\n */\n static create(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n if (\n data &&\n contributions &&\n Array.isArray(contributions.children) &&\n Array.isArray(data.children)\n ) {\n // a composite with multiple data elements and one contributions element\n // multiple 'composites' are returned\n const isMultipleTableRows = Array.isArray(data.children[0]);\n if (isMultipleTableRows) {\n return CompositeAttributeChildCollection.createMultiData(\n data,\n contributions,\n modelOptions,\n );\n }\n\n return CompositeAttributeChildCollection.createStandard(\n data,\n contributions,\n modelOptions,\n );\n }\n\n return new CompositeAttributeChildCollection();\n }\n\n /**\n */\n static createStandard(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n const compositeChildCollection = new CompositeAttributeChildCollection();\n\n compositeChildCollection.collection = contributions.children\n .map((contribution) => {\n const [key] = Object.keys(contribution);\n\n const attributeData = Array.isArray(data.children)\n ? data.children.find((attr) => attr.key === key)\n : {};\n\n const attributeContribution = contribution[key];\n\n if (\n contributions.type.includes(\"range\") &&\n !attributeContribution.type\n ) {\n attributeContribution.type = contributions.type.replace(\"range\", \"\");\n }\n\n const attribute = createAttribute(\n key,\n {\n ...attributeData,\n dynamicschema: attributeData?.dynamicschema,\n },\n {\n ...attributeContribution,\n readonly: attributeContribution.readonly || contributions.readonly,\n },\n modelOptions,\n );\n\n if (attribute) {\n attribute.parentKey = data.key;\n }\n\n return attribute;\n })\n .filter((attribute) => attribute !== null);\n\n return compositeChildCollection;\n }\n\n /*\n * Creates a composite for each child data element using the same contributions\n */\n /**\n */\n static createMultiData(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n const compositeChildCollection = new CompositeAttributeChildCollection();\n\n compositeChildCollection.collection = data.children.map((childData) =>\n CompositeAttributeChildCollection.create(\n {\n ...data,\n children: childData,\n },\n contributions,\n modelOptions,\n ),\n );\n\n return compositeChildCollection;\n }\n\n /**\n * Get input value of contributions\n */\n getInputValue(): string {\n return this.collection.map((child) => child.inputvalue).join(\",\");\n }\n\n /**\n * Validate input\n */\n validate(): boolean {\n return this.collection.every((child) => child.isValid);\n }\n\n /**\n * Retrieve error messages of this attribute\n */\n get errorCollection(): ErrorCollection {\n return new ErrorCollection(\"compositechildren\");\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.serverErrors.length > 0 ||\n this.collection.some((child) => child.hasServerErrors())\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.collection.some((child) => child.hasErrors())\n );\n }\n\n /**\n * Reset attribute to empty string\n */\n reset() {\n this.collection.forEach((child) => {\n child.reset();\n });\n }\n\n /**\n */\n get initvalue(): any {\n if (this.first instanceof CompositeAttributeChildCollection) {\n // $FlowFixMe[missing-type-arg]\n return this.collection.map<Array<Object>>(\n (collection) => collection.initvalue,\n );\n }\n\n const children: { [string]: any } = {};\n this.collection\n .filter((child) => child.initvalue !== null)\n .forEach((child) => {\n children[child.key] = child.initvalue;\n });\n\n if (Object.keys(children).length === 0) {\n return null;\n }\n\n return children;\n }\n\n /**\n */\n get value(): any {\n if (this.first instanceof CompositeAttributeChildCollection) {\n return this.collection.map((collection) => collection.value);\n }\n\n let children: { [string]: any } = {};\n\n this.collection.forEach((attribute) => {\n if (attribute.formdata !== null && !attribute.readonly) {\n children = {\n ...children,\n ...attribute.formdata,\n };\n }\n });\n\n if (Object.keys(children).length === 0) {\n return null;\n }\n\n return children;\n }\n\n /**\n */\n get readonlyvalue(): string {\n if (this.first instanceof CompositeAttributeChildCollection) {\n return this.collection\n .map((collection) => collection.readonlyvalue)\n .join(\" | \");\n }\n\n return this.collection\n .filter((child) => child.value !== null)\n .map((child) => child.readonlyvalue)\n .join(\", \");\n }\n\n /**\n */\n updateValidations(prefix: string, errors: Object) {\n this.collection.forEach((child) => {\n const attributeErrors = errors.filter(\n (error) => error.anchor?.elementid === `${prefix}${child.key}`,\n );\n\n child.updateValidations(attributeErrors);\n });\n }\n\n /**\n */\n hasValue(): boolean {\n return this.collection.some((child) => child.hasValue());\n }\n}\n\nexport default CompositeAttributeChildCollection;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACA,MAAMG,iCAAiC,SAASC,2BAAkB,CAAgB;EAChF;AACF;EACE,OAAOC,MAAMA,CACXC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EACQ;IACnC,IACEF,IAAI,IACJC,aAAa,IACbE,KAAK,CAACC,OAAO,CAACH,aAAa,CAACI,QAAQ,CAAC,IACrCF,KAAK,CAACC,OAAO,CAACJ,IAAI,CAACK,QAAQ,CAAC,EAC5B;MACA;MACA;MACA,MAAMC,mBAAmB,GAAGH,KAAK,CAACC,OAAO,CAACJ,IAAI,CAACK,QAAQ,CAAC,CAAC,CAAC,CAAC;MAC3D,IAAIC,mBAAmB,EAAE;QACvB,OAAOT,iCAAiC,CAACU,eAAe,CACtDP,IAAI,EACJC,aAAa,EACbC,YACF,CAAC;MACH;MAEA,OAAOL,iCAAiC,CAACW,cAAc,CACrDR,IAAI,EACJC,aAAa,EACbC,YACF,CAAC;IACH;IAE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AAAC,OAAA,EAAAiD,UAAA,OAAI,CAACnD,UAAU,EAAAI,IAAA,CAAA+C,UAAA,EACXzB,KAAK,IAAKA,KAAK,CAACoB,KAAK,KAAK,IAAI,CAAC,EAAA1C,IAAA,CAAA8C,UAAA,EAClCxB,KAAK,IAAKA,KAAK,CAACuB,aAAa,CAAC,CACnCrB,IAAI,CAAC,IAAI,CAAC;EACf;;EAEA;AACF;EACEyB,iBAAiBA,CAACC,MAAc,EAAEC,MAAc,EAAE;IAChD,IAAI,CAACvD,UAAU,CAACyC,OAAO,CAAEf,KAAK,IAAK;MACjC,MAAM8B,eAAe,GAAG,IAAAvD,OAAA,CAAAC,OAAA,EAAAqD,MAAM,EAAAnD,IAAA,CAANmD,MAAM,EAC3BE,KAAK,IAAKA,KAAK,CAACC,MAAM,EAAEC,SAAS,KAAK,GAAGL,MAAM,GAAG5B,KAAK,CAAClB,GAAG,EAC9D,CAAC;MAEDkB,KAAK,CAAC2B,iBAAiB,CAACG,eAAe,CAAC;IAC1C,CAAC,CAAC;EACJ;;EAEA;AACF;EACEI,QAAQA,CAAA,EAAY;IAClB,OAAO,IAAI,CAAC5D,UAAU,CAACqC,IAAI,CAAEX,KAAK,IAAKA,KAAK,CAACkC,QAAQ,CAAC,CAAC,CAAC;EAC1D;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA5D,OAAA,GAEcjB,iCAAiC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"CompositeAttributeChildCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ErrorCollection","_createAttribute","CompositeAttributeChildCollection","ResourceCollection","create","data","contributions","modelOptions","Array","isArray","children","isMultipleTableRows","createMultiData","createStandard","_context","_context2","compositeChildCollection","collection","_filter","default","_map","call","contribution","_context3","_context4","key","_keys","attributeData","_find","attr","attributeContribution","_includes","type","replace","attribute","createAttribute","dynamicschema","readonly","parentKey","_context5","childData","getInputValue","_context6","child","inputvalue","join","validate","every","isValid","errorCollection","ErrorCollection","hasServerErrors","serverErrors","length","some","hasErrors","hasItems","reset","forEach","initvalue","_context8","first","_context7","value","_context9","formdata","readonlyvalue","_context1","_context10","_context0","updateValidations","prefix","errors","attributeErrors","error","anchor","elementid","hasValue","_default","exports"],"sources":["../../../src/models/attributes/CompositeAttributeChildCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ErrorCollection from \"../error/ErrorCollection\";\n\nimport createAttribute from \"./_createAttribute\";\n\nimport type { AttributeType, ModelOptions } from \"../types\";\n\n/**\n * Collection of choice attribute options\n */\nclass CompositeAttributeChildCollection extends ResourceCollection<AttributeType> {\n /**\n */\n static create(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n if (\n data &&\n contributions &&\n Array.isArray(contributions.children) &&\n Array.isArray(data.children)\n ) {\n // a composite with multiple data elements and one contributions element\n // multiple 'composites' are returned\n const isMultipleTableRows = Array.isArray(data.children[0]);\n if (isMultipleTableRows) {\n return CompositeAttributeChildCollection.createMultiData(\n data,\n contributions,\n modelOptions,\n );\n }\n\n return CompositeAttributeChildCollection.createStandard(\n data,\n contributions,\n modelOptions,\n );\n }\n\n return new CompositeAttributeChildCollection();\n }\n\n /**\n */\n static createStandard(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n const compositeChildCollection = new CompositeAttributeChildCollection();\n\n compositeChildCollection.collection = contributions.children\n .map((contribution) => {\n const [key] = Object.keys(contribution);\n\n const attributeData = Array.isArray(data.children)\n ? data.children.find((attr) => attr.key === key)\n : {};\n\n const attributeContribution = contribution[key];\n\n if (\n contributions.type.includes(\"range\") &&\n !attributeContribution.type\n ) {\n attributeContribution.type = contributions.type.replace(\"range\", \"\");\n }\n\n const attribute = createAttribute(\n key,\n {\n ...attributeData,\n dynamicschema: attributeData?.dynamicschema,\n },\n {\n ...attributeContribution,\n readonly: attributeContribution.readonly || contributions.readonly,\n },\n modelOptions,\n );\n\n if (attribute) {\n attribute.parentKey = data.key;\n }\n\n return attribute;\n })\n .filter((attribute) => attribute !== null);\n\n return compositeChildCollection;\n }\n\n /*\n * Creates a composite for each child data element using the same contributions\n */\n /**\n */\n static createMultiData(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): CompositeAttributeChildCollection {\n const compositeChildCollection = new CompositeAttributeChildCollection();\n\n compositeChildCollection.collection = data.children.map((childData) =>\n CompositeAttributeChildCollection.create(\n {\n ...data,\n children: childData,\n },\n contributions,\n modelOptions,\n ),\n );\n\n return compositeChildCollection;\n }\n\n /**\n * Get input value of contributions\n */\n getInputValue(): string {\n return this.collection.map((child) => child.inputvalue).join(\",\");\n }\n\n /**\n * Validate input\n */\n validate(): boolean {\n return this.collection.every((child) => child.isValid);\n }\n\n /**\n * Retrieve error messages of this attribute\n */\n get errorCollection(): ErrorCollection {\n return new ErrorCollection(\"compositechildren\");\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.serverErrors.length > 0 ||\n this.collection.some((child) => child.hasServerErrors())\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.collection.some((child) => child.hasErrors())\n );\n }\n\n /**\n * Reset attribute to empty string\n */\n reset() {\n this.collection.forEach((child) => {\n child.reset();\n });\n }\n\n /**\n */\n get initvalue(): any {\n if (this.first instanceof CompositeAttributeChildCollection) {\n // $FlowFixMe[missing-type-arg]\n return this.collection.map<Array<Object>>(\n (collection) => collection.initvalue,\n );\n }\n\n const children: { [string]: any } = {};\n this.collection\n .filter((child) => child.initvalue !== null)\n .forEach((child) => {\n children[child.key] = child.initvalue;\n });\n\n if (Object.keys(children).length === 0) {\n return null;\n }\n\n return children;\n }\n\n /**\n */\n get value(): any {\n if (this.first instanceof CompositeAttributeChildCollection) {\n return this.collection.map((collection) => collection.value);\n }\n\n let children: { [string]: any } = {};\n\n this.collection.forEach((attribute) => {\n if (attribute.formdata !== null && !attribute.readonly) {\n children = {\n ...children,\n ...attribute.formdata,\n };\n }\n });\n\n if (Object.keys(children).length === 0) {\n return null;\n }\n\n return children;\n }\n\n /**\n */\n get readonlyvalue(): string {\n if (this.first instanceof CompositeAttributeChildCollection) {\n return this.collection\n .map((collection) => collection.readonlyvalue)\n .join(\" | \");\n }\n\n return this.collection\n .filter((child) => child.value !== null)\n .map((child) => child.readonlyvalue)\n .join(\", \");\n }\n\n /**\n */\n updateValidations(prefix: string, errors: Object) {\n this.collection.forEach((child) => {\n const attributeErrors = errors.filter(\n (error) => error.anchor?.elementid === `${prefix}${child.key}`,\n );\n\n child.updateValidations(attributeErrors);\n });\n }\n\n /**\n */\n hasValue(): boolean {\n return this.collection.some((child) => child.hasValue());\n }\n}\n\nexport default CompositeAttributeChildCollection;\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACA,MAAMG,iCAAiC,SAASC,2BAAkB,CAAgB;EAChF;AACF;EACE,OAAOC,MAAMA,CACXC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EACQ;IACnC,IACEF,IAAI,IACJC,aAAa,IACbE,KAAK,CAACC,OAAO,CAACH,aAAa,CAACI,QAAQ,CAAC,IACrCF,KAAK,CAACC,OAAO,CAACJ,IAAI,CAACK,QAAQ,CAAC,EAC5B;MACA;MACA;MACA,MAAMC,mBAAmB,GAAGH,KAAK,CAACC,OAAO,CAACJ,IAAI,CAACK,QAAQ,CAAC,CAAC,CAAC,CAAC;MAC3D,IAAIC,mBAAmB,EAAE;QACvB,OAAOT,iCAAiC,CAACU,eAAe,CACtDP,IAAI,EACJC,aAAa,EACbC,YACF,CAAC;MACH;MAEA,OAAOL,iCAAiC,CAACW,cAAc,CACrDR,IAAI,EACJC,aAAa,EACbC,YACF,CAAC;IACH;IAEA,OAAO,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AA,EAAAiD,UAAA,OAAI,CAACnD,UAAU,EAAAI,IAAA,CAAA+C,UAAA,EACXzB,KAAK,IAAKA,KAAK,CAACoB,KAAK,KAAK,IAAI,CAAC,EAAA1C,IAAA,CAAA8C,SAAA,EAClCxB,KAAK,IAAKA,KAAK,CAACuB,aAAa,CAAC,CACnCrB,IAAI,CAAC,IAAI,CAAC;EACf;;EAEA;AACF;EACEyB,iBAAiBA,CAACC,MAAc,EAAEC,MAAc,EAAE;IAChD,IAAI,CAACvD,UAAU,CAACyC,OAAO,CAAEf,KAAK,IAAK;MACjC,MAAM8B,eAAe,GAAG,IAAAvD,OAAA,CAAAC,OAAA,EAAAqD,MAAM,EAAAnD,IAAA,CAANmD,MAAM,EAC3BE,KAAK,IAAKA,KAAK,CAACC,MAAM,EAAEC,SAAS,KAAK,GAAGL,MAAM,GAAG5B,KAAK,CAAClB,GAAG,EAC9D,CAAC;MAEDkB,KAAK,CAAC2B,iBAAiB,CAACG,eAAe,CAAC;IAC1C,CAAC,CAAC;EACJ;;EAEA;AACF;EACEI,QAAQA,CAAA,EAAY;IAClB,OAAO,IAAI,CAAC5D,UAAU,CAACqC,IAAI,CAAEX,KAAK,IAAKA,KAAK,CAACkC,QAAQ,CAAC,CAAC,CAAC;EAC1D;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA5D,OAAA,GAEcjB,iCAAiC","ignoreList":[]}
|
|
@@ -220,8 +220,8 @@ class ConceptDetailModel extends _ResourceModel.default {
|
|
|
220
220
|
* Get text fragments by id
|
|
221
221
|
*/
|
|
222
222
|
getTextFragmentByKeys(keys) {
|
|
223
|
-
var
|
|
224
|
-
return (0, _filter.default)(
|
|
223
|
+
var _context0;
|
|
224
|
+
return (0, _filter.default)(_context0 = this.textfragments).call(_context0, textfragment => (0, _includes.default)(keys).call(keys, textfragment.type));
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
/**
|
|
@@ -244,21 +244,21 @@ class ConceptDetailModel extends _ResourceModel.default {
|
|
|
244
244
|
getSourceReferencesForCurrentLanguage(availableLocales) {
|
|
245
245
|
const LANGUAGE_POSTFIX_LENGTH = 3;
|
|
246
246
|
if (this.data.sourceReferences) {
|
|
247
|
-
var
|
|
248
|
-
const availableLanguagesInSourceReferences = (0, _map.default)(
|
|
247
|
+
var _context1, _context12;
|
|
248
|
+
const availableLanguagesInSourceReferences = (0, _map.default)(_context1 = this.data.sourceReferences).call(_context1, sourceReference => sourceReference.type.substring(sourceReference.type.length - LANGUAGE_POSTFIX_LENGTH));
|
|
249
249
|
const currentLanguagePostfix = `_${this.locale}`;
|
|
250
250
|
if ((0, _includes.default)(availableLanguagesInSourceReferences).call(availableLanguagesInSourceReferences, currentLanguagePostfix)) {
|
|
251
|
-
var
|
|
251
|
+
var _context10;
|
|
252
252
|
// return all sourceReferences that end with language that is selected
|
|
253
|
-
return (0, _filter.default)(
|
|
254
|
-
var
|
|
255
|
-
return (0, _endsWith.default)(
|
|
253
|
+
return (0, _filter.default)(_context10 = this.data.sourceReferences).call(_context10, sourceReference => {
|
|
254
|
+
var _context11;
|
|
255
|
+
return (0, _endsWith.default)(_context11 = sourceReference.type).call(_context11, currentLanguagePostfix);
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
258
|
const availableLanguages = (0, _map.default)(availableLocales).call(availableLocales, locale => `_${locale.split("-")[0]}`);
|
|
259
259
|
|
|
260
260
|
// return all sourceReferences that do not end with language postfix
|
|
261
|
-
return (0, _filter.default)(
|
|
261
|
+
return (0, _filter.default)(_context12 = this.data.sourceReferences).call(_context12, sourceReference => !(0, _includes.default)(availableLanguages).call(availableLanguages, sourceReference.type.substring(sourceReference.type.length - LANGUAGE_POSTFIX_LENGTH)));
|
|
262
262
|
}
|
|
263
263
|
return [];
|
|
264
264
|
}
|