@beinformed/ui 1.9.0-beta.6 → 1.9.1
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 +50 -0
- package/esm/constants/Settings.js +10 -8
- package/esm/constants/Settings.js.map +1 -1
- 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 +126 -58
- 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/AttributeModel.js +3 -3
- package/esm/models/attributes/AttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +4 -4
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/attributes/HelptextAttributeModel.js +17 -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/content/SectionModel.js +2 -1
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/content/SubSectionModel.js +3 -1
- package/esm/models/content/SubSectionModel.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/utils/helpers/text.js +19 -0
- package/esm/utils/helpers/text.js.map +1 -0
- package/esm/utils/index.js +2 -1
- package/esm/utils/index.js.map +1 -1
- package/lib/constants/Settings.js +12 -1
- package/lib/constants/Settings.js.flow +9 -5
- package/lib/constants/Settings.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 +136 -59
- package/lib/models/attributes/AttributeContent.js.flow +91 -39
- 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/AttributeModel.js +1 -1
- package/lib/models/attributes/AttributeModel.js.flow +2 -3
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +3 -3
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +4 -7
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/HelptextAttributeModel.js +17 -1
- package/lib/models/attributes/HelptextAttributeModel.js.flow +11 -1
- package/lib/models/attributes/HelptextAttributeModel.js.map +1 -1
- package/lib/models/attributes/__tests__/AttributeContent.spec.js.flow +10 -2
- package/lib/models/attributes/__tests__/AttributeDataHelper.spec.js.flow +9 -3
- package/lib/models/attributes/__tests__/HelptextAttributeModel.spec.js.flow +39 -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/content/SectionModel.js +3 -1
- package/lib/models/content/SectionModel.js.flow +2 -1
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/content/SubSectionModel.js +4 -1
- package/lib/models/content/SubSectionModel.js.flow +3 -1
- package/lib/models/content/SubSectionModel.js.map +1 -1
- 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 +38 -11
- 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/utils/helpers/text.js +28 -0
- package/lib/utils/helpers/text.js.flow +23 -0
- package/lib/utils/helpers/text.js.map +1 -0
- package/lib/utils/index.js +14 -0
- package/lib/utils/index.js.flow +1 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +13 -13
- package/src/constants/Settings.js +9 -5
- 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 +91 -39
- package/src/models/attributes/AttributeDataHelper.js +2 -1
- package/src/models/attributes/AttributeModel.js +2 -3
- package/src/models/attributes/ChoiceAttributeOptionModel.js +4 -7
- package/src/models/attributes/HelptextAttributeModel.js +11 -1
- package/src/models/attributes/__tests__/AttributeContent.spec.js +10 -2
- package/src/models/attributes/__tests__/AttributeDataHelper.spec.js +9 -3
- package/src/models/attributes/__tests__/HelptextAttributeModel.spec.js +39 -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/content/SectionModel.js +2 -1
- package/src/models/content/SubSectionModel.js +3 -1
- 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 +1 -0
- 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 +38 -11
- package/src/modularui/ModularUIRequest.js +1 -0
- package/src/utils/helpers/text.js +23 -0
- package/src/utils/index.js +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/content/SubSectionModel.js"],"names":["SubSectionModel","data","referred","id","_id","getData","number","label","subSections","subSection","_links","LinkCollection","contributions","links","getLinkByKey","selflink","href","hrefs","relatedConceptsHref","push","forEach","relatedConceptsHrefs","relatedConceptsLink","selfhref","Href","sections","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA;AACA;AACA;IACqBA,e;;;;;AAGnB;AACF;AACE,2BAAYC,IAAZ,EAA0B;AAAA;;AAAA;AACxB,8BAAMA,IAAN,EAAY,EAAZ;AADwB;AAAA;AAEzB;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,KAAKA,IAAL,CAAUC,QAAjB;AACD;AAED;AACF;;;;SACE,eAAiB;AACf,aAAO,KAAKD,IAAL,CAAUE,EAAV,IAAgB,KAAKF,IAAL,CAAUG,GAAjC;AACD;AAED;AACF;AACA;;;;SACE,eAAmB;AACjB,aAAO,KAAKD,EAAZ;AACD;AAED;AACF;AACA;;;;SACE,eAAmB;AACjB,
|
|
1
|
+
{"version":3,"sources":["../../../src/models/content/SubSectionModel.js"],"names":["SubSectionModel","data","referred","id","_id","body","getData","number","label","subSections","subSection","_links","LinkCollection","contributions","links","getLinkByKey","selflink","href","hrefs","relatedConceptsHref","push","forEach","relatedConceptsHrefs","relatedConceptsLink","selfhref","Href","sections","referredChilds","getReferredSections","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;;;AAEA;AACA;AACA;IACqBA,e;;;;;AAGnB;AACF;AACE,2BAAYC,IAAZ,EAA0B;AAAA;;AAAA;AACxB,8BAAMA,IAAN,EAAY,EAAZ;AADwB;AAAA;AAEzB;AAED;AACF;;;;;SACE,eAAwB;AACtB,aAAO,KAAKA,IAAL,CAAUC,QAAjB;AACD;AAED;AACF;;;;SACE,eAAiB;AACf,aAAO,KAAKD,IAAL,CAAUE,EAAV,IAAgB,KAAKF,IAAL,CAAUG,GAAjC;AACD;AAED;AACF;AACA;;;;SACE,eAAmB;AACjB,aAAO,KAAKD,EAAZ;AACD;AAED;AACF;AACA;;;;SACE,eAAmB;AACjB,UAAME,IAAI,GAAG,KAAKC,OAAL,CAAa,MAAb,EAAqB,EAArB,CAAb;AACA,aAAO,yBAAaD,IAAb,CAAP;AACD;AAED;AACF;AACA;;;;SACE,eAA4B;AAAA;;AAC1B,kCAAO,KAAKJ,IAAL,CAAUM,MAAjB,iEAA2B,IAA3B;AACD;AAED;AACF;AACA;;;;SACE,eAAqB;AACnB,aAAO,KAAKN,IAAL,CAAUO,KAAjB;AACD;AAED;AACF;AACA;;;;SACE,eAA0C;AAAA;;AACxC,aAAO,KAAKP,IAAL,CAAUQ,WAAV,GACH,kCAAKR,IAAL,CAAUQ,WAAV,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AQ,GAAG,EAAjB;;AAD4C,iDAGnB,KAAKjB,WAHc;AAAA;;AAAA;AAG5C,4DAA2C;AAAA,cAAhCC,UAAgC;;AACzC,cAAIA,UAAU,CAACR,QAAf,EAAyB;AACvBwB,YAAAA,QAAQ,CAACN,IAAT,CAAcV,UAAd;AACD;;AAED,cAAMiB,cAAc,GAAGjB,UAAU,CAACkB,mBAAX,EAAvB;AACAF,UAAAA,QAAQ,CAACN,IAAT,OAAAM,QAAQ,mCAASC,cAAT,EAAR;AACD;AAV2C;AAAA;AAAA;AAAA;AAAA;;AAY5C,aAAOD,QAAP;AACD;;;EA5I0CG,mB","sourcesContent":["// @flow\nimport { createHashFromHref } from \"../../utils/helpers/createHash\";\n\nimport BaseModel from \"../base/BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\nimport Href from \"../href/Href\";\nimport LinkModel from \"../links/LinkModel\";\nimport { retrieveText } from \"../../utils\";\n\n/**\n * Link to a concept\n */\nexport default class SubSectionModel extends BaseModel {\n _links: LinkCollection;\n\n /**\n */\n constructor(data: Object) {\n super(data, {});\n }\n\n /**\n */\n get referred(): boolean {\n return this.data.referred;\n }\n\n /**\n */\n get id(): string {\n return this.data.id || this.data._id;\n }\n\n /**\n * Retrieve key of subsection\n */\n get key(): ?string {\n return this.id;\n }\n\n /**\n * Retrieve html body\n */\n get body(): string {\n const body = this.getData(\"body\", \"\");\n return retrieveText(body);\n }\n\n /**\n * Retrieve number of section\n */\n get number(): string | null {\n return this.data.number ?? null;\n }\n\n /**\n * Retrieve label of section\n */\n get label(): ?string {\n return this.data.label;\n }\n\n /**\n * Get sub sections\n */\n get subSections(): Array<SubSectionModel> {\n return this.data.subSections\n ? this.data.subSections.map(\n (subSection) => new SubSectionModel(subSection)\n )\n : [];\n }\n\n /**\n * Retrieve links of section\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n this.data._links,\n this.contributions._links\n );\n }\n\n return this._links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel | null {\n return this.links.getLinkByKey(\"self\");\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href | null {\n return this.selflink ? this.selflink.href : null;\n }\n\n /**\n */\n get relatedConceptsHrefs(): Array<Href> {\n const hrefs = [];\n if (this.relatedConceptsHref) {\n hrefs.push(this.relatedConceptsHref);\n }\n\n this.subSections.forEach((subSection) => {\n hrefs.push(...subSection.relatedConceptsHrefs);\n });\n\n return hrefs;\n }\n\n /**\n * Get related concepts link\n */\n get relatedConceptsHref(): Href | null {\n const relatedConceptsLink = this.links.getLinkByKey(\"relatedConcepts\");\n\n if (relatedConceptsLink) {\n return relatedConceptsLink.href;\n }\n\n return null;\n }\n\n /**\n */\n get referenceHash(): number {\n const selfhref = this.selfhref || new Href();\n\n return createHashFromHref(selfhref);\n }\n\n /**\n */\n getReferredSections(): Array<SubSectionModel> {\n const sections = [];\n\n for (const subSection of this.subSections) {\n if (subSection.referred) {\n sections.push(subSection);\n }\n\n const referredChilds = subSection.getReferredSections();\n sections.push(...referredChilds);\n }\n\n return sections;\n }\n}\n"],"file":"SubSectionModel.js"}
|
|
@@ -66,8 +66,8 @@ var ContentConfigurationResults = /*#__PURE__*/function () {
|
|
|
66
66
|
|
|
67
67
|
var description = this._configuration.description;
|
|
68
68
|
|
|
69
|
-
if ((0, _utils.isPlainObject)(description) && "
|
|
70
|
-
return description.
|
|
69
|
+
if ((0, _utils.isPlainObject)(description) && "message" in description) {
|
|
70
|
+
return description.message;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
return description;
|
|
@@ -35,8 +35,8 @@ class ContentConfigurationResults {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const description = this._configuration.description;
|
|
38
|
-
if (isPlainObject(description) && "
|
|
39
|
-
return description.
|
|
38
|
+
if (isPlainObject(description) && "message" in description) {
|
|
39
|
+
return description.message;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
return description;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/contentconfiguration/ContentConfigurationResults.js"],"names":["ContentConfigurationResults","configuration","_configuration","_layouthint","LayoutHintCollection","layouthint","label","description","
|
|
1
|
+
{"version":3,"sources":["../../../src/models/contentconfiguration/ContentConfigurationResults.js"],"names":["ContentConfigurationResults","configuration","_configuration","_layouthint","LayoutHintCollection","layouthint","label","description","message","attributes","all","hint","substring","length","elementKey","ContentConfigurationElements","configElement","getFormConfigElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;AACA;;AAEA;AACA;IACMA,2B;AAIJ;AACF;AACE,uCAAYC,aAAZ,EAAmC;AAAA;AAAA;AAAA;AACjC,SAAKC,cAAL,GAAsBD,aAAa,IAAI,IAAvC;AAEA,SAAKE,WAAL,GAAmB,IAAIC,6BAAJ,CAAyBH,aAAzB,aAAyBA,aAAzB,uBAAyBA,aAAa,CAAEI,UAAxC,CAAnB;AACD;AAED;AACF;;;;;SACE,eAA2B;AACzB,UAAI,KAAKH,cAAL,KAAwB,IAA5B,EAAkC;AAChC,eAAO,IAAP;AACD;;AAED,aAAO,KAAKA,cAAL,CAAoBI,KAA3B;AACD;AAED;AACF;;;;SACE,eAAiC;AAC/B,UAAI,KAAKJ,cAAL,KAAwB,IAA5B,EAAkC;AAChC,eAAO,IAAP;AACD;;AAED,UAAMK,WAAW,GAAG,KAAKL,cAAL,CAAoBK,WAAxC;;AACA,UAAI,0BAAcA,WAAd,KAA8B,aAAaA,WAA/C,EAA4D;AAC1D,eAAOA,WAAW,CAACC,OAAnB;AACD;;AAED,aAAOD,WAAP;AACD;AAED;AACF;;;;SACE,eAAgC;AAAA;;AAC9B,UAAI,KAAKL,cAAL,KAAwB,IAA5B,EAAkC;AAChC,eAAO,EAAP;AACD,OAH6B,CAK9B;AACA;;;AACA,iGACK,KAAKA,cAAL,CAAoBO,UADzB,oCAEK,oEAAKJ,UAAL,CAAgBK,GAAhB,kBACO,UAACC,IAAD;AAAA,eAAU,uBAAAA,IAAI,MAAJ,CAAAA,IAAI,EAAU,YAAV,CAAd;AAAA,OADP,mBAEI,UAACA,IAAD;AAAA,eAAUA,IAAI,CAACC,SAAL,CAAe,aAAaC,MAA5B,CAAV;AAAA,OAFJ,CAFL;AAMD;AAED;AACF;;;;WACE,8BAAqBC,UAArB,EAAuE;AACrE,UAAI,KAAKZ,cAAL,KAAwB,IAA5B,EAAkC;AAChC,eAAO,IAAIa,qCAAJ,CAAiC,EAAjC,CAAP;AACD;;AAED,UAAMC,aAAa,GAAG,KAAKd,cAAL,CAAoBY,UAApB,CAAtB;AAEA,aAAO,IAAIC,qCAAJ,CAAiCC,aAAjC,CAAP;AACD;AAED;AACF;;;;SACE,eAA6D;AAC3D,aAAO,KAAKC,oBAAL,CAA0B,0BAA1B,CAAP;AACD;AAED;AACF;;;;SACE,eAA2D;AACzD,aAAO,KAAKA,oBAAL,CAA0B,wBAA1B,CAAP;AACD;AAED;AACF;;;;SACE,eAA2D;AACzD,aAAO,KAAKA,oBAAL,CAA0B,wBAA1B,CAAP;AACD;AAED;AACF;;;;SACE,eAAmD;AACjD,aAAO,KAAKA,oBAAL,CAA0B,gBAA1B,CAAP;AACD;AAED;AACF;;;;SACE,eAAuC;AACrC,aAAO,KAAKd,WAAZ;AACD;;;;;eAGYH,2B","sourcesContent":["// @flow\nimport ContentConfigurationElements from \"./ContentConfigurationElements\";\nimport LayoutHintCollection from \"../layouthint/LayoutHintCollection\";\nimport { isPlainObject } from \"../../utils\";\n\n/**\n */\nclass ContentConfigurationResults {\n _configuration: Object;\n _layouthint: LayoutHintCollection;\n\n /**\n */\n constructor(configuration: Object) {\n this._configuration = configuration || null;\n\n this._layouthint = new LayoutHintCollection(configuration?.layouthint);\n }\n\n /**\n */\n get label(): string | null {\n if (this._configuration === null) {\n return null;\n }\n\n return this._configuration.label;\n }\n\n /**\n */\n get description(): string | null {\n if (this._configuration === null) {\n return null;\n }\n\n const description = this._configuration.description;\n if (isPlainObject(description) && \"message\" in description) {\n return description.message;\n }\n\n return description;\n }\n\n /**\n */\n get attributes(): Array<string> {\n if (this._configuration === null) {\n return [];\n }\n\n // An issue with mapped attributes is giving us the wrong attribute keys in the attributes property\n // as a temporary fix a layouthint with the correct mapped attribute key can be set in the configuration of the end results\n return [\n ...this._configuration.attributes,\n ...this.layouthint.all\n .filter((hint) => hint.includes(\"attribute:\"))\n .map((hint) => hint.substring(\"attribute:\".length)),\n ];\n }\n\n /**\n */\n getFormConfigElement(elementKey: string): ContentConfigurationElements {\n if (this._configuration === null) {\n return new ContentConfigurationElements([]);\n }\n\n const configElement = this._configuration[elementKey];\n\n return new ContentConfigurationElements(configElement);\n }\n\n /**\n */\n get calculatedResultElements(): ContentConfigurationElements {\n return this.getFormConfigElement(\"calculatedResultElements\");\n }\n\n /**\n */\n get positiveResultElements(): ContentConfigurationElements {\n return this.getFormConfigElement(\"positiveResultElements\");\n }\n\n /**\n */\n get negativeResultElements(): ContentConfigurationElements {\n return this.getFormConfigElement(\"negativeResultElements\");\n }\n\n /**\n */\n get resultElements(): ContentConfigurationElements {\n return this.getFormConfigElement(\"resultElements\");\n }\n\n /**\n */\n get layouthint(): LayoutHintCollection {\n return this._layouthint;\n }\n}\n\nexport default ContentConfigurationResults;\n"],"file":"ContentConfigurationResults.js"}
|
|
@@ -33,14 +33,14 @@ describe("ContentConfigurationResults", () => {
|
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
it("can handle configuration with description object", () => {
|
|
36
|
-
const
|
|
36
|
+
const message =
|
|
37
37
|
"<p>The property value is ${EstimatedPropertyValue} and my personal deposit is ${MortgageDeposit}. The mortgage is a repayment mortgage for a term of ${MortgageTermInYears} years. The rate type is ${InterestRateType} for a period of ${PeriodOfInterestRate}.</p>";
|
|
38
38
|
|
|
39
39
|
const contributions = {
|
|
40
40
|
label: "Total cost of mortgage",
|
|
41
41
|
description: {
|
|
42
42
|
id: "CalculatorResults.TotalCostOfMortgage.introText",
|
|
43
|
-
|
|
43
|
+
message,
|
|
44
44
|
},
|
|
45
45
|
layouthint: ["render-description:TotalCostOfMortgage"],
|
|
46
46
|
attributes: ["TotalCostOfMortgage"],
|
|
@@ -59,7 +59,7 @@ describe("ContentConfigurationResults", () => {
|
|
|
59
59
|
);
|
|
60
60
|
|
|
61
61
|
expect(contentConfigurationResults.label).toBe("Total cost of mortgage");
|
|
62
|
-
expect(contentConfigurationResults.description).toBe(
|
|
62
|
+
expect(contentConfigurationResults.description).toBe(message);
|
|
63
63
|
expect(contentConfigurationResults.attributes).toStrictEqual([
|
|
64
64
|
"TotalCostOfMortgage",
|
|
65
65
|
]);
|
|
@@ -87,15 +87,15 @@ describe("ContentConfigurationResults", () => {
|
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
it("can handle configuration with description string", () => {
|
|
90
|
-
const
|
|
90
|
+
const message =
|
|
91
91
|
"<p>The property value is ${EstimatedPropertyValue} and my personal deposit is ${MortgageDeposit}. The mortgage is a repayment mortgage for a term of ${MortgageTermInYears} years. The rate type is ${InterestRateType} for a period of ${PeriodOfInterestRate}.</p>";
|
|
92
92
|
|
|
93
93
|
const contentConfigurationResults = new ContentConfigurationResults({
|
|
94
94
|
label: "Total cost of mortgage",
|
|
95
|
-
description:
|
|
95
|
+
description: message,
|
|
96
96
|
});
|
|
97
97
|
|
|
98
98
|
expect(contentConfigurationResults.label).toBe("Total cost of mortgage");
|
|
99
|
-
expect(contentConfigurationResults.description).toBe(
|
|
99
|
+
expect(contentConfigurationResults.description).toBe(message);
|
|
100
100
|
});
|
|
101
101
|
});
|
|
@@ -386,9 +386,15 @@ var FormObjectModel = /*#__PURE__*/function (_BaseModel) {
|
|
|
386
386
|
}, {
|
|
387
387
|
key: "introText",
|
|
388
388
|
get: function get() {
|
|
389
|
-
var _this$contributions$i, _this$contributions$i2;
|
|
389
|
+
var _this$data$content, _this$contributions$i, _this$contributions$i2;
|
|
390
390
|
|
|
391
|
-
|
|
391
|
+
if ((_this$data$content = this.data.content) !== null && _this$data$content !== void 0 && _this$data$content.text) {
|
|
392
|
+
var _this$data$content$te;
|
|
393
|
+
|
|
394
|
+
return (_this$data$content$te = this.data.content.text.message) !== null && _this$data$content$te !== void 0 ? _this$data$content$te : this.data.content.text;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return (_this$contributions$i = (_this$contributions$i2 = this.contributions.introText) === null || _this$contributions$i2 === void 0 ? void 0 : _this$contributions$i2.message) !== null && _this$contributions$i !== void 0 ? _this$contributions$i : this.contributions.introText;
|
|
392
398
|
}
|
|
393
399
|
/**
|
|
394
400
|
* Get assistent of form object
|
|
@@ -295,8 +295,12 @@ export default class FormObjectModel extends BaseModel {
|
|
|
295
295
|
* Get introText of form object
|
|
296
296
|
*/
|
|
297
297
|
get introText(): string {
|
|
298
|
+
if (this.data.content?.text) {
|
|
299
|
+
return this.data.content.text.message ?? this.data.content.text;
|
|
300
|
+
}
|
|
301
|
+
|
|
298
302
|
return (
|
|
299
|
-
this.contributions.introText?.
|
|
303
|
+
this.contributions.introText?.message ?? this.contributions.introText
|
|
300
304
|
);
|
|
301
305
|
}
|
|
302
306
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/form/FormObjectModel.js"],"names":["FormObjectModel","object","objectContributions","getElements","length","_attributeCollection","AttributeCollection","getApplicableAttributeContributions","_contentConfiguration","ContentConfiguration","content","_errorCollection","ErrorCollection","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","withRepeatIndex","key","objectContainsOneOfTheAttributes","all","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","dataResults","result","elementid","contributions","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","models","setChildModels","objectid","getContribution","_repeatIndex","index","isRepeatable","maxRepeats","last","label","introText","rawText","assistent","oldObject","forEach","mergeWithAttribute","mergeAttribute","value","attributeToUpdate","Error","name","CompositeAttributeModel","update","timestamp","isChangedSince","resetErrors","error","anchor","addServerError","id","message","properties","errorCollection","hasItems","hasServerErrors","hasErrors","visible","every","isValid","_dynamicValidationsLoaded","dynamicValidationsLoaded","attributeErrors","Array","isArray","errors","missing","anchors","updateValidations","formdata","validationData","getFormData","formObjectModel","IllegalArgumentException","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAKA;AACA;AACA;IACqBA,e;;;;;AAOnB;AACF;AACA;AACE,2BAAYC,MAAZ,EAA4BC,mBAA5B,EAAyD;AAAA;;AAAA;AACvD,8BAAMD,MAAN,EAAcC,mBAAd;AADuD;AAAA;AAAA;AAAA;AAAA;;AAGvD,QAAID,MAAM,IAAI,MAAKE,WAAL,GAAmBC,MAAnB,GAA4B,CAA1C,EAA6C;AAC3C,YAAKC,oBAAL,GAA4B,IAAIC,4BAAJ,CAC1B,MAAKH,WAAL,EAD0B,EAE1B,MAAKI,mCAAL,EAF0B,CAA5B;AAID,KALD,MAKO;AACL,YAAKF,oBAAL,GAA4B,IAAIC,4BAAJ,EAA5B;AACD;;AAED,UAAKE,qBAAL,GAA6B,IAAIC,6BAAJ,CAC3BP,mBAAmB,GAAGA,mBAAmB,CAACQ,OAAvB,GAAiC,EADzB,CAA7B;AAIA,UAAKC,gBAAL,GAAwB,IAAIC,wBAAJ,CAAoB,YAApB,CAAxB;;AAEA,QAAI,kBAAI,MAAKC,IAAT,EAAe,eAAf,CAAJ,EAAqC;AACnC,YAAKC,mBAAL,CAAyBC,gBAAzB,CAA0C,MAAKC,OAAL,CAAa,eAAb,CAA1C;AACD;;AAED,UAAKF,mBAAL,CAAyBG,4BAAzB,CACE,MAAKC,oBADP;;AAtBuD;AAyBxD;AAED;AACF;;;;;;AAaE;AACF;AACE,oBAAOjB,MAAP,EAA2E;AAAA;;AAAA,UAA1CkB,eAA0C,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F,OAAnB,kDAAc,cAAcC,OAA5B,CAAJ,EAA0C;AAAA;;AACxCL,QAAAA,eAAe,CAAC3D,IAAhB,OAAA2D,eAAe,mCACV,8BAAA9E,IAAI,CAACkF,OAAL,CAAaC,OAAb,kBAAyB,UAACnB,MAAD;AAAA,iBAAa;AACvCA,YAAAA,MAAM,EAANA,MADuC;AAEvCE,YAAAA,EAAE,EAAE;AAFmC,WAAb;AAAA,SAAzB,CADU,EAAf;AAMD;;AAED,WAAKjE,mBAAL,CAAyBmF,iBAAzB,CAA2CN,eAA3C;AAEA,WAAKD,wBAAL,GAAgC,IAAhC;AAEA,aAAO,IAAP;AACD;AAED;AACF;AACA;;;;SACE,eAAyC;AACvC,aAAO,KAAK5E,mBAAL,CAAyBoF,QAAhC;AACD;AAED;AACF;;;;WACE,uBAAuE;AAAA,UAA3DC,cAA2D,uEAAjC,KAAiC;AACrE,aAAO,KAAKrF,mBAAL,CAAyBsF,WAAzB,CAAqCD,cAArC,CAAP;AACD;;;WAtbD,qBAAmBE,eAAnB,EAAsE;AACpE,UAAI,CAACA,eAAL,EAAsB;AACpB,cAAM,IAAIC,oCAAJ,CACJ,oGADI,CAAN;AAGD;;AACD,aAAO,IAAItG,eAAJ,CACLqG,eAAe,CAACxF,IADX,EAELwF,eAAe,CAAChE,aAFX,CAAP;AAID;;;EAjD0CkE,mB","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\";\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 return (\n this.contributions.introText?.rawText ?? this.contributions.introText\n );\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 );\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 */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n const attributeErrors = [];\n\n if (Array.isArray(data.errors)) {\n data.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 );\n }\n }\n });\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n attributeErrors.push(\n ...data.missing.anchors.map((anchor) => ({\n anchor,\n id: \"Constraint.Mandatory\",\n }))\n );\n }\n\n this.attributeCollection.updateValidations(attributeErrors);\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"],"file":"FormObjectModel.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/models/form/FormObjectModel.js"],"names":["FormObjectModel","object","objectContributions","getElements","length","_attributeCollection","AttributeCollection","getApplicableAttributeContributions","_contentConfiguration","ContentConfiguration","content","_errorCollection","ErrorCollection","data","attributeCollection","setReferenceDate","getData","indicateContentConfiguration","contentConfiguration","withRepeatIndex","key","objectContainsOneOfTheAttributes","all","attribute","isResult","some","hasAttributeByKey","hasSameRepeatIndex","repeatIndex","getAttributeByAttribute","getAttributeByKey","elements","push","results","dataResults","result","elementid","contributions","dataElementIds","element","getAttributesInData","attributes","isDynamic","attributeKey","mandatory","attributesContributions","attributeContributions","dataElementId","split","getInitialChildModelLinks","models","setChildModels","objectid","getContribution","_repeatIndex","index","isRepeatable","maxRepeats","last","label","text","message","introText","assistent","oldObject","forEach","mergeWithAttribute","mergeAttribute","value","attributeToUpdate","Error","name","CompositeAttributeModel","update","timestamp","isChangedSince","resetErrors","error","anchor","addServerError","id","properties","errorCollection","hasItems","hasServerErrors","hasErrors","visible","every","isValid","_dynamicValidationsLoaded","dynamicValidationsLoaded","attributeErrors","Array","isArray","errors","missing","anchors","updateValidations","formdata","validationData","getFormData","formObjectModel","IllegalArgumentException","BaseModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A,eAAe,CAAC3D,IAAhB,OAAA2D,eAAe,mCACV,8BAAA9E,IAAI,CAACkF,OAAL,CAAaC,OAAb,kBAAyB,UAAClB,MAAD;AAAA,iBAAa;AACvCA,YAAAA,MAAM,EAANA,MADuC;AAEvCE,YAAAA,EAAE,EAAE;AAFmC,WAAb;AAAA,SAAzB,CADU,EAAf;AAMD;;AAED,WAAKlE,mBAAL,CAAyBmF,iBAAzB,CAA2CN,eAA3C;AAEA,WAAKD,wBAAL,GAAgC,IAAhC;AAEA,aAAO,IAAP;AACD;AAED;AACF;AACA;;;;SACE,eAAyC;AACvC,aAAO,KAAK5E,mBAAL,CAAyBoF,QAAhC;AACD;AAED;AACF;;;;WACE,uBAAuE;AAAA,UAA3DC,cAA2D,uEAAjC,KAAiC;AACrE,aAAO,KAAKrF,mBAAL,CAAyBsF,WAAzB,CAAqCD,cAArC,CAAP;AACD;;;WA1bD,qBAAmBE,eAAnB,EAAsE;AACpE,UAAI,CAACA,eAAL,EAAsB;AACpB,cAAM,IAAIC,oCAAJ,CACJ,oGADI,CAAN;AAGD;;AACD,aAAO,IAAItG,eAAJ,CACLqG,eAAe,CAACxF,IADX,EAELwF,eAAe,CAAChE,aAFX,CAAP;AAID;;;EAjD0CkE,mB","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\";\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 ?? this.data.content.text;\n }\n\n return (\n this.contributions.introText?.message ?? this.contributions.introText\n );\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 );\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 */\n updateValidations(data: any): FormObjectModel {\n this.resetErrors();\n\n const attributeErrors = [];\n\n if (Array.isArray(data.errors)) {\n data.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 );\n }\n }\n });\n }\n\n // missing attribute errors\n if (Array.isArray(data.missing?.anchors)) {\n attributeErrors.push(\n ...data.missing.anchors.map((anchor) => ({\n anchor,\n id: \"Constraint.Mandatory\",\n }))\n );\n }\n\n this.attributeCollection.updateValidations(attributeErrors);\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"],"file":"FormObjectModel.js"}
|
|
@@ -19,7 +19,7 @@ const data = {
|
|
|
19
19
|
const contributions = {
|
|
20
20
|
repeatable: false,
|
|
21
21
|
label: "Create person",
|
|
22
|
-
introText: { id: "IntroTextID",
|
|
22
|
+
introText: { id: "IntroTextID", message: "This is introtext" },
|
|
23
23
|
attributes: [
|
|
24
24
|
{
|
|
25
25
|
Name: {
|
|
@@ -122,7 +122,7 @@ describe("formObjectModel", () => {
|
|
|
122
122
|
const contributions2 = {
|
|
123
123
|
repeatable: false,
|
|
124
124
|
label: "Create person",
|
|
125
|
-
introText: { id: "IntroTextID",
|
|
125
|
+
introText: { id: "IntroTextID", message: "This is new introtext" },
|
|
126
126
|
attributes: [],
|
|
127
127
|
};
|
|
128
128
|
|
|
@@ -11,6 +11,8 @@ exports.default = void 0;
|
|
|
11
11
|
|
|
12
12
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
13
13
|
|
|
14
|
+
var _flat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/flat"));
|
|
15
|
+
|
|
14
16
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
15
17
|
|
|
16
18
|
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
|
|
@@ -90,7 +92,7 @@ var LayoutHintCollection = /*#__PURE__*/function (_BaseCollection) {
|
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
var hintArray = hints.length > 0 ? (0, _concat.default)(_context = []).call(_context, hints) : [];
|
|
93
|
-
return hintArray.some(function (hint) {
|
|
95
|
+
return (0, _flat.default)(hintArray).call(hintArray).some(function (hint) {
|
|
94
96
|
var _context2;
|
|
95
97
|
|
|
96
98
|
return (0, _includes.default)(_context2 = _this2.layouthint).call(_context2, hint) || _this2.layouthint.some(function (hint2) {
|
|
@@ -117,7 +119,7 @@ var LayoutHintCollection = /*#__PURE__*/function (_BaseCollection) {
|
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
var hintArray = hints.length > 0 ? (0, _concat.default)(_context3 = []).call(_context3, hints) : [];
|
|
120
|
-
return hintArray.some(function (hint) {
|
|
122
|
+
return (0, _flat.default)(hintArray).call(hintArray).some(function (hint) {
|
|
121
123
|
var _context4;
|
|
122
124
|
|
|
123
125
|
return (0, _includes.default)(_context4 = _this3.layouthint).call(_context4, hint);
|
|
@@ -35,11 +35,13 @@ export default class LayoutHintCollection extends BaseCollection<string> {
|
|
|
35
35
|
has(...hints: Array<string>): boolean {
|
|
36
36
|
const hintArray = hints.length > 0 ? [...hints] : [];
|
|
37
37
|
|
|
38
|
-
return hintArray
|
|
39
|
-
(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
return hintArray
|
|
39
|
+
.flat()
|
|
40
|
+
.some(
|
|
41
|
+
(hint) =>
|
|
42
|
+
this.layouthint.includes(hint) ||
|
|
43
|
+
this.layouthint.some((hint2) => hint2.startsWith(hint))
|
|
44
|
+
);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -51,8 +53,7 @@ export default class LayoutHintCollection extends BaseCollection<string> {
|
|
|
51
53
|
*/
|
|
52
54
|
hasExact(...hints: Array<string>): boolean {
|
|
53
55
|
const hintArray = hints.length > 0 ? [...hints] : [];
|
|
54
|
-
|
|
55
|
-
return hintArray.some((hint) => this.layouthint.includes(hint));
|
|
56
|
+
return hintArray.flat().some((hint) => this.layouthint.includes(hint));
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/layouthint/LayoutHintCollection.js"],"names":["LayoutHintCollection","layouthint","Array","isArray","IllegalArgumentException","collection","hints","hintArray","length","some","hint","hint2","foundHint","toString","checkHint","substr","match","getByLayoutHint","has","value","getLayoutHintValue","split","BaseCollection"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/models/layouthint/LayoutHintCollection.js"],"names":["LayoutHintCollection","layouthint","Array","isArray","IllegalArgumentException","collection","hints","hintArray","length","some","hint","hint2","foundHint","toString","checkHint","substr","match","getByLayoutHint","has","value","getLayoutHintValue","split","BaseCollection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AACA;;;;;;AAEA;AACA;AACA;IACqBA,oB;;;;;AACnB;AACF;AACA;AACE,kCAA4C;AAAA;;AAAA,QAAhCC,UAAgC,uEAAJ,EAAI;AAAA;AAC1C;;AAEA,QAAI,CAACC,KAAK,CAACC,OAAN,CAAcF,UAAd,CAAL,EAAgC;AAC9B,YAAM,IAAIG,oCAAJ,WAAgCH,UAAhC,sBAAN;AACD;;AAED,UAAKI,UAAL,GAAkBJ,UAAlB;AAP0C;AAQ3C;AAED;AACF;AACA;;;;;SACE,eAAgC;AAC9B,aAAO,KAAKI,UAAZ;AACD;AAED;AACF;AACA;AACA;AACA;AACA;;;;WACE,eAAsC;AAAA;AAAA;;AAAA,wCAA/BC,KAA+B;AAA/BA,QAAAA,KAA+B;AAAA;;AACpC,UAAMC,SAAS,GAAGD,KAAK,CAACE,MAAN,GAAe,CAAf,sDAAuBF,KAAvB,IAAgC,EAAlD;AAEA,aAAO,mBAAAC,SAAS,MAAT,CAAAA,SAAS,EAEbE,IAFI,CAGH,UAACC,IAAD;AAAA;;AA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,EAAeL,IAAI,CAACF,MAAL,GAAc,CAA7B,CADc,GAEdE,IAFJ;AAIA,UAAMM,KAAK,GAAG,KAAKC,eAAL,CACZ,UAACN,KAAD;AAAA,eACE,yBAAAA,KAAK,MAAL,CAAAA,KAAK,YAAeG,SAAf,OAAL,IAAqC,yBAAAH,KAAK,MAAL,CAAAA,KAAK,YAAeG,SAAf,OAD5C;AAAA,OADY,CAAd;;AAKA,UAAI,CAACE,KAAL,EAAY;AACV,eAAO,IAAP;AACD;;AAED,aAAOA,KAAK,CAACD,MAAN,CAAaD,SAAS,CAACN,MAAV,GAAmB,CAAhC,CAAP;AACD;AAED;AACF;AACA;AACA;;;;WACE,6BAAoBE,IAApB,EAAwD;AACtD,UAAI,CAAC,KAAKQ,GAAL,CAASR,IAAT,CAAL,EAAqB;AACnB,eAAO,IAAP;AACD;;AAED,UAAMS,KAAK,GAAG,KAAKC,kBAAL,CAAwBV,IAAxB,CAAd;;AAEA,UAAI,CAACS,KAAL,EAAY;AACV,eAAO,EAAP;AACD;;AAED,aAAOA,KAAK,CAACE,KAAN,CAAY,GAAZ,CAAP;AACD;;;EA3G+CC,wB","sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport { IllegalArgumentException } from \"../../exceptions\";\n\n/**\n * Collection of layouthint\n */\nexport default class LayoutHintCollection extends BaseCollection<string> {\n /**\n * Constructs the layouthint collection\n */\n constructor(layouthint: Array<string> = []) {\n super();\n\n if (!Array.isArray(layouthint)) {\n throw new IllegalArgumentException(`${layouthint} is not an Array`);\n }\n\n this.collection = layouthint;\n }\n\n /**\n * Retrieve layout hints\n */\n get layouthint(): Array<string> {\n return this.collection;\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration\n * This method matches all exact matches and hints starting with. For example\n * when calling layouth.has(\"hide\"), this will return true for both \"hide\" and \"hide-when-empty\".\n * If only exact matches are required, use the method {@link hasExact}.\n */\n has(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n\n return hintArray\n .flat()\n .some(\n (hint) =>\n this.layouthint.includes(hint) ||\n this.layouthint.some((hint2) => hint2.startsWith(hint))\n );\n }\n\n /**\n * Checks if a specific layouthint exists in the component configuration,\n * only checks on exact matches.\n * If layouthints that start with the given hint should also match, use {@link has}.\n * @param hints\n * @returns {boolean}\n */\n hasExact(...hints: Array<string>): boolean {\n const hintArray = hints.length > 0 ? [...hints] : [];\n return hintArray.flat().some((hint) => this.layouthint.includes(hint));\n }\n\n /**\n * Retrieve the first layouthint starting with hint\n */\n getByLayoutHint(hint: Function | string): null | string {\n let foundHint = null;\n\n if (typeof hint === \"function\") {\n foundHint = this.layouthint.find(hint);\n }\n\n if (typeof hint === \"string\") {\n foundHint = this.layouthint.find((hint2) =>\n hint2.startsWith(hint.toString())\n );\n }\n\n return foundHint || null;\n }\n\n /**\n * Get the value of a specific hint\n * Format: hint=value\n */\n getLayoutHintValue(hint: string): ?string {\n const checkHint = hint.endsWith(\":\")\n ? hint.substr(0, hint.length - 1)\n : hint;\n\n const match = this.getByLayoutHint(\n (hint2) =>\n hint2.startsWith(`${checkHint}=`) || hint2.startsWith(`${checkHint}:`)\n );\n\n if (!match) {\n return null;\n }\n\n return match.substr(checkHint.length + 1);\n }\n\n /**\n * Get an array of multiple values from a specific hint\n * Format: hint=value1;value2;value3\n */\n getLayoutHintValues(hint: string): Array<string> | null {\n if (!this.has(hint)) {\n return null;\n }\n\n const value = this.getLayoutHintValue(hint);\n\n if (!value) {\n return [];\n }\n\n return value.split(\";\");\n }\n}\n"],"file":"LayoutHintCollection.js"}
|
|
@@ -193,6 +193,31 @@ var ListDetailModel = /*#__PURE__*/function (_DetailModel) {
|
|
|
193
193
|
set: function set(configuration) {
|
|
194
194
|
this._contentConfiguration = configuration;
|
|
195
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Getting the introduction text configured on the case view
|
|
198
|
+
*/
|
|
199
|
+
|
|
200
|
+
}, {
|
|
201
|
+
key: "introtext",
|
|
202
|
+
get: function get() {
|
|
203
|
+
if (this.data._text) {
|
|
204
|
+
var _this$data$_text$mess;
|
|
205
|
+
|
|
206
|
+
return (_this$data$_text$mess = this.data._text.message) !== null && _this$data$_text$mess !== void 0 ? _this$data$_text$mess : this.data._text;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (this.contributions.text) {
|
|
210
|
+
var _this$contributions$t;
|
|
211
|
+
|
|
212
|
+
return (_this$contributions$t = this.contributions.text.message) !== null && _this$contributions$t !== void 0 ? _this$contributions$t : this.contributions.text;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
216
|
+
return this.contributions.texts[0].text;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return "";
|
|
220
|
+
}
|
|
196
221
|
/**
|
|
197
222
|
*/
|
|
198
223
|
|
|
@@ -133,6 +133,25 @@ export default class ListDetailModel extends DetailModel {
|
|
|
133
133
|
this._contentConfiguration = configuration;
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Getting the introduction text configured on the case view
|
|
138
|
+
*/
|
|
139
|
+
get introtext(): string {
|
|
140
|
+
if (this.data._text) {
|
|
141
|
+
return this.data._text.message ?? this.data._text;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (this.contributions.text) {
|
|
145
|
+
return this.contributions.text.message ?? this.contributions.text;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
149
|
+
return this.contributions.texts[0].text;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return "";
|
|
153
|
+
}
|
|
154
|
+
|
|
136
155
|
/**
|
|
137
156
|
*/
|
|
138
157
|
setResultSection() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/list/ListDetailModel.js"],"names":["ListDetailModel","modularUIResponse","_actionCollection","ActionCollection","_contentConfiguration","ContentConfiguration","contributions","content","setResultSection","setEventData","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","getInitialChildModelLinks","givenAnswers","models","_attributeCollection","setChildModels","_listitem","actionCollection","configuration","data","setResults","setGivenAnswers","key","dynamicschema","resultSection","CompositeAttributeModel","isResult","indicateContentConfiguration","contentConfiguration","_results","givenAnswersData","givenAnswersContributions","filteredContributions","children","child","childKey","_givenAnswers","eventdata","eventData","eventContributions","_eventdata","AttributeSetModel","hasEventData","forEach","eventDataContribution","Array","isArray","eventDataData","i","addAttributes","resourcetype","DetailModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAQA;AACA;AACA;IACqBA,e;;;;;AAOnB;AACF;AACA;AACE,2BAAYC,iBAAZ,EAAkD;AAAA;;AAAA;AAChD,8BAAMA,iBAAN;AADgD;AAAA;AAAA;AAAA;AAAA;AAGhD,UAAKC,iBAAL,GAAyB,IAAIC,yBAAJ,EAAzB;AAEA,UAAKC,qBAAL,GAA6B,IAAIC,6BAAJ,CAC3B,MAAKC,aAAL,GAAqB,MAAKA,aAAL,CAAmBC,OAAxC,GAAkD,EADvB,CAA7B;;AAIA,UAAKC,gBAAL;;AACA,UAAKC,YAAL;;AAVgD;AAWjD;AAED;AACF;AACA;;;;;WACE,qCAA8C;AAAA;;AAC5C,UAAMC,cAAc,GAAG,KAAKC,QAAL,GACnB,KAAKA,QAAL,CAAcC,KAAd,CAAoBC,eAApB,CAAoC,OAApC,EAA6CC,GAD1B,GAEnB,EAFJ;AAIA,UAAMF,KAAK,qPAA6CF,cAA7C,EAAX;;AAEA,UAAI,KAAKK,UAAT,EAAqB;AACnB,YAAI,KAAKC,OAAT,EAAkB;AAChBJ,UAAAA,KAAK,CAACK,IAAN,OAAAL,KAAK,mCAAS,KAAKI,OAAL,CAAaE,yBAAb,EAAT,EAAL;AACD;;AACD,YAAI,KAAKC,YAAT,EAAuB;AACrB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3C,cAAA,MAAI,CAACH,IAAL,CAAUkB,SAAV,CAAoBf,GAApB,EAAyBqB,OAAzB,CAAiC,UAACI,aAAD,EAAgBC,CAAhB,EAAsB;AAAA;;AACrD,gBAAA,MAAI,CAACC,aAAL,4CACK3B,GADL,wBACY0B,CAAC,GAAG,CADhB,mCAGOD,aAHP;AAIIxB,kBAAAA,aAAa,EAAE,MAAI,CAACJ,IAAL,CAAUI;AAJ7B,oBAMEqB,qBAAqB,CAACtB,GAAD,CANvB;AAQD,eATD;AAUD,aAXD,MAWO;AACL,cAAA,MAAI,CAAC2B,aAAL,CACE3B,GADF,kCAGO,MAAI,CAACH,IAAL,CAAUkB,SAAV,CAAoBf,GAApB,CAHP;AAIIC,gBAAAA,aAAa,EAAE,MAAI,CAACJ,IAAL,CAAUI;AAJ7B,kBAMEqB,qBAAqB,CAACtB,GAAD,CANvB;AAQD;AACF;AACF,SAzBD;AA0BD;AACF;AAED;AACF;;;;SACE,eAA0C;AACxC,aAAO,KAAKkB,UAAZ;AACD;;;WAvMD,2BAAyBrB,IAAzB,EAA2D;AAAA;;AACzD,UAAM+B,YAAY,mDAAG/B,IAAI,CAACpB,aAAR,wDAAG,oBAAoBmD,YAAvB,yEAAuC,SAAzD;AAEA,aACE,uBAAAA,YAAY,MAAZ,CAAAA,YAAY,EAAU,iBAAV,CAAZ,IACA,uBAAAA,YAAY,MAAZ,CAAAA,YAAY,EAAU,YAAV,CADZ,IAEAA,YAAY,KAAK,sCAFjB,IAGAA,YAAY,KAAK,iCAJnB;AAMD;;;EA5E0CC,qB","sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {}\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n\n if (this.results) {\n this.results.setChildModels(models);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n\n return (\n resourcetype.endsWith(\"ListPanelDetail\") ||\n resourcetype.endsWith(\"ListDetail\") ||\n resourcetype === \"DatastoreRelatedDatastorePanelDetail\" ||\n resourcetype === \"CaseRelatedDataStorePanelDetail\"\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\n }\n\n /**\n */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.results,\n ...this.data.resultSection,\n },\n this.contributions.resultSection.results\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n };\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.givenAnswers,\n ...this.data.resultSection,\n },\n filteredContributions\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(key, eventData, eventContributions)\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key]\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key]\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"file":"ListDetailModel.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/models/list/ListDetailModel.js"],"names":["ListDetailModel","modularUIResponse","_actionCollection","ActionCollection","_contentConfiguration","ContentConfiguration","contributions","content","setResultSection","setEventData","listitemPanels","listitem","links","getLinksByGroup","all","hasResults","results","push","getInitialChildModelLinks","givenAnswers","models","_attributeCollection","setChildModels","_listitem","actionCollection","configuration","data","_text","message","text","Array","isArray","texts","setResults","setGivenAnswers","key","dynamicschema","resultSection","CompositeAttributeModel","isResult","indicateContentConfiguration","contentConfiguration","_results","givenAnswersData","givenAnswersContributions","filteredContributions","children","child","childKey","_givenAnswers","eventdata","eventData","eventContributions","_eventdata","AttributeSetModel","hasEventData","forEach","eventDataContribution","eventDataData","i","addAttributes","resourcetype","DetailModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAQA;AACA;AACA;IACqBA,e;;;;;AAOnB;AACF;AACA;AACE,2BAAYC,iBAAZ,EAAkD;AAAA;;AAAA;AAChD,8BAAMA,iBAAN;AADgD;AAAA;AAAA;AAAA;AAAA;AAGhD,UAAKC,iBAAL,GAAyB,IAAIC,yBAAJ,EAAzB;AAEA,UAAKC,qBAAL,GAA6B,IAAIC,6BAAJ,CAC3B,MAAKC,aAAL,GAAqB,MAAKA,aAAL,CAAmBC,OAAxC,GAAkD,EADvB,CAA7B;;AAIA,UAAKC,gBAAL;;AACA,UAAKC,YAAL;;AAVgD;AAWjD;AAED;AACF;AACA;;;;;WACE,qCAA8C;AAAA;;AAC5C,UAAMC,cAAc,GAAG,KAAKC,QAAL,GACnB,KAAKA,QAAL,CAAcC,KAAd,CAAoBC,eAApB,CAAoC,OAApC,EAA6CC,GAD1B,GAEnB,EAFJ;AAIA,UAAMF,KAAK,qPAA6CF,cAA7C,EAAX;;AAEA,UAAI,KAAKK,UAAT,EAAqB;AACnB,YAAI,KAAKC,OAAT,EAAkB;AAChBJ,UAAAA,KAAK,CAACK,IAAN,OAAAL,KAAK,mCAAS,KAAKI,OAAL,CAAaE,yBAAb,EAAT,EAAL;AACD;;AACD,YAAI,KAAKC,YAAT,EAAuB;AACrBP,UAAAA,KAAK,CAACK,IAAN,OAAAL,KAAK,mCAAS,KAAKO,YAAL,CAAkBD,yBAAlB,EAAT,EAAL;AACD;AACF;;AAED,aAAON,KAAP;AACD;AAED;AACF;;;;WACE,wBAAeQ,MAAf,EAA8C;AAC5C,WAAKC,oBAAL,CAA0BC,cAA1B,CAAyCF,MAAzC;;AAEA,UAAI,KAAKJ,OAAT,EAAkB;AAChB,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CC,qB","sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport DetailModel from \"../detail/DetailModel\";\nimport ContentConfiguration from \"../contentconfiguration/ContentConfiguration\";\nimport AttributeSetModel from \"../attributes/AttributeSetModel\";\n\nimport createAttribute from \"../attributes/_createAttribute\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type ListItemModel from \"../list/ListItemModel\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Detail of a list item\n */\nexport default class ListDetailModel extends DetailModel {\n _contentConfiguration: ContentConfiguration;\n _listitem: ListItemModel;\n _givenAnswers: ?CompositeAttributeModel;\n _results: ?CompositeAttributeModel;\n _eventdata: Array<AttributeSetModel>;\n\n /**\n * Construct\n */\n constructor(modularUIResponse: ModularUIResponse) {\n super(modularUIResponse);\n\n this._actionCollection = new ActionCollection();\n\n this._contentConfiguration = new ContentConfiguration(\n this.contributions ? this.contributions.content : {}\n );\n\n this.setResultSection();\n this.setEventData();\n }\n\n /**\n * Add links to expand on initialization of this model\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const listitemPanels = this.listitem\n ? this.listitem.links.getLinksByGroup(\"panel\").all\n : [];\n\n const links = [...super.getInitialChildModelLinks(), ...listitemPanels];\n\n if (this.hasResults) {\n if (this.results) {\n links.push(...this.results.getInitialChildModelLinks());\n }\n if (this.givenAnswers) {\n links.push(...this.givenAnswers.getInitialChildModelLinks());\n }\n }\n\n return links;\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this._attributeCollection.setChildModels(models);\n\n if (this.results) {\n this.results.setChildModels(models);\n }\n\n if (this.givenAnswers) {\n this.givenAnswers.setChildModels(models);\n }\n }\n\n /**\n */\n get type(): string {\n return \"ListDetail\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourcetype = data.contributions?.resourcetype ?? \"unknown\";\n\n return (\n resourcetype.endsWith(\"ListPanelDetail\") ||\n resourcetype.endsWith(\"ListDetail\") ||\n resourcetype === \"DatastoreRelatedDatastorePanelDetail\" ||\n resourcetype === \"CaseRelatedDataStorePanelDetail\"\n );\n }\n\n /**\n * Set listitem of this listdetail and transfer listitem actions to listdetail actions\n */\n set listitem(listitem: ListItemModel) {\n this._listitem = listitem;\n\n // transfer listitem actions to _actions\n this._actionCollection = listitem.actionCollection;\n }\n\n /**\n * Get listitem\n */\n get listitem(): ListItemModel {\n return this._listitem;\n }\n\n /**\n * Getting panel links\n */\n get panelLinks(): LinkCollection {\n return this.listitem.links.getLinksByGroup(\"panel\");\n }\n\n /**\n * Getting the contentConfiguration\n */\n get contentConfiguration(): ContentConfiguration {\n return this._contentConfiguration;\n }\n\n /**\n */\n set contentConfiguration(configuration: ContentConfiguration) {\n this._contentConfiguration = configuration;\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 */\n setResultSection() {\n if (\n has(this.contributions, \"resultSection\") &&\n has(this.data, \"resultSection\")\n ) {\n this.setResults();\n this.setGivenAnswers();\n }\n }\n\n /**\n */\n setResults() {\n if (\n has(this.data, \"resultSection.results\") &&\n has(this.contributions, \"resultSection.results\")\n ) {\n const results = createAttribute(\n \"results\",\n {\n key: \"results\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.results,\n ...this.data.resultSection,\n },\n this.contributions.resultSection.results\n );\n\n if (results instanceof CompositeAttributeModel) {\n results.isResult = true;\n results.indicateContentConfiguration(this.contentConfiguration);\n this._results = results;\n }\n }\n }\n\n /**\n */\n setGivenAnswers() {\n if (\n has(this.data, \"resultSection.givenAnswers\") &&\n has(this.contributions, \"resultSection.givenAnswers\")\n ) {\n const givenAnswersData = this.data.resultSection.givenAnswers;\n const givenAnswersContributions =\n this.contributions.resultSection.givenAnswers;\n\n const filteredContributions = {\n ...givenAnswersContributions,\n children: givenAnswersContributions.children.filter((child) => {\n const childKey = Object.keys(child)[0];\n return childKey in givenAnswersData;\n }),\n };\n\n const givenAnswers = createAttribute(\n \"givenAnswers\",\n {\n key: \"givenAnswers\",\n dynamicschema: this.data.dynamicschema,\n content: this.data.content?.givenAnswers,\n ...this.data.resultSection,\n },\n filteredContributions\n );\n\n if (givenAnswers instanceof CompositeAttributeModel) {\n givenAnswers.isResult = true;\n this._givenAnswers = givenAnswers;\n }\n }\n }\n\n /**\n */\n get givenAnswers(): ?CompositeAttributeModel {\n return this._givenAnswers;\n }\n\n /**\n */\n get hasResults(): boolean {\n return has(this.contributions, \"resultSection\");\n }\n\n /**\n */\n get results(): ?CompositeAttributeModel {\n return this._results;\n }\n\n /**\n */\n get hasEventData(): boolean {\n return (\n has(this.contributions, \"eventdata\") &&\n has(this.data, \"eventdata\") &&\n this.data.eventdata != null &&\n this.contributions.eventdata != null\n );\n }\n\n /**\n */\n addAttributes(key: string, eventData: Object, eventContributions: Object) {\n this._eventdata.push(\n new AttributeSetModel(key, eventData, eventContributions)\n );\n }\n\n /**\n */\n setEventData() {\n if (this.hasEventData) {\n this._eventdata = [];\n\n this.contributions.eventdata.forEach((eventDataContribution) => {\n const [key] = Object.keys(eventDataContribution);\n if (key in this.data.eventdata) {\n if (Array.isArray(this.data.eventdata[key])) {\n this.data.eventdata[key].forEach((eventDataData, i) => {\n this.addAttributes(\n `${key}-${i + 1}`,\n {\n ...eventDataData,\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key]\n );\n });\n } else {\n this.addAttributes(\n key,\n {\n ...this.data.eventdata[key],\n dynamicschema: this.data.dynamicschema,\n },\n eventDataContribution[key]\n );\n }\n }\n });\n }\n }\n\n /**\n */\n get eventdata(): Array<AttributeSetModel> {\n return this._eventdata;\n }\n}\n"],"file":"ListDetailModel.js"}
|
|
@@ -172,13 +172,20 @@ var ListModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
172
172
|
}, {
|
|
173
173
|
key: "introtext",
|
|
174
174
|
get: function get() {
|
|
175
|
-
if (this.
|
|
176
|
-
var
|
|
175
|
+
if (this.data.text) {
|
|
176
|
+
var _this$data$text$messa;
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
return (_this$data$text$messa = this.data.text.message) !== null && _this$data$text$messa !== void 0 ? _this$data$text$messa : this.data.text;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (this.contributions.text) {
|
|
182
|
+
var _this$contributions$t;
|
|
183
|
+
|
|
184
|
+
return (_this$contributions$t = this.contributions.text.message) !== null && _this$contributions$t !== void 0 ? _this$contributions$t : this.contributions.text;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
188
|
+
return this.contributions.texts[0].text;
|
|
182
189
|
}
|
|
183
190
|
|
|
184
191
|
return "";
|
|
@@ -197,13 +204,13 @@ var ListModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
197
204
|
var _embedded = this.getData("_embedded");
|
|
198
205
|
|
|
199
206
|
if (_embedded !== null) {
|
|
200
|
-
var
|
|
207
|
+
var _context3;
|
|
201
208
|
|
|
202
209
|
if (Array.isArray(_embedded)) {
|
|
203
210
|
throw new _exceptions.ConfigurationException("One record panel with multiple tables is not supported, place all types in one panel for the panel with key ".concat(this.key));
|
|
204
211
|
}
|
|
205
212
|
|
|
206
|
-
listitemCollection.collection = (0, _map.default)(
|
|
213
|
+
listitemCollection.collection = (0, _map.default)(_context3 = _embedded.results).call(_context3, function (result) {
|
|
207
214
|
return _this2.createListItem(result);
|
|
208
215
|
});
|
|
209
216
|
}
|
|
@@ -269,10 +276,10 @@ var ListModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
269
276
|
,
|
|
270
277
|
set: function set(detail) {
|
|
271
278
|
if (detail instanceof _ListDetailModel.default) {
|
|
272
|
-
var
|
|
279
|
+
var _context4;
|
|
273
280
|
|
|
274
281
|
var listitemHref = detail.selfhref;
|
|
275
|
-
var listitem = (0, _find.default)(
|
|
282
|
+
var listitem = (0, _find.default)(_context4 = this.listItemCollection).call(_context4, function (listItem) {
|
|
276
283
|
return listItem.selfhref.equals(listitemHref);
|
|
277
284
|
});
|
|
278
285
|
|
|
@@ -340,10 +347,10 @@ var ListModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
340
347
|
}, {
|
|
341
348
|
key: "getListItemById",
|
|
342
349
|
value: function getListItemById(id) {
|
|
343
|
-
var
|
|
350
|
+
var _context5;
|
|
344
351
|
|
|
345
352
|
var decodedId = decodeURIComponent(id.toString());
|
|
346
|
-
return (0, _find.default)(
|
|
353
|
+
return (0, _find.default)(_context5 = this.listItemCollection).call(_context5, function (result) {
|
|
347
354
|
return result.id.toString() === decodedId;
|
|
348
355
|
});
|
|
349
356
|
}
|
|
@@ -354,9 +361,9 @@ var ListModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
354
361
|
}, {
|
|
355
362
|
key: "getListItemByHref",
|
|
356
363
|
value: function getListItemByHref(href) {
|
|
357
|
-
var
|
|
364
|
+
var _context6;
|
|
358
365
|
|
|
359
|
-
return (0, _find.default)(
|
|
366
|
+
return (0, _find.default)(_context6 = this.listItemCollection).call(_context6, function (result) {
|
|
360
367
|
return result.selfhref.equals(href);
|
|
361
368
|
});
|
|
362
369
|
}
|
|
@@ -576,9 +583,9 @@ var ListModel = /*#__PURE__*/function (_ResourceModel) {
|
|
|
576
583
|
}], [{
|
|
577
584
|
key: "isApplicableModel",
|
|
578
585
|
value: function isApplicableModel(data) {
|
|
579
|
-
var _context8, _context9
|
|
586
|
+
var _context7, _context8, _context9;
|
|
580
587
|
|
|
581
|
-
return data.contributions.resourcetype && ((0, _endsWith.default)(
|
|
588
|
+
return data.contributions.resourcetype && ((0, _endsWith.default)(_context7 = data.contributions.resourcetype).call(_context7, "List") || (0, _endsWith.default)(_context8 = data.contributions.resourcetype).call(_context8, "ListPanel") || (0, _includes.default)(_context9 = ["DatastoreRelatedDatastorePanel", "list-related-cases", "CaseRelatedDataStorePanel", "RecordPanel", "EventHistoryPanel", "NotePanel", "AppointmentPanel", "DocumentPanel", "AssignmentPanel"]).call(_context9, data.contributions.resourcetype));
|
|
582
589
|
}
|
|
583
590
|
}]);
|
|
584
591
|
return ListModel;
|