@beinformed/ui 1.44.3 → 1.44.4

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 CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.44.4](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.44.3...v1.44.4) (2024-03-19)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **avatar:** add isUser property to lookup service response ([f59ffee](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/f59ffeea51775fe15ae8ff1176beaac07e467230))
11
+
5
12
  ## [1.44.3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.44.2...v1.44.3) (2024-03-19)
6
13
 
7
14
 
@@ -12,13 +12,25 @@ class LookupOptionCollection extends ResourceCollection {
12
12
  data.options.forEach(option => {
13
13
  collection.add(new ChoiceAttributeOptionModel([], {
14
14
  ...option,
15
- optionType: contributions.optionType ?? "generic",
15
+ optionType: this.getOptionType(option, contributions),
16
16
  elementsContributions: contributions.options[0].elements
17
17
  }));
18
18
  });
19
19
  }
20
20
  return collection;
21
21
  }
22
+
23
+ /**
24
+ */
25
+ static getOptionType(option, contributions) {
26
+ if (contributions.optionType) {
27
+ return contributions.optionType;
28
+ }
29
+ if (option._links?.download?.[0].name === "avatar") {
30
+ return "user";
31
+ }
32
+ return "generic";
33
+ }
22
34
  }
23
35
  export default LookupOptionCollection;
24
36
  //# sourceMappingURL=LookupOptionCollection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LookupOptionCollection.js","names":["ResourceCollection","ChoiceAttributeOptionModel","LookupOptionCollection","create","data","contributions","collection","options","forEach","option","add","optionType","elementsContributions","elements"],"sources":["../../../src/models/lookup/LookupOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"../attributes/ChoiceAttributeOptionModel\";\n\n/**\n */\nclass LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n /**\n */\n static create(data: Object, contributions: Object): LookupOptionCollection {\n const collection = new LookupOptionCollection();\n\n if (data.options && contributions.options) {\n data.options.forEach((option) => {\n collection.add(\n new ChoiceAttributeOptionModel([], {\n ...option,\n optionType: contributions.optionType ?? \"generic\",\n elementsContributions: contributions.options[0].elements,\n }),\n );\n });\n }\n\n return collection;\n }\n}\n\nexport default LookupOptionCollection;\n"],"mappings":"AACA,OAAOA,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,0BAA0B,MAAM,0CAA0C;;AAEjF;AACA;AACA,MAAMC,sBAAsB,SAASF,kBAAkB,CAA6B;EAClF;AACF;EACE,OAAOG,MAAMA,CAACC,IAAY,EAAEC,aAAqB,EAA0B;IACzE,MAAMC,UAAU,GAAG,IAAIJ,sBAAsB,CAAC,CAAC;IAE/C,IAAIE,IAAI,CAACG,OAAO,IAAIF,aAAa,CAACE,OAAO,EAAE;MACzCH,IAAI,CAACG,OAAO,CAACC,OAAO,CAAEC,MAAM,IAAK;QAC/BH,UAAU,CAACI,GAAG,CACZ,IAAIT,0BAA0B,CAAC,EAAE,EAAE;UACjC,GAAGQ,MAAM;UACTE,UAAU,EAAEN,aAAa,CAACM,UAAU,IAAI,SAAS;UACjDC,qBAAqB,EAAEP,aAAa,CAACE,OAAO,CAAC,CAAC,CAAC,CAACM;QAClD,CAAC,CACH,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOP,UAAU;EACnB;AACF;AAEA,eAAeJ,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"LookupOptionCollection.js","names":["ResourceCollection","ChoiceAttributeOptionModel","LookupOptionCollection","create","data","contributions","collection","options","forEach","option","add","optionType","getOptionType","elementsContributions","elements","_links","download","name"],"sources":["../../../src/models/lookup/LookupOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"../attributes/ChoiceAttributeOptionModel\";\n\n/**\n */\nclass LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n /**\n */\n static create(data: Object, contributions: Object): LookupOptionCollection {\n const collection = new LookupOptionCollection();\n\n if (data.options && contributions.options) {\n data.options.forEach((option) => {\n collection.add(\n new ChoiceAttributeOptionModel([], {\n ...option,\n optionType: this.getOptionType(option, contributions),\n elementsContributions: contributions.options[0].elements,\n }),\n );\n });\n }\n\n return collection;\n }\n\n /**\n */\n static getOptionType(option: Object, contributions: Object): string {\n if (contributions.optionType) {\n return contributions.optionType;\n }\n if (option._links?.download?.[0].name === \"avatar\") {\n return \"user\";\n }\n return \"generic\";\n }\n}\n\nexport default LookupOptionCollection;\n"],"mappings":"AACA,OAAOA,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,0BAA0B,MAAM,0CAA0C;;AAEjF;AACA;AACA,MAAMC,sBAAsB,SAASF,kBAAkB,CAA6B;EAClF;AACF;EACE,OAAOG,MAAMA,CAACC,IAAY,EAAEC,aAAqB,EAA0B;IACzE,MAAMC,UAAU,GAAG,IAAIJ,sBAAsB,CAAC,CAAC;IAE/C,IAAIE,IAAI,CAACG,OAAO,IAAIF,aAAa,CAACE,OAAO,EAAE;MACzCH,IAAI,CAACG,OAAO,CAACC,OAAO,CAAEC,MAAM,IAAK;QAC/BH,UAAU,CAACI,GAAG,CACZ,IAAIT,0BAA0B,CAAC,EAAE,EAAE;UACjC,GAAGQ,MAAM;UACTE,UAAU,EAAE,IAAI,CAACC,aAAa,CAACH,MAAM,EAAEJ,aAAa,CAAC;UACrDQ,qBAAqB,EAAER,aAAa,CAACE,OAAO,CAAC,CAAC,CAAC,CAACO;QAClD,CAAC,CACH,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOR,UAAU;EACnB;;EAEA;AACF;EACE,OAAOM,aAAaA,CAACH,MAAc,EAAEJ,aAAqB,EAAU;IAClE,IAAIA,aAAa,CAACM,UAAU,EAAE;MAC5B,OAAON,aAAa,CAACM,UAAU;IACjC;IACA,IAAIF,MAAM,CAACM,MAAM,EAAEC,QAAQ,GAAG,CAAC,CAAC,CAACC,IAAI,KAAK,QAAQ,EAAE;MAClD,OAAO,MAAM;IACf;IACA,OAAO,SAAS;EAClB;AACF;AAEA,eAAef,sBAAsB","ignoreList":[]}
@@ -18,13 +18,25 @@ class LookupOptionCollection extends _ResourceCollection.default {
18
18
  data.options.forEach(option => {
19
19
  collection.add(new _ChoiceAttributeOptionModel.default([], {
20
20
  ...option,
21
- optionType: contributions.optionType ?? "generic",
21
+ optionType: this.getOptionType(option, contributions),
22
22
  elementsContributions: contributions.options[0].elements
23
23
  }));
24
24
  });
25
25
  }
26
26
  return collection;
27
27
  }
28
+
29
+ /**
30
+ */
31
+ static getOptionType(option, contributions) {
32
+ if (contributions.optionType) {
33
+ return contributions.optionType;
34
+ }
35
+ if (option._links?.download?.[0].name === "avatar") {
36
+ return "user";
37
+ }
38
+ return "generic";
39
+ }
28
40
  }
29
41
  var _default = exports.default = LookupOptionCollection;
30
42
  //# sourceMappingURL=LookupOptionCollection.js.map
@@ -15,7 +15,7 @@ class LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionMod
15
15
  collection.add(
16
16
  new ChoiceAttributeOptionModel([], {
17
17
  ...option,
18
- optionType: contributions.optionType ?? "generic",
18
+ optionType: this.getOptionType(option, contributions),
19
19
  elementsContributions: contributions.options[0].elements,
20
20
  }),
21
21
  );
@@ -24,6 +24,18 @@ class LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionMod
24
24
 
25
25
  return collection;
26
26
  }
27
+
28
+ /**
29
+ */
30
+ static getOptionType(option: Object, contributions: Object): string {
31
+ if (contributions.optionType) {
32
+ return contributions.optionType;
33
+ }
34
+ if (option._links?.download?.[0].name === "avatar") {
35
+ return "user";
36
+ }
37
+ return "generic";
38
+ }
27
39
  }
28
40
 
29
41
  export default LookupOptionCollection;
@@ -1 +1 @@
1
- {"version":3,"file":"LookupOptionCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ChoiceAttributeOptionModel","LookupOptionCollection","ResourceCollection","create","data","contributions","collection","options","forEach","option","add","ChoiceAttributeOptionModel","optionType","elementsContributions","elements","_default","exports","default"],"sources":["../../../src/models/lookup/LookupOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"../attributes/ChoiceAttributeOptionModel\";\n\n/**\n */\nclass LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n /**\n */\n static create(data: Object, contributions: Object): LookupOptionCollection {\n const collection = new LookupOptionCollection();\n\n if (data.options && contributions.options) {\n data.options.forEach((option) => {\n collection.add(\n new ChoiceAttributeOptionModel([], {\n ...option,\n optionType: contributions.optionType ?? \"generic\",\n elementsContributions: contributions.options[0].elements,\n }),\n );\n });\n }\n\n return collection;\n }\n}\n\nexport default LookupOptionCollection;\n"],"mappings":";;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA,MAAME,sBAAsB,SAASC,2BAAkB,CAA6B;EAClF;AACF;EACE,OAAOC,MAAMA,CAACC,IAAY,EAAEC,aAAqB,EAA0B;IACzE,MAAMC,UAAU,GAAG,IAAIL,sBAAsB,CAAC,CAAC;IAE/C,IAAIG,IAAI,CAACG,OAAO,IAAIF,aAAa,CAACE,OAAO,EAAE;MACzCH,IAAI,CAACG,OAAO,CAACC,OAAO,CAAEC,MAAM,IAAK;QAC/BH,UAAU,CAACI,GAAG,CACZ,IAAIC,mCAA0B,CAAC,EAAE,EAAE;UACjC,GAAGF,MAAM;UACTG,UAAU,EAAEP,aAAa,CAACO,UAAU,IAAI,SAAS;UACjDC,qBAAqB,EAAER,aAAa,CAACE,OAAO,CAAC,CAAC,CAAC,CAACO;QAClD,CAAC,CACH,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOR,UAAU;EACnB;AACF;AAAC,IAAAS,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEchB,sBAAsB","ignoreList":[]}
1
+ {"version":3,"file":"LookupOptionCollection.js","names":["_ResourceCollection","_interopRequireDefault","require","_ChoiceAttributeOptionModel","LookupOptionCollection","ResourceCollection","create","data","contributions","collection","options","forEach","option","add","ChoiceAttributeOptionModel","optionType","getOptionType","elementsContributions","elements","_links","download","name","_default","exports","default"],"sources":["../../../src/models/lookup/LookupOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"../attributes/ChoiceAttributeOptionModel\";\n\n/**\n */\nclass LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n /**\n */\n static create(data: Object, contributions: Object): LookupOptionCollection {\n const collection = new LookupOptionCollection();\n\n if (data.options && contributions.options) {\n data.options.forEach((option) => {\n collection.add(\n new ChoiceAttributeOptionModel([], {\n ...option,\n optionType: this.getOptionType(option, contributions),\n elementsContributions: contributions.options[0].elements,\n }),\n );\n });\n }\n\n return collection;\n }\n\n /**\n */\n static getOptionType(option: Object, contributions: Object): string {\n if (contributions.optionType) {\n return contributions.optionType;\n }\n if (option._links?.download?.[0].name === \"avatar\") {\n return \"user\";\n }\n return \"generic\";\n }\n}\n\nexport default LookupOptionCollection;\n"],"mappings":";;;;;;;AACA,IAAAA,mBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,2BAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA,MAAME,sBAAsB,SAASC,2BAAkB,CAA6B;EAClF;AACF;EACE,OAAOC,MAAMA,CAACC,IAAY,EAAEC,aAAqB,EAA0B;IACzE,MAAMC,UAAU,GAAG,IAAIL,sBAAsB,CAAC,CAAC;IAE/C,IAAIG,IAAI,CAACG,OAAO,IAAIF,aAAa,CAACE,OAAO,EAAE;MACzCH,IAAI,CAACG,OAAO,CAACC,OAAO,CAAEC,MAAM,IAAK;QAC/BH,UAAU,CAACI,GAAG,CACZ,IAAIC,mCAA0B,CAAC,EAAE,EAAE;UACjC,GAAGF,MAAM;UACTG,UAAU,EAAE,IAAI,CAACC,aAAa,CAACJ,MAAM,EAAEJ,aAAa,CAAC;UACrDS,qBAAqB,EAAET,aAAa,CAACE,OAAO,CAAC,CAAC,CAAC,CAACQ;QAClD,CAAC,CACH,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAOT,UAAU;EACnB;;EAEA;AACF;EACE,OAAOO,aAAaA,CAACJ,MAAc,EAAEJ,aAAqB,EAAU;IAClE,IAAIA,aAAa,CAACO,UAAU,EAAE;MAC5B,OAAOP,aAAa,CAACO,UAAU;IACjC;IACA,IAAIH,MAAM,CAACO,MAAM,EAAEC,QAAQ,GAAG,CAAC,CAAC,CAACC,IAAI,KAAK,QAAQ,EAAE;MAClD,OAAO,MAAM;IACf;IACA,OAAO,SAAS;EAClB;AACF;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcpB,sBAAsB","ignoreList":[]}
@@ -0,0 +1,80 @@
1
+ import LookupOptionCollection from "../LookupOptionCollection";
2
+ import ChoiceAttributeOptionModel from "../../attributes/ChoiceAttributeOptionModel";
3
+
4
+ const data = {
5
+ _links: {
6
+ self: {
7
+ href: "/lookupOptions",
8
+ },
9
+ api_doc: {
10
+ href: "/api-docs/v3/lookupOptions",
11
+ },
12
+ contributions: {
13
+ href: "/contributions/lookupOptions",
14
+ },
15
+ },
16
+ options: [
17
+ {
18
+ code: "1",
19
+ label: "Administrator",
20
+ },
21
+ {
22
+ code: "19",
23
+ label: "Angela Turner",
24
+ _links: {
25
+ download: [
26
+ {
27
+ href: "/resources/7dbd0538-bbda-4945-90ea-5de60d4dfbcb.jpg",
28
+ name: "avatar",
29
+ },
30
+ ],
31
+ },
32
+ },
33
+ ],
34
+ filter: {
35
+ name: "labelFilter",
36
+ param: "labelFilter",
37
+ value: "a",
38
+ },
39
+ };
40
+
41
+ const contributions = {
42
+ resourcetype: "lookupOptions",
43
+ filter: [
44
+ {
45
+ labelFilter: {
46
+ type: "stringfilter",
47
+ label: "labelFilter",
48
+ multiplechoice: false,
49
+ operator: "contains",
50
+ },
51
+ },
52
+ ],
53
+ options: [
54
+ {
55
+ code: {
56
+ type: "string",
57
+ label: "Code",
58
+ displaysize: 50,
59
+ maxLength: 255,
60
+ },
61
+ label: {
62
+ type: "string",
63
+ label: "Label",
64
+ displaysize: 50,
65
+ maxLength: 255,
66
+ },
67
+ },
68
+ ],
69
+ };
70
+
71
+ describe("lookupOptionCollection spec", () => {
72
+ it("set option type to user when avatar link present", () => {
73
+ const collection = LookupOptionCollection.create(data, contributions);
74
+
75
+ expect(collection).toBeInstanceOf(LookupOptionCollection);
76
+ expect(collection.first).toBeInstanceOf(ChoiceAttributeOptionModel);
77
+ expect(collection.all[0].isUser).toBe(false);
78
+ expect(collection.all[1].isUser).toBe(true);
79
+ });
80
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.44.3",
3
+ "version": "1.44.4",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -15,7 +15,7 @@ class LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionMod
15
15
  collection.add(
16
16
  new ChoiceAttributeOptionModel([], {
17
17
  ...option,
18
- optionType: contributions.optionType ?? "generic",
18
+ optionType: this.getOptionType(option, contributions),
19
19
  elementsContributions: contributions.options[0].elements,
20
20
  }),
21
21
  );
@@ -24,6 +24,18 @@ class LookupOptionCollection extends ResourceCollection<ChoiceAttributeOptionMod
24
24
 
25
25
  return collection;
26
26
  }
27
+
28
+ /**
29
+ */
30
+ static getOptionType(option: Object, contributions: Object): string {
31
+ if (contributions.optionType) {
32
+ return contributions.optionType;
33
+ }
34
+ if (option._links?.download?.[0].name === "avatar") {
35
+ return "user";
36
+ }
37
+ return "generic";
38
+ }
27
39
  }
28
40
 
29
41
  export default LookupOptionCollection;
@@ -0,0 +1,80 @@
1
+ import LookupOptionCollection from "../LookupOptionCollection";
2
+ import ChoiceAttributeOptionModel from "../../attributes/ChoiceAttributeOptionModel";
3
+
4
+ const data = {
5
+ _links: {
6
+ self: {
7
+ href: "/lookupOptions",
8
+ },
9
+ api_doc: {
10
+ href: "/api-docs/v3/lookupOptions",
11
+ },
12
+ contributions: {
13
+ href: "/contributions/lookupOptions",
14
+ },
15
+ },
16
+ options: [
17
+ {
18
+ code: "1",
19
+ label: "Administrator",
20
+ },
21
+ {
22
+ code: "19",
23
+ label: "Angela Turner",
24
+ _links: {
25
+ download: [
26
+ {
27
+ href: "/resources/7dbd0538-bbda-4945-90ea-5de60d4dfbcb.jpg",
28
+ name: "avatar",
29
+ },
30
+ ],
31
+ },
32
+ },
33
+ ],
34
+ filter: {
35
+ name: "labelFilter",
36
+ param: "labelFilter",
37
+ value: "a",
38
+ },
39
+ };
40
+
41
+ const contributions = {
42
+ resourcetype: "lookupOptions",
43
+ filter: [
44
+ {
45
+ labelFilter: {
46
+ type: "stringfilter",
47
+ label: "labelFilter",
48
+ multiplechoice: false,
49
+ operator: "contains",
50
+ },
51
+ },
52
+ ],
53
+ options: [
54
+ {
55
+ code: {
56
+ type: "string",
57
+ label: "Code",
58
+ displaysize: 50,
59
+ maxLength: 255,
60
+ },
61
+ label: {
62
+ type: "string",
63
+ label: "Label",
64
+ displaysize: 50,
65
+ maxLength: 255,
66
+ },
67
+ },
68
+ ],
69
+ };
70
+
71
+ describe("lookupOptionCollection spec", () => {
72
+ it("set option type to user when avatar link present", () => {
73
+ const collection = LookupOptionCollection.create(data, contributions);
74
+
75
+ expect(collection).toBeInstanceOf(LookupOptionCollection);
76
+ expect(collection.first).toBeInstanceOf(ChoiceAttributeOptionModel);
77
+ expect(collection.all[0].isUser).toBe(false);
78
+ expect(collection.all[1].isUser).toBe(true);
79
+ });
80
+ });