@beinformed/ui 1.43.7 → 1.44.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/esm/models/attributes/AttributeModel.js +0 -7
  3. package/esm/models/attributes/AttributeModel.js.map +1 -1
  4. package/esm/models/attributes/ChoiceAttributeModel.js +28 -24
  5. package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
  6. package/esm/models/attributes/ChoiceAttributeOptionCollection.js +2 -1
  7. package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  8. package/esm/models/attributes/ChoiceAttributeOptionModel.js +8 -0
  9. package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  10. package/esm/models/detail/DetailModel.js +2 -6
  11. package/esm/models/detail/DetailModel.js.map +1 -1
  12. package/esm/models/user/UserModel.js +1 -1
  13. package/esm/models/user/UserModel.js.map +1 -1
  14. package/lib/models/attributes/AttributeModel.js +0 -7
  15. package/lib/models/attributes/AttributeModel.js.flow +0 -7
  16. package/lib/models/attributes/AttributeModel.js.map +1 -1
  17. package/lib/models/attributes/ChoiceAttributeModel.js +28 -24
  18. package/lib/models/attributes/ChoiceAttributeModel.js.flow +12 -10
  19. package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
  20. package/lib/models/attributes/ChoiceAttributeOptionCollection.js +2 -1
  21. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.flow +1 -0
  22. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  23. package/lib/models/attributes/ChoiceAttributeOptionModel.js +8 -0
  24. package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +9 -0
  25. package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
  26. package/lib/models/attributes/__tests__/ChoiceAttributeModel.spec.js.flow +27 -0
  27. package/lib/models/detail/DetailModel.js +2 -6
  28. package/lib/models/detail/DetailModel.js.flow +8 -16
  29. package/lib/models/detail/DetailModel.js.map +1 -1
  30. package/lib/models/user/UserModel.js +1 -1
  31. package/lib/models/user/UserModel.js.flow +2 -2
  32. package/lib/models/user/UserModel.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/models/attributes/AttributeModel.js +0 -7
  35. package/src/models/attributes/ChoiceAttributeModel.js +12 -10
  36. package/src/models/attributes/ChoiceAttributeOptionCollection.js +1 -0
  37. package/src/models/attributes/ChoiceAttributeOptionModel.js +9 -0
  38. package/src/models/attributes/__tests__/ChoiceAttributeModel.spec.js +27 -0
  39. package/src/models/detail/DetailModel.js +8 -16
  40. package/src/models/user/UserModel.js +2 -2
  41. package/types/constants/Constants.d.ts +4 -0
  42. package/types/constants/LayoutHintConfig.d.ts +30 -0
  43. package/types/constants/LayoutHints.d.ts +5 -0
  44. package/types/models/attributes/ChoiceAttributeModel.d.ts +6 -0
  45. package/types/models/attributes/ChoiceAttributeOptionModel.d.ts +8 -0
  46. package/types/models/attributes/layouthint-rules/LayoutHintRuleCollection.d.ts +1 -1
  47. package/types/models/base/ResourceModel.d.ts +4 -0
  48. package/types/models/content/ContentLinkModel.d.ts +3 -0
  49. package/types/models/detail/DetailModel.d.ts +4 -0
  50. package/types/models/user/UserModel.d.ts +4 -0
  51. package/types/models/user/UserServicesModel.d.ts +3 -0
  52. package/types/utils/helpers/createHref.d.ts +7 -0
  53. package/types/utils/helpers/index.d.ts +1 -0
@@ -196,30 +196,22 @@ export default class DetailModel extends ResourceModel {
196
196
  * Getting the attribute that has as layout hint 'avatar-for-title'
197
197
  */
198
198
  get avatarForTitleAttribute(): ?AttributeType {
199
- const avatarAttributes = this._attributeCollection.all.filter((attribute) =>
200
- attribute.layouthint.hasExact(AVATAR),
199
+ return this._attributeCollection.find(
200
+ (attribute) =>
201
+ attribute.layouthint.hasExact(AVATAR_IN_TITLE) &&
202
+ attribute.layouthint.hasExact(AVATAR),
201
203
  );
202
-
203
- const avatarForTitleAttribute = avatarAttributes.find((attribute) =>
204
- attribute.layouthint.hasExact(AVATAR_IN_TITLE),
205
- );
206
-
207
- return avatarForTitleAttribute || null;
208
204
  }
209
205
 
210
206
  /**
211
207
  * Getting the attribute that has as layout hint 'title'
212
208
  */
213
209
  get titleAttribute(): ?AttributeType {
214
- const nonAvatarAttributes = this._attributeCollection.all.filter(
215
- (attribute) => !attribute.layouthint.hasExact(AVATAR),
210
+ return this._attributeCollection.find(
211
+ (attribute) =>
212
+ attribute.layouthint.has(TITLE) &&
213
+ !attribute.layouthint.hasExact(AVATAR),
216
214
  );
217
-
218
- const titleAttribute = nonAvatarAttributes.find((attribute) =>
219
- attribute.layouthint.has(TITLE),
220
- );
221
-
222
- return titleAttribute || null;
223
215
  }
224
216
 
225
217
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"DetailModel.js","names":["_objects","require","_ActionCollection","_interopRequireDefault","_AttributeCollection","_ResourceModel","_LayoutHints","DetailModel","ResourceModel","constructor","modularuiResponse","_defineProperty2","default","createAttributeCollection","createMetadataCollection","createActionCollection","type","modelName","isApplicableModel","data","_context","resourceType","contributions","resourcetype","_endsWith","call","_includes","getInitialChildModelLinks","_attributeCollection","setChildModels","models","id","getData","key","label","getContribution","_context2","attributeContributions","attributes","_filter","contribution","_keys","has","attributeCollection","AttributeCollection","collection","_context3","all","attribute","hasTitle","layouthint","hasExact","TITLE","hasAvatar","AVATAR","hasAvatarForTitle","AVATAR_IN_TITLE","isHidden","getAttributeByKey","_context4","metadataContributions","metadata","_map","metadataKey","metadataCollection","_metadataCollection","_actionCollection","ActionCollection","actions","actionCollection","isCase","avatarForTitleAttribute","_context5","avatarAttributes","_find","titleAttribute","_context6","nonAvatarAttributes","update","model","clonedModel","clone","equals","toString","exports"],"sources":["../../../src/models/detail/DetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport { AVATAR, AVATAR_IN_TITLE, TITLE } from \"../../constants/LayoutHints\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type { ModularUIModel, AttributeType } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Base class for details<br/>\n * For instance the details of case 1<br/>\n * For instance the details of record 12<br/>\n */\nexport default class DetailModel extends ResourceModel {\n _attributeCollection: AttributeCollection;\n _metadataCollection: AttributeCollection;\n _actionCollection: ActionCollection;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this.createAttributeCollection();\n this.createMetadataCollection();\n this.createActionCollection();\n }\n\n /**\n */\n get type(): string {\n return \"Detail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"DetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourceType = data.contributions?.resourcetype;\n return (\n resourceType &&\n (resourceType.endsWith(\"DetailPanel\") ||\n [\"Detail\", \"CasePropertiesPanel\", \"CasePropertiesPanelDetail\"].includes(\n resourceType,\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 * Getting the unique identifier of the details\n */\n get id(): string {\n return this.getData(\"_id\", this.key);\n }\n\n /**\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Attribute collection\n */\n createAttributeCollection() {\n const attributeContributions = this.contributions.attributes\n ? this.contributions.attributes.filter((contribution) => {\n const [key] = Object.keys(contribution);\n return has(this.data, key);\n })\n : [];\n\n this.attributeCollection = new AttributeCollection(\n this.data,\n attributeContributions,\n true,\n );\n }\n\n /**\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(collection: AttributeCollection) {\n this._attributeCollection = collection;\n }\n\n /**\n * Retrieve list of visible attributes\n */\n get attributes(): Array<AttributeType> {\n return this.attributeCollection.all.filter((attribute) => {\n const hasTitle = attribute.layouthint.hasExact(TITLE);\n const hasAvatar = attribute.layouthint.hasExact(AVATAR);\n const hasAvatarForTitle = attribute.layouthint.hasExact(AVATAR_IN_TITLE);\n return (\n !attribute.isHidden &&\n (!hasTitle || (hasTitle && hasAvatar)) &&\n (!hasAvatarForTitle || (hasAvatarForTitle && !hasAvatar))\n );\n });\n }\n\n /**\n * Retrieve an attribute by it's key\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this._attributeCollection.getAttributeByKey(key);\n }\n\n /**\n * Metadata collection\n */\n createMetadataCollection() {\n const metadataContributions = this.contributions.metadata\n ? Object.keys(this.contributions.metadata).map((metadataKey) => ({\n [metadataKey]: this.contributions.metadata[metadataKey],\n }))\n : [];\n\n this.metadataCollection = new AttributeCollection(\n this.data,\n metadataContributions,\n true,\n );\n }\n\n /**\n */\n get metadataCollection(): AttributeCollection {\n return this._metadataCollection;\n }\n\n /**\n */\n set metadataCollection(collection: AttributeCollection) {\n this._metadataCollection = collection;\n }\n\n /**\n * Action collection\n */\n createActionCollection() {\n this._actionCollection = new ActionCollection(\n this.data.actions,\n this.contributions.actions,\n );\n }\n\n /**\n */\n get actionCollection(): ActionCollection {\n return this._actionCollection;\n }\n\n /**\n */\n set actionCollection(actionCollection: ActionCollection) {\n this._actionCollection = actionCollection;\n }\n\n /**\n * Determines if this is a case\n */\n get isCase(): boolean {\n return this.contributions.resourcetype === \"CaseView\";\n }\n\n /**\n * Getting the attribute that has as layout hint 'avatar-for-title'\n */\n get avatarForTitleAttribute(): ?AttributeType {\n const avatarAttributes = this._attributeCollection.all.filter((attribute) =>\n attribute.layouthint.hasExact(AVATAR),\n );\n\n const avatarForTitleAttribute = avatarAttributes.find((attribute) =>\n attribute.layouthint.hasExact(AVATAR_IN_TITLE),\n );\n\n return avatarForTitleAttribute || null;\n }\n\n /**\n * Getting the attribute that has as layout hint 'title'\n */\n get titleAttribute(): ?AttributeType {\n const nonAvatarAttributes = this._attributeCollection.all.filter(\n (attribute) => !attribute.layouthint.hasExact(AVATAR),\n );\n\n const titleAttribute = nonAvatarAttributes.find((attribute) =>\n attribute.layouthint.has(TITLE),\n );\n\n return titleAttribute || null;\n }\n\n /**\n * Update current detail with a new detail model and return a cloned version of the model\n */\n update(model: ModularUIModel): DetailModel {\n if (model instanceof DetailModel) {\n const clonedModel = this.clone();\n\n clonedModel.attributeCollection = model._attributeCollection;\n clonedModel.metadataCollection = model._metadataCollection;\n clonedModel.actionCollection = model._actionCollection;\n\n return clonedModel;\n }\n\n return this;\n }\n\n /**\n */\n equals(model: DetailModel): boolean {\n return this.id.toString() === model.id.toString();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,iBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,oBAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,cAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,YAAA,GAAAL,OAAA;AAMA;AACA;AACA;AACA;AACA;AACe,MAAMM,WAAW,SAASC,sBAAa,CAAC;EAKrD;AACF;EACEC,WAAWA,CAACC,iBAAoC,EAAE;IAChD,KAAK,CAACA,iBAAiB,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzB,IAAI,CAACC,yBAAyB,CAAC,CAAC;IAChC,IAAI,CAACC,wBAAwB,CAAC,CAAC;IAC/B,IAAI,CAACC,sBAAsB,CAAC,CAAC;EAC/B;;EAEA;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,QAAQ;EACjB;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,aAAa;EACtB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IAAA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,KAAKJ,KAAK,CAAChD,EAAE,CAACoD,QAAQ,CAAC,CAAC;EACnD;AACF;AAACC,OAAA,CAAAxE,OAAA,GAAAL,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"DetailModel.js","names":["_objects","require","_ActionCollection","_interopRequireDefault","_AttributeCollection","_ResourceModel","_LayoutHints","DetailModel","ResourceModel","constructor","modularuiResponse","_defineProperty2","default","createAttributeCollection","createMetadataCollection","createActionCollection","type","modelName","isApplicableModel","data","_context","resourceType","contributions","resourcetype","_endsWith","call","_includes","getInitialChildModelLinks","_attributeCollection","setChildModels","models","id","getData","key","label","getContribution","_context2","attributeContributions","attributes","_filter","contribution","_keys","has","attributeCollection","AttributeCollection","collection","_context3","all","attribute","hasTitle","layouthint","hasExact","TITLE","hasAvatar","AVATAR","hasAvatarForTitle","AVATAR_IN_TITLE","isHidden","getAttributeByKey","_context4","metadataContributions","metadata","_map","metadataKey","metadataCollection","_metadataCollection","_actionCollection","ActionCollection","actions","actionCollection","isCase","avatarForTitleAttribute","_context5","_find","titleAttribute","_context6","update","model","clonedModel","clone","equals","toString","exports"],"sources":["../../../src/models/detail/DetailModel.js"],"sourcesContent":["// @flow\nimport { has } from \"../../utils/helpers/objects\";\n\nimport ActionCollection from \"../actions/ActionCollection\";\nimport AttributeCollection from \"../attributes/AttributeCollection\";\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport { AVATAR, AVATAR_IN_TITLE, TITLE } from \"../../constants/LayoutHints\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type { ModularUIModel, AttributeType } from \"../types\";\nimport type LinkModel from \"../links/LinkModel\";\n\n/**\n * Base class for details<br/>\n * For instance the details of case 1<br/>\n * For instance the details of record 12<br/>\n */\nexport default class DetailModel extends ResourceModel {\n _attributeCollection: AttributeCollection;\n _metadataCollection: AttributeCollection;\n _actionCollection: ActionCollection;\n\n /**\n */\n constructor(modularuiResponse: ModularUIResponse) {\n super(modularuiResponse);\n\n this.createAttributeCollection();\n this.createMetadataCollection();\n this.createActionCollection();\n }\n\n /**\n */\n get type(): string {\n return \"Detail\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"DetailModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n const resourceType = data.contributions?.resourcetype;\n return (\n resourceType &&\n (resourceType.endsWith(\"DetailPanel\") ||\n [\"Detail\", \"CasePropertiesPanel\", \"CasePropertiesPanelDetail\"].includes(\n resourceType,\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 * Getting the unique identifier of the details\n */\n get id(): string {\n return this.getData(\"_id\", this.key);\n }\n\n /**\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Attribute collection\n */\n createAttributeCollection() {\n const attributeContributions = this.contributions.attributes\n ? this.contributions.attributes.filter((contribution) => {\n const [key] = Object.keys(contribution);\n return has(this.data, key);\n })\n : [];\n\n this.attributeCollection = new AttributeCollection(\n this.data,\n attributeContributions,\n true,\n );\n }\n\n /**\n */\n get attributeCollection(): AttributeCollection {\n return this._attributeCollection;\n }\n\n /**\n */\n set attributeCollection(collection: AttributeCollection) {\n this._attributeCollection = collection;\n }\n\n /**\n * Retrieve list of visible attributes\n */\n get attributes(): Array<AttributeType> {\n return this.attributeCollection.all.filter((attribute) => {\n const hasTitle = attribute.layouthint.hasExact(TITLE);\n const hasAvatar = attribute.layouthint.hasExact(AVATAR);\n const hasAvatarForTitle = attribute.layouthint.hasExact(AVATAR_IN_TITLE);\n return (\n !attribute.isHidden &&\n (!hasTitle || (hasTitle && hasAvatar)) &&\n (!hasAvatarForTitle || (hasAvatarForTitle && !hasAvatar))\n );\n });\n }\n\n /**\n * Retrieve an attribute by it's key\n */\n getAttributeByKey(key: string): AttributeType | null {\n return this._attributeCollection.getAttributeByKey(key);\n }\n\n /**\n * Metadata collection\n */\n createMetadataCollection() {\n const metadataContributions = this.contributions.metadata\n ? Object.keys(this.contributions.metadata).map((metadataKey) => ({\n [metadataKey]: this.contributions.metadata[metadataKey],\n }))\n : [];\n\n this.metadataCollection = new AttributeCollection(\n this.data,\n metadataContributions,\n true,\n );\n }\n\n /**\n */\n get metadataCollection(): AttributeCollection {\n return this._metadataCollection;\n }\n\n /**\n */\n set metadataCollection(collection: AttributeCollection) {\n this._metadataCollection = collection;\n }\n\n /**\n * Action collection\n */\n createActionCollection() {\n this._actionCollection = new ActionCollection(\n this.data.actions,\n this.contributions.actions,\n );\n }\n\n /**\n */\n get actionCollection(): ActionCollection {\n return this._actionCollection;\n }\n\n /**\n */\n set actionCollection(actionCollection: ActionCollection) {\n this._actionCollection = actionCollection;\n }\n\n /**\n * Determines if this is a case\n */\n get isCase(): boolean {\n return this.contributions.resourcetype === \"CaseView\";\n }\n\n /**\n * Getting the attribute that has as layout hint 'avatar-for-title'\n */\n get avatarForTitleAttribute(): ?AttributeType {\n return this._attributeCollection.find(\n (attribute) =>\n attribute.layouthint.hasExact(AVATAR_IN_TITLE) &&\n attribute.layouthint.hasExact(AVATAR),\n );\n }\n\n /**\n * Getting the attribute that has as layout hint 'title'\n */\n get titleAttribute(): ?AttributeType {\n return this._attributeCollection.find(\n (attribute) =>\n attribute.layouthint.has(TITLE) &&\n !attribute.layouthint.hasExact(AVATAR),\n );\n }\n\n /**\n * Update current detail with a new detail model and return a cloned version of the model\n */\n update(model: ModularUIModel): DetailModel {\n if (model instanceof DetailModel) {\n const clonedModel = this.clone();\n\n clonedModel.attributeCollection = model._attributeCollection;\n clonedModel.metadataCollection = model._metadataCollection;\n clonedModel.actionCollection = model._actionCollection;\n\n return clonedModel;\n }\n\n return this;\n }\n\n /**\n */\n equals(model: DetailModel): boolean {\n return this.id.toString() === model.id.toString();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,iB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CAACC,KAAK,CAAC,CAAC;MAEhCD,WAAW,CAACnC,mBAAmB,GAAGkC,KAAK,CAACjD,oBAAoB;MAC5DkD,WAAW,CAACd,kBAAkB,GAAGa,KAAK,CAACZ,mBAAmB;MAC1Da,WAAW,CAACT,gBAAgB,GAAGQ,KAAK,CAACX,iBAAiB;MAEtD,OAAOY,WAAW;IACpB;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;EACEE,MAAMA,CAACH,KAAkB,EAAW;IAClC,OAAO,IAAI,CAAC9C,EAAE,CAACkD,QAAQ,CAAC,CAAC,KAAKJ,KAAK,CAAC9C,EAAE,CAACkD,QAAQ,CAAC,CAAC;EACnD;AACF;AAACC,OAAA,CAAAtE,OAAA,GAAAL,WAAA","ignoreList":[]}
@@ -29,7 +29,7 @@ class UserModel extends _ResourceModel.default {
29
29
  }
30
30
 
31
31
  /**
32
- * Retrieve username of user
32
+ * Retrieve avatar of user
33
33
  */
34
34
  get avatar() {
35
35
  return this.data.Avatar;
@@ -29,9 +29,9 @@ export default class UserModel extends ResourceModel {
29
29
  }
30
30
 
31
31
  /**
32
- * Retrieve username of user
32
+ * Retrieve avatar of user
33
33
  */
34
- get avatar(): string {
34
+ get avatar(): string | null {
35
35
  return this.data.Avatar;
36
36
  }
37
37
 
@@ -1 +1 @@
1
- {"version":3,"file":"UserModel.js","names":["_ResourceModel","_interopRequireDefault","require","UserModel","ResourceModel","type","modelName","isApplicableModel","data","contributions","resourcetype","avatar","Avatar","username","Username","fullname","Fullname","label","exports","default"],"sources":["../../../src/models/user/UserModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * User model\n */\nexport default class UserModel extends ResourceModel {\n /**\n */\n get type(): string {\n return \"User\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"UserModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"userdata\"\n );\n }\n\n /**\n * Retrieve username of user\n */\n get avatar(): string {\n return this.data.Avatar;\n }\n\n /**\n * Retrieve username of user\n */\n get username(): string {\n return this.data.Username || \"Guest\";\n }\n\n /**\n * retrieve the fullname of the user\n */\n get fullname(): string {\n return this.data.Fullname || \"Guest\";\n }\n\n /**\n */\n get label(): string {\n return this.contributions.label;\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACe,MAAMC,SAAS,SAASC,sBAAa,CAAC;EACnD;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,MAAM;EACf;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,WAAW;EACpB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,YAAY,KAAK,UAAU;EAElD;;EAEA;AACF;AACA;EACE,IAAIC,MAAMA,CAAA,EAAW;IACnB,OAAO,IAAI,CAACH,IAAI,CAACI,MAAM;EACzB;;EAEA;AACF;AACA;EACE,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACL,IAAI,CAACM,QAAQ,IAAI,OAAO;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACP,IAAI,CAACQ,QAAQ,IAAI,OAAO;EACtC;;EAEA;AACF;EACE,IAAIC,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACR,aAAa,CAACQ,KAAK;EACjC;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAhB,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"UserModel.js","names":["_ResourceModel","_interopRequireDefault","require","UserModel","ResourceModel","type","modelName","isApplicableModel","data","contributions","resourcetype","avatar","Avatar","username","Username","fullname","Fullname","label","exports","default"],"sources":["../../../src/models/user/UserModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\n\nimport type { ModularUIResponse } from \"../../modularui\";\n\n/**\n * User model\n */\nexport default class UserModel extends ResourceModel {\n /**\n */\n get type(): string {\n return \"User\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"UserModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"userdata\"\n );\n }\n\n /**\n * Retrieve avatar of user\n */\n get avatar(): string | null {\n return this.data.Avatar;\n }\n\n /**\n * Retrieve username of user\n */\n get username(): string {\n return this.data.Username || \"Guest\";\n }\n\n /**\n * retrieve the fullname of the user\n */\n get fullname(): string {\n return this.data.Fullname || \"Guest\";\n }\n\n /**\n */\n get label(): string {\n return this.contributions.label;\n }\n}\n"],"mappings":";;;;;;;AACA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACe,MAAMC,SAAS,SAASC,sBAAa,CAAC;EACnD;AACF;EACE,IAAIC,IAAIA,CAAA,EAAW;IACjB,OAAO,MAAM;EACf;;EAEA;AACF;EACE,WAAWC,SAASA,CAAA,EAAW;IAC7B,OAAO,WAAW;EACpB;;EAEA;AACF;EACE,OAAOC,iBAAiBA,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,YAAY,KAAK,UAAU;EAElD;;EAEA;AACF;AACA;EACE,IAAIC,MAAMA,CAAA,EAAkB;IAC1B,OAAO,IAAI,CAACH,IAAI,CAACI,MAAM;EACzB;;EAEA;AACF;AACA;EACE,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACL,IAAI,CAACM,QAAQ,IAAI,OAAO;EACtC;;EAEA;AACF;AACA;EACE,IAAIC,QAAQA,CAAA,EAAW;IACrB,OAAO,IAAI,CAACP,IAAI,CAACQ,QAAQ,IAAI,OAAO;EACtC;;EAEA;AACF;EACE,IAAIC,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACR,aAAa,CAACQ,KAAK;EACjC;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAhB,SAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.43.7",
3
+ "version": "1.44.1",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -554,13 +554,6 @@ export default class AttributeModel
554
554
  this._isResult = isResult;
555
555
  }
556
556
 
557
- /**
558
- *
559
- */
560
- get isAvatar(): boolean {
561
- return this.contributions?.optionType === "user" ?? false;
562
- }
563
-
564
557
  /**
565
558
  * Getting the display and input format of a attribute
566
559
  */
@@ -71,6 +71,18 @@ export default class ChoiceAttributeModel extends AttributeModel {
71
71
  return "choice";
72
72
  }
73
73
 
74
+ /**
75
+ */
76
+ get optionType(): string {
77
+ return this.contributions?.optionType ?? "generic";
78
+ }
79
+
80
+ /**
81
+ */
82
+ get isUser(): boolean {
83
+ return this.optionType === "user";
84
+ }
85
+
74
86
  /**
75
87
  */
76
88
  getInitialChildModelLinks(): Array<LinkModel> {
@@ -122,16 +134,6 @@ export default class ChoiceAttributeModel extends AttributeModel {
122
134
  return this.contributions.lookupList?.label ?? "";
123
135
  }
124
136
 
125
- /**
126
- *
127
- */
128
- get avatarLink(): LinkModel | null {
129
- return (
130
- this.options.collection.find((option) => option.code === this.value)
131
- ?.avatarLink || null
132
- );
133
- }
134
-
135
137
  /**
136
138
  * Retrieve reference date of attribute which can be used as entryDate for content
137
139
  */
@@ -114,6 +114,7 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
114
114
  {
115
115
  ...optionContributions,
116
116
  count: this.getOptionCount(optionCode, data.options),
117
+ optionType: contributions.optionType ?? "generic",
117
118
  },
118
119
  referenceDate,
119
120
  );
@@ -32,6 +32,7 @@ class ChoiceAttributeOptionModel
32
32
  _links: LinkCollection;
33
33
  _attributeCollection: AttributeCollection;
34
34
  _content: AttributeContent;
35
+ _isUser: boolean = false;
35
36
 
36
37
  /**
37
38
  */
@@ -56,6 +57,8 @@ class ChoiceAttributeOptionModel
56
57
  this._links = new LinkCollection(this.contributions._links);
57
58
 
58
59
  this._content = new AttributeContent(option.content);
60
+
61
+ this._isUser = option.optionType === "user";
59
62
  }
60
63
 
61
64
  /**
@@ -381,6 +384,12 @@ class ChoiceAttributeOptionModel
381
384
  get content(): AttributeContent {
382
385
  return this._content;
383
386
  }
387
+
388
+ /**
389
+ */
390
+ get isUser(): boolean {
391
+ return this._isUser;
392
+ }
384
393
  }
385
394
 
386
395
  export default ChoiceAttributeOptionModel;
@@ -677,4 +677,31 @@ describe("choiceAttributeModel", () => {
677
677
  "answer-option-key": "book-label",
678
678
  });
679
679
  });
680
+
681
+ it("sets isUser on options where attribute has optionType user", () => {
682
+ const data = {
683
+ key: "Users",
684
+ value: [],
685
+ };
686
+
687
+ const contributions = {
688
+ label: "Users",
689
+ type: "choice",
690
+ optionType: "user",
691
+ options: [
692
+ {
693
+ code: "user1",
694
+ label: "User 1",
695
+ },
696
+ {
697
+ code: "user2",
698
+ label: "User 2",
699
+ },
700
+ ],
701
+ };
702
+
703
+ const attribute = new ChoiceAttributeModel(data, contributions);
704
+
705
+ expect(attribute.options.first.isUser).toBe(true);
706
+ });
680
707
  });
@@ -196,30 +196,22 @@ export default class DetailModel extends ResourceModel {
196
196
  * Getting the attribute that has as layout hint 'avatar-for-title'
197
197
  */
198
198
  get avatarForTitleAttribute(): ?AttributeType {
199
- const avatarAttributes = this._attributeCollection.all.filter((attribute) =>
200
- attribute.layouthint.hasExact(AVATAR),
199
+ return this._attributeCollection.find(
200
+ (attribute) =>
201
+ attribute.layouthint.hasExact(AVATAR_IN_TITLE) &&
202
+ attribute.layouthint.hasExact(AVATAR),
201
203
  );
202
-
203
- const avatarForTitleAttribute = avatarAttributes.find((attribute) =>
204
- attribute.layouthint.hasExact(AVATAR_IN_TITLE),
205
- );
206
-
207
- return avatarForTitleAttribute || null;
208
204
  }
209
205
 
210
206
  /**
211
207
  * Getting the attribute that has as layout hint 'title'
212
208
  */
213
209
  get titleAttribute(): ?AttributeType {
214
- const nonAvatarAttributes = this._attributeCollection.all.filter(
215
- (attribute) => !attribute.layouthint.hasExact(AVATAR),
210
+ return this._attributeCollection.find(
211
+ (attribute) =>
212
+ attribute.layouthint.has(TITLE) &&
213
+ !attribute.layouthint.hasExact(AVATAR),
216
214
  );
217
-
218
- const titleAttribute = nonAvatarAttributes.find((attribute) =>
219
- attribute.layouthint.has(TITLE),
220
- );
221
-
222
- return titleAttribute || null;
223
215
  }
224
216
 
225
217
  /**
@@ -29,9 +29,9 @@ export default class UserModel extends ResourceModel {
29
29
  }
30
30
 
31
31
  /**
32
- * Retrieve username of user
32
+ * Retrieve avatar of user
33
33
  */
34
- get avatar(): string {
34
+ get avatar(): string | null {
35
35
  return this.data.Avatar;
36
36
  }
37
37
 
@@ -10,6 +10,10 @@ export const UPLOAD_PATH: "/uploadFile";
10
10
  * Captcha Path
11
11
  */
12
12
  export const CAPTCHA_PATH: "/captchaServices";
13
+ /**
14
+ * Path to change avatar page / component
15
+ */
16
+ export const CHANGEAVATAR_PATH: "/change-avatar";
13
17
  /**
14
18
  * Path to change password page / component
15
19
  */
@@ -238,4 +238,34 @@ export namespace LayoutHintConfiguration {
238
238
  let component_16: string[];
239
239
  export { component_16 as component };
240
240
  }
241
+ namespace AVATAR {
242
+ let hint_17: string;
243
+ export { hint_17 as hint };
244
+ export namespace description_17 {
245
+ let NL_17: string;
246
+ export { NL_17 as NL };
247
+ let EN_17: string;
248
+ export { EN_17 as EN };
249
+ }
250
+ export { description_17 as description };
251
+ let link_12: string;
252
+ export { link_12 as link };
253
+ let component_17: string[];
254
+ export { component_17 as component };
255
+ }
256
+ namespace AVATAR_IN_TITLE {
257
+ let hint_18: string;
258
+ export { hint_18 as hint };
259
+ export namespace description_18 {
260
+ let NL_18: string;
261
+ export { NL_18 as NL };
262
+ let EN_18: string;
263
+ export { EN_18 as EN };
264
+ }
265
+ export { description_18 as description };
266
+ let link_13: string;
267
+ export { link_13 as link };
268
+ let component_18: string[];
269
+ export { component_18 as component };
270
+ }
241
271
  }
@@ -71,6 +71,11 @@ export const RENDER_SECTION_LABEL: "render-section-label";
71
71
  */
72
72
  export const HIDE_IN_USER_INTERFACE: string;
73
73
  export function getLayoutHintConfiguration(): Object;
74
+ /**
75
+ * Layout-hint: Marks an attribute as an avatar for the title attribute.
76
+ */
77
+ export const AVATAR_IN_TITLE: string;
78
+ export const AVATAR: string;
74
79
  export default getHint;
75
80
  /**
76
81
  * Retrieve layout hint by id from the layout hint configuration
@@ -3,6 +3,12 @@
3
3
  */
4
4
  export default class ChoiceAttributeModel extends AttributeModel {
5
5
  _options: ChoiceAttributeOptionCollection;
6
+ /**
7
+ */
8
+ get optionType(): string;
9
+ /**
10
+ */
11
+ get isUser(): boolean;
6
12
  /**
7
13
  * Retrieve lookup service link
8
14
  */
@@ -17,6 +17,7 @@ declare class ChoiceAttributeOptionModel extends BaseModel {
17
17
  _links: LinkCollection;
18
18
  _attributeCollection: AttributeCollection;
19
19
  _content: AttributeContent;
20
+ _isUser: boolean;
20
21
  /**
21
22
  */
22
23
  set code(code: string);
@@ -102,6 +103,10 @@ declare class ChoiceAttributeOptionModel extends BaseModel {
102
103
  * Retrieve concept link of attribute when available
103
104
  */
104
105
  get conceptLink(): LinkModel;
106
+ /**
107
+ *
108
+ */
109
+ get avatarLink(): LinkModel;
105
110
  /**
106
111
  * Set level of option
107
112
  */
@@ -126,6 +131,9 @@ declare class ChoiceAttributeOptionModel extends BaseModel {
126
131
  /**
127
132
  */
128
133
  get content(): AttributeContent;
134
+ /**
135
+ */
136
+ get isUser(): boolean;
129
137
  }
130
138
  import BaseModel from "../base/BaseModel";
131
139
  import ChoiceAttributeOptionCollection from "./ChoiceAttributeOptionCollection";
@@ -10,7 +10,7 @@ declare class LayoutHintRuleCollection extends BaseCollection<ILayoutHintRule> {
10
10
  /**
11
11
  * Set layout hint rules on the applicable attributes
12
12
  */
13
- static setLayoutHintRules<T, AttributeType_1>(attribute: T): T;
13
+ static setLayoutHintRules<T, AttributeType>(attribute: T): T;
14
14
  constructor(initCollection?: ILayoutHintRule[]);
15
15
  /**
16
16
  * Retrieve all rules available in the collection
@@ -55,6 +55,10 @@ declare class ResourceModel extends BaseModel {
55
55
  * Getting the links of the resource
56
56
  */
57
57
  get links(): LinkCollection;
58
+ /**
59
+ *
60
+ */
61
+ get downloadLink(): LinkModel;
58
62
  /**
59
63
  * Get self link of model
60
64
  */
@@ -38,6 +38,9 @@ export default class ContentLinkModel extends BaseModel {
38
38
  * Retrieve the label of the source a link to a section belongs to
39
39
  */
40
40
  get sourceLabel(): string;
41
+ /**
42
+ */
43
+ createEncodedHref(): Href;
41
44
  /**
42
45
  * Encode the content-identifier of the path to the content resource.
43
46
  * This makes it a single uri part, which can be used on routes to make nested routes
@@ -53,6 +53,10 @@ export default class DetailModel extends ResourceModel {
53
53
  * Determines if this is a case
54
54
  */
55
55
  get isCase(): boolean;
56
+ /**
57
+ * Getting the attribute that has as layout hint 'avatar-for-title'
58
+ */
59
+ get avatarForTitleAttribute(): AttributeType;
56
60
  /**
57
61
  * Getting the attribute that has as layout hint 'title'
58
62
  */
@@ -2,6 +2,10 @@
2
2
  * User model
3
3
  */
4
4
  export default class UserModel extends ResourceModel {
5
+ /**
6
+ * Retrieve avatar of user
7
+ */
8
+ get avatar(): string;
5
9
  /**
6
10
  * Retrieve username of user
7
11
  */
@@ -18,6 +18,9 @@ declare class UserServicesModel extends ResourceModel {
18
18
  /**
19
19
  */
20
20
  get changePassword(): Href;
21
+ /**
22
+ */
23
+ get changeAvatar(): Href;
21
24
  /**
22
25
  */
23
26
  get isLoggedIn(): boolean;
@@ -0,0 +1,7 @@
1
+ export function parseUrl(href: string): {
2
+ path: string;
3
+ querystring: null | string;
4
+ hash: null | string;
5
+ };
6
+ export function filterParameters(href: string, allowedParameters?: Array<string>): string;
7
+ export function createHref(context: string, dynamicPart: string, location?: Location, allowedParameters?: Array<string>): string;
@@ -4,4 +4,5 @@ export * from "./objects";
4
4
  export * from "./text";
5
5
  export * from "./checkResource";
6
6
  export * from "./repositoryResource";
7
+ export * from "./createHref";
7
8
  export { default as createUUID } from "./createUUID";