@beinformed/ui 1.9.0-beta.9 → 1.9.3
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 +48 -0
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useNotification.js.map +1 -1
- package/esm/hooks/useRouter.js.map +1 -1
- package/esm/models/attributes/AttributeContent.js +49 -20
- package/esm/models/attributes/AttributeContent.js.map +1 -1
- package/esm/models/attributes/AttributeDataHelper.js +1 -1
- package/esm/models/attributes/AttributeDataHelper.js.map +1 -1
- package/esm/models/attributes/HelptextAttributeModel.js +3 -1
- package/esm/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/esm/models/caseview/CaseViewModel.js +26 -12
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/esm/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/esm/models/form/FormObjectModel.js +8 -2
- package/esm/models/form/FormObjectModel.js.map +1 -1
- package/esm/models/layouthint/LayoutHintCollection.js +3 -2
- package/esm/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/esm/models/list/ListDetailModel.js +25 -0
- package/esm/models/list/ListDetailModel.js.map +1 -1
- package/esm/models/list/ListModel.js +22 -16
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/panels/GroupingPanelModel.js +19 -17
- package/esm/models/panels/GroupingPanelModel.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +2 -1
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/redux/actions/FormAutosave.js +2 -1
- package/esm/redux/actions/FormAutosave.js.map +1 -1
- package/esm/redux/actions/FormValidations.js +2 -1
- package/esm/redux/actions/FormValidations.js.map +1 -1
- package/lib/hooks/useForm.js.flow +10 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useNotification.js.flow +5 -2
- package/lib/hooks/useNotification.js.map +1 -1
- package/lib/hooks/useRouter.js.flow +12 -5
- package/lib/hooks/useRouter.js.map +1 -1
- package/lib/models/attributes/AttributeContent.js +51 -20
- package/lib/models/attributes/AttributeContent.js.flow +38 -13
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/attributes/AttributeDataHelper.js +1 -1
- package/lib/models/attributes/AttributeDataHelper.js.flow +2 -1
- package/lib/models/attributes/AttributeDataHelper.js.map +1 -1
- package/lib/models/attributes/HelptextAttributeModel.js +3 -1
- package/lib/models/attributes/HelptextAttributeModel.js.flow +1 -1
- package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +4 -2
- package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +9 -3
- package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +1 -1
- package/lib/models/caseview/CaseViewModel.js +27 -13
- package/lib/models/caseview/CaseViewModel.js.flow +17 -7
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/caseview/__tests__/CaseViewModel.spec.js.flow +68 -184
- package/lib/models/concepts/__mock__/business_scenario.js.flow +14 -1
- package/lib/models/concepts/__mock__/conceptdetail.js.flow +15 -6
- package/lib/models/concepts/__tests__/BusinessScenarioModel.spec.js.flow +5 -6
- package/lib/models/concepts/__tests__/ConceptDetailModel.spec.js.flow +58 -3
- package/lib/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.flow +2 -2
- package/lib/models/contentconfiguration/ContentConfigurationResults.js.map +1 -1
- package/lib/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js.flow +6 -6
- package/lib/models/form/FormObjectModel.js +8 -2
- package/lib/models/form/FormObjectModel.js.flow +5 -1
- package/lib/models/form/FormObjectModel.js.map +1 -1
- package/lib/models/form/__tests__/FormObjectModel.spec.js.flow +2 -2
- package/lib/models/layouthint/LayoutHintCollection.js +4 -2
- package/lib/models/layouthint/LayoutHintCollection.js.flow +8 -7
- package/lib/models/layouthint/LayoutHintCollection.js.map +1 -1
- package/lib/models/list/ListDetailModel.js +25 -0
- package/lib/models/list/ListDetailModel.js.flow +19 -0
- package/lib/models/list/ListDetailModel.js.map +1 -1
- package/lib/models/list/ListModel.js +23 -16
- package/lib/models/list/ListModel.js.flow +9 -5
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/list/__tests__/ListDetailModel.spec.js.flow +64 -0
- package/lib/models/list/__tests__/ListModel.spec.js.flow +64 -2
- package/lib/models/panels/GroupingPanelModel.js +21 -18
- package/lib/models/panels/GroupingPanelModel.js.flow +10 -9
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/panels/__tests__/GroupingPanelModel.spec.js.flow +90 -0
- package/lib/models/types.js.flow +24 -6
- package/lib/modularui/ModularUIRequest.js +2 -1
- package/lib/modularui/ModularUIRequest.js.flow +1 -0
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/redux/actions/FormAutosave.js +2 -1
- package/lib/redux/actions/FormAutosave.js.flow +1 -0
- package/lib/redux/actions/FormAutosave.js.map +1 -1
- package/lib/redux/actions/FormValidations.js +2 -1
- package/lib/redux/actions/FormValidations.js.flow +1 -0
- package/lib/redux/actions/FormValidations.js.map +1 -1
- package/package.json +15 -15
- package/src/hooks/useForm.js +10 -5
- package/src/hooks/useNotification.js +5 -2
- package/src/hooks/useRouter.js +12 -5
- package/src/models/attributes/AttributeContent.js +38 -13
- package/src/models/attributes/AttributeDataHelper.js +2 -1
- package/src/models/attributes/HelptextAttributeModel.js +1 -1
- package/src/models/attributes/__tests__/AttributeContent.spec.js +4 -2
- package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +9 -3
- package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +1 -1
- package/src/models/caseview/CaseViewModel.js +17 -7
- package/src/models/caseview/__tests__/CaseViewModel.spec.js +68 -184
- package/src/models/caseview/__tests__/caseview.json +38 -0
- package/src/models/caseview/__tests__/caseviewContributions.json +147 -0
- package/src/models/concepts/__mock__/business_scenario.js +14 -1
- package/src/models/concepts/__mock__/business_scenario_step.json +64 -0
- package/src/models/concepts/__mock__/conceptdetail.js +15 -6
- package/src/models/concepts/__mock__/conceptdetail_data.json +117 -17
- package/src/models/concepts/__mock__/concepttype_Calculation.json +75 -0
- package/src/models/concepts/__tests__/BusinessScenarioModel.spec.js +5 -6
- package/src/models/concepts/__tests__/ConceptDetailModel.spec.js +58 -3
- package/src/models/contentconfiguration/ContentConfigurationResults.js +2 -2
- package/src/models/contentconfiguration/__tests__/ContentConfigurationResults.spec.js +6 -6
- package/src/models/form/FormObjectModel.js +5 -1
- package/src/models/form/__tests__/FormObjectModel.spec.js +2 -2
- package/src/models/form/__tests__/FormWithContentData.json +2 -1
- package/src/models/layouthint/LayoutHintCollection.js +8 -7
- package/src/models/list/ListDetailModel.js +19 -0
- package/src/models/list/ListModel.js +9 -5
- package/src/models/list/__tests__/ListDetailModel.spec.js +64 -0
- package/src/models/list/__tests__/ListModel.spec.js +64 -2
- package/src/models/list/__tests__/caselist-34.contributions.json +1 -1
- package/src/models/list/__tests__/listContributions.json +1 -1
- package/src/models/panels/GroupingPanelModel.js +10 -9
- package/src/models/panels/__tests__/GroupingPanelModel.spec.js +90 -0
- package/src/models/panels/__tests__/groupingPanel.json +30 -0
- package/src/models/panels/__tests__/groupingPanelContributions.json +46 -0
- package/src/models/types.js +24 -6
- package/src/modularui/ModularUIRequest.js +1 -0
- package/src/redux/actions/FormAutosave.js +1 -0
- package/src/redux/actions/FormValidations.js +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","label","header","description","message","elements","element","
|
|
1
|
+
{"version":3,"sources":["../../../src/models/attributes/AttributeContent.js"],"names":["AttributeContent","content","_content","headerLabel","headerDescription","label","header","description","message","elements","element","propertyElement","layouthint","properties","LayoutHintCollection","textFragmentElement","textfragments","textfragment","text","contentElement","sections","section","SectionModel","elementName","collectionName","getContentElements","ids","property","type","keys","types","referredSections","push","getReferredSections"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AASA;;AACA;;;;;;;;;;;;IAEMA,gB;AAGJ,4BAAYC,OAAZ,EAAmC;AAAA;AAAA;AACjC,SAAKC,QAAL,GAAgBD,OAAhB;AACD;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,oCAAP;AACD;AAED;AACF;;;;SACE,eAGE;AAAA;;AACA,UAAIE,WAAW,GAAG,IAAlB;AACA,UAAIC,iBAAiB,GAAG,IAAxB;AAEA,UAAMC,KAAK,qBAAG,KAAKH,QAAR,4EAAG,eAAeI,MAAlB,0DAAG,sBAAuBD,KAArC;;AACA,UAAIA,KAAJ,EAAW;AACTF,QAAAA,WAAW,GAAGE,KAAd;AACD;;AAED,UAAME,WAAW,sBAAG,KAAKL,QAAR,6EAAG,gBAAeI,MAAlB,0DAAG,sBAAuBC,WAA3C;;AACA,UAAIA,WAAJ,EAAiB;AACf,YAAI,0BAAcA,WAAd,KAA8B,aAAaA,WAA/C,EAA4D;AAC1DH,UAAAA,iBAAiB,GAAGG,WAAW,CAACC,OAAhC;AACD,SAFD,MAEO,IAAI,OAAOD,WAAP,KAAuB,QAA3B,EAAqC;AAC1CH,UAAAA,iBAAiB,GAAGG,WAApB;AACD;AACF;;AAED,aAAO;AAAEF,QAAAA,KAAK,EAAEF,WAAT;AAAsBI,QAAAA,WAAW,EAAEH;AAAnC,OAAP;AACD;AAED;AACF;;;;SACE,eAA2B;AAAA;;AACzB,6BAAI,KAAKF,QAAT,4CAAI,gBAAeO,QAAnB,EAA6B;AAAA;;AAC3B,wCAAO,KAAKP,QAAL,CAAcO,QAArB,0DAAO,qEAA4B,UAACC,OAAD,EAAa;AAC9C,cAAI,qBAAqBA,OAAzB,EAAkC;AAChC;AACA,wCAA0CA,OAAO,CAACC,eAAlD;AAAA,gBAAQN,KAAR,yB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AA6D;AAAA;;AAC3D,aAAO,sCAAKV,QAAL,kBAAqB,UAACC,OAAD;AAAA,eAAa,uBAAAS,KAAK,MAAL,CAAAA,KAAK,EAAUT,OAAO,CAACO,IAAlB,CAAlB;AAAA,OAArB,CAAP;AACD;AAED;AACF;;;;WACE,+BAA6D;AAC3D,UAAMG,gBAAgB,GAAG,EAAzB;;AAD2D,iDAGrC,KAAKX,QAHgC;AAAA;;AAAA;AAG3D,4DAAqC;AAAA,cAA1BC,OAA0B;AACnCU,UAAAA,gBAAgB,CAACC,IAAjB,OAAAD,gBAAgB,mCAASV,OAAO,CAACY,mBAAR,EAAT,EAAhB;AACD;AAL0D;AAAA;AAAA;AAAA;AAAA;;AAO3D,aAAOF,gBAAP;AACD;;;;;eAGY/B,gB","sourcesContent":["// @flow\nimport { retrieveText } from \"../../utils/helpers/text\";\nimport { hasAllContentInData } from \"../../constants/Settings\";\nimport SectionModel from \"../content/SectionModel\";\n\nimport type {\n ContentData,\n PropertyData,\n TextFragmentData,\n ContentAll,\n} from \"../types\";\nimport type SubSectionModel from \"../content/SubSectionModel\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\nclass AttributeContent {\n _content: ?ContentData;\n\n constructor(content: ?ContentData) {\n this._content = content;\n }\n\n /**\n */\n get fromData(): boolean {\n return hasAllContentInData();\n }\n\n /**\n */\n get header(): {\n label: ?string,\n description: ?string,\n } {\n let headerLabel = null;\n let headerDescription = null;\n\n const label = this._content?.header?.label;\n if (label) {\n headerLabel = label;\n }\n\n const description = this._content?.header?.description;\n if (description) {\n if (isPlainObject(description) && \"message\" in description) {\n headerDescription = description.message;\n } else if (typeof description === \"string\") {\n headerDescription = description;\n }\n }\n\n return { label: headerLabel, description: headerDescription };\n }\n\n /**\n */\n get elements(): ContentAll {\n if (this._content?.elements) {\n return this._content.elements?.map((element) => {\n if (\"propertyElement\" in element) {\n // $FlowIssue\n const { label, layouthint, properties } = element.propertyElement;\n\n return {\n propertyElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n properties,\n },\n };\n }\n\n if (\"textFragmentElement\" in element) {\n const { label, layouthint, textfragments } =\n // $FlowIssue\n element.textFragmentElement;\n return {\n textFragmentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n textfragments: textfragments.map((textfragment) => ({\n ...textfragment,\n text: retrieveText(textfragment.text),\n })),\n },\n };\n }\n\n if (\"contentElement\" in element) {\n // $FlowIssue\n const { label, layouthint, sections } = element.contentElement;\n return {\n contentElement: {\n label,\n layouthint: new LayoutHintCollection(layouthint),\n sections: sections.map(\n (section) => new SectionModel(section, null)\n ),\n },\n };\n }\n\n // $FlowIssue\n return element;\n });\n }\n\n return [];\n }\n\n /**\n */\n get label(): ?string {\n return this._content?.label;\n }\n\n /**\n */\n getContentElements<T>(elementName: string, collectionName: string): Array<T> {\n return this.elements\n .filter((element) => elementName in element)\n .map((element) => element[elementName][collectionName])\n .flat();\n }\n\n /**\n */\n get properties(): Array<PropertyData> {\n return this.getContentElements<PropertyData>(\n \"propertyElement\",\n \"properties\"\n );\n }\n\n /**\n * Get concept properties by id\n */\n getConceptPropertiesByIds(ids: Array<string>): Array<PropertyData> {\n return this.properties.filter((property) => ids.includes(property.type));\n }\n\n /**\n */\n get textfragments(): Array<TextFragmentData> {\n return this.getContentElements<TextFragmentData>(\n \"textFragmentElement\",\n \"textfragments\"\n );\n }\n\n /**\n * Get concept text fragments by type\n */\n getTextFragmentByKeys(keys: Array<string>): Array<TextFragmentData> {\n return this.textfragments.filter((textfragment) =>\n keys.includes(textfragment.type)\n );\n }\n\n /**\n */\n get sections(): Array<SectionModel> {\n return this.getContentElements<SectionModel>(\"contentElement\", \"sections\");\n }\n\n /**\n */\n getSectionsByType(types: Array<string>): Array<SectionModel> {\n return this.sections.filter((section) => types.includes(section.type));\n }\n\n /**\n */\n getReferredSections(): Array<SectionModel | SubSectionModel> {\n const referredSections = [];\n\n for (const section of this.sections) {\n referredSections.push(...section.getReferredSections());\n }\n\n return referredSections;\n }\n}\n\nexport default AttributeContent;\n"],"file":"AttributeContent.js"}
|
|
@@ -321,7 +321,7 @@ var AttributeDataHelper = /*#__PURE__*/function () {
|
|
|
321
321
|
key: "content",
|
|
322
322
|
get: function get() {
|
|
323
323
|
if (this._attribute.content) {
|
|
324
|
-
var pickedContent = (0, _pick.default)(this._attribute.content, ["header", "label", "
|
|
324
|
+
var pickedContent = (0, _pick.default)(this._attribute.content, ["header", "label", "elements", "layouthint"]);
|
|
325
325
|
|
|
326
326
|
if ((0, _keys.default)(pickedContent).length > 0) {
|
|
327
327
|
return pickedContent;
|
|
@@ -267,9 +267,10 @@ class AttributeDataHelper {
|
|
|
267
267
|
const pickedContent = pick(this._attribute.content, [
|
|
268
268
|
"header",
|
|
269
269
|
"label",
|
|
270
|
-
"description",
|
|
271
270
|
"elements",
|
|
271
|
+
"layouthint",
|
|
272
272
|
]);
|
|
273
|
+
|
|
273
274
|
if (Object.keys(pickedContent).length > 0) {
|
|
274
275
|
return pickedContent;
|
|
275
276
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"names":["AttributeDataHelper","data","key","childrenKeys","_key","Array","isArray","_attribute","attr","elementid","name","param","_value","getValue","attributeData","_links","undefined","_children","createChildren","parentKey","childKey","elements","element","parentData","content","childData","keyObject","dynamicschema","dynamicschemaId","children","childrenIsArray","value","createChild","attribute","suggestions","suggestion","options","option","selected","code","static","attrDS","message","isResult","referenceDate","pickedContent","length","links","child","subChild","getData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;IACMA,mB;AAMJ;AACF;AACE,+BACEC,IADF,EAEEC,GAFF,EAGEC,YAHF,EAIE;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAKC,IAAL,GAAYF,GAAZ;;AAEA,QAAIG,KAAK,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;AASLC,QAAAA,QAAQ,EAAE,KAAKA,QATV;AAULC,QAAAA,aAAa,EAAE,KAAKA,aAVf;AAWLf,QAAAA,QAAQ,EAAE,mCAAKA,QAAL,kBAAkB,UAACmB,KAAD;AAAA,iBAC1B3C,KAAK,CAACC,OAAN,CAAc0C,KAAd,IACI,kBAAAA,KAAK,MAAL,CAAAA,KAAK,EAAK,UAACC,QAAD;AAAA,mBAAcA,QAAQ,CAACC,OAAT,EAAd;AAAA,WAAL,CADT,GAEIF,KAAK,CAACE,OAAN,EAHsB;AAAA,SAAlB,CAXL;AAgBL1B,QAAAA,OAAO,EAAE,KAAKA;AAhBT,OAAP;AAkBD;;;;;eAGYxB,mB","sourcesContent":["// @flow\nimport cloneDeep from \"lodash/cloneDeep\";\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 = cloneDeep(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n this._value = data[key] === undefined ? this.getValue(data) : data[key];\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 \"description\",\n \"elements\",\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"],"file":"AttributeDataHelper.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/models/attributes/AttributeDataHelper.js"],"names":["AttributeDataHelper","data","key","childrenKeys","_key","Array","isArray","_attribute","attr","elementid","name","param","_value","getValue","attributeData","_links","undefined","_children","createChildren","parentKey","childKey","elements","element","parentData","content","childData","keyObject","dynamicschema","dynamicschemaId","children","childrenIsArray","value","createChild","attribute","suggestions","suggestion","options","option","selected","code","static","attrDS","message","isResult","referenceDate","pickedContent","length","links","child","subChild","getData"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;IACMA,mB;AAMJ;AACF;AACE,+BACEC,IADF,EAEEC,GAFF,EAGEC,YAHF,EAIE;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAKC,IAAL,GAAYF,GAAZ;;AAEA,QAAIG,KAAK,CAACC,OAAN,CAAcL,IAAd,CAAJ,EAAyB;AACvB,WAAKM,UAAL,GACE,mBAAAN,IAAI,MAAJ,CAAAA,IAAI,EACF,UAACO,IAAD;AAAA,eACEA,IAAI,CAACC,SAAL,KAAmBP,GAAnB,IAA0BM,IAAI,CAACE,IAAL,KAAcR,GAAxC,IAA+CM,IAAI,CAACG,KAAL,KAAeT,GADhE;AAAA,OADE,CAAJ,IAGK,EAJP;AAKA,WAAKU,MAAL,GAAc,KAAKC,QAAL,CAAc,KAAKN,UAAnB,CAAd;AACD,KAPD,MAOO;AACL,UAAMO,aAAa,GAAG,wBAAUb,IAAV,CAAtB;AACAa,MAAAA,aAAa,CAACC,MAAd,GAAuB,mBAAKd,IAAI,CAACc,MAAV,EAAkB,CACvC,SADuC,EAEvC,UAFuC,EAGvC,eAHuC,EAIvC,YAJuC,CAAlB,CAAvB;AAOA,WAAKR,UAAL,GAAkBO,aAAlB;AAEA,WAAKF,MAAL,GAAcX,IAAI,CAACC,GAAD,CAAJ,KAAcc,SAAd,GAA0B,KAAKH,QAAL,CAAcZ,IAAd,CAA1B,GAAgDA,IAAI,CAACC,GAAD,CAAlE;AACD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EAIlD,YAJkD,CAA9B,CAAtB;;AAOA,YAAI,mBAAYqB,aAAZ,EAA2BC,MAA3B,GAAoC,CAAxC,EAA2C;AACzC,iBAAOD,aAAP;AACD;AACF;;AAED,aAAO,IAAP;AACD;AAED;AACF;;;;WACE,mBAAkB;AAAA;;AAChB,aAAO;AACL3C,QAAAA,GAAG,EAAE,KAAKA,GADL;AAEL6B,QAAAA,KAAK,EAAE,KAAKA,KAFP;AAGLS,QAAAA,MAAM,EAAE,KAAKA,MAHR;AAILzB,QAAAA,MAAM,EAAE,KAAKgC,KAJR;AAKLpB,QAAAA,aAAa,EAAE,KAAKA,aALf;AAMLC,QAAAA,eAAe,EAAE,KAAKA,eANjB;AAOLQ,QAAAA,OAAO,EAAE,KAAKA,OAPT;AAQLM,QAAAA,OAAO,EAAE,KAAKA,OART;AASLC,QAAAA,QAAQ,EAAE,KAAKA,QATV;AAULC,QAAAA,aAAa,EAAE,KAAKA,aAVf;AAWLf,QAAAA,QAAQ,EAAE,mCAAKA,QAAL,kBAAkB,UAACmB,KAAD;AAAA,iBAC1B3C,KAAK,CAACC,OAAN,CAAc0C,KAAd,IACI,kBAAAA,KAAK,MAAL,CAAAA,KAAK,EAAK,UAACC,QAAD;AAAA,mBAAcA,QAAQ,CAACC,OAAT,EAAd;AAAA,WAAL,CADT,GAEIF,KAAK,CAACE,OAAN,EAHsB;AAAA,SAAlB,CAXL;AAgBL1B,QAAAA,OAAO,EAAE,KAAKA;AAhBT,OAAP;AAkBD;;;;;eAGYxB,mB","sourcesContent":["// @flow\nimport cloneDeep from \"lodash/cloneDeep\";\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 = cloneDeep(data);\n attributeData._links = pick(data._links, [\n \"concept\",\n \"download\",\n \"lookupOptions\",\n \"lookupList\",\n ]);\n\n this._attribute = attributeData;\n\n this._value = data[key] === undefined ? this.getValue(data) : data[key];\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 ]);\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"],"file":"AttributeDataHelper.js"}
|
|
@@ -58,7 +58,9 @@ var HelptextAttributeModel = /*#__PURE__*/function (_LabelAttributeModel) {
|
|
|
58
58
|
var dataText = this.getData("value");
|
|
59
59
|
|
|
60
60
|
if (dataText) {
|
|
61
|
-
|
|
61
|
+
var _dataText$message;
|
|
62
|
+
|
|
63
|
+
return (_dataText$message = dataText.message) !== null && _dataText$message !== void 0 ? _dataText$message : dataText;
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
var contributionText = this.getContribution("text");
|
|
@@ -28,7 +28,7 @@ export default class HelptextAttributeModel extends LabelAttributeModel {
|
|
|
28
28
|
get text(): string | null {
|
|
29
29
|
const dataText = this.getData("value");
|
|
30
30
|
if (dataText) {
|
|
31
|
-
return dataText.message;
|
|
31
|
+
return dataText.message ?? dataText;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
const contributionText = this.getContribution("text");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/attributes/HelptextAttributeModel.js"],"names":["HelptextAttributeModel","dataText","getData","message","contributionText","getContribution","contributions","type","readonly","LabelAttributeModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;IACqBA,sB;;;;;;;;;;;;;AAUnB;AACF;AACE,mBAAmB;AACjB,aAAO,UAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA0B;AACxB,UAAMC,QAAQ,GAAG,KAAKC,OAAL,CAAa,OAAb,CAAjB;;AACA,UAAID,QAAJ,EAAc;AACZ,
|
|
1
|
+
{"version":3,"sources":["../../../src/models/attributes/HelptextAttributeModel.js"],"names":["HelptextAttributeModel","dataText","getData","message","contributionText","getContribution","contributions","type","readonly","LabelAttributeModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;;;;;AAEA;AACA;AACA;IACqBA,sB;;;;;;;;;;;;;AAUnB;AACF;AACE,mBAAmB;AACjB,aAAO,UAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA0B;AACxB,UAAMC,QAAQ,GAAG,KAAKC,OAAL,CAAa,OAAb,CAAjB;;AACA,UAAID,QAAJ,EAAc;AAAA;;AACZ,oCAAOA,QAAQ,CAACE,OAAhB,iEAA2BF,QAA3B;AACD;;AAED,UAAMG,gBAAgB,GAAG,KAAKC,eAAL,CAAqB,MAArB,CAAzB;;AACA,UAAID,gBAAJ,EAAsB;AAAA;;AACpB,wCAAOA,gBAAgB,CAACD,OAAxB,yEAAmCC,gBAAnC;AACD;;AAED,aAAO,IAAP;AACD;;;;AA9BD;AACF;AACE,+BAAyBE,aAAzB,EAAyD;AACvD,aACEA,aAAa,CAACC,IAAd,KAAuB,UAAvB,IACCD,aAAa,CAACE,QAAd,IAA0B,kBAAIF,aAAJ,EAAmB,MAAnB,CAF7B;AAID;;;EARiDG,6B","sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport LabelAttributeModel from \"./LabelAttributeModel\";\n\n/**\n * Helptext attribute\n */\nexport default class HelptextAttributeModel extends LabelAttributeModel {\n /**\n */\n static isApplicableModel(contributions: Object): boolean {\n return (\n contributions.type === \"helptext\" ||\n (contributions.readonly && has(contributions, \"text\"))\n );\n }\n\n /**\n */\n get type(): string {\n return \"helptext\";\n }\n\n /**\n * Get helptext text\n */\n get text(): string | null {\n const dataText = this.getData(\"value\");\n if (dataText) {\n return dataText.message ?? dataText;\n }\n\n const contributionText = this.getContribution(\"text\");\n if (contributionText) {\n return contributionText.message ?? contributionText;\n }\n\n return null;\n }\n}\n"],"file":"HelptextAttributeModel.js"}
|
|
@@ -3,11 +3,12 @@ import SectionModel from "../../content/SectionModel";
|
|
|
3
3
|
|
|
4
4
|
const json = {
|
|
5
5
|
header: {
|
|
6
|
-
label: "
|
|
6
|
+
label: "Header label",
|
|
7
7
|
description: {
|
|
8
8
|
message: "Dit is de beschrijving",
|
|
9
9
|
},
|
|
10
10
|
},
|
|
11
|
+
label: "Blaastest geslaagd",
|
|
11
12
|
elements: [
|
|
12
13
|
{
|
|
13
14
|
propertyElement: {
|
|
@@ -152,7 +153,8 @@ describe("AttributeContent", () => {
|
|
|
152
153
|
it("Handles basic content elements", () => {
|
|
153
154
|
const content = new AttributeContent(json);
|
|
154
155
|
expect(content.label).toBe("Blaastest geslaagd");
|
|
155
|
-
expect(content.
|
|
156
|
+
expect(content.header.label).toBe("Header label");
|
|
157
|
+
expect(content.header.description).toBe("Dit is de beschrijving");
|
|
156
158
|
expect(content.properties).toHaveLength(2);
|
|
157
159
|
expect(content.textfragments).toHaveLength(1);
|
|
158
160
|
expect(content.sections).toHaveLength(1);
|
|
@@ -499,18 +499,20 @@ describe("attributeDataHelper", () => {
|
|
|
499
499
|
key: "results",
|
|
500
500
|
content: {
|
|
501
501
|
InvestigationNecessary: {
|
|
502
|
+
header: {
|
|
503
|
+
label: "label",
|
|
504
|
+
description: "description",
|
|
505
|
+
},
|
|
502
506
|
elements: [
|
|
503
507
|
{
|
|
504
508
|
textFragmentElement: {
|
|
505
509
|
label: "Text fragment: Description",
|
|
506
510
|
textfragments: [
|
|
507
511
|
{
|
|
508
|
-
type: "Description",
|
|
509
|
-
label: "Description",
|
|
510
512
|
text: "Text fragment for investigation necessary",
|
|
511
513
|
},
|
|
512
514
|
],
|
|
513
|
-
|
|
515
|
+
layouthint: ["full"],
|
|
514
516
|
},
|
|
515
517
|
},
|
|
516
518
|
],
|
|
@@ -536,6 +538,10 @@ describe("attributeDataHelper", () => {
|
|
|
536
538
|
expect(firstChild.dynamicschemaId).toBe("results.InvestigationNecessary");
|
|
537
539
|
expect(firstChild.key).toBe("InvestigationNecessary");
|
|
538
540
|
expect(firstChild.value).toBe(true);
|
|
541
|
+
expect(firstChild.content.header).toStrictEqual({
|
|
542
|
+
label: "label",
|
|
543
|
+
description: "description",
|
|
544
|
+
});
|
|
539
545
|
expect(firstChild.content.elements).toHaveLength(1);
|
|
540
546
|
|
|
541
547
|
expect(firstChild.dynamicschema).toBeUndefined();
|
|
@@ -43,7 +43,7 @@ describe("helptextAttributeModel", () => {
|
|
|
43
43
|
readonly: true,
|
|
44
44
|
text: {
|
|
45
45
|
id: "CarDetails.text",
|
|
46
|
-
|
|
46
|
+
message:
|
|
47
47
|
"<p>Currently the person drives in a ${PersonPrivateCar}, although his favorite cars are ${PersonFavoriteCars}. Less favorite cars of the person are ${PersonLessFavoriteCars}.</p>",
|
|
48
48
|
},
|
|
49
49
|
}
|
|
@@ -9,12 +9,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
9
9
|
});
|
|
10
10
|
exports.default = void 0;
|
|
11
11
|
|
|
12
|
-
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
13
|
-
|
|
14
12
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
15
13
|
|
|
16
14
|
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
|
17
15
|
|
|
16
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
17
|
+
|
|
18
18
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
19
19
|
|
|
20
20
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
@@ -122,6 +122,7 @@ var CaseViewModel = /*#__PURE__*/function (_DetailModel) {
|
|
|
122
122
|
return this.attributeCollection.getAttributeByLayoutHint(_LayoutHints.TITLE);
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
|
+
* Retrieve the case label, this can be configured with a case property with the layout hint 'title'
|
|
125
126
|
*/
|
|
126
127
|
|
|
127
128
|
}, {
|
|
@@ -129,6 +130,15 @@ var CaseViewModel = /*#__PURE__*/function (_DetailModel) {
|
|
|
129
130
|
get: function get() {
|
|
130
131
|
return this.casename ? this.casename.value : "";
|
|
131
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Retrieve the label that was configured on the caseview
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
}, {
|
|
138
|
+
key: "viewLabel",
|
|
139
|
+
get: function get() {
|
|
140
|
+
return this.getContribution("label", "");
|
|
141
|
+
}
|
|
132
142
|
/**
|
|
133
143
|
* Check if an introtext exists for this caseview
|
|
134
144
|
*/
|
|
@@ -145,16 +155,20 @@ var CaseViewModel = /*#__PURE__*/function (_DetailModel) {
|
|
|
145
155
|
}, {
|
|
146
156
|
key: "introtext",
|
|
147
157
|
get: function get() {
|
|
148
|
-
if (this.
|
|
149
|
-
var
|
|
158
|
+
if (this.data._text) {
|
|
159
|
+
var _this$data$_text$mess;
|
|
150
160
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
161
|
+
return (_this$data$_text$mess = this.data._text.message) !== null && _this$data$_text$mess !== void 0 ? _this$data$_text$mess : this.data._text;
|
|
162
|
+
}
|
|
154
163
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
164
|
+
if (this.contributions.text) {
|
|
165
|
+
var _this$contributions$t;
|
|
166
|
+
|
|
167
|
+
return (_this$contributions$t = this.contributions.text.message) !== null && _this$contributions$t !== void 0 ? _this$contributions$t : this.contributions.text;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
171
|
+
return this.contributions.texts[0].text;
|
|
158
172
|
}
|
|
159
173
|
|
|
160
174
|
return "";
|
|
@@ -180,15 +194,15 @@ var CaseViewModel = /*#__PURE__*/function (_DetailModel) {
|
|
|
180
194
|
}, {
|
|
181
195
|
key: "createTaskGroupCollection",
|
|
182
196
|
value: function createTaskGroupCollection() {
|
|
183
|
-
var
|
|
197
|
+
var _context;
|
|
184
198
|
|
|
185
199
|
var allTaskgroupData = this.getData("taskgroups", []);
|
|
186
200
|
var allTaskgroupContributions = this.getContribution("taskgroups", []);
|
|
187
|
-
this.taskGroupCollection = (0, _map.default)(
|
|
201
|
+
this.taskGroupCollection = (0, _map.default)(_context = (0, _filter.default)(allTaskgroupData).call(allTaskgroupData, function (taskgroup) {
|
|
188
202
|
return allTaskgroupContributions.some(function (taskgroupContribution) {
|
|
189
203
|
return taskgroupContribution.name === taskgroup.name;
|
|
190
204
|
});
|
|
191
|
-
})).call(
|
|
205
|
+
})).call(_context, function (taskgroup) {
|
|
192
206
|
var taskgroupContributions = (0, _find.default)(allTaskgroupContributions).call(allTaskgroupContributions, function (taskgroupContribution) {
|
|
193
207
|
return taskgroupContribution.name === taskgroup.name;
|
|
194
208
|
});
|
|
@@ -76,11 +76,19 @@ export default class CaseViewModel extends DetailModel {
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
+
* Retrieve the case label, this can be configured with a case property with the layout hint 'title'
|
|
79
80
|
*/
|
|
80
81
|
get label(): string {
|
|
81
82
|
return this.casename ? this.casename.value : "";
|
|
82
83
|
}
|
|
83
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Retrieve the label that was configured on the caseview
|
|
87
|
+
*/
|
|
88
|
+
get viewLabel(): string {
|
|
89
|
+
return this.getContribution("label", "");
|
|
90
|
+
}
|
|
91
|
+
|
|
84
92
|
/**
|
|
85
93
|
* Check if an introtext exists for this caseview
|
|
86
94
|
*/
|
|
@@ -92,14 +100,16 @@ export default class CaseViewModel extends DetailModel {
|
|
|
92
100
|
* Getting the introduction text configured on the case view
|
|
93
101
|
*/
|
|
94
102
|
get introtext(): string {
|
|
95
|
-
if (this.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
);
|
|
103
|
+
if (this.data._text) {
|
|
104
|
+
return this.data._text.message ?? this.data._text;
|
|
105
|
+
}
|
|
99
106
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
if (this.contributions.text) {
|
|
108
|
+
return this.contributions.text.message ?? this.contributions.text;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
112
|
+
return this.contributions.texts[0].text;
|
|
103
113
|
}
|
|
104
114
|
|
|
105
115
|
return "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/caseview/CaseViewModel.js"],"names":["CaseViewModel","caseviewData","createTaskGroupCollection","links","getLinksByGroup","all","models","taskGroupModels","i","length","TaskGroupModel","push","taskGroupCollection","add","attributeCollection","getAttributeByLayoutHint","TITLE","casename","value","introtext","
|
|
1
|
+
{"version":3,"sources":["../../../src/models/caseview/CaseViewModel.js"],"names":["CaseViewModel","caseviewData","createTaskGroupCollection","links","getLinksByGroup","all","models","taskGroupModels","i","length","TaskGroupModel","push","taskGroupCollection","add","attributeCollection","getAttributeByLayoutHint","TITLE","casename","value","getContribution","introtext","data","_text","message","contributions","text","Array","isArray","texts","selfLink","getLinkByKey","Error","Href","href","allTaskgroupData","getData","allTaskgroupContributions","taskgroup","some","taskgroupContribution","name","taskgroupContributions","create","_taskGroupCollection","taskgroups","TaskGroupCollection","hasItems","resourcetype","DetailModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAOA;AACA;AACA;IACqBA,a;;;;;AAGnB;AACF;AACE,yBAAYC,YAAZ,EAA6C;AAAA;;AAAA;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CAACG,IAD3C;AAAA,SADsD,CAAxD;AAKA,eAAO9B,wBAAegC,MAAf,CACLL,SAAS,CAACG,IADL,EAELH,SAFK,EAGLI,sBAHK,CAAP;AAKD,OAlBwB,CAA3B;AAmBD;AAED;AACF;AACA;;;;;AAKE;AACF;AACA;AACE,mBAA+C;AAC7C,aAAO,KAAKE,oBAAZ;AACD;AAED;AACF;AACA;;SAbE,aAAwBC,UAAxB,EAA2D;AACzD,WAAKD,oBAAL,GAA4B,IAAIE,4BAAJ,CAAwBD,UAAxB,CAA5B;AACD;;;WAYD,yBAAyB;AACvB,aAAO,KAAKhC,mBAAL,IAA4B,KAAKA,mBAAL,CAAyBkC,QAA5D;AACD;;;WA7ID,2BAAyBzB,IAAzB,EAA2D;AACzD,aACEA,IAAI,CAACG,aAAL,CAAmBuB,YAAnB,IACA1B,IAAI,CAACG,aAAL,CAAmBuB,YAAnB,KAAoC,UAFtC;AAID;;;EAxBwCC,qB","sourcesContent":["// @flow\nimport DetailModel from \"../detail/DetailModel\";\nimport Href from \"../href/Href\";\nimport TaskGroupCollection from \"../taskgroup/TaskGroupCollection\";\nimport TaskGroupModel from \"../taskgroup/TaskGroupModel\";\n\nimport { TITLE } from \"../../constants/LayoutHints\";\n\nimport type { ModularUIModel, AttributeType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Model containing the details of one case.\n */\nexport default class CaseViewModel extends DetailModel {\n _taskGroupCollection: TaskGroupCollection;\n\n /**\n */\n constructor(caseviewData: ModularUIResponse) {\n super(caseviewData);\n\n this.createTaskGroupCollection();\n }\n\n /**\n */\n get type(): string {\n return \"CaseView\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"CaseView\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return this.links.getLinksByGroup(\"taskgroup\").all;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.links.getLinksByGroup(\"panel\");\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n super.setChildModels(models);\n\n const taskGroupModels = [];\n for (let i = 0; i < models.length; i++) {\n if (models[i] instanceof TaskGroupModel) {\n taskGroupModels.push(models[i]);\n }\n }\n\n this.taskGroupCollection.add(taskGroupModels);\n }\n\n /**\n * Getting the case name\n */\n get casename(): ?AttributeType {\n return this.attributeCollection.getAttributeByLayoutHint(TITLE);\n }\n\n /**\n * Retrieve the case label, this can be configured with a case property with the layout hint 'title'\n */\n get label(): string {\n return this.casename ? this.casename.value : \"\";\n }\n\n /**\n * Retrieve the label that was configured on the caseview\n */\n get viewLabel(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Check if an introtext exists for this caseview\n */\n hasIntroText(): boolean {\n return this.introtext !== \"\";\n }\n\n /**\n * Getting the introduction text configured on the case view\n */\n get introtext(): string {\n if (this.data._text) {\n return this.data._text.message ?? this.data._text;\n }\n\n if (this.contributions.text) {\n return this.contributions.text.message ?? this.contributions.text;\n }\n\n if (Array.isArray(this.contributions.texts)) {\n return this.contributions.texts[0].text;\n }\n\n return \"\";\n }\n\n /**\n * Getting the self href\n */\n get selfhref(): Href {\n const selfLink = this.links.getLinkByKey(\"self\");\n\n if (selfLink === null) {\n throw new Error(\"No self href available\");\n }\n\n return new Href(selfLink.href);\n }\n\n /**\n */\n createTaskGroupCollection() {\n const allTaskgroupData = this.getData(\"taskgroups\", []);\n const allTaskgroupContributions = this.getContribution(\"taskgroups\", []);\n\n this.taskGroupCollection = allTaskgroupData\n .filter((taskgroup) =>\n allTaskgroupContributions.some(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name\n )\n )\n .map((taskgroup) => {\n const taskgroupContributions = allTaskgroupContributions.find(\n (taskgroupContribution) =>\n taskgroupContribution.name === taskgroup.name\n );\n\n return TaskGroupModel.create(\n taskgroup.name,\n taskgroup,\n taskgroupContributions\n );\n });\n }\n\n /**\n * Setting the taskgroup panel collection\n */\n set taskGroupCollection(taskgroups: Array<TaskGroupModel>) {\n this._taskGroupCollection = new TaskGroupCollection(taskgroups);\n }\n\n /**\n * Getting the taskgrouppanels on the tab\n */\n get taskGroupCollection(): TaskGroupCollection {\n return this._taskGroupCollection;\n }\n\n /**\n * Has taskgroups\n */\n hasTaskGroups(): boolean {\n return this.taskGroupCollection && this.taskGroupCollection.hasItems;\n }\n}\n"],"file":"CaseViewModel.js"}
|