@beinformed/ui 1.45.0 → 1.45.2
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 +15 -0
- package/esm/models/attributes/AttributeDataHelper.js +12 -2
- package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +16 -10
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/attributes/AttributeDataHelper.js +12 -2
- package/lib/models/attributes/AttributeDataHelper.js.flow +14 -2
- package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
- package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +85 -0
- package/lib/models/form/FormObjectModel.js +16 -10
- package/lib/models/form/FormObjectModel.js.flow +13 -9
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/package.json +1 -1
- package/src/models/attributes/AttributeDataHelper.js +14 -2
- package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +85 -0
- package/src/models/form/FormObjectModel.js +13 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.45.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.45.0...v1.45.2) (2024-03-28)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **CompositeAttributeModel:** prioritizes parent attribute null value over child values in composite attributes ([f717455](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/f7174552c11241cb8ecaa13d67027612bfe6b809))
|
|
11
|
+
* **form-validation:** missing validation should check if missing is for current object id ([03297e6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/03297e63ee422aadd89a12a4f3346e4351f75c22))
|
|
12
|
+
|
|
13
|
+
## [1.45.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.45.0...v1.45.1) (2024-03-27)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* **CompositeAttributeModel:** prioritizes parent attribute null value over child values in composite attributes ([f717455](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/f7174552c11241cb8ecaa13d67027612bfe6b809))
|
|
19
|
+
|
|
5
20
|
## [1.45.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.44.5...v1.45.0) (2024-03-25)
|
|
6
21
|
|
|
7
22
|
|
|
@@ -86,6 +86,15 @@ class AttributeDataHelper {
|
|
|
86
86
|
*/
|
|
87
87
|
createChildren(data) {
|
|
88
88
|
let childrenKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
89
|
+
// Check if the original data explicitly contains the key and is explicitly null.
|
|
90
|
+
const keyExplicitlyNull = this.value === null;
|
|
91
|
+
if (keyExplicitlyNull) {
|
|
92
|
+
// Handling for when the value is explicitly null: set childData to null.
|
|
93
|
+
return _mapInstanceProperty(childrenKeys).call(childrenKeys, keyObject => {
|
|
94
|
+
const childData = null;
|
|
95
|
+
return this.createChild(data, childData, keyObject);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
89
98
|
const childrenIsArray = Array.isArray(this.value);
|
|
90
99
|
if (childrenIsArray) {
|
|
91
100
|
var _context2;
|
|
@@ -119,7 +128,7 @@ class AttributeDataHelper {
|
|
|
119
128
|
var _context3, _context4;
|
|
120
129
|
return _mapInstanceProperty(_context3 = _filterInstanceProperty(_context4 = attribute.options).call(_context4, option => option.selected)).call(_context3, option => option.code || option.key);
|
|
121
130
|
}
|
|
122
|
-
return
|
|
131
|
+
return undefined;
|
|
123
132
|
}
|
|
124
133
|
|
|
125
134
|
/**
|
|
@@ -231,9 +240,10 @@ class AttributeDataHelper {
|
|
|
231
240
|
*/
|
|
232
241
|
getData() {
|
|
233
242
|
var _context5;
|
|
243
|
+
const value = this.value === undefined ? null : this.value;
|
|
234
244
|
return {
|
|
235
245
|
key: this.key,
|
|
236
|
-
value:
|
|
246
|
+
value: value,
|
|
237
247
|
static: this.static,
|
|
238
248
|
_links: this.links,
|
|
239
249
|
dynamicschema: this.dynamicschema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeDataHelper.js","names":["klona","pick","has","isPlainObject","AttributeDataHelper","constructor","data","key","childrenKeys","_defineProperty","_key","Array","isArray","_attribute","_findInstanceProperty","call","attr","elementid","name","param","_value","getValue","attributeData","_links","undefined","_children","createChildren","childData","parentKey","childKey","elements","_context","element","parentData","content","createChild","keyObject","dynamicschema","dynamicschemaId","children","arguments","length","childrenIsArray","value","_context2","_mapInstanceProperty","attribute","_valuesInstanceProperty","suggestions","suggestion","options","_context3","_context4","_filterInstanceProperty","option","selected","code","static","links","attrDS","message","isResult","referenceDate","pickedContent","_Object$keys","getData","_context5","child","subChild"],"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"sourcesContent":["// @flow\nimport { klona } from \"klona/full\";\nimport pick from \"lodash/pick\";\n\nimport { has, isPlainObject } from \"../../utils/helpers/objects\";\n\n/**\n * This util helps to normalize various attribute data formats available in the modular ui.\n * It fixes differences in choice attributes with dynamic schema's, links on download attributes, composites with various children, etc\n *\n * @private\n */\nclass AttributeDataHelper {\n _key: string;\n _attribute: Object;\n _value: any;\n _children: Array<AttributeDataHelper>;\n\n /**\n */\n constructor(\n data: Object | Array<Object>,\n key: string,\n childrenKeys: Array<Object>,\n ) {\n this._key = key;\n\n if (Array.isArray(data)) {\n this._attribute =\n data.find(\n (attr) =>\n attr.elementid === key || attr.name === key || attr.param === key,\n ) || {};\n this._value = this.getValue(this._attribute);\n } else {\n const attributeData = klona(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n if (data[key] === undefined || (\"name\" in data && \"param\" in data)) {\n this._value = this.getValue(data);\n } else {\n this._value = data[key];\n }\n }\n\n this._children = this.createChildren(data, childrenKeys);\n }\n\n /**\n */\n childData(\n data: Object | Array<Object>,\n parentKey: string,\n childKey: string,\n ): Object {\n if (Array.isArray(data)) {\n if (Array.isArray(this._attribute.elements)) {\n return this._attribute.elements.find(\n (element) => element.elementid === childKey,\n );\n }\n } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {\n const parentData = data[parentKey];\n if (isPlainObject(parentData) && data.content?.[childKey]) {\n return { ...parentData, content: data.content[childKey] };\n }\n return parentData;\n } else if (has(data, childKey) && isPlainObject(data[childKey])) {\n return data[childKey];\n }\n\n if (isPlainObject(data)) {\n return data;\n }\n\n return {};\n }\n\n /**\n */\n createChild(\n data: Object | Array<Object>,\n childData: Object,\n keyObject: Object,\n ): AttributeDataHelper {\n const dynamicschema =\n isPlainObject(data) && !Array.isArray(data)\n ? data.dynamicschema\n : undefined;\n\n let dynamicschemaId = null;\n if (keyObject.dynamicschemaId) {\n dynamicschemaId = keyObject.dynamicschemaId;\n } else if (\n isPlainObject(data) &&\n typeof data.key === \"string\" &&\n keyObject.key\n ) {\n dynamicschemaId = `${data.key}.${keyObject.key}`;\n }\n\n return new AttributeDataHelper(\n {\n ...childData,\n dynamicschema,\n dynamicschemaId,\n },\n keyObject.key,\n keyObject.children,\n );\n }\n\n /**\n */\n createChildren(\n data: Object | Array<Object>,\n childrenKeys: Array<Object> = [],\n ): Array<AttributeDataHelper> {\n const childrenIsArray = Array.isArray(this.value);\n\n if (childrenIsArray) {\n return this.value.map((value) =>\n childrenKeys.map((keyObject) => {\n const childData = this.childData(value, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n }),\n );\n }\n\n return childrenKeys.map((keyObject) => {\n const childData = this.childData(data, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n });\n }\n\n /**\n */\n getValue(attribute: Object): any {\n if (\"values\" in attribute) {\n return attribute.values;\n }\n\n if (\"value\" in attribute) {\n return attribute.value;\n }\n\n if (\"suggestions\" in attribute) {\n return attribute.suggestions;\n }\n\n if (\"suggestion\" in attribute) {\n return attribute.suggestion;\n }\n\n if (Array.isArray(attribute.options)) {\n return attribute.options\n .filter((option) => option.selected)\n .map((option) => option.code || option.key);\n }\n\n return null;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n get value(): any {\n return this._value;\n }\n\n /**\n */\n get static(): boolean {\n return this._attribute.static || false;\n }\n\n /**\n */\n get links(): any {\n return this._attribute._links || void 0;\n }\n\n /**\n */\n get dynamicschemaId(): string {\n return this._attribute.dynamicschemaId || this.key;\n }\n\n /*\n retrieve the dynamischema by the dynamischemaId\n mentioned in the contributions of the attribute\n */\n /**\n */\n get dynamicschema(): any {\n const { dynamicschema } = this._attribute;\n if (!dynamicschema) {\n return void 0;\n }\n\n if (Array.isArray(dynamicschema)) {\n return dynamicschema;\n } else if (dynamicschema[this.dynamicschemaId]) {\n const attrDS = dynamicschema[this.dynamicschemaId];\n return attrDS.map((attr) => {\n if (attr.elements) {\n return {\n ...attr,\n elements: {\n ...attr.elements,\n dynamicschema,\n },\n };\n }\n\n return attr;\n });\n }\n\n return void 0;\n }\n\n /**\n */\n get options(): any {\n return this._attribute.options || void 0;\n }\n\n /**\n */\n get message(): any {\n return this._attribute.message || void 0;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._attribute.isResult || false;\n }\n\n /**\n */\n get referenceDate(): any {\n return this._attribute.referenceDate || void 0;\n }\n\n /**\n */\n get children(): Array<AttributeDataHelper> {\n return this._children || [];\n }\n\n /**\n */\n get content(): Object {\n if (this._attribute.content) {\n const pickedContent = pick(this._attribute.content, [\n \"header\",\n \"label\",\n \"elements\",\n \"layouthint\",\n \"text\",\n ]);\n\n if (Object.keys(pickedContent).length > 0) {\n return pickedContent;\n }\n }\n\n return null;\n }\n\n /**\n */\n getData(): Object {\n return {\n key: this.key,\n value: this.value,\n static: this.static,\n _links: this.links,\n dynamicschema: this.dynamicschema,\n dynamicschemaId: this.dynamicschemaId,\n options: this.options,\n message: this.message,\n isResult: this.isResult,\n referenceDate: this.referenceDate,\n children: this.children.map((child) =>\n Array.isArray(child)\n ? child.map((subChild) => subChild.getData())\n : child.getData(),\n ),\n content: this.content,\n };\n }\n}\n\nexport default AttributeDataHelper;\n"],"mappings":";;;;;;AACA,SAASA,KAAK,QAAQ,YAAY;AAClC,OAAOC,IAAI,MAAM,aAAa;AAE9B,SAASC,GAAG,EAAEC,aAAa,QAAQ,6BAA6B;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,CAAC;EAMxB;AACF;EACEC,WAAWA,CACTC,IAA4B,EAC5BC,GAAW,EACXC,YAA2B,EAC3B;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACA,IAAI,CAACC,IAAI,GAAGH,GAAG;IAEf,IAAII,KAAK,CAACC,OAAO,CAACN,IAAI,CAAC,EAAE;MACvB,IAAI,CAACO,UAAU,GACbC,qBAAA,CAAAR,IAAI,EAAAS,IAAA,CAAJT,IAAI,EACDU,IAAI,IACHA,IAAI,CAACC,SAAS,KAAKV,GAAG,IAAIS,IAAI,CAACE,IAAI,KAAKX,GAAG,IAAIS,IAAI,CAACG,KAAK,KAAKZ,GAClE,CAAC,IAAI,CAAC,CAAC;MACT,IAAI,CAACa,MAAM,GAAG,IAAI,CAACC,QAAQ,CAAC,IAAI,CAACR,UAAU,CAAC;IAC9C,CAAC,MAAM;MACL,MAAMS,aAAa,GAAGtB,KAAK,CAACM,IAAI,CAAC;MACjCgB,aAAa,CAACC,MAAM,GAAGtB,IAAI,CAACK,IAAI,CAACiB,MAAM,EAAE,CACvC,SAAS,EACT,UAAU,EACV,eAAe,EACf,YAAY,CACb,CAAC;MAEF,IAAI,CAACV,UAAU,GAAGS,aAAa;MAE/B,IAAIhB,IAAI,CAACC,GAAG,CAAC,KAAKiB,SAAS,IAAK,MAAM,IAAIl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,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBU,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBC,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBC,aAAa,EAAE,IAAI,CAACA,aAAa;MACjCvB,QAAQ,EAAEM,oBAAA,CAAAqB,SAAA,OAAI,CAAC3B,QAAQ,EAAAxB,IAAA,CAAAmD,SAAA,EAAMC,KAAK,IAChCxD,KAAK,CAACC,OAAO,CAACuD,KAAK,CAAC,GAChBtB,oBAAA,CAAAsB,KAAK,EAAApD,IAAA,CAALoD,KAAK,EAAMC,QAAQ,IAAKA,QAAQ,CAACH,OAAO,CAAC,CAAC,CAAC,GAC3CE,KAAK,CAACF,OAAO,CAAC,CACpB,CAAC;MACD/B,OAAO,EAAE,IAAI,CAACA;IAChB,CAAC;EACH;AACF;AAEA,eAAe9B,mBAAmB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"AttributeDataHelper.js","names":["klona","pick","has","isPlainObject","AttributeDataHelper","constructor","data","key","childrenKeys","_defineProperty","_key","Array","isArray","_attribute","_findInstanceProperty","call","attr","elementid","name","param","_value","getValue","attributeData","_links","undefined","_children","createChildren","childData","parentKey","childKey","elements","_context","element","parentData","content","createChild","keyObject","dynamicschema","dynamicschemaId","children","arguments","length","keyExplicitlyNull","value","_mapInstanceProperty","childrenIsArray","_context2","attribute","_valuesInstanceProperty","suggestions","suggestion","options","_context3","_context4","_filterInstanceProperty","option","selected","code","static","links","attrDS","message","isResult","referenceDate","pickedContent","_Object$keys","getData","_context5","child","subChild"],"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"sourcesContent":["// @flow\nimport { klona } from \"klona/full\";\nimport pick from \"lodash/pick\";\n\nimport { has, isPlainObject } from \"../../utils/helpers/objects\";\n\n/**\n * This util helps to normalize various attribute data formats available in the modular ui.\n * It fixes differences in choice attributes with dynamic schema's, links on download attributes, composites with various children, etc\n *\n * @private\n */\nclass AttributeDataHelper {\n _key: string;\n _attribute: Object;\n _value: any;\n _children: Array<AttributeDataHelper>;\n\n /**\n */\n constructor(\n data: Object | Array<Object>,\n key: string,\n childrenKeys: Array<Object>,\n ) {\n this._key = key;\n\n if (Array.isArray(data)) {\n this._attribute =\n data.find(\n (attr) =>\n attr.elementid === key || attr.name === key || attr.param === key,\n ) || {};\n this._value = this.getValue(this._attribute);\n } else {\n const attributeData = klona(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n if (data[key] === undefined || (\"name\" in data && \"param\" in data)) {\n this._value = this.getValue(data);\n } else {\n this._value = data[key];\n }\n }\n\n this._children = this.createChildren(data, childrenKeys);\n }\n\n /**\n */\n childData(\n data: Object | Array<Object>,\n parentKey: string,\n childKey: string,\n ): Object {\n if (Array.isArray(data)) {\n if (Array.isArray(this._attribute.elements)) {\n return this._attribute.elements.find(\n (element) => element.elementid === childKey,\n );\n }\n } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {\n const parentData = data[parentKey];\n if (isPlainObject(parentData) && data.content?.[childKey]) {\n return { ...parentData, content: data.content[childKey] };\n }\n return parentData;\n } else if (has(data, childKey) && isPlainObject(data[childKey])) {\n return data[childKey];\n }\n\n if (isPlainObject(data)) {\n return data;\n }\n\n return {};\n }\n\n /**\n */\n createChild(\n data: Object | Array<Object>,\n childData: Object,\n keyObject: Object,\n ): AttributeDataHelper {\n const dynamicschema =\n isPlainObject(data) && !Array.isArray(data)\n ? data.dynamicschema\n : undefined;\n\n let dynamicschemaId = null;\n if (keyObject.dynamicschemaId) {\n dynamicschemaId = keyObject.dynamicschemaId;\n } else if (\n isPlainObject(data) &&\n typeof data.key === \"string\" &&\n keyObject.key\n ) {\n dynamicschemaId = `${data.key}.${keyObject.key}`;\n }\n\n return new AttributeDataHelper(\n {\n ...childData,\n dynamicschema,\n dynamicschemaId,\n },\n keyObject.key,\n keyObject.children,\n );\n }\n\n /**\n */\n createChildren(\n data: Object | Array<Object>,\n childrenKeys: Array<Object> = [],\n ): Array<AttributeDataHelper> {\n // Check if the original data explicitly contains the key and is explicitly null.\n const keyExplicitlyNull = this.value === null;\n\n if (keyExplicitlyNull) {\n // Handling for when the value is explicitly null: set childData to null.\n return childrenKeys.map((keyObject) => {\n const childData = null;\n return this.createChild(data, childData, keyObject);\n });\n }\n\n const childrenIsArray = Array.isArray(this.value);\n\n if (childrenIsArray) {\n return this.value.map((value) =>\n childrenKeys.map((keyObject) => {\n const childData = this.childData(value, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n }),\n );\n }\n\n return childrenKeys.map((keyObject) => {\n const childData = this.childData(data, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n });\n }\n\n /**\n */\n getValue(attribute: Object): any {\n if (\"values\" in attribute) {\n return attribute.values;\n }\n\n if (\"value\" in attribute) {\n return attribute.value;\n }\n\n if (\"suggestions\" in attribute) {\n return attribute.suggestions;\n }\n\n if (\"suggestion\" in attribute) {\n return attribute.suggestion;\n }\n\n if (Array.isArray(attribute.options)) {\n return attribute.options\n .filter((option) => option.selected)\n .map((option) => option.code || option.key);\n }\n\n return undefined;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n get value(): any {\n return this._value;\n }\n\n /**\n */\n get static(): boolean {\n return this._attribute.static || false;\n }\n\n /**\n */\n get links(): any {\n return this._attribute._links || void 0;\n }\n\n /**\n */\n get dynamicschemaId(): string {\n return this._attribute.dynamicschemaId || this.key;\n }\n\n /*\n retrieve the dynamischema by the dynamischemaId\n mentioned in the contributions of the attribute\n */\n /**\n */\n get dynamicschema(): any {\n const { dynamicschema } = this._attribute;\n if (!dynamicschema) {\n return void 0;\n }\n\n if (Array.isArray(dynamicschema)) {\n return dynamicschema;\n } else if (dynamicschema[this.dynamicschemaId]) {\n const attrDS = dynamicschema[this.dynamicschemaId];\n return attrDS.map((attr) => {\n if (attr.elements) {\n return {\n ...attr,\n elements: {\n ...attr.elements,\n dynamicschema,\n },\n };\n }\n\n return attr;\n });\n }\n\n return void 0;\n }\n\n /**\n */\n get options(): any {\n return this._attribute.options || void 0;\n }\n\n /**\n */\n get message(): any {\n return this._attribute.message || void 0;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._attribute.isResult || false;\n }\n\n /**\n */\n get referenceDate(): any {\n return this._attribute.referenceDate || void 0;\n }\n\n /**\n */\n get children(): Array<AttributeDataHelper> {\n return this._children || [];\n }\n\n /**\n */\n get content(): Object {\n if (this._attribute.content) {\n const pickedContent = pick(this._attribute.content, [\n \"header\",\n \"label\",\n \"elements\",\n \"layouthint\",\n \"text\",\n ]);\n\n if (Object.keys(pickedContent).length > 0) {\n return pickedContent;\n }\n }\n\n return null;\n }\n\n /**\n */\n getData(): Object {\n const value = this.value === undefined ? null : this.value;\n return {\n key: this.key,\n value: value,\n static: this.static,\n _links: this.links,\n dynamicschema: this.dynamicschema,\n dynamicschemaId: this.dynamicschemaId,\n options: this.options,\n message: this.message,\n isResult: this.isResult,\n referenceDate: this.referenceDate,\n children: this.children.map((child) =>\n Array.isArray(child)\n ? child.map((subChild) => subChild.getData())\n : child.getData(),\n ),\n content: this.content,\n };\n }\n}\n\nexport default AttributeDataHelper;\n"],"mappings":";;;;;;AACA,SAASA,KAAK,QAAQ,YAAY;AAClC,OAAOC,IAAI,MAAM,aAAa;AAE9B,SAASC,GAAG,EAAEC,aAAa,QAAQ,6BAA6B;;AAEhE;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,mBAAmB,CAAC;EAMxB;AACF;EACEC,WAAWA,CACTC,IAA4B,EAC5BC,GAAW,EACXC,YAA2B,EAC3B;IAAAC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IACA,IAAI,CAACC,IAAI,GAAGH,GAAG;IAEf,IAAII,KAAK,CAACC,OAAO,CAACN,IAAI,CAAC,EAAE;MACvB,IAAI,CAACO,UAAU,GACbC,qBAAA,CAAAR,IAAI,EAAAS,IAAA,CAAJT,IAAI,EACDU,I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ChBxB,oBAAA,CAAAwB,KAAK,EAAArD,IAAA,CAALqD,KAAK,EAAMC,QAAQ,IAAKA,QAAQ,CAACH,OAAO,CAAC,CAAC,CAAC,GAC3CE,KAAK,CAACF,OAAO,CAAC,CACpB,CAAC;MACDhC,OAAO,EAAE,IAAI,CAACA;IAChB,CAAC;EACH;AACF;AAEA,eAAe9B,mBAAmB","ignoreList":[]}
|
|
@@ -401,20 +401,26 @@ export default class FormObjectModel extends BaseModel {
|
|
|
401
401
|
handleMissingValidations(missing) {
|
|
402
402
|
const attributeErrors = [];
|
|
403
403
|
for (const anchor of missing.anchors) {
|
|
404
|
-
|
|
405
|
-
|
|
404
|
+
const {
|
|
405
|
+
objectid,
|
|
406
|
+
elements
|
|
407
|
+
} = anchor;
|
|
408
|
+
if (!objectid || objectid === this.key) {
|
|
409
|
+
if (Array.isArray(elements)) {
|
|
410
|
+
for (const element of elements) {
|
|
411
|
+
attributeErrors.push({
|
|
412
|
+
anchor: {
|
|
413
|
+
elementid: element.elementid
|
|
414
|
+
},
|
|
415
|
+
id: "Constraint.Mandatory"
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
} else {
|
|
406
419
|
attributeErrors.push({
|
|
407
|
-
anchor
|
|
408
|
-
elementid: element.elementid
|
|
409
|
-
},
|
|
420
|
+
anchor,
|
|
410
421
|
id: "Constraint.Mandatory"
|
|
411
422
|
});
|
|
412
423
|
}
|
|
413
|
-
} else {
|
|
414
|
-
attributeErrors.push({
|
|
415
|
-
anchor,
|
|
416
|
-
id: "Constraint.Mandatory"
|
|
417
|
-
});
|
|
418
424
|
}
|
|
419
425
|
}
|
|
420
426
|
this.attributeCollection.updateValidations(attributeErrors);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormObjectModel.js","names":["has","BaseModel","AttributeCollection","CompositeAttributeModel","ContentConfiguration","ErrorCollection","IllegalArgumentException","LayoutHintCollection","FormObjectModel","constructor","object","objectContributions","_defineProperty","getElements","length","_attributeCollection","getApplicableAttributeContributions","_contentConfiguration","content","_errorCollection","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","contributions","equals","_context","withRepeatIndex","arguments","undefined","key","objectContainsOneOfTheAttributes","_filterInstanceProperty","all","call","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","_context2","dataResults","_mapInstanceProperty","result","elementid","_context3","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","_Object$keys","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","setChildModels","models","objectid","hasEndResultConfiguration","getContribution","hasDynamicValidations","isRepeatable","_repeatIndex","index","maxRepeats","hasFixedNrOfRepeats","isRepeatWithUnknownTotal","isLastRepeat","last","repeatIndexLabel","label","introText","text","message","assistent","buttonLabels","mergeObject","oldObject","forEach","mergeWithAttribute","mergeAttribute","updateAttribute","value","attributeToUpdate","Error","name","update","isChangedSince","timestamp","_context4","_findInstanceProperty","resetErrors","errorCollection","addServerError","error","anchor","id","properties","layouthint","hasServerErrors","hasItems","hasErrors","isValid","visible","every","dynamicValidationsLoaded","_dynamicValidationsLoaded","handleErrorValidations","errors","attributeErrors","updateValidations","handleMissingValidations","missing","anchors","Array","isArray","formdata","getFormData","validationData"],"sources":["../../../src/models/form/FormObjectModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { AttributeType, ModularUIModel, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport type { MessageParameters } from \"../../i18n\";\n\n/**\n * Form Object\n */\nexport default class FormObjectModel extends BaseModel {\n _attributeCollection: AttributeCollection;\n _contentConfiguration: ContentConfiguration;\n _errorCollection: ErrorCollection;\n _repeatIndex: number;\n _dynamicValidationsLoaded: boolean;\n\n /**\n * Construct FormObjectModel\n */\n constructor(object: Object, objectContributions: Object) {\n super(object, objectContributions);\n\n if (object && this.getElements().length > 0) {\n this._attributeCollection = new AttributeCollection(\n this.getElements(),\n this.getApplicableAttributeContributions(),\n );\n } else {\n this._attributeCollection = new AttributeCollection();\n }\n\n this._contentConfiguration = new ContentConfiguration(\n objectContributions ? objectContributions.content : {},\n );\n\n this._errorCollection = new ErrorCollection(\"formobject\");\n\n if (has(this.data, \"referenceDate\")) {\n this.attributeCollection.setReferenceDate(this.getData(\"referenceDate\"));\n }\n\n this.attributeCollection.indicateContentConfiguration(\n this.contentConfiguration,\n );\n }\n\n /**\n */\n static createEmpty(formObjectModel: FormObjectModel): FormObjectModel {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\n \"createEmpty method needs a FormObjectModel as input argument to create a new version of the object\",\n );\n }\n return new FormObjectModel(\n formObjectModel.data,\n formObjectModel.contributions,\n );\n }\n\n /**\n */\n equals(object: ?FormObjectModel, withRepeatIndex: boolean = true): boolean {\n if (!object || this.key !== object.key) {\n return false;\n }\n\n const objectContainsOneOfTheAttributes = this.attributeCollection.all\n .filter((attribute) => !attribute.isResult)\n .some(\n (attribute) =>\n object && object.attributeCollection.hasAttributeByKey(attribute.key),\n );\n\n const hasSameRepeatIndex = withRepeatIndex\n ? this.repeatIndex === object.repeatIndex\n : true;\n\n return hasSameRepeatIndex && objectContainsOneOfTheAttributes;\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.attributeCollection.getAttributeByAttribute(attribute);\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.attributeCollection.hasAttributeByKey(key);\n }\n\n /**\n * Get elements from both the missing attributes and the result attributes\n */\n getElements(): Array<Object> {\n const elements = [];\n\n if (this.data.elements) {\n elements.push(...this.data.elements);\n }\n\n if (this.data.results) {\n const dataResults = this.data.results.map((result) => ({\n ...result,\n isResult: true,\n }));\n\n elements.push(...dataResults);\n }\n\n if (this.data.elementid) {\n elements.push({\n ...this.data,\n });\n }\n\n return elements;\n }\n\n /**\n * Map available contributions on the available data. Only use contributions that are needed for the data\n */\n getApplicableAttributeContributions(): Array<Object> {\n if (this.data && this.contributions) {\n const dataElementIds = this.getElements().map(\n (element) => element.elementid,\n );\n\n const contributions = this.getAttributesInData(\n dataElementIds,\n this.contributions.attributes,\n );\n\n // set all attribute mandatory for dynamic object\n if (this.isDynamic) {\n return contributions.map((attribute) => {\n const [attributeKey] = Object.keys(attribute);\n return {\n [attributeKey]: {\n ...attribute[attributeKey],\n mandatory: true,\n },\n };\n });\n }\n\n return contributions;\n }\n\n return [];\n }\n\n /**\n * Recursevily check if an attribute id occurs in the tree of attribute contributions.\n * The complete leaf of the tree is returned when an attribute id matches\n */\n getAttributesInData(\n dataElementIds: Array<string>,\n attributesContributions: Object,\n ): Array<Object> {\n return attributesContributions.filter((attributeContributions) => {\n const [attributeKey] = Object.keys(attributeContributions);\n\n return dataElementIds.some(\n (dataElementId) => dataElementId.split(\".\")[0] === attributeKey,\n );\n });\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this._attributeCollection.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n }\n\n /**\n * get key\n */\n get key(): string {\n return this.data.objectid;\n }\n\n /**\n * Get content configuration for form objects\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n get hasEndResultConfiguration(): boolean {\n return this.contributions.content?.results != null;\n }\n\n /**\n * Indicates if object is dynamic. A dynamic object should be submitted on each attribute change\n */\n get isDynamic(): boolean {\n return this.getContribution(\"dynamicObject\", false);\n }\n\n /**\n */\n get hasDynamicValidations(): boolean {\n return this.getContribution(\"dynamicValidations\", false);\n }\n\n /**\n * Indicates if object is repeatable\n */\n get isRepeatable(): boolean {\n return this.getContribution(\"repeatable\", false);\n }\n\n /**\n */\n get repeatIndex(): number {\n return this._repeatIndex ?? this.data.index ?? 1;\n }\n\n /**\n */\n set repeatIndex(repeatIndex: number) {\n this._repeatIndex = repeatIndex;\n }\n\n /**\n */\n get maxRepeats(): number {\n if (this.isRepeatable) {\n return this.getData(\"numberofrepeats\", -1);\n }\n\n return 1;\n }\n\n /**\n */\n get hasFixedNrOfRepeats(): boolean {\n return this.maxRepeats > -1;\n }\n\n /**\n */\n get isRepeatWithUnknownTotal(): boolean {\n return this.isRepeatable && this.maxRepeats === -1;\n }\n\n /**\n */\n get isLastRepeat(): boolean {\n if (this.isRepeatable) {\n return this.data.last || false;\n }\n\n return true;\n }\n\n /**\n */\n get repeatIndexLabel(): string | null {\n return this.data[\"index-identifier\"] || null;\n }\n\n /**\n * Get label of form object\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Get introText of form object\n */\n get introText(): string {\n if (this.data.content?.text) {\n return this.data.content.text.message;\n }\n\n if (this.contributions.text?.message) {\n return this.contributions.text.message;\n }\n\n return this.contributions.introText;\n }\n\n /**\n * Get assistent of form object\n */\n get assistent(): string {\n return this.contributions.assistent;\n }\n\n /**\n * Get button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * get attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n mergeObject(oldObject: FormObjectModel) {\n this.attributeCollection.forEach((attribute) => {\n const mergeWithAttribute = oldObject.getAttributeByAttribute(attribute);\n if (mergeWithAttribute) {\n attribute.mergeAttribute(mergeWithAttribute);\n }\n });\n\n this.repeatIndex = oldObject.repeatIndex;\n }\n\n /**\n * Update attribute\n */\n updateAttribute(attribute: AttributeType, value: any): AttributeType {\n const attributeToUpdate =\n this.attributeCollection.getAttributeByAttribute(attribute);\n\n if (attributeToUpdate === null) {\n throw new Error(`Attribute with name: ${attribute.name} not found.`);\n }\n\n if (attributeToUpdate instanceof CompositeAttributeModel) {\n attributeToUpdate.update(value, attribute);\n } else {\n attributeToUpdate.update(value);\n }\n\n return attributeToUpdate;\n }\n\n /**\n * Inidicates if Form is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return (\n this.attributeCollection.find((attribute) =>\n attribute.isChangedSince(timestamp),\n ) !== null\n );\n }\n\n /**\n * Reset all errors on Form Object\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"formobject\");\n this.attributeCollection.forEach((attribute) => attribute.resetErrors());\n }\n\n /**\n * Get error messages\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n if (error.anchor?.elementid != null) {\n this.attributeCollection.addServerError(error);\n } else {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n error.layouthint,\n );\n }\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.attributeCollection.hasServerErrors()\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems || this.attributeCollection.hasErrors()\n );\n }\n\n /**\n */\n get isValid(): boolean {\n return (\n this.attributeCollection.visible.every(\n (attribute) => attribute.isValid,\n ) && !this.errorCollection.hasItems\n );\n }\n\n /**\n */\n get dynamicValidationsLoaded(): boolean {\n return this._dynamicValidationsLoaded;\n }\n\n /**\n */\n set dynamicValidationsLoaded(dynamicValidationsLoaded: boolean) {\n this._dynamicValidationsLoaded = dynamicValidationsLoaded;\n }\n\n /**\n * Convert error json from a form service to validation messages on the form object and attributes\n */\n handleErrorValidations(\n errors: Array<{\n anchor: {\n objectid: string,\n elementid?: string,\n },\n id: string,\n message: string,\n properties: MessageParameters,\n layouthint: Array<string>,\n }>,\n ) {\n const attributeErrors = [];\n\n errors.forEach((error) => {\n if (error.anchor?.objectid === this.key) {\n if (has(error.anchor, \"elementid\")) {\n attributeErrors.push(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n new LayoutHintCollection(error.layouthint),\n );\n }\n }\n });\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n * Convert missing json from a form service to mandatory validation constraints and messages\n */\n handleMissingValidations(missing: {\n anchors: Array<\n | {\n elements: Array<{ elementid: string }>,\n }\n | { anchor: { elementid: string } },\n >,\n }) {\n const attributeErrors = [];\n\n for (const anchor of missing.anchors) {\n if (Array.isArray(anchor.elements)) {\n for (const element of anchor.elements) {\n attributeErrors.push({\n anchor: { elementid: element.elementid },\n id: \"Constraint.Mandatory\",\n });\n }\n } else {\n attributeErrors.push({\n anchor,\n id: \"Constraint.Mandatory\",\n });\n }\n }\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n if (Array.isArray(data.errors)) {\n this.handleErrorValidations(data.errors);\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n this.handleMissingValidations(data.missing);\n }\n\n this.dynamicValidationsLoaded = true;\n\n return this;\n }\n\n /**\n * Generate formdata object for current formobject based on formdata of attributes\n */\n get formdata(): { [string]: any } | null {\n return this.attributeCollection.formdata;\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n return this.attributeCollection.getFormData(validationData);\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,mBAAmB,MAAM,mCAAmC;AACnE,OAAOC,uBAAuB,MAAM,uCAAuC;AAC3E,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,CAAA,EAA4D;IAAA,IAA3DC,cAAuB,GAAApG,SAAA,CAAAlB,MAAA,QAAAkB,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,KAAK;IACzC,OAAO,IAAI,CAACX,mBAAmB,CAAC8G,WAAW,CAACC,cAAc,CAAC;EAC7D;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FormObjectModel.js","names":["has","BaseModel","AttributeCollection","CompositeAttributeModel","ContentConfiguration","ErrorCollection","IllegalArgumentException","LayoutHintCollection","FormObjectModel","constructor","object","objectContributions","_defineProperty","getElements","length","_attributeCollection","getApplicableAttributeContributions","_contentConfiguration","content","_errorCollection","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","contributions","equals","_context","withRepeatIndex","arguments","undefined","key","objectContainsOneOfTheAttributes","_filterInstanceProperty","all","call","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","_context2","dataResults","_mapInstanceProperty","result","elementid","_context3","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","_Object$keys","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","setChildModels","models","objectid","hasEndResultConfiguration","getContribution","hasDynamicValidations","isRepeatable","_repeatIndex","index","maxRepeats","hasFixedNrOfRepeats","isRepeatWithUnknownTotal","isLastRepeat","last","repeatIndexLabel","label","introText","text","message","assistent","buttonLabels","mergeObject","oldObject","forEach","mergeWithAttribute","mergeAttribute","updateAttribute","value","attributeToUpdate","Error","name","update","isChangedSince","timestamp","_context4","_findInstanceProperty","resetErrors","errorCollection","addServerError","error","anchor","id","properties","layouthint","hasServerErrors","hasItems","hasErrors","isValid","visible","every","dynamicValidationsLoaded","_dynamicValidationsLoaded","handleErrorValidations","errors","attributeErrors","updateValidations","handleMissingValidations","missing","anchors","Array","isArray","formdata","getFormData","validationData"],"sources":["../../../src/models/form/FormObjectModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { AttributeType, ModularUIModel, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport type { MessageParameters } from \"../../i18n\";\n\n/**\n * Form Object\n */\nexport default class FormObjectModel extends BaseModel {\n _attributeCollection: AttributeCollection;\n _contentConfiguration: ContentConfiguration;\n _errorCollection: ErrorCollection;\n _repeatIndex: number;\n _dynamicValidationsLoaded: boolean;\n\n /**\n * Construct FormObjectModel\n */\n constructor(object: Object, objectContributions: Object) {\n super(object, objectContributions);\n\n if (object && this.getElements().length > 0) {\n this._attributeCollection = new AttributeCollection(\n this.getElements(),\n this.getApplicableAttributeContributions(),\n );\n } else {\n this._attributeCollection = new AttributeCollection();\n }\n\n this._contentConfiguration = new ContentConfiguration(\n objectContributions ? objectContributions.content : {},\n );\n\n this._errorCollection = new ErrorCollection(\"formobject\");\n\n if (has(this.data, \"referenceDate\")) {\n this.attributeCollection.setReferenceDate(this.getData(\"referenceDate\"));\n }\n\n this.attributeCollection.indicateContentConfiguration(\n this.contentConfiguration,\n );\n }\n\n /**\n */\n static createEmpty(formObjectModel: FormObjectModel): FormObjectModel {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\n \"createEmpty method needs a FormObjectModel as input argument to create a new version of the object\",\n );\n }\n return new FormObjectModel(\n formObjectModel.data,\n formObjectModel.contributions,\n );\n }\n\n /**\n */\n equals(object: ?FormObjectModel, withRepeatIndex: boolean = true): boolean {\n if (!object || this.key !== object.key) {\n return false;\n }\n\n const objectContainsOneOfTheAttributes = this.attributeCollection.all\n .filter((attribute) => !attribute.isResult)\n .some(\n (attribute) =>\n object && object.attributeCollection.hasAttributeByKey(attribute.key),\n );\n\n const hasSameRepeatIndex = withRepeatIndex\n ? this.repeatIndex === object.repeatIndex\n : true;\n\n return hasSameRepeatIndex && objectContainsOneOfTheAttributes;\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.attributeCollection.getAttributeByAttribute(attribute);\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.attributeCollection.hasAttributeByKey(key);\n }\n\n /**\n * Get elements from both the missing attributes and the result attributes\n */\n getElements(): Array<Object> {\n const elements = [];\n\n if (this.data.elements) {\n elements.push(...this.data.elements);\n }\n\n if (this.data.results) {\n const dataResults = this.data.results.map((result) => ({\n ...result,\n isResult: true,\n }));\n\n elements.push(...dataResults);\n }\n\n if (this.data.elementid) {\n elements.push({\n ...this.data,\n });\n }\n\n return elements;\n }\n\n /**\n * Map available contributions on the available data. Only use contributions that are needed for the data\n */\n getApplicableAttributeContributions(): Array<Object> {\n if (this.data && this.contributions) {\n const dataElementIds = this.getElements().map(\n (element) => element.elementid,\n );\n\n const contributions = this.getAttributesInData(\n dataElementIds,\n this.contributions.attributes,\n );\n\n // set all attribute mandatory for dynamic object\n if (this.isDynamic) {\n return contributions.map((attribute) => {\n const [attributeKey] = Object.keys(attribute);\n return {\n [attributeKey]: {\n ...attribute[attributeKey],\n mandatory: true,\n },\n };\n });\n }\n\n return contributions;\n }\n\n return [];\n }\n\n /**\n * Recursevily check if an attribute id occurs in the tree of attribute contributions.\n * The complete leaf of the tree is returned when an attribute id matches\n */\n getAttributesInData(\n dataElementIds: Array<string>,\n attributesContributions: Object,\n ): Array<Object> {\n return attributesContributions.filter((attributeContributions) => {\n const [attributeKey] = Object.keys(attributeContributions);\n\n return dataElementIds.some(\n (dataElementId) => dataElementId.split(\".\")[0] === attributeKey,\n );\n });\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this._attributeCollection.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n }\n\n /**\n * get key\n */\n get key(): string {\n return this.data.objectid;\n }\n\n /**\n * Get content configuration for form objects\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n get hasEndResultConfiguration(): boolean {\n return this.contributions.content?.results != null;\n }\n\n /**\n * Indicates if object is dynamic. A dynamic object should be submitted on each attribute change\n */\n get isDynamic(): boolean {\n return this.getContribution(\"dynamicObject\", false);\n }\n\n /**\n */\n get hasDynamicValidations(): boolean {\n return this.getContribution(\"dynamicValidations\", false);\n }\n\n /**\n * Indicates if object is repeatable\n */\n get isRepeatable(): boolean {\n return this.getContribution(\"repeatable\", false);\n }\n\n /**\n */\n get repeatIndex(): number {\n return this._repeatIndex ?? this.data.index ?? 1;\n }\n\n /**\n */\n set repeatIndex(repeatIndex: number) {\n this._repeatIndex = repeatIndex;\n }\n\n /**\n */\n get maxRepeats(): number {\n if (this.isRepeatable) {\n return this.getData(\"numberofrepeats\", -1);\n }\n\n return 1;\n }\n\n /**\n */\n get hasFixedNrOfRepeats(): boolean {\n return this.maxRepeats > -1;\n }\n\n /**\n */\n get isRepeatWithUnknownTotal(): boolean {\n return this.isRepeatable && this.maxRepeats === -1;\n }\n\n /**\n */\n get isLastRepeat(): boolean {\n if (this.isRepeatable) {\n return this.data.last || false;\n }\n\n return true;\n }\n\n /**\n */\n get repeatIndexLabel(): string | null {\n return this.data[\"index-identifier\"] || null;\n }\n\n /**\n * Get label of form object\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Get introText of form object\n */\n get introText(): string {\n if (this.data.content?.text) {\n return this.data.content.text.message;\n }\n\n if (this.contributions.text?.message) {\n return this.contributions.text.message;\n }\n\n return this.contributions.introText;\n }\n\n /**\n * Get assistent of form object\n */\n get assistent(): string {\n return this.contributions.assistent;\n }\n\n /**\n * Get button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * get attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n mergeObject(oldObject: FormObjectModel) {\n this.attributeCollection.forEach((attribute) => {\n const mergeWithAttribute = oldObject.getAttributeByAttribute(attribute);\n if (mergeWithAttribute) {\n attribute.mergeAttribute(mergeWithAttribute);\n }\n });\n\n this.repeatIndex = oldObject.repeatIndex;\n }\n\n /**\n * Update attribute\n */\n updateAttribute(attribute: AttributeType, value: any): AttributeType {\n const attributeToUpdate =\n this.attributeCollection.getAttributeByAttribute(attribute);\n\n if (attributeToUpdate === null) {\n throw new Error(`Attribute with name: ${attribute.name} not found.`);\n }\n\n if (attributeToUpdate instanceof CompositeAttributeModel) {\n attributeToUpdate.update(value, attribute);\n } else {\n attributeToUpdate.update(value);\n }\n\n return attributeToUpdate;\n }\n\n /**\n * Inidicates if Form is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return (\n this.attributeCollection.find((attribute) =>\n attribute.isChangedSince(timestamp),\n ) !== null\n );\n }\n\n /**\n * Reset all errors on Form Object\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"formobject\");\n this.attributeCollection.forEach((attribute) => attribute.resetErrors());\n }\n\n /**\n * Get error messages\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n if (error.anchor?.elementid != null) {\n this.attributeCollection.addServerError(error);\n } else {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n error.layouthint,\n );\n }\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.attributeCollection.hasServerErrors()\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems || this.attributeCollection.hasErrors()\n );\n }\n\n /**\n */\n get isValid(): boolean {\n return (\n this.attributeCollection.visible.every(\n (attribute) => attribute.isValid,\n ) && !this.errorCollection.hasItems\n );\n }\n\n /**\n */\n get dynamicValidationsLoaded(): boolean {\n return this._dynamicValidationsLoaded;\n }\n\n /**\n */\n set dynamicValidationsLoaded(dynamicValidationsLoaded: boolean) {\n this._dynamicValidationsLoaded = dynamicValidationsLoaded;\n }\n\n /**\n * Convert error json from a form service to validation messages on the form object and attributes\n */\n handleErrorValidations(\n errors: Array<{\n anchor: {\n objectid: string,\n elementid?: string,\n },\n id: string,\n message: string,\n properties: MessageParameters,\n layouthint: Array<string>,\n }>,\n ) {\n const attributeErrors = [];\n\n errors.forEach((error) => {\n if (error.anchor?.objectid === this.key) {\n if (has(error.anchor, \"elementid\")) {\n attributeErrors.push(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n new LayoutHintCollection(error.layouthint),\n );\n }\n }\n });\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n * Convert missing json from a form service to mandatory validation constraints and messages\n */\n handleMissingValidations(missing: {\n anchors: Array<\n | {\n elements: Array<{ elementid: string }>,\n objectid?: string,\n }\n | { anchor: { elementid: string, objectid?: string } },\n >,\n }) {\n const attributeErrors = [];\n\n for (const anchor of missing.anchors) {\n const { objectid, elements } = anchor;\n if (!objectid || objectid === this.key) {\n if (Array.isArray(elements)) {\n for (const element of elements) {\n attributeErrors.push({\n anchor: { elementid: element.elementid },\n id: \"Constraint.Mandatory\",\n });\n }\n } else {\n attributeErrors.push({\n anchor,\n id: \"Constraint.Mandatory\",\n });\n }\n }\n }\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n if (Array.isArray(data.errors)) {\n this.handleErrorValidations(data.errors);\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n this.handleMissingValidations(data.missing);\n }\n\n this.dynamicValidationsLoaded = true;\n\n return this;\n }\n\n /**\n * Generate formdata object for current formobject based on formdata of attributes\n */\n get formdata(): { [string]: any } | null {\n return this.attributeCollection.formdata;\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n return this.attributeCollection.getFormData(validationData);\n }\n}\n"],"mappings":";;;;;AACA,SAASA,GAAG,QAAQ,6BAA6B;AAEjD,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,mBAAmB,MAAM,mCAAmC;AACnE,OAAOC,uBAAuB,MAAM,uCAAuC;AAC3E,OAAOC,oBAAoB,MAAM,8CAA8C;AAC/E,OAAOC,eAAe,MAAM,0BAA0B;AACtD,SAASC,wBAAwB,QAAQ,kBAAkB;AAI3D,OAAOC,oBAAoB,MAAM,oCAAoC;AAGrE;AACA;AACA;AACA,eAAe,MAAMC,eAAe,SAASP,SAAS,CAAC;EAOrD;AACF;AACA;EACEQ,WAAWA,CAACC,MAAc,EAAEC,mBAA2B,EAAE;IACvD,KAAK,CAACD,MAAM,EAAEC,mBAAmB,CAAC;IAACC,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAEnC,IAAIF,MAAM,IAAI,IAAI,CAACG,WAAW,CAAC,CAAC,CAACC,MAAM,GAAG,CAAC,EAAE;MAC3C,IAAI,CAACC,oBAAoB,GAAG,IAAIb,mBAAmB,CACjD,IAAI,CAACW,WAAW,CAAC,CAAC,EAClB,IAAI,CAACG,mCAAmC,CAAC,CAC3C,CAAC;IACH,CAAC,MAAM;MACL,IAAI,CAACD,oBAAoB,GAAG,IAAIb,mBAAmB,CAAC,CAAC;IACvD;IAEA,IAAI,CAACe,qBAAqB,GAAG,IAAIb,oBAAoB,CACnDO,mBAAmB,GAAGA,mBAAmB,CAACO,OAAO,GAAG,CAAC,CACvD,CAAC;IAED,IAAI,CAACC,gBA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AmB;IAC5C,IAAI,CAACqF,WAAW,CAAC,CAAC;IAElB,IAAIuB,KAAK,CAACC,OAAO,CAAC7G,IAAI,CAACsG,MAAM,CAAC,EAAE;MAC9B,IAAI,CAACD,sBAAsB,CAACrG,IAAI,CAACsG,MAAM,CAAC;IAC1C;;IAEA;IACA,IAAIM,KAAK,CAACC,OAAO,CAAC7G,IAAI,CAAC0G,OAAO,EAAEC,OAAO,CAAC,EAAE;MACxC,IAAI,CAACF,wBAAwB,CAACzG,IAAI,CAAC0G,OAAO,CAAC;IAC7C;IAEA,IAAI,CAACP,wBAAwB,GAAG,IAAI;IAEpC,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,IAAIW,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAAC7G,mBAAmB,CAAC6G,QAAQ;EAC1C;;EAEA;AACF;EACEC,WAAWA,CAAA,EAA4D;IAAA,IAA3DC,cAAuB,GAAApG,SAAA,CAAAlB,MAAA,QAAAkB,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,KAAK;IACzC,OAAO,IAAI,CAACX,mBAAmB,CAAC8G,WAAW,CAACC,cAAc,CAAC;EAC7D;AACF","ignoreList":[]}
|
|
@@ -92,6 +92,15 @@ class AttributeDataHelper {
|
|
|
92
92
|
*/
|
|
93
93
|
createChildren(data) {
|
|
94
94
|
let childrenKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
95
|
+
// Check if the original data explicitly contains the key and is explicitly null.
|
|
96
|
+
const keyExplicitlyNull = this.value === null;
|
|
97
|
+
if (keyExplicitlyNull) {
|
|
98
|
+
// Handling for when the value is explicitly null: set childData to null.
|
|
99
|
+
return (0, _map.default)(childrenKeys).call(childrenKeys, keyObject => {
|
|
100
|
+
const childData = null;
|
|
101
|
+
return this.createChild(data, childData, keyObject);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
95
104
|
const childrenIsArray = Array.isArray(this.value);
|
|
96
105
|
if (childrenIsArray) {
|
|
97
106
|
var _context2;
|
|
@@ -125,7 +134,7 @@ class AttributeDataHelper {
|
|
|
125
134
|
var _context3, _context4;
|
|
126
135
|
return (0, _map.default)(_context3 = (0, _filter.default)(_context4 = attribute.options).call(_context4, option => option.selected)).call(_context3, option => option.code || option.key);
|
|
127
136
|
}
|
|
128
|
-
return
|
|
137
|
+
return undefined;
|
|
129
138
|
}
|
|
130
139
|
|
|
131
140
|
/**
|
|
@@ -237,9 +246,10 @@ class AttributeDataHelper {
|
|
|
237
246
|
*/
|
|
238
247
|
getData() {
|
|
239
248
|
var _context5;
|
|
249
|
+
const value = this.value === undefined ? null : this.value;
|
|
240
250
|
return {
|
|
241
251
|
key: this.key,
|
|
242
|
-
value:
|
|
252
|
+
value: value,
|
|
243
253
|
static: this.static,
|
|
244
254
|
_links: this.links,
|
|
245
255
|
dynamicschema: this.dynamicschema,
|
|
@@ -123,6 +123,17 @@ class AttributeDataHelper {
|
|
|
123
123
|
data: Object | Array<Object>,
|
|
124
124
|
childrenKeys: Array<Object> = [],
|
|
125
125
|
): Array<AttributeDataHelper> {
|
|
126
|
+
// Check if the original data explicitly contains the key and is explicitly null.
|
|
127
|
+
const keyExplicitlyNull = this.value === null;
|
|
128
|
+
|
|
129
|
+
if (keyExplicitlyNull) {
|
|
130
|
+
// Handling for when the value is explicitly null: set childData to null.
|
|
131
|
+
return childrenKeys.map((keyObject) => {
|
|
132
|
+
const childData = null;
|
|
133
|
+
return this.createChild(data, childData, keyObject);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
126
137
|
const childrenIsArray = Array.isArray(this.value);
|
|
127
138
|
|
|
128
139
|
if (childrenIsArray) {
|
|
@@ -167,7 +178,7 @@ class AttributeDataHelper {
|
|
|
167
178
|
.map((option) => option.code || option.key);
|
|
168
179
|
}
|
|
169
180
|
|
|
170
|
-
return
|
|
181
|
+
return undefined;
|
|
171
182
|
}
|
|
172
183
|
|
|
173
184
|
/**
|
|
@@ -287,9 +298,10 @@ class AttributeDataHelper {
|
|
|
287
298
|
/**
|
|
288
299
|
*/
|
|
289
300
|
getData(): Object {
|
|
301
|
+
const value = this.value === undefined ? null : this.value;
|
|
290
302
|
return {
|
|
291
303
|
key: this.key,
|
|
292
|
-
value:
|
|
304
|
+
value: value,
|
|
293
305
|
static: this.static,
|
|
294
306
|
_links: this.links,
|
|
295
307
|
dynamicschema: this.dynamicschema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AttributeDataHelper.js","names":["_full","require","_pick","_interopRequireDefault","_objects","AttributeDataHelper","constructor","data","key","childrenKeys","_defineProperty2","default","_key","Array","isArray","_attribute","_find","call","attr","elementid","name","param","_value","getValue","attributeData","klona","_links","pick","undefined","_children","createChildren","childData","parentKey","childKey","elements","_context","element","has","isPlainObject","parentData","content","createChild","keyObject","dynamicschema","dynamicschemaId","children","arguments","length","childrenIsArray","value","_context2","_map","attribute","_values","suggestions","suggestion","options","_context3","_context4","_filter","option","selected","code","static","links","attrDS","message","isResult","referenceDate","pickedContent","_keys","getData","_context5","child","subChild","_default","exports"],"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"sourcesContent":["// @flow\nimport { klona } from \"klona/full\";\nimport pick from \"lodash/pick\";\n\nimport { has, isPlainObject } from \"../../utils/helpers/objects\";\n\n/**\n * This util helps to normalize various attribute data formats available in the modular ui.\n * It fixes differences in choice attributes with dynamic schema's, links on download attributes, composites with various children, etc\n *\n * @private\n */\nclass AttributeDataHelper {\n _key: string;\n _attribute: Object;\n _value: any;\n _children: Array<AttributeDataHelper>;\n\n /**\n */\n constructor(\n data: Object | Array<Object>,\n key: string,\n childrenKeys: Array<Object>,\n ) {\n this._key = key;\n\n if (Array.isArray(data)) {\n this._attribute =\n data.find(\n (attr) =>\n attr.elementid === key || attr.name === key || attr.param === key,\n ) || {};\n this._value = this.getValue(this._attribute);\n } else {\n const attributeData = klona(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n if (data[key] === undefined || (\"name\" in data && \"param\" in data)) {\n this._value = this.getValue(data);\n } else {\n this._value = data[key];\n }\n }\n\n this._children = this.createChildren(data, childrenKeys);\n }\n\n /**\n */\n childData(\n data: Object | Array<Object>,\n parentKey: string,\n childKey: string,\n ): Object {\n if (Array.isArray(data)) {\n if (Array.isArray(this._attribute.elements)) {\n return this._attribute.elements.find(\n (element) => element.elementid === childKey,\n );\n }\n } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {\n const parentData = data[parentKey];\n if (isPlainObject(parentData) && data.content?.[childKey]) {\n return { ...parentData, content: data.content[childKey] };\n }\n return parentData;\n } else if (has(data, childKey) && isPlainObject(data[childKey])) {\n return data[childKey];\n }\n\n if (isPlainObject(data)) {\n return data;\n }\n\n return {};\n }\n\n /**\n */\n createChild(\n data: Object | Array<Object>,\n childData: Object,\n keyObject: Object,\n ): AttributeDataHelper {\n const dynamicschema =\n isPlainObject(data) && !Array.isArray(data)\n ? data.dynamicschema\n : undefined;\n\n let dynamicschemaId = null;\n if (keyObject.dynamicschemaId) {\n dynamicschemaId = keyObject.dynamicschemaId;\n } else if (\n isPlainObject(data) &&\n typeof data.key === \"string\" &&\n keyObject.key\n ) {\n dynamicschemaId = `${data.key}.${keyObject.key}`;\n }\n\n return new AttributeDataHelper(\n {\n ...childData,\n dynamicschema,\n dynamicschemaId,\n },\n keyObject.key,\n keyObject.children,\n );\n }\n\n /**\n */\n createChildren(\n data: Object | Array<Object>,\n childrenKeys: Array<Object> = [],\n ): Array<AttributeDataHelper> {\n const childrenIsArray = Array.isArray(this.value);\n\n if (childrenIsArray) {\n return this.value.map((value) =>\n childrenKeys.map((keyObject) => {\n const childData = this.childData(value, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n }),\n );\n }\n\n return childrenKeys.map((keyObject) => {\n const childData = this.childData(data, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n });\n }\n\n /**\n */\n getValue(attribute: Object): any {\n if (\"values\" in attribute) {\n return attribute.values;\n }\n\n if (\"value\" in attribute) {\n return attribute.value;\n }\n\n if (\"suggestions\" in attribute) {\n return attribute.suggestions;\n }\n\n if (\"suggestion\" in attribute) {\n return attribute.suggestion;\n }\n\n if (Array.isArray(attribute.options)) {\n return attribute.options\n .filter((option) => option.selected)\n .map((option) => option.code || option.key);\n }\n\n return null;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n get value(): any {\n return this._value;\n }\n\n /**\n */\n get static(): boolean {\n return this._attribute.static || false;\n }\n\n /**\n */\n get links(): any {\n return this._attribute._links || void 0;\n }\n\n /**\n */\n get dynamicschemaId(): string {\n return this._attribute.dynamicschemaId || this.key;\n }\n\n /*\n retrieve the dynamischema by the dynamischemaId\n mentioned in the contributions of the attribute\n */\n /**\n */\n get dynamicschema(): any {\n const { dynamicschema } = this._attribute;\n if (!dynamicschema) {\n return void 0;\n }\n\n if (Array.isArray(dynamicschema)) {\n return dynamicschema;\n } else if (dynamicschema[this.dynamicschemaId]) {\n const attrDS = dynamicschema[this.dynamicschemaId];\n return attrDS.map((attr) => {\n if (attr.elements) {\n return {\n ...attr,\n elements: {\n ...attr.elements,\n dynamicschema,\n },\n };\n }\n\n return attr;\n });\n }\n\n return void 0;\n }\n\n /**\n */\n get options(): any {\n return this._attribute.options || void 0;\n }\n\n /**\n */\n get message(): any {\n return this._attribute.message || void 0;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._attribute.isResult || false;\n }\n\n /**\n */\n get referenceDate(): any {\n return this._attribute.referenceDate || void 0;\n }\n\n /**\n */\n get children(): Array<AttributeDataHelper> {\n return this._children || [];\n }\n\n /**\n */\n get content(): Object {\n if (this._attribute.content) {\n const pickedContent = pick(this._attribute.content, [\n \"header\",\n \"label\",\n \"elements\",\n \"layouthint\",\n \"text\",\n ]);\n\n if (Object.keys(pickedContent).length > 0) {\n return pickedContent;\n }\n }\n\n return null;\n }\n\n /**\n */\n getData(): Object {\n return {\n key: this.key,\n value: this.value,\n static: this.static,\n _links: this.links,\n dynamicschema: this.dynamicschema,\n dynamicschemaId: this.dynamicschemaId,\n options: this.options,\n message: this.message,\n isResult: this.isResult,\n referenceDate: this.referenceDate,\n children: this.children.map((child) =>\n Array.isArray(child)\n ? child.map((subChild) => subChild.getData())\n : child.getData(),\n ),\n content: this.content,\n };\n }\n}\n\nexport default AttributeDataHelper;\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,QAAA,GAAAH,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMI,mBAAmB,CAAC;EAMxB;AACF;EACEC,WAAWA,CACTC,IAA4B,EAC5BC,GAAW,EACXC,YAA2B,EAC3B;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IACA,IAAI,CAACC,IAAI,GAAGJ,GAAG;IAEf,IAAIK,KAAK,CAACC,OAAO,CAACP,IAAI,CAAC,EAAE;MACvB,IAAI,CAACQ,UAAU,GACb,IAAAC,KAAA,CAAAL,OAAA,EAAAJ,IAAI,EAAAU,IAAA,CAAJV,IAAI,EACDW,IAAI,IACHA,IAAI,CAACC,SAAS,KAAKX,GAAG,IAAIU,IAAI,CAACE,IAAI,KAAKZ,GAAG,IAAIU,IAAI,CAACG,KAAK,KAAKb,GAClE,CAAC,IAAI,CAAC,CAAC;MACT,IAAI,CAACc,MAAM,GAAG,IAAI,CAACC,QAAQ,CAAC,IAAI,CAACR,UAAU,CAAC;IAC9C,CAAC,MAAM;MACL,MAAMS,aAAa,GAAG,IAAAC,WAAK,EAAClB,IAAI,CAAC;MACjCiB,aAAa,CAACE,MAAM,GAAG,IAAAC,aAAI,EAACpB,IAAI,CAACmB,MAAM,EAAE,CACvC,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aAAa,CAAC,CAACtB,MAAM,GAAG,CAAC,EAAE;QACzC,OAAOsB,aAAa;MACtB;IACF;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACEE,OAAOA,CAAA,EAAW;IAAA,IAAAC,SAAA;IAChB,OAAO;MACLhE,GAAG,EAAE,IAAI,CAACA,GAAG;MACbyC,KAAK,EAAE,IAAI,CAACA,KAAK;MACjBc,MAAM,EAAE,IAAI,CAACA,MAAM;MACnBrC,MAAM,EAAE,IAAI,CAACsC,KAAK;MAClBrB,aAAa,EAAE,IAAI,CAACA,aAAa;MACjCC,eAAe,EAAE,IAAI,CAACA,eAAe;MACrCY,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBU,OAAO,EAAE,IAAI,CAACA,OAAO;MACrBC,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBC,aAAa,EAAE,IAAI,CAACA,aAAa;MACjCvB,QAAQ,EAAE,IAAAM,IAAA,CAAAxC,OAAA,EAAA6D,SAAA,OAAI,CAAC3B,QAAQ,EAAA5B,IAAA,CAAAuD,SAAA,EAAMC,KAAK,IAChC5D,KAAK,CAACC,OAAO,CAAC2D,KAAK,CAAC,GAChB,IAAAtB,IAAA,CAAAxC,OAAA,EAAA8D,KAAK,EAAAxD,IAAA,CAALwD,KAAK,EAAMC,QAAQ,IAAKA,QAAQ,CAACH,OAAO,CAAC,CAAC,CAAC,GAC3CE,KAAK,CAACF,OAAO,CAAC,CACpB,CAAC;MACD/B,OAAO,EAAE,IAAI,CAACA;IAChB,CAAC;EACH;AACF;AAAC,IAAAmC,QAAA,GAAAC,OAAA,CAAAjE,OAAA,GAEcN,mBAAmB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"AttributeDataHelper.js","names":["_full","require","_pick","_interopRequireDefault","_objects","AttributeDataHelper","constructor","data","key","childrenKeys","_defineProperty2","default","_key","Array","isArray","_attribute","_find","call","attr","elementid","name","param","_value","getValue","attributeData","klona","_links","pick","undefined","_children","createChildren","childData","parentKey","childKey","elements","_context","element","has","isPlainObject","parentData","content","createChild","keyObject","dynamicschema","dynamicschemaId","children","arguments","length","keyExplicitlyNull","value","_map","childrenIsArray","_context2","attribute","_values","suggestions","suggestion","options","_context3","_context4","_filter","option","selected","code","static","links","attrDS","message","isResult","referenceDate","pickedContent","_keys","getData","_context5","child","subChild","_default","exports"],"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"sourcesContent":["// @flow\nimport { klona } from \"klona/full\";\nimport pick from \"lodash/pick\";\n\nimport { has, isPlainObject } from \"../../utils/helpers/objects\";\n\n/**\n * This util helps to normalize various attribute data formats available in the modular ui.\n * It fixes differences in choice attributes with dynamic schema's, links on download attributes, composites with various children, etc\n *\n * @private\n */\nclass AttributeDataHelper {\n _key: string;\n _attribute: Object;\n _value: any;\n _children: Array<AttributeDataHelper>;\n\n /**\n */\n constructor(\n data: Object | Array<Object>,\n key: string,\n childrenKeys: Array<Object>,\n ) {\n this._key = key;\n\n if (Array.isArray(data)) {\n this._attribute =\n data.find(\n (attr) =>\n attr.elementid === key || attr.name === key || attr.param === key,\n ) || {};\n this._value = this.getValue(this._attribute);\n } else {\n const attributeData = klona(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n if (data[key] === undefined || (\"name\" in data && \"param\" in data)) {\n this._value = this.getValue(data);\n } else {\n this._value = data[key];\n }\n }\n\n this._children = this.createChildren(data, childrenKeys);\n }\n\n /**\n */\n childData(\n data: Object | Array<Object>,\n parentKey: string,\n childKey: string,\n ): Object {\n if (Array.isArray(data)) {\n if (Array.isArray(this._attribute.elements)) {\n return this._attribute.elements.find(\n (element) => element.elementid === childKey,\n );\n }\n } else if (has(data, parentKey) && isPlainObject(data[parentKey])) {\n const parentData = data[parentKey];\n if (isPlainObject(parentData) && data.content?.[childKey]) {\n return { ...parentData, content: data.content[childKey] };\n }\n return parentData;\n } else if (has(data, childKey) && isPlainObject(data[childKey])) {\n return data[childKey];\n }\n\n if (isPlainObject(data)) {\n return data;\n }\n\n return {};\n }\n\n /**\n */\n createChild(\n data: Object | Array<Object>,\n childData: Object,\n keyObject: Object,\n ): AttributeDataHelper {\n const dynamicschema =\n isPlainObject(data) && !Array.isArray(data)\n ? data.dynamicschema\n : undefined;\n\n let dynamicschemaId = null;\n if (keyObject.dynamicschemaId) {\n dynamicschemaId = keyObject.dynamicschemaId;\n } else if (\n isPlainObject(data) &&\n typeof data.key === \"string\" &&\n keyObject.key\n ) {\n dynamicschemaId = `${data.key}.${keyObject.key}`;\n }\n\n return new AttributeDataHelper(\n {\n ...childData,\n dynamicschema,\n dynamicschemaId,\n },\n keyObject.key,\n keyObject.children,\n );\n }\n\n /**\n */\n createChildren(\n data: Object | Array<Object>,\n childrenKeys: Array<Object> = [],\n ): Array<AttributeDataHelper> {\n // Check if the original data explicitly contains the key and is explicitly null.\n const keyExplicitlyNull = this.value === null;\n\n if (keyExplicitlyNull) {\n // Handling for when the value is explicitly null: set childData to null.\n return childrenKeys.map((keyObject) => {\n const childData = null;\n return this.createChild(data, childData, keyObject);\n });\n }\n\n const childrenIsArray = Array.isArray(this.value);\n\n if (childrenIsArray) {\n return this.value.map((value) =>\n childrenKeys.map((keyObject) => {\n const childData = this.childData(value, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n }),\n );\n }\n\n return childrenKeys.map((keyObject) => {\n const childData = this.childData(data, this.key, keyObject.key);\n\n return this.createChild(data, childData, keyObject);\n });\n }\n\n /**\n */\n getValue(attribute: Object): any {\n if (\"values\" in attribute) {\n return attribute.values;\n }\n\n if (\"value\" in attribute) {\n return attribute.value;\n }\n\n if (\"suggestions\" in attribute) {\n return attribute.suggestions;\n }\n\n if (\"suggestion\" in attribute) {\n return attribute.suggestion;\n }\n\n if (Array.isArray(attribute.options)) {\n return attribute.options\n .filter((option) => option.selected)\n .map((option) => option.code || option.key);\n }\n\n return undefined;\n }\n\n /**\n */\n get key(): string {\n return this._key;\n }\n\n /**\n */\n get value(): any {\n return this._value;\n }\n\n /**\n */\n get static(): boolean {\n return this._attribute.static || false;\n }\n\n /**\n */\n get links(): any {\n return this._attribute._links || void 0;\n }\n\n /**\n */\n get dynamicschemaId(): string {\n return this._attribute.dynamicschemaId || this.key;\n }\n\n /*\n retrieve the dynamischema by the dynamischemaId\n mentioned in the contributions of the attribute\n */\n /**\n */\n get dynamicschema(): any {\n const { dynamicschema } = this._attribute;\n if (!dynamicschema) {\n return void 0;\n }\n\n if (Array.isArray(dynamicschema)) {\n return dynamicschema;\n } else if (dynamicschema[this.dynamicschemaId]) {\n const attrDS = dynamicschema[this.dynamicschemaId];\n return attrDS.map((attr) => {\n if (attr.elements) {\n return {\n ...attr,\n elements: {\n ...attr.elements,\n dynamicschema,\n },\n };\n }\n\n return attr;\n });\n }\n\n return void 0;\n }\n\n /**\n */\n get options(): any {\n return this._attribute.options || void 0;\n }\n\n /**\n */\n get message(): any {\n return this._attribute.message || void 0;\n }\n\n /**\n */\n get isResult(): boolean {\n return this._attribute.isResult || false;\n }\n\n /**\n */\n get referenceDate(): any {\n return this._attribute.referenceDate || void 0;\n }\n\n /**\n */\n get children(): Array<AttributeDataHelper> {\n return this._children || [];\n }\n\n /**\n */\n get content(): Object {\n if (this._attribute.content) {\n const pickedContent = pick(this._attribute.content, [\n \"header\",\n \"label\",\n \"elements\",\n \"layouthint\",\n \"text\",\n ]);\n\n if (Object.keys(pickedContent).length > 0) {\n return pickedContent;\n }\n }\n\n return null;\n }\n\n /**\n */\n getData(): Object {\n const value = this.value === undefined ? null : this.value;\n return {\n key: this.key,\n value: value,\n static: this.static,\n _links: this.links,\n dynamicschema: this.dynamicschema,\n dynamicschemaId: this.dynamicschemaId,\n options: this.options,\n message: this.message,\n isResult: this.isResult,\n referenceDate: this.referenceDate,\n children: this.children.map((child) =>\n Array.isArray(child)\n ? child.map((subChild) => subChild.getData())\n : child.getData(),\n ),\n content: this.content,\n };\n }\n}\n\nexport default AttributeDataHelper;\n"],"mapp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=> {
|
|
|
546
546
|
|
|
547
547
|
expect(firstChild.dynamicschema).toBeUndefined();
|
|
548
548
|
});
|
|
549
|
+
|
|
550
|
+
it("prioritizes parent attribute null value over child values in composite attributes", () => {
|
|
551
|
+
const data = {
|
|
552
|
+
_links: {
|
|
553
|
+
self: {
|
|
554
|
+
href: "/dockets/act/21",
|
|
555
|
+
},
|
|
556
|
+
api_doc: {
|
|
557
|
+
href: "/api-docs/v3/dockets/act/(case-id)",
|
|
558
|
+
},
|
|
559
|
+
contributions: {
|
|
560
|
+
href: "/contributions/dockets/act/(case-id)",
|
|
561
|
+
},
|
|
562
|
+
ActOverview: {
|
|
563
|
+
href: "/dockets/act/21/act-overview",
|
|
564
|
+
},
|
|
565
|
+
Conversation: {
|
|
566
|
+
href: "/dockets/act/21/messages",
|
|
567
|
+
},
|
|
568
|
+
History: {
|
|
569
|
+
href: "/dockets/act/21/history",
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
taskgroups: [
|
|
573
|
+
{
|
|
574
|
+
name: "Act",
|
|
575
|
+
actions: [
|
|
576
|
+
{
|
|
577
|
+
name: "delete",
|
|
578
|
+
method: "POST",
|
|
579
|
+
href: "/dockets/act/21/delete",
|
|
580
|
+
},
|
|
581
|
+
],
|
|
582
|
+
},
|
|
583
|
+
],
|
|
584
|
+
_id: 21,
|
|
585
|
+
Name: "Collect material for another borrower",
|
|
586
|
+
CaseState: "Review",
|
|
587
|
+
Explanation: null,
|
|
588
|
+
Actor_reference: null,
|
|
589
|
+
Object_reference: null,
|
|
590
|
+
Recipient_reference: null,
|
|
591
|
+
Action_reference: null,
|
|
592
|
+
};
|
|
593
|
+
const key = "Actor_reference";
|
|
594
|
+
const childrenKeys = [
|
|
595
|
+
{
|
|
596
|
+
key: "Name",
|
|
597
|
+
children: [],
|
|
598
|
+
},
|
|
599
|
+
];
|
|
600
|
+
|
|
601
|
+
const dataHelper = new AttributeDataHelper(data, key, childrenKeys);
|
|
602
|
+
|
|
603
|
+
expect(dataHelper.getData()).toStrictEqual({
|
|
604
|
+
key: "Actor_reference",
|
|
605
|
+
value: null,
|
|
606
|
+
static: false,
|
|
607
|
+
_links: {},
|
|
608
|
+
dynamicschemaId: "Actor_reference",
|
|
609
|
+
dynamicschema: undefined,
|
|
610
|
+
message: undefined,
|
|
611
|
+
options: undefined,
|
|
612
|
+
referenceDate: undefined,
|
|
613
|
+
isResult: false,
|
|
614
|
+
|
|
615
|
+
children: [
|
|
616
|
+
{
|
|
617
|
+
key: "Name",
|
|
618
|
+
static: false,
|
|
619
|
+
_links: {},
|
|
620
|
+
dynamicschemaId: "Name",
|
|
621
|
+
dynamicschema: undefined,
|
|
622
|
+
message: undefined,
|
|
623
|
+
options: undefined,
|
|
624
|
+
referenceDate: undefined,
|
|
625
|
+
isResult: false,
|
|
626
|
+
children: [],
|
|
627
|
+
content: null,
|
|
628
|
+
value: null,
|
|
629
|
+
},
|
|
630
|
+
],
|
|
631
|
+
content: null,
|
|
632
|
+
});
|
|
633
|
+
});
|
|
549
634
|
});
|
|
@@ -408,20 +408,26 @@ class FormObjectModel extends _BaseModel.default {
|
|
|
408
408
|
handleMissingValidations(missing) {
|
|
409
409
|
const attributeErrors = [];
|
|
410
410
|
for (const anchor of missing.anchors) {
|
|
411
|
-
|
|
412
|
-
|
|
411
|
+
const {
|
|
412
|
+
objectid,
|
|
413
|
+
elements
|
|
414
|
+
} = anchor;
|
|
415
|
+
if (!objectid || objectid === this.key) {
|
|
416
|
+
if (Array.isArray(elements)) {
|
|
417
|
+
for (const element of elements) {
|
|
418
|
+
attributeErrors.push({
|
|
419
|
+
anchor: {
|
|
420
|
+
elementid: element.elementid
|
|
421
|
+
},
|
|
422
|
+
id: "Constraint.Mandatory"
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
} else {
|
|
413
426
|
attributeErrors.push({
|
|
414
|
-
anchor
|
|
415
|
-
elementid: element.elementid
|
|
416
|
-
},
|
|
427
|
+
anchor,
|
|
417
428
|
id: "Constraint.Mandatory"
|
|
418
429
|
});
|
|
419
430
|
}
|
|
420
|
-
} else {
|
|
421
|
-
attributeErrors.push({
|
|
422
|
-
anchor,
|
|
423
|
-
id: "Constraint.Mandatory"
|
|
424
|
-
});
|
|
425
431
|
}
|
|
426
432
|
}
|
|
427
433
|
this.attributeCollection.updateValidations(attributeErrors);
|
|
@@ -491,25 +491,29 @@ export default class FormObjectModel extends BaseModel {
|
|
|
491
491
|
anchors: Array<
|
|
492
492
|
| {
|
|
493
493
|
elements: Array<{ elementid: string }>,
|
|
494
|
+
objectid?: string,
|
|
494
495
|
}
|
|
495
|
-
| { anchor: { elementid: string } },
|
|
496
|
+
| { anchor: { elementid: string, objectid?: string } },
|
|
496
497
|
>,
|
|
497
498
|
}) {
|
|
498
499
|
const attributeErrors = [];
|
|
499
500
|
|
|
500
501
|
for (const anchor of missing.anchors) {
|
|
501
|
-
|
|
502
|
-
|
|
502
|
+
const { objectid, elements } = anchor;
|
|
503
|
+
if (!objectid || objectid === this.key) {
|
|
504
|
+
if (Array.isArray(elements)) {
|
|
505
|
+
for (const element of elements) {
|
|
506
|
+
attributeErrors.push({
|
|
507
|
+
anchor: { elementid: element.elementid },
|
|
508
|
+
id: "Constraint.Mandatory",
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
} else {
|
|
503
512
|
attributeErrors.push({
|
|
504
|
-
anchor
|
|
513
|
+
anchor,
|
|
505
514
|
id: "Constraint.Mandatory",
|
|
506
515
|
});
|
|
507
516
|
}
|
|
508
|
-
} else {
|
|
509
|
-
attributeErrors.push({
|
|
510
|
-
anchor,
|
|
511
|
-
id: "Constraint.Mandatory",
|
|
512
|
-
});
|
|
513
517
|
}
|
|
514
518
|
}
|
|
515
519
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormObjectModel.js","names":["_objects","require","_BaseModel","_interopRequireDefault","_AttributeCollection","_CompositeAttributeModel","_ContentConfiguration","_ErrorCollection","_exceptions","_LayoutHintCollection","FormObjectModel","BaseModel","constructor","object","objectContributions","_defineProperty2","default","getElements","length","_attributeCollection","AttributeCollection","getApplicableAttributeContributions","_contentConfiguration","ContentConfiguration","content","_errorCollection","ErrorCollection","has","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","IllegalArgumentException","contributions","equals","_context","withRepeatIndex","arguments","undefined","key","objectContainsOneOfTheAttributes","_filter","all","call","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","_context2","dataResults","_map","result","elementid","_context3","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","_keys","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","setChildModels","models","objectid","hasEndResultConfiguration","getContribution","hasDynamicValidations","isRepeatable","_repeatIndex","index","maxRepeats","hasFixedNrOfRepeats","isRepeatWithUnknownTotal","isLastRepeat","last","repeatIndexLabel","label","introText","text","message","assistent","buttonLabels","mergeObject","oldObject","forEach","mergeWithAttribute","mergeAttribute","updateAttribute","value","attributeToUpdate","Error","name","CompositeAttributeModel","update","isChangedSince","timestamp","_context4","_find","resetErrors","errorCollection","addServerError","error","anchor","id","properties","layouthint","hasServerErrors","hasItems","hasErrors","isValid","visible","every","dynamicValidationsLoaded","_dynamicValidationsLoaded","handleErrorValidations","errors","attributeErrors","LayoutHintCollection","updateValidations","handleMissingValidations","missing","anchors","Array","isArray","formdata","getFormData","validationData","exports"],"sources":["../../../src/models/form/FormObjectModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { AttributeType, ModularUIModel, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport type { MessageParameters } from \"../../i18n\";\n\n/**\n * Form Object\n */\nexport default class FormObjectModel extends BaseModel {\n _attributeCollection: AttributeCollection;\n _contentConfiguration: ContentConfiguration;\n _errorCollection: ErrorCollection;\n _repeatIndex: number;\n _dynamicValidationsLoaded: boolean;\n\n /**\n * Construct FormObjectModel\n */\n constructor(object: Object, objectContributions: Object) {\n super(object, objectContributions);\n\n if (object && this.getElements().length > 0) {\n this._attributeCollection = new AttributeCollection(\n this.getElements(),\n this.getApplicableAttributeContributions(),\n );\n } else {\n this._attributeCollection = new AttributeCollection();\n }\n\n this._contentConfiguration = new ContentConfiguration(\n objectContributions ? objectContributions.content : {},\n );\n\n this._errorCollection = new ErrorCollection(\"formobject\");\n\n if (has(this.data, \"referenceDate\")) {\n this.attributeCollection.setReferenceDate(this.getData(\"referenceDate\"));\n }\n\n this.attributeCollection.indicateContentConfiguration(\n this.contentConfiguration,\n );\n }\n\n /**\n */\n static createEmpty(formObjectModel: FormObjectModel): FormObjectModel {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\n \"createEmpty method needs a FormObjectModel as input argument to create a new version of the object\",\n );\n }\n return new FormObjectModel(\n formObjectModel.data,\n formObjectModel.contributions,\n );\n }\n\n /**\n */\n equals(object: ?FormObjectModel, withRepeatIndex: boolean = true): boolean {\n if (!object || this.key !== object.key) {\n return false;\n }\n\n const objectContainsOneOfTheAttributes = this.attributeCollection.all\n .filter((attribute) => !attribute.isResult)\n .some(\n (attribute) =>\n object && object.attributeCollection.hasAttributeByKey(attribute.key),\n );\n\n const hasSameRepeatIndex = withRepeatIndex\n ? this.repeatIndex === object.repeatIndex\n : true;\n\n return hasSameRepeatIndex && objectContainsOneOfTheAttributes;\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.attributeCollection.getAttributeByAttribute(attribute);\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.attributeCollection.hasAttributeByKey(key);\n }\n\n /**\n * Get elements from both the missing attributes and the result attributes\n */\n getElements(): Array<Object> {\n const elements = [];\n\n if (this.data.elements) {\n elements.push(...this.data.elements);\n }\n\n if (this.data.results) {\n const dataResults = this.data.results.map((result) => ({\n ...result,\n isResult: true,\n }));\n\n elements.push(...dataResults);\n }\n\n if (this.data.elementid) {\n elements.push({\n ...this.data,\n });\n }\n\n return elements;\n }\n\n /**\n * Map available contributions on the available data. Only use contributions that are needed for the data\n */\n getApplicableAttributeContributions(): Array<Object> {\n if (this.data && this.contributions) {\n const dataElementIds = this.getElements().map(\n (element) => element.elementid,\n );\n\n const contributions = this.getAttributesInData(\n dataElementIds,\n this.contributions.attributes,\n );\n\n // set all attribute mandatory for dynamic object\n if (this.isDynamic) {\n return contributions.map((attribute) => {\n const [attributeKey] = Object.keys(attribute);\n return {\n [attributeKey]: {\n ...attribute[attributeKey],\n mandatory: true,\n },\n };\n });\n }\n\n return contributions;\n }\n\n return [];\n }\n\n /**\n * Recursevily check if an attribute id occurs in the tree of attribute contributions.\n * The complete leaf of the tree is returned when an attribute id matches\n */\n getAttributesInData(\n dataElementIds: Array<string>,\n attributesContributions: Object,\n ): Array<Object> {\n return attributesContributions.filter((attributeContributions) => {\n const [attributeKey] = Object.keys(attributeContributions);\n\n return dataElementIds.some(\n (dataElementId) => dataElementId.split(\".\")[0] === attributeKey,\n );\n });\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this._attributeCollection.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n }\n\n /**\n * get key\n */\n get key(): string {\n return this.data.objectid;\n }\n\n /**\n * Get content configuration for form objects\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n get hasEndResultConfiguration(): boolean {\n return this.contributions.content?.results != null;\n }\n\n /**\n * Indicates if object is dynamic. A dynamic object should be submitted on each attribute change\n */\n get isDynamic(): boolean {\n return this.getContribution(\"dynamicObject\", false);\n }\n\n /**\n */\n get hasDynamicValidations(): boolean {\n return this.getContribution(\"dynamicValidations\", false);\n }\n\n /**\n * Indicates if object is repeatable\n */\n get isRepeatable(): boolean {\n return this.getContribution(\"repeatable\", false);\n }\n\n /**\n */\n get repeatIndex(): number {\n return this._repeatIndex ?? this.data.index ?? 1;\n }\n\n /**\n */\n set repeatIndex(repeatIndex: number) {\n this._repeatIndex = repeatIndex;\n }\n\n /**\n */\n get maxRepeats(): number {\n if (this.isRepeatable) {\n return this.getData(\"numberofrepeats\", -1);\n }\n\n return 1;\n }\n\n /**\n */\n get hasFixedNrOfRepeats(): boolean {\n return this.maxRepeats > -1;\n }\n\n /**\n */\n get isRepeatWithUnknownTotal(): boolean {\n return this.isRepeatable && this.maxRepeats === -1;\n }\n\n /**\n */\n get isLastRepeat(): boolean {\n if (this.isRepeatable) {\n return this.data.last || false;\n }\n\n return true;\n }\n\n /**\n */\n get repeatIndexLabel(): string | null {\n return this.data[\"index-identifier\"] || null;\n }\n\n /**\n * Get label of form object\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Get introText of form object\n */\n get introText(): string {\n if (this.data.content?.text) {\n return this.data.content.text.message;\n }\n\n if (this.contributions.text?.message) {\n return this.contributions.text.message;\n }\n\n return this.contributions.introText;\n }\n\n /**\n * Get assistent of form object\n */\n get assistent(): string {\n return this.contributions.assistent;\n }\n\n /**\n * Get button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * get attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n mergeObject(oldObject: FormObjectModel) {\n this.attributeCollection.forEach((attribute) => {\n const mergeWithAttribute = oldObject.getAttributeByAttribute(attribute);\n if (mergeWithAttribute) {\n attribute.mergeAttribute(mergeWithAttribute);\n }\n });\n\n this.repeatIndex = oldObject.repeatIndex;\n }\n\n /**\n * Update attribute\n */\n updateAttribute(attribute: AttributeType, value: any): AttributeType {\n const attributeToUpdate =\n this.attributeCollection.getAttributeByAttribute(attribute);\n\n if (attributeToUpdate === null) {\n throw new Error(`Attribute with name: ${attribute.name} not found.`);\n }\n\n if (attributeToUpdate instanceof CompositeAttributeModel) {\n attributeToUpdate.update(value, attribute);\n } else {\n attributeToUpdate.update(value);\n }\n\n return attributeToUpdate;\n }\n\n /**\n * Inidicates if Form is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return (\n this.attributeCollection.find((attribute) =>\n attribute.isChangedSince(timestamp),\n ) !== null\n );\n }\n\n /**\n * Reset all errors on Form Object\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"formobject\");\n this.attributeCollection.forEach((attribute) => attribute.resetErrors());\n }\n\n /**\n * Get error messages\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n if (error.anchor?.elementid != null) {\n this.attributeCollection.addServerError(error);\n } else {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n error.layouthint,\n );\n }\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.attributeCollection.hasServerErrors()\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems || this.attributeCollection.hasErrors()\n );\n }\n\n /**\n */\n get isValid(): boolean {\n return (\n this.attributeCollection.visible.every(\n (attribute) => attribute.isValid,\n ) && !this.errorCollection.hasItems\n );\n }\n\n /**\n */\n get dynamicValidationsLoaded(): boolean {\n return this._dynamicValidationsLoaded;\n }\n\n /**\n */\n set dynamicValidationsLoaded(dynamicValidationsLoaded: boolean) {\n this._dynamicValidationsLoaded = dynamicValidationsLoaded;\n }\n\n /**\n * Convert error json from a form service to validation messages on the form object and attributes\n */\n handleErrorValidations(\n errors: Array<{\n anchor: {\n objectid: string,\n elementid?: string,\n },\n id: string,\n message: string,\n properties: MessageParameters,\n layouthint: Array<string>,\n }>,\n ) {\n const attributeErrors = [];\n\n errors.forEach((error) => {\n if (error.anchor?.objectid === this.key) {\n if (has(error.anchor, \"elementid\")) {\n attributeErrors.push(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n new LayoutHintCollection(error.layouthint),\n );\n }\n }\n });\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n * Convert missing json from a form service to mandatory validation constraints and messages\n */\n handleMissingValidations(missing: {\n anchors: Array<\n | {\n elements: Array<{ elementid: string }>,\n }\n | { anchor: { elementid: string } },\n >,\n }) {\n const attributeErrors = [];\n\n for (const anchor of missing.anchors) {\n if (Array.isArray(anchor.elements)) {\n for (const element of anchor.elements) {\n attributeErrors.push({\n anchor: { elementid: element.elementid },\n id: \"Constraint.Mandatory\",\n });\n }\n } else {\n attributeErrors.push({\n anchor,\n id: \"Constraint.Mandatory\",\n });\n }\n }\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n if (Array.isArray(data.errors)) {\n this.handleErrorValidations(data.errors);\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n this.handleMissingValidations(data.missing);\n }\n\n this.dynamicValidationsLoaded = true;\n\n return this;\n }\n\n /**\n * Generate formdata object for current formobject based on formdata of attributes\n */\n get formdata(): { [string]: any } | null {\n return this.attributeCollection.formdata;\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n return this.attributeCollection.getFormData(validationData);\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,U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CAACwG,MAAM,CAAC,EAAE;MAC9B,IAAI,CAACD,sBAAsB,CAACvG,IAAI,CAACwG,MAAM,CAAC;IAC1C;;IAEA;IACA,IAAIO,KAAK,CAACC,OAAO,CAAChH,IAAI,CAAC6G,OAAO,EAAEC,OAAO,CAAC,EAAE;MACxC,IAAI,CAACF,wBAAwB,CAAC5G,IAAI,CAAC6G,OAAO,CAAC;IAC7C;IAEA,IAAI,CAACR,wBAAwB,GAAG,IAAI;IAEpC,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,IAAIY,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAAChH,mBAAmB,CAACgH,QAAQ;EAC1C;;EAEA;AACF;EACEC,WAAWA,CAAA,EAA4D;IAAA,IAA3DC,cAAuB,GAAAtG,SAAA,CAAAvB,MAAA,QAAAuB,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,KAAK;IACzC,OAAO,IAAI,CAACZ,mBAAmB,CAACiH,WAAW,CAACC,cAAc,CAAC;EAC7D;AACF;AAACC,OAAA,CAAAhI,OAAA,GAAAN,eAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FormObjectModel.js","names":["_objects","require","_BaseModel","_interopRequireDefault","_AttributeCollection","_CompositeAttributeModel","_ContentConfiguration","_ErrorCollection","_exceptions","_LayoutHintCollection","FormObjectModel","BaseModel","constructor","object","objectContributions","_defineProperty2","default","getElements","length","_attributeCollection","AttributeCollection","getApplicableAttributeContributions","_contentConfiguration","ContentConfiguration","content","_errorCollection","ErrorCollection","has","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","createEmpty","formObjectModel","IllegalArgumentException","contributions","equals","_context","withRepeatIndex","arguments","undefined","key","objectContainsOneOfTheAttributes","_filter","all","call","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","_context2","dataResults","_map","result","elementid","_context3","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","_keys","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","setChildModels","models","objectid","hasEndResultConfiguration","getContribution","hasDynamicValidations","isRepeatable","_repeatIndex","index","maxRepeats","hasFixedNrOfRepeats","isRepeatWithUnknownTotal","isLastRepeat","last","repeatIndexLabel","label","introText","text","message","assistent","buttonLabels","mergeObject","oldObject","forEach","mergeWithAttribute","mergeAttribute","updateAttribute","value","attributeToUpdate","Error","name","CompositeAttributeModel","update","isChangedSince","timestamp","_context4","_find","resetErrors","errorCollection","addServerError","error","anchor","id","properties","layouthint","hasServerErrors","hasItems","hasErrors","isValid","visible","every","dynamicValidationsLoaded","_dynamicValidationsLoaded","handleErrorValidations","errors","attributeErrors","LayoutHintCollection","updateValidations","handleMissingValidations","missing","anchors","Array","isArray","formdata","getFormData","validationData","exports"],"sources":["../../../src/models/form/FormObjectModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport ErrorCollection from \"../error/ErrorCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\nimport type { AttributeType, ModularUIModel, FormErrorAnchor } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport type { MessageParameters } from \"../../i18n\";\n\n/**\n * Form Object\n */\nexport default class FormObjectModel extends BaseModel {\n _attributeCollection: AttributeCollection;\n _contentConfiguration: ContentConfiguration;\n _errorCollection: ErrorCollection;\n _repeatIndex: number;\n _dynamicValidationsLoaded: boolean;\n\n /**\n * Construct FormObjectModel\n */\n constructor(object: Object, objectContributions: Object) {\n super(object, objectContributions);\n\n if (object && this.getElements().length > 0) {\n this._attributeCollection = new AttributeCollection(\n this.getElements(),\n this.getApplicableAttributeContributions(),\n );\n } else {\n this._attributeCollection = new AttributeCollection();\n }\n\n this._contentConfiguration = new ContentConfiguration(\n objectContributions ? objectContributions.content : {},\n );\n\n this._errorCollection = new ErrorCollection(\"formobject\");\n\n if (has(this.data, \"referenceDate\")) {\n this.attributeCollection.setReferenceDate(this.getData(\"referenceDate\"));\n }\n\n this.attributeCollection.indicateContentConfiguration(\n this.contentConfiguration,\n );\n }\n\n /**\n */\n static createEmpty(formObjectModel: FormObjectModel): FormObjectModel {\n if (!formObjectModel) {\n throw new IllegalArgumentException(\n \"createEmpty method needs a FormObjectModel as input argument to create a new version of the object\",\n );\n }\n return new FormObjectModel(\n formObjectModel.data,\n formObjectModel.contributions,\n );\n }\n\n /**\n */\n equals(object: ?FormObjectModel, withRepeatIndex: boolean = true): boolean {\n if (!object || this.key !== object.key) {\n return false;\n }\n\n const objectContainsOneOfTheAttributes = this.attributeCollection.all\n .filter((attribute) => !attribute.isResult)\n .some(\n (attribute) =>\n object && object.attributeCollection.hasAttributeByKey(attribute.key),\n );\n\n const hasSameRepeatIndex = withRepeatIndex\n ? this.repeatIndex === object.repeatIndex\n : true;\n\n return hasSameRepeatIndex && objectContainsOneOfTheAttributes;\n }\n\n /**\n */\n getAttributeByAttribute(attribute: AttributeType): AttributeType | null {\n return this.attributeCollection.getAttributeByAttribute(attribute);\n }\n\n /**\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this.attributeCollection.getAttributeByKey(key);\n }\n\n /**\n */\n hasAttributeByKey(key: string): boolean {\n return this.attributeCollection.hasAttributeByKey(key);\n }\n\n /**\n * Get elements from both the missing attributes and the result attributes\n */\n getElements(): Array<Object> {\n const elements = [];\n\n if (this.data.elements) {\n elements.push(...this.data.elements);\n }\n\n if (this.data.results) {\n const dataResults = this.data.results.map((result) => ({\n ...result,\n isResult: true,\n }));\n\n elements.push(...dataResults);\n }\n\n if (this.data.elementid) {\n elements.push({\n ...this.data,\n });\n }\n\n return elements;\n }\n\n /**\n * Map available contributions on the available data. Only use contributions that are needed for the data\n */\n getApplicableAttributeContributions(): Array<Object> {\n if (this.data && this.contributions) {\n const dataElementIds = this.getElements().map(\n (element) => element.elementid,\n );\n\n const contributions = this.getAttributesInData(\n dataElementIds,\n this.contributions.attributes,\n );\n\n // set all attribute mandatory for dynamic object\n if (this.isDynamic) {\n return contributions.map((attribute) => {\n const [attributeKey] = Object.keys(attribute);\n return {\n [attributeKey]: {\n ...attribute[attributeKey],\n mandatory: true,\n },\n };\n });\n }\n\n return contributions;\n }\n\n return [];\n }\n\n /**\n * Recursevily check if an attribute id occurs in the tree of attribute contributions.\n * The complete leaf of the tree is returned when an attribute id matches\n */\n getAttributesInData(\n dataElementIds: Array<string>,\n attributesContributions: Object,\n ): Array<Object> {\n return attributesContributions.filter((attributeContributions) => {\n const [attributeKey] = Object.keys(attributeContributions);\n\n return dataElementIds.some(\n (dataElementId) => dataElementId.split(\".\")[0] === attributeKey,\n );\n });\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this._attributeCollection.getInitialChildModelLinks();\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n }\n\n /**\n * get key\n */\n get key(): string {\n return this.data.objectid;\n }\n\n /**\n * Get content configuration for form objects\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n get hasEndResultConfiguration(): boolean {\n return this.contributions.content?.results != null;\n }\n\n /**\n * Indicates if object is dynamic. A dynamic object should be submitted on each attribute change\n */\n get isDynamic(): boolean {\n return this.getContribution(\"dynamicObject\", false);\n }\n\n /**\n */\n get hasDynamicValidations(): boolean {\n return this.getContribution(\"dynamicValidations\", false);\n }\n\n /**\n * Indicates if object is repeatable\n */\n get isRepeatable(): boolean {\n return this.getContribution(\"repeatable\", false);\n }\n\n /**\n */\n get repeatIndex(): number {\n return this._repeatIndex ?? this.data.index ?? 1;\n }\n\n /**\n */\n set repeatIndex(repeatIndex: number) {\n this._repeatIndex = repeatIndex;\n }\n\n /**\n */\n get maxRepeats(): number {\n if (this.isRepeatable) {\n return this.getData(\"numberofrepeats\", -1);\n }\n\n return 1;\n }\n\n /**\n */\n get hasFixedNrOfRepeats(): boolean {\n return this.maxRepeats > -1;\n }\n\n /**\n */\n get isRepeatWithUnknownTotal(): boolean {\n return this.isRepeatable && this.maxRepeats === -1;\n }\n\n /**\n */\n get isLastRepeat(): boolean {\n if (this.isRepeatable) {\n return this.data.last || false;\n }\n\n return true;\n }\n\n /**\n */\n get repeatIndexLabel(): string | null {\n return this.data[\"index-identifier\"] || null;\n }\n\n /**\n * Get label of form object\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Get introText of form object\n */\n get introText(): string {\n if (this.data.content?.text) {\n return this.data.content.text.message;\n }\n\n if (this.contributions.text?.message) {\n return this.contributions.text.message;\n }\n\n return this.contributions.introText;\n }\n\n /**\n * Get assistent of form object\n */\n get assistent(): string {\n return this.contributions.assistent;\n }\n\n /**\n * Get button labels\n */\n get buttonLabels(): Object {\n return this.getContribution(\"buttonLabels\", {});\n }\n\n /**\n * get attribute collection\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(attributeCollection: AttributeCollection) {\n this._attributeCollection = attributeCollection;\n }\n\n /**\n */\n mergeObject(oldObject: FormObjectModel) {\n this.attributeCollection.forEach((attribute) => {\n const mergeWithAttribute = oldObject.getAttributeByAttribute(attribute);\n if (mergeWithAttribute) {\n attribute.mergeAttribute(mergeWithAttribute);\n }\n });\n\n this.repeatIndex = oldObject.repeatIndex;\n }\n\n /**\n * Update attribute\n */\n updateAttribute(attribute: AttributeType, value: any): AttributeType {\n const attributeToUpdate =\n this.attributeCollection.getAttributeByAttribute(attribute);\n\n if (attributeToUpdate === null) {\n throw new Error(`Attribute with name: ${attribute.name} not found.`);\n }\n\n if (attributeToUpdate instanceof CompositeAttributeModel) {\n attributeToUpdate.update(value, attribute);\n } else {\n attributeToUpdate.update(value);\n }\n\n return attributeToUpdate;\n }\n\n /**\n * Inidicates if Form is changed since a given timestamp (Date.now)\n */\n isChangedSince(timestamp: number): boolean {\n return (\n this.attributeCollection.find((attribute) =>\n attribute.isChangedSince(timestamp),\n ) !== null\n );\n }\n\n /**\n * Reset all errors on Form Object\n */\n resetErrors() {\n this._errorCollection = new ErrorCollection(\"formobject\");\n this.attributeCollection.forEach((attribute) => attribute.resetErrors());\n }\n\n /**\n * Get error messages\n */\n get errorCollection(): ErrorCollection {\n return this._errorCollection;\n }\n\n /**\n * Registers an error that was received from a server response\n */\n addServerError(error: FormErrorAnchor) {\n if (error.anchor?.elementid != null) {\n this.attributeCollection.addServerError(error);\n } else {\n this._errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n error.layouthint,\n );\n }\n }\n\n /**\n */\n hasServerErrors(): boolean {\n return (\n this.errorCollection.hasItems ||\n this.attributeCollection.hasServerErrors()\n );\n }\n\n /**\n */\n hasErrors(): boolean {\n return (\n this.errorCollection.hasItems || this.attributeCollection.hasErrors()\n );\n }\n\n /**\n */\n get isValid(): boolean {\n return (\n this.attributeCollection.visible.every(\n (attribute) => attribute.isValid,\n ) && !this.errorCollection.hasItems\n );\n }\n\n /**\n */\n get dynamicValidationsLoaded(): boolean {\n return this._dynamicValidationsLoaded;\n }\n\n /**\n */\n set dynamicValidationsLoaded(dynamicValidationsLoaded: boolean) {\n this._dynamicValidationsLoaded = dynamicValidationsLoaded;\n }\n\n /**\n * Convert error json from a form service to validation messages on the form object and attributes\n */\n handleErrorValidations(\n errors: Array<{\n anchor: {\n objectid: string,\n elementid?: string,\n },\n id: string,\n message: string,\n properties: MessageParameters,\n layouthint: Array<string>,\n }>,\n ) {\n const attributeErrors = [];\n\n errors.forEach((error) => {\n if (error.anchor?.objectid === this.key) {\n if (has(error.anchor, \"elementid\")) {\n attributeErrors.push(error);\n } else {\n this.errorCollection.addServerError(\n error.id,\n error.message,\n error.properties,\n new LayoutHintCollection(error.layouthint),\n );\n }\n }\n });\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n * Convert missing json from a form service to mandatory validation constraints and messages\n */\n handleMissingValidations(missing: {\n anchors: Array<\n | {\n elements: Array<{ elementid: string }>,\n objectid?: string,\n }\n | { anchor: { elementid: string, objectid?: string } },\n >,\n }) {\n const attributeErrors = [];\n\n for (const anchor of missing.anchors) {\n const { objectid, elements } = anchor;\n if (!objectid || objectid === this.key) {\n if (Array.isArray(elements)) {\n for (const element of elements) {\n attributeErrors.push({\n anchor: { elementid: element.elementid },\n id: \"Constraint.Mandatory\",\n });\n }\n } else {\n attributeErrors.push({\n anchor,\n id: \"Constraint.Mandatory\",\n });\n }\n }\n }\n\n this.attributeCollection.updateValidations(attributeErrors);\n }\n\n /**\n */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n if (Array.isArray(data.errors)) {\n this.handleErrorValidations(data.errors);\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n this.handleMissingValidations(data.missing);\n }\n\n this.dynamicValidationsLoaded = true;\n\n return this;\n }\n\n /**\n * Generate formdata object for current formobject based on formdata of attributes\n */\n get formdata(): { [string]: any } | null {\n return this.attributeCollection.formdata;\n }\n\n /**\n */\n getFormData(validationData: boolean = false): { [string]: any } | null {\n return this.attributeCollection.getFormData(validationData);\n }\n}\n"],"mappings":";;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,wBAAA,GAAAF,sBAAA,CAAAF,OAAA;AACA,IAAAK,qBAAA,GAAAH,sBAAA,CAAAF,OAAA;AACA,IAAAM,gBAAA,GAAAJ,sBAAA,CAAAF,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAIA,IAAAQ,qBAAA,GAAAN,sBAAA,CAAAF,OAAA;AAGA;AACA;AACA;AACe,MAAMS,eAAe,SAASC,kB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,OAAO,CAAC;IAC7C;IAEA,IAAI,CAACR,wBAAwB,GAAG,IAAI;IAEpC,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACE,IAAIY,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAAChH,mBAAmB,CAACgH,QAAQ;EAC1C;;EAEA;AACF;EACEC,WAAWA,CAAA,EAA4D;IAAA,IAA3DC,cAAuB,GAAAtG,SAAA,CAAAvB,MAAA,QAAAuB,SAAA,QAAAC,SAAA,GAAAD,SAAA,MAAG,KAAK;IACzC,OAAO,IAAI,CAACZ,mBAAmB,CAACiH,WAAW,CAACC,cAAc,CAAC;EAC7D;AACF;AAACC,OAAA,CAAAhI,OAAA,GAAAN,eAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -123,6 +123,17 @@ class AttributeDataHelper {
|
|
|
123
123
|
data: Object | Array<Object>,
|
|
124
124
|
childrenKeys: Array<Object> = [],
|
|
125
125
|
): Array<AttributeDataHelper> {
|
|
126
|
+
// Check if the original data explicitly contains the key and is explicitly null.
|
|
127
|
+
const keyExplicitlyNull = this.value === null;
|
|
128
|
+
|
|
129
|
+
if (keyExplicitlyNull) {
|
|
130
|
+
// Handling for when the value is explicitly null: set childData to null.
|
|
131
|
+
return childrenKeys.map((keyObject) => {
|
|
132
|
+
const childData = null;
|
|
133
|
+
return this.createChild(data, childData, keyObject);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
126
137
|
const childrenIsArray = Array.isArray(this.value);
|
|
127
138
|
|
|
128
139
|
if (childrenIsArray) {
|
|
@@ -167,7 +178,7 @@ class AttributeDataHelper {
|
|
|
167
178
|
.map((option) => option.code || option.key);
|
|
168
179
|
}
|
|
169
180
|
|
|
170
|
-
return
|
|
181
|
+
return undefined;
|
|
171
182
|
}
|
|
172
183
|
|
|
173
184
|
/**
|
|
@@ -287,9 +298,10 @@ class AttributeDataHelper {
|
|
|
287
298
|
/**
|
|
288
299
|
*/
|
|
289
300
|
getData(): Object {
|
|
301
|
+
const value = this.value === undefined ? null : this.value;
|
|
290
302
|
return {
|
|
291
303
|
key: this.key,
|
|
292
|
-
value:
|
|
304
|
+
value: value,
|
|
293
305
|
static: this.static,
|
|
294
306
|
_links: this.links,
|
|
295
307
|
dynamicschema: this.dynamicschema,
|
|
@@ -546,4 +546,89 @@ describe("attributeDataHelper", () => {
|
|
|
546
546
|
|
|
547
547
|
expect(firstChild.dynamicschema).toBeUndefined();
|
|
548
548
|
});
|
|
549
|
+
|
|
550
|
+
it("prioritizes parent attribute null value over child values in composite attributes", () => {
|
|
551
|
+
const data = {
|
|
552
|
+
_links: {
|
|
553
|
+
self: {
|
|
554
|
+
href: "/dockets/act/21",
|
|
555
|
+
},
|
|
556
|
+
api_doc: {
|
|
557
|
+
href: "/api-docs/v3/dockets/act/(case-id)",
|
|
558
|
+
},
|
|
559
|
+
contributions: {
|
|
560
|
+
href: "/contributions/dockets/act/(case-id)",
|
|
561
|
+
},
|
|
562
|
+
ActOverview: {
|
|
563
|
+
href: "/dockets/act/21/act-overview",
|
|
564
|
+
},
|
|
565
|
+
Conversation: {
|
|
566
|
+
href: "/dockets/act/21/messages",
|
|
567
|
+
},
|
|
568
|
+
History: {
|
|
569
|
+
href: "/dockets/act/21/history",
|
|
570
|
+
},
|
|
571
|
+
},
|
|
572
|
+
taskgroups: [
|
|
573
|
+
{
|
|
574
|
+
name: "Act",
|
|
575
|
+
actions: [
|
|
576
|
+
{
|
|
577
|
+
name: "delete",
|
|
578
|
+
method: "POST",
|
|
579
|
+
href: "/dockets/act/21/delete",
|
|
580
|
+
},
|
|
581
|
+
],
|
|
582
|
+
},
|
|
583
|
+
],
|
|
584
|
+
_id: 21,
|
|
585
|
+
Name: "Collect material for another borrower",
|
|
586
|
+
CaseState: "Review",
|
|
587
|
+
Explanation: null,
|
|
588
|
+
Actor_reference: null,
|
|
589
|
+
Object_reference: null,
|
|
590
|
+
Recipient_reference: null,
|
|
591
|
+
Action_reference: null,
|
|
592
|
+
};
|
|
593
|
+
const key = "Actor_reference";
|
|
594
|
+
const childrenKeys = [
|
|
595
|
+
{
|
|
596
|
+
key: "Name",
|
|
597
|
+
children: [],
|
|
598
|
+
},
|
|
599
|
+
];
|
|
600
|
+
|
|
601
|
+
const dataHelper = new AttributeDataHelper(data, key, childrenKeys);
|
|
602
|
+
|
|
603
|
+
expect(dataHelper.getData()).toStrictEqual({
|
|
604
|
+
key: "Actor_reference",
|
|
605
|
+
value: null,
|
|
606
|
+
static: false,
|
|
607
|
+
_links: {},
|
|
608
|
+
dynamicschemaId: "Actor_reference",
|
|
609
|
+
dynamicschema: undefined,
|
|
610
|
+
message: undefined,
|
|
611
|
+
options: undefined,
|
|
612
|
+
referenceDate: undefined,
|
|
613
|
+
isResult: false,
|
|
614
|
+
|
|
615
|
+
children: [
|
|
616
|
+
{
|
|
617
|
+
key: "Name",
|
|
618
|
+
static: false,
|
|
619
|
+
_links: {},
|
|
620
|
+
dynamicschemaId: "Name",
|
|
621
|
+
dynamicschema: undefined,
|
|
622
|
+
message: undefined,
|
|
623
|
+
options: undefined,
|
|
624
|
+
referenceDate: undefined,
|
|
625
|
+
isResult: false,
|
|
626
|
+
children: [],
|
|
627
|
+
content: null,
|
|
628
|
+
value: null,
|
|
629
|
+
},
|
|
630
|
+
],
|
|
631
|
+
content: null,
|
|
632
|
+
});
|
|
633
|
+
});
|
|
549
634
|
});
|
|
@@ -491,25 +491,29 @@ export default class FormObjectModel extends BaseModel {
|
|
|
491
491
|
anchors: Array<
|
|
492
492
|
| {
|
|
493
493
|
elements: Array<{ elementid: string }>,
|
|
494
|
+
objectid?: string,
|
|
494
495
|
}
|
|
495
|
-
| { anchor: { elementid: string } },
|
|
496
|
+
| { anchor: { elementid: string, objectid?: string } },
|
|
496
497
|
>,
|
|
497
498
|
}) {
|
|
498
499
|
const attributeErrors = [];
|
|
499
500
|
|
|
500
501
|
for (const anchor of missing.anchors) {
|
|
501
|
-
|
|
502
|
-
|
|
502
|
+
const { objectid, elements } = anchor;
|
|
503
|
+
if (!objectid || objectid === this.key) {
|
|
504
|
+
if (Array.isArray(elements)) {
|
|
505
|
+
for (const element of elements) {
|
|
506
|
+
attributeErrors.push({
|
|
507
|
+
anchor: { elementid: element.elementid },
|
|
508
|
+
id: "Constraint.Mandatory",
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
} else {
|
|
503
512
|
attributeErrors.push({
|
|
504
|
-
anchor
|
|
513
|
+
anchor,
|
|
505
514
|
id: "Constraint.Mandatory",
|
|
506
515
|
});
|
|
507
516
|
}
|
|
508
|
-
} else {
|
|
509
|
-
attributeErrors.push({
|
|
510
|
-
anchor,
|
|
511
|
-
id: "Constraint.Mandatory",
|
|
512
|
-
});
|
|
513
517
|
}
|
|
514
518
|
}
|
|
515
519
|
|