@beinformed/ui 1.43.7 → 1.44.0
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 +7 -0
- package/esm/models/attributes/AttributeModel.js +0 -7
- package/esm/models/attributes/AttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +22 -24
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js +2 -1
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeOptionModel.js +8 -0
- package/esm/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/esm/models/detail/DetailModel.js +2 -6
- package/esm/models/detail/DetailModel.js.map +1 -1
- package/esm/models/user/UserModel.js.map +1 -1
- package/lib/models/attributes/AttributeModel.js +0 -7
- package/lib/models/attributes/AttributeModel.js.flow +0 -7
- package/lib/models/attributes/AttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +22 -24
- package/lib/models/attributes/ChoiceAttributeModel.js.flow +6 -10
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js +2 -1
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.flow +1 -0
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionModel.js +8 -0
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.flow +9 -0
- package/lib/models/attributes/ChoiceAttributeOptionModel.js.map +1 -1
- package/lib/models/attributes/__tests__/ChoiceAttributeModel.spec.js.flow +27 -0
- package/lib/models/detail/DetailModel.js +2 -6
- package/lib/models/detail/DetailModel.js.flow +8 -16
- package/lib/models/detail/DetailModel.js.map +1 -1
- package/lib/models/user/UserModel.js.flow +1 -1
- package/lib/models/user/UserModel.js.map +1 -1
- package/package.json +1 -1
- package/src/models/attributes/AttributeModel.js +0 -7
- package/src/models/attributes/ChoiceAttributeModel.js +6 -10
- package/src/models/attributes/ChoiceAttributeOptionCollection.js +1 -0
- package/src/models/attributes/ChoiceAttributeOptionModel.js +9 -0
- package/src/models/attributes/__tests__/ChoiceAttributeModel.spec.js +27 -0
- package/src/models/detail/DetailModel.js +8 -16
- package/src/models/user/UserModel.js +1 -1
package/package.json
CHANGED
|
@@ -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,12 @@ 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
|
+
|
|
74
80
|
/**
|
|
75
81
|
*/
|
|
76
82
|
getInitialChildModelLinks(): Array<LinkModel> {
|
|
@@ -122,16 +128,6 @@ export default class ChoiceAttributeModel extends AttributeModel {
|
|
|
122
128
|
return this.contributions.lookupList?.label ?? "";
|
|
123
129
|
}
|
|
124
130
|
|
|
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
131
|
/**
|
|
136
132
|
* Retrieve reference date of attribute which can be used as entryDate for content
|
|
137
133
|
*/
|
|
@@ -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
|
-
|
|
200
|
-
attribute
|
|
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
|
-
|
|
215
|
-
(attribute) =>
|
|
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
|
/**
|