@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/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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oC;AAClCc,cAAAA,eAAe,CAAC3D,IAAhB,CAAqB4C,KAArB;AACD,aAFD,MAEO;AACL,cAAA,MAAI,CAACM,eAAL,CAAqBJ,cAArB,CACEF,KAAK,CAACG,EADR,EAEEH,KAAK,CAACI,OAFR,EAGEJ,KAAK,CAACK,UAHR;AAKD;AACF;AACF,SAZD;AAaD,OAnB2C,CAqB5C;;;AACA,UAAIW,KAAK,CAACC,OAAN,kBAAchF,IAAI,CAACkF,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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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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,MAEO;AACL,cAAA,MAAI,CAACK,eAAL,CAAqBH,cAArB,CACEF,KAAK,CAACG,EADR,EAEEH,KAAK,CAAChB,OAFR,EAGEgB,KAAK,CAACI,UAHR;AAKD;AACF;AACF,SAZD;AAaD,OAnB2C,CAqB5C;;;AACA,UAAIW,KAAK,CAACC,OAAN,kBAAchF,IAAI,CAACkF,OAAnB,kDAAc,cAAcC,OAA5B,CAAJ,EAA0C;AAAA;;AACxCL,QAAAA,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;AAC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AAL,CAAAA,KAAK,EAAYD,IAAI,CAACG,QAAL,EAAZ,CAD0B;AAAA,SAArB,CAAZ;AAGD;;AAED,aAAOD,SAAS,IAAI,IAApB;AACD;AAED;AACF;AACA;AACA;;;;WACE,4BAAmBF,IAAnB,EAA0C;AACxC,UAAMI,SAAS,GAAG,uBAAAJ,IAAI,MAAJ,CAAAA,IAAI,EAAU,GAAV,CAAJ,GACdA,IAAI,CAACK,MAAL,CAAY,CAAZ,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,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;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,Y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A;;AACzD,UAAMmC,YAAY,mDAAGnC,IAAI,CAACpB,aAAR,wDAAG,oBAAoBuD,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 * 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;
|
|
@@ -98,12 +98,16 @@ export default class ListModel extends ResourceModel {
|
|
|
98
98
|
* Getting the introduction text
|
|
99
99
|
*/
|
|
100
100
|
get introtext(): string {
|
|
101
|
-
if (this.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
if (this.data.text) {
|
|
102
|
+
return this.data.text.message ?? this.data.text;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (this.contributions.text) {
|
|
106
|
+
return this.contributions.text.message ?? this.contributions.text;
|
|
107
|
+
}
|
|
105
108
|
|
|
106
|
-
|
|
109
|
+
if (Array.isArray(this.contributions.texts)) {
|
|
110
|
+
return this.contributions.texts[0].text;
|
|
107
111
|
}
|
|
108
112
|
|
|
109
113
|
return "";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/models/list/ListModel.js"],"names":["ListModel","layouthint","has","SHOW_ONE_RESULT_AS_DETAIL","listItemCollection","length","listItem","listDetailLink","selflink","targetModel","ListDetailModel","models","detail","childModel","type","contributions","label","texts","text","item","listitemCollection","ListItemCollection","_embedded","getData","Array","isArray","ConfigurationException","key","collection","results","result","createListItem","resultItem","listitemData","listitemContributions","data","dynamicschema","listitemModelInput","ModularUIResponse","ListItemModel","_listItemCollection","createListItemCollection","_detail","listitemHref","selfhref","listitem","equals","setSelfHref","_grouping","setGrouping","GroupingModel","grouping","contexts","hasGroups","hasItems","HIDE_WHEN_EMPTY","hasResults","actionCollection","isEmpty","filterCollection","hasActiveFilters","id","decodedId","decodeURIComponent","toString","href","_paging","setPaging","PagingModel","paging","_sorting","setSorting","SortingModel","getSortingLabels","sorting","_filterCollection","setFilters","FilterCollection","listkey","filter","_actionCollection","setActionCollection","ActionCollection","actions","selfLink","links","getLinkByKey","ListHref","_selfhref","_headers","setHeaders","tempHeaders","forEach","attributes","attribute","listHeader","ListHeaderModel","exists","some","tempHeader","CASEVIEW_LINK","push","sortingLabels","attributeKey","actionType","getActionsByType","resourcetype","ResourceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AASA;AACA;AACA;IACqBA,S;;;;;;;;;;;;;;;;;0FACS,I;;;;;;;;;;;;;;;AAU5B;AACF;AACE,mBAAmB;AACjB,aAAO,MAAP;AACD;AAED;AACF;;;;;AAoBE;AACF;AACE,yCAA8C;AAC5C,UACE,KAAKC,UAAL,CAAgBC,GAAhB,CAAoBC,sCAApB,KACA,KAAKC,kBAAL,CAAwBC,MAAxB,KAAmC,CAFrC,EAGE;AAAA;;AACA,eAAO,mCAAKD,kBAAL,kBAA4B,UAACE,QAAD,EAAc;AAC/C,cAAMC,cAAc,GAAGD,QAAQ,CAACE,QAAhC;AACAD,UAAAA,cAAc,CAACE,WAAf,GAA6BC,wBAA7B;AACA,iB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zD,aACEA,IAAI,CAACpB,aAAL,CAAmB2F,YAAnB,KACC,mCAAAvE,IAAI,CAACpB,aAAL,CAAmB2F,YAAnB,kBAAyC,MAAzC,KACC,mCAAAvE,IAAI,CAACpB,aAAL,CAAmB2F,YAAnB,kBAAyC,WAAzC,CADD,IAEC,qCACE,gCADF,EAEE,oBAFF,EAGE,2BAHF,EAIE,aAJF,EAKE,mBALF,EAME,WANF,EAOE,kBAPF,EAQE,eARF,EASE,iBATF,oBAUWvE,IAAI,CAACpB,aAAL,CAAmB2F,YAV9B,CAHF,CADF;AAgBD;;;EApCoCC,uB","sourcesContent":["// @flow\nimport { ConfigurationException } from \"../../exceptions\";\n\nimport ModularUIResponse from \"../../modularui/ModularUIResponse\";\n\nimport ListItemCollection from \"../list/ListItemCollection\";\nimport ListDetailModel from \"../list/ListDetailModel\";\nimport ActionCollection from \"../actions/ActionCollection\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport GroupingModel from \"../grouping/GroupingModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\nimport ListHref from \"../href/ListHref\";\nimport ListItemModel from \"../list/ListItemModel\";\nimport PagingModel from \"../paging/PagingModel\";\nimport ResourceModel from \"../base/ResourceModel\";\nimport SortingModel from \"../sorting/SortingModel\";\nimport {\n CASEVIEW_LINK,\n HIDE_WHEN_EMPTY,\n SHOW_ONE_RESULT_AS_DETAIL,\n} from \"../../constants/LayoutHints\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Defines a list object\n */\nexport default class ListModel extends ResourceModel {\n _detail: ?ListDetailModel = null;\n _headers: Array<ListHeaderModel>;\n _paging: PagingModel;\n _filterCollection: FilterCollection;\n _sorting: SortingModel;\n _actionCollection: ActionCollection;\n _listItemCollection: ListItemCollection;\n _grouping: GroupingModel;\n _selfhref: ListHref;\n\n /**\n */\n get type(): string {\n return \"List\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n (data.contributions.resourcetype.endsWith(\"List\") ||\n data.contributions.resourcetype.endsWith(\"ListPanel\") ||\n [\n \"DatastoreRelatedDatastorePanel\",\n \"list-related-cases\",\n \"CaseRelatedDataStorePanel\",\n \"RecordPanel\",\n \"EventHistoryPanel\",\n \"NotePanel\",\n \"AppointmentPanel\",\n \"DocumentPanel\",\n \"AssignmentPanel\",\n ].includes(data.contributions.resourcetype))\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n if (\n this.layouthint.has(SHOW_ONE_RESULT_AS_DETAIL) &&\n this.listItemCollection.length === 1\n ) {\n return this.listItemCollection.map((listItem) => {\n const listDetailLink = listItem.selflink;\n listDetailLink.targetModel = ListDetailModel;\n return listDetailLink;\n });\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.detail = models.find((childModel) => childModel.type === \"ListDetail\");\n }\n\n /**\n * Getting the label of the list\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Getting the introduction text\n */\n get introtext(): string {\n if (this.contributions.texts) {\n const text = this.contributions.texts.find(\n (item) => item.type === \"master\"\n );\n\n return text ? text.text : \"\";\n }\n\n return \"\";\n }\n\n /**\n * Create a listitem collection from the data and contributions of a list\n */\n createListItemCollection(): ListItemCollection {\n const listitemCollection = new ListItemCollection();\n\n const _embedded = this.getData(\"_embedded\");\n if (_embedded !== null) {\n if (Array.isArray(_embedded)) {\n throw new ConfigurationException(\n `One record panel with multiple tables is not supported, place all types in one panel for the panel with key ${this.key}`\n );\n }\n\n listitemCollection.collection = _embedded.results.map((result) =>\n this.createListItem(result)\n );\n }\n\n return listitemCollection;\n }\n\n /**\n * Create a ListItem\n */\n createListItem(resultItem: Object): ListItemModel {\n const [key] = Object.keys(resultItem);\n const listitemData = resultItem[key];\n const listitemContributions = this.contributions.results[key];\n\n if (this.data.dynamicschema) {\n listitemData.dynamicschema = this.data.dynamicschema;\n }\n\n const listitemModelInput = new ModularUIResponse();\n listitemModelInput.key = key;\n listitemModelInput.data = listitemData;\n listitemModelInput.contributions = listitemContributions;\n\n return new ListItemModel(listitemModelInput);\n }\n\n /**\n * Getting the results\n */\n get listItemCollection(): ListItemCollection {\n if (!this._listItemCollection) {\n this._listItemCollection = this.createListItemCollection();\n }\n\n return this._listItemCollection;\n }\n\n /**\n * Set results\n */\n set listItemCollection(listItemCollection: ListItemCollection) {\n this._listItemCollection = listItemCollection;\n }\n\n /**\n * Getting the detail\n */\n get detail(): ?ListDetailModel {\n return this._detail;\n }\n\n /**\n * Add detail model to the {ListModel}\n */\n set detail(detail: ?ModularUIModel) {\n if (detail instanceof ListDetailModel) {\n const listitemHref = detail.selfhref;\n\n const listitem = this.listItemCollection.find((listItem) =>\n listItem.selfhref.equals(listitemHref)\n );\n\n if (listitem) {\n detail.listitem = listitem;\n }\n\n this._detail = detail;\n }\n\n this.setSelfHref();\n }\n\n /**\n * Retrieve grouping information\n */\n get grouping(): GroupingModel {\n if (!this._grouping) {\n this._grouping = this.setGrouping();\n }\n\n return this._grouping;\n }\n\n /**\n */\n setGrouping(): GroupingModel {\n return new GroupingModel(\n { ...this.data.grouping, dynamicschema: this.data.dynamicschema },\n this.contributions.contexts\n );\n }\n\n /**\n */\n hasGrouping(): boolean {\n return this.grouping.hasGroups();\n }\n\n /**\n * Check if list has results\n */\n hasResults(): boolean {\n return this.listItemCollection.hasItems;\n }\n\n /**\n */\n get shouldHide(): boolean {\n return (\n this.layouthint.has(HIDE_WHEN_EMPTY) &&\n !this.hasResults() &&\n this.actionCollection.isEmpty &&\n !this.filterCollection.hasActiveFilters()\n );\n }\n\n /**\n * Get list item by ID\n */\n getListItemById(id: string | number): ListItemModel | null {\n const decodedId = decodeURIComponent(id.toString());\n return this.listItemCollection.find(\n (result) => result.id.toString() === decodedId\n );\n }\n\n /**\n * Get list item by Href\n */\n getListItemByHref(href: ListHref): ListItemModel | null {\n return this.listItemCollection.find((result) =>\n result.selfhref.equals(href)\n );\n }\n\n /**\n * Getting paging information\n */\n get paging(): PagingModel {\n if (!this._paging) {\n this._paging = this.setPaging();\n }\n return this._paging;\n }\n\n /**\n */\n setPaging(): PagingModel {\n return new PagingModel(this.data.paging, this.contributions.paging);\n }\n\n /**\n * Getting sorting information\n */\n get sorting(): SortingModel {\n if (!this._sorting) {\n this._sorting = this.setSorting();\n }\n\n return this._sorting;\n }\n\n /**\n */\n setSorting(): SortingModel {\n return new SortingModel(\n this.contributions,\n this.getSortingLabels(),\n this.grouping,\n this.data.sorting\n );\n }\n\n /**\n * Getting the filters\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = this.setFilters();\n }\n\n return this._filterCollection;\n }\n\n /**\n * Set filterCollection\n */\n set filterCollection(filterCollection: FilterCollection) {\n this._filterCollection = filterCollection;\n }\n\n /**\n */\n setFilters(): FilterCollection {\n return new FilterCollection(this.data.filter, {\n listkey: this.key,\n filter: this.contributions.filter,\n contexts: this.contributions.contexts,\n dynamicschema: this.data.dynamicschema,\n });\n }\n\n /**\n * Indicates if list results are filtered\n */\n isFiltered(): boolean {\n return this.filterCollection.hasActiveFilters();\n }\n\n /**\n * Getting actions\n */\n get actionCollection(): ActionCollection {\n if (!this._actionCollection) {\n this._actionCollection = this.setActionCollection();\n }\n return this._actionCollection;\n }\n\n /**\n */\n setActionCollection(): ActionCollection {\n return new ActionCollection(this.data.actions, this.contributions.actions);\n }\n\n /**\n * Contains this model list data\n */\n hasList(): boolean {\n return this.key != null;\n }\n\n /**\n * Sets self href from links collection\n */\n setSelfHref(): ListHref {\n const selfLink = this.links ? this.links.getLinkByKey(\"self\") : null;\n\n if (selfLink !== null) {\n return new ListHref(selfLink.href, this);\n }\n\n return new ListHref();\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): ListHref {\n if (!this._selfhref) {\n this._selfhref = this.setSelfHref();\n }\n return this._selfhref;\n }\n\n /**\n * Getting the headers of this list\n */\n get headers(): Array<ListHeaderModel> {\n if (!this._headers) {\n this._headers = this.setHeaders();\n }\n\n return this._headers;\n }\n\n /**\n * Set initial headers of list\n */\n setHeaders(): Array<ListHeaderModel> {\n const tempHeaders = [];\n\n if (this.contributions.results) {\n const { results } = this.contributions;\n\n Object.keys(results).forEach((key) => {\n results[key].attributes.forEach((attribute) => {\n const listHeader = new ListHeaderModel(attribute, this.sorting);\n\n const exists = tempHeaders.some((tempHeader) =>\n tempHeader.equals(listHeader)\n );\n\n if (!exists && !listHeader.layouthint.has(CASEVIEW_LINK)) {\n tempHeaders.push(listHeader);\n }\n });\n });\n }\n\n return tempHeaders;\n }\n\n /**\n */\n getSortingLabels(): { [string]: string } {\n const sortingLabels = {};\n\n if (this.contributions.results) {\n const { results } = this.contributions;\n Object.keys(results).forEach((key) => {\n results[key].attributes.forEach((attribute) => {\n const attributeKey = Object.keys(attribute)[0];\n sortingLabels[attributeKey] = attribute[attributeKey].label;\n });\n });\n }\n\n return sortingLabels;\n }\n\n /**\n * Retrieve all actions by type\n */\n getActionsByType(actionType: string): ActionCollection {\n return this.actionCollection.getActionsByType(actionType);\n }\n}\n"],"file":"ListModel.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/models/list/ListModel.js"],"names":["ListModel","layouthint","has","SHOW_ONE_RESULT_AS_DETAIL","listItemCollection","length","listItem","listDetailLink","selflink","targetModel","ListDetailModel","models","detail","childModel","type","contributions","label","data","text","message","Array","isArray","texts","listitemCollection","ListItemCollection","_embedded","getData","ConfigurationException","key","collection","results","result","createListItem","resultItem","listitemData","listitemContributions","dynamicschema","listitemModelInput","ModularUIResponse","ListItemModel","_listItemCollection","createListItemCollection","_detail","listitemHref","selfhref","listitem","equals","setSelfHref","_grouping","setGrouping","GroupingModel","grouping","contexts","hasGroups","hasItems","HIDE_WHEN_EMPTY","hasResults","actionCollection","isEmpty","filterCollection","hasActiveFilters","id","decodedId","decodeURIComponent","toString","href","_paging","setPaging","PagingModel","paging","_sorting","setSorting","SortingModel","getSortingLabels","sorting","_filterCollection","setFilters","FilterCollection","listkey","filter","_actionCollection","setActionCollection","ActionCollection","actions","selfLink","links","getLinkByKey","ListHref","_selfhref","_headers","setHeaders","tempHeaders","forEach","attributes","attribute","listHeader","ListHeaderModel","exists","some","tempHeader","CASEVIEW_LINK","push","sortingLabels","attributeKey","actionType","getActionsByType","resourcetype","ResourceModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AASA;AACA;AACA;IACqBA,S;;;;;;;;;;;;;;;;;0FACS,I;;;;;;;;;;;;;;;AAU5B;AACF;AACE,mBAAmB;AACjB,aAAO,MAAP;AACD;AAED;AACF;;;;;AAoBE;AACF;AACE,yCAA8C;AAC5C,UACE,KAAKC,UAAL,CAAgBC,GAAhB,CAAoBC,sCAApB,KACA,KAAKC,kBAAL,CAAwBC,MAAxB,KAAmC,CAFrC,EAGE;AAAA;;AACA,eAAO,mCAAKD,kBAAL,kBAA4B,UAACE,QAAD,EAAc;AAC/C,cAAMC,cAAc,GAAGD,QAAQ,CAACE,QAAhC;AACAD,UAAAA,cAAc,CAACE,WAAf,GAA6BC,wBAA7B;AACA,iBAAOH,cAAP;AACD,SAJM,CAAP;AAKD;;AAED,aAAO,EAAP;AACD;AAED;AACF;;;;WACE,wBAAeI,MAAf,EAA8C;AAC5C,WAAKC,MAAL,GAAc,mBAAAD,MAAM,MAAN,CAAAA,MAAM,EAAM,UAACE,UAAD;AAAA,eAAgBA,UAAU,CAACC,IAAX,KAAoB,YAApC;AAAA,OAAN,CAApB;AACD;AAED;AACF;AACA;;;;SACE,eAAoB;AAClB,aAAO,KAAKC,aAAL,CAAmBC,KAA1B;AACD;AAED;AACF;AACA;;;;SACE,eAAwB;AACtB,UAAI,KAAKC,IAAL,CAAUC,IAAd,EAAoB;AAAA;;AAClB,wCAAO,KAAKD,IAAL,CAAU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EAGE,2BAHF,EAIE,aAJF,EAKE,mBALF,EAME,WANF,EAOE,kBAPF,EAQE,eARF,EASE,iBATF,mBAUWzF,IAAI,CAACF,aAAL,CAAmB2F,YAV9B,CAHF,CADF;AAgBD;;;EApCoCC,uB","sourcesContent":["// @flow\nimport { ConfigurationException } from \"../../exceptions\";\n\nimport ModularUIResponse from \"../../modularui/ModularUIResponse\";\n\nimport ListItemCollection from \"../list/ListItemCollection\";\nimport ListDetailModel from \"../list/ListDetailModel\";\nimport ActionCollection from \"../actions/ActionCollection\";\nimport FilterCollection from \"../filters/FilterCollection\";\nimport GroupingModel from \"../grouping/GroupingModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\nimport ListHref from \"../href/ListHref\";\nimport ListItemModel from \"../list/ListItemModel\";\nimport PagingModel from \"../paging/PagingModel\";\nimport ResourceModel from \"../base/ResourceModel\";\nimport SortingModel from \"../sorting/SortingModel\";\nimport {\n CASEVIEW_LINK,\n HIDE_WHEN_EMPTY,\n SHOW_ONE_RESULT_AS_DETAIL,\n} from \"../../constants/LayoutHints\";\n\nimport type { ModularUIModel } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Defines a list object\n */\nexport default class ListModel extends ResourceModel {\n _detail: ?ListDetailModel = null;\n _headers: Array<ListHeaderModel>;\n _paging: PagingModel;\n _filterCollection: FilterCollection;\n _sorting: SortingModel;\n _actionCollection: ActionCollection;\n _listItemCollection: ListItemCollection;\n _grouping: GroupingModel;\n _selfhref: ListHref;\n\n /**\n */\n get type(): string {\n return \"List\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n (data.contributions.resourcetype.endsWith(\"List\") ||\n data.contributions.resourcetype.endsWith(\"ListPanel\") ||\n [\n \"DatastoreRelatedDatastorePanel\",\n \"list-related-cases\",\n \"CaseRelatedDataStorePanel\",\n \"RecordPanel\",\n \"EventHistoryPanel\",\n \"NotePanel\",\n \"AppointmentPanel\",\n \"DocumentPanel\",\n \"AssignmentPanel\",\n ].includes(data.contributions.resourcetype))\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n if (\n this.layouthint.has(SHOW_ONE_RESULT_AS_DETAIL) &&\n this.listItemCollection.length === 1\n ) {\n return this.listItemCollection.map((listItem) => {\n const listDetailLink = listItem.selflink;\n listDetailLink.targetModel = ListDetailModel;\n return listDetailLink;\n });\n }\n\n return [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n this.detail = models.find((childModel) => childModel.type === \"ListDetail\");\n }\n\n /**\n * Getting the label of the list\n */\n get label(): string {\n return this.contributions.label;\n }\n\n /**\n * Getting the introduction text\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 * Create a listitem collection from the data and contributions of a list\n */\n createListItemCollection(): ListItemCollection {\n const listitemCollection = new ListItemCollection();\n\n const _embedded = this.getData(\"_embedded\");\n if (_embedded !== null) {\n if (Array.isArray(_embedded)) {\n throw new ConfigurationException(\n `One record panel with multiple tables is not supported, place all types in one panel for the panel with key ${this.key}`\n );\n }\n\n listitemCollection.collection = _embedded.results.map((result) =>\n this.createListItem(result)\n );\n }\n\n return listitemCollection;\n }\n\n /**\n * Create a ListItem\n */\n createListItem(resultItem: Object): ListItemModel {\n const [key] = Object.keys(resultItem);\n const listitemData = resultItem[key];\n const listitemContributions = this.contributions.results[key];\n\n if (this.data.dynamicschema) {\n listitemData.dynamicschema = this.data.dynamicschema;\n }\n\n const listitemModelInput = new ModularUIResponse();\n listitemModelInput.key = key;\n listitemModelInput.data = listitemData;\n listitemModelInput.contributions = listitemContributions;\n\n return new ListItemModel(listitemModelInput);\n }\n\n /**\n * Getting the results\n */\n get listItemCollection(): ListItemCollection {\n if (!this._listItemCollection) {\n this._listItemCollection = this.createListItemCollection();\n }\n\n return this._listItemCollection;\n }\n\n /**\n * Set results\n */\n set listItemCollection(listItemCollection: ListItemCollection) {\n this._listItemCollection = listItemCollection;\n }\n\n /**\n * Getting the detail\n */\n get detail(): ?ListDetailModel {\n return this._detail;\n }\n\n /**\n * Add detail model to the {ListModel}\n */\n set detail(detail: ?ModularUIModel) {\n if (detail instanceof ListDetailModel) {\n const listitemHref = detail.selfhref;\n\n const listitem = this.listItemCollection.find((listItem) =>\n listItem.selfhref.equals(listitemHref)\n );\n\n if (listitem) {\n detail.listitem = listitem;\n }\n\n this._detail = detail;\n }\n\n this.setSelfHref();\n }\n\n /**\n * Retrieve grouping information\n */\n get grouping(): GroupingModel {\n if (!this._grouping) {\n this._grouping = this.setGrouping();\n }\n\n return this._grouping;\n }\n\n /**\n */\n setGrouping(): GroupingModel {\n return new GroupingModel(\n { ...this.data.grouping, dynamicschema: this.data.dynamicschema },\n this.contributions.contexts\n );\n }\n\n /**\n */\n hasGrouping(): boolean {\n return this.grouping.hasGroups();\n }\n\n /**\n * Check if list has results\n */\n hasResults(): boolean {\n return this.listItemCollection.hasItems;\n }\n\n /**\n */\n get shouldHide(): boolean {\n return (\n this.layouthint.has(HIDE_WHEN_EMPTY) &&\n !this.hasResults() &&\n this.actionCollection.isEmpty &&\n !this.filterCollection.hasActiveFilters()\n );\n }\n\n /**\n * Get list item by ID\n */\n getListItemById(id: string | number): ListItemModel | null {\n const decodedId = decodeURIComponent(id.toString());\n return this.listItemCollection.find(\n (result) => result.id.toString() === decodedId\n );\n }\n\n /**\n * Get list item by Href\n */\n getListItemByHref(href: ListHref): ListItemModel | null {\n return this.listItemCollection.find((result) =>\n result.selfhref.equals(href)\n );\n }\n\n /**\n * Getting paging information\n */\n get paging(): PagingModel {\n if (!this._paging) {\n this._paging = this.setPaging();\n }\n return this._paging;\n }\n\n /**\n */\n setPaging(): PagingModel {\n return new PagingModel(this.data.paging, this.contributions.paging);\n }\n\n /**\n * Getting sorting information\n */\n get sorting(): SortingModel {\n if (!this._sorting) {\n this._sorting = this.setSorting();\n }\n\n return this._sorting;\n }\n\n /**\n */\n setSorting(): SortingModel {\n return new SortingModel(\n this.contributions,\n this.getSortingLabels(),\n this.grouping,\n this.data.sorting\n );\n }\n\n /**\n * Getting the filters\n */\n get filterCollection(): FilterCollection {\n if (!this._filterCollection) {\n this._filterCollection = this.setFilters();\n }\n\n return this._filterCollection;\n }\n\n /**\n * Set filterCollection\n */\n set filterCollection(filterCollection: FilterCollection) {\n this._filterCollection = filterCollection;\n }\n\n /**\n */\n setFilters(): FilterCollection {\n return new FilterCollection(this.data.filter, {\n listkey: this.key,\n filter: this.contributions.filter,\n contexts: this.contributions.contexts,\n dynamicschema: this.data.dynamicschema,\n });\n }\n\n /**\n * Indicates if list results are filtered\n */\n isFiltered(): boolean {\n return this.filterCollection.hasActiveFilters();\n }\n\n /**\n * Getting actions\n */\n get actionCollection(): ActionCollection {\n if (!this._actionCollection) {\n this._actionCollection = this.setActionCollection();\n }\n return this._actionCollection;\n }\n\n /**\n */\n setActionCollection(): ActionCollection {\n return new ActionCollection(this.data.actions, this.contributions.actions);\n }\n\n /**\n * Contains this model list data\n */\n hasList(): boolean {\n return this.key != null;\n }\n\n /**\n * Sets self href from links collection\n */\n setSelfHref(): ListHref {\n const selfLink = this.links ? this.links.getLinkByKey(\"self\") : null;\n\n if (selfLink !== null) {\n return new ListHref(selfLink.href, this);\n }\n\n return new ListHref();\n }\n\n /**\n * Getting the self link of this list\n */\n get selfhref(): ListHref {\n if (!this._selfhref) {\n this._selfhref = this.setSelfHref();\n }\n return this._selfhref;\n }\n\n /**\n * Getting the headers of this list\n */\n get headers(): Array<ListHeaderModel> {\n if (!this._headers) {\n this._headers = this.setHeaders();\n }\n\n return this._headers;\n }\n\n /**\n * Set initial headers of list\n */\n setHeaders(): Array<ListHeaderModel> {\n const tempHeaders = [];\n\n if (this.contributions.results) {\n const { results } = this.contributions;\n\n Object.keys(results).forEach((key) => {\n results[key].attributes.forEach((attribute) => {\n const listHeader = new ListHeaderModel(attribute, this.sorting);\n\n const exists = tempHeaders.some((tempHeader) =>\n tempHeader.equals(listHeader)\n );\n\n if (!exists && !listHeader.layouthint.has(CASEVIEW_LINK)) {\n tempHeaders.push(listHeader);\n }\n });\n });\n }\n\n return tempHeaders;\n }\n\n /**\n */\n getSortingLabels(): { [string]: string } {\n const sortingLabels = {};\n\n if (this.contributions.results) {\n const { results } = this.contributions;\n Object.keys(results).forEach((key) => {\n results[key].attributes.forEach((attribute) => {\n const attributeKey = Object.keys(attribute)[0];\n sortingLabels[attributeKey] = attribute[attributeKey].label;\n });\n });\n }\n\n return sortingLabels;\n }\n\n /**\n * Retrieve all actions by type\n */\n getActionsByType(actionType: string): ActionCollection {\n return this.actionCollection.getActionsByType(actionType);\n }\n}\n"],"file":"ListModel.js"}
|