@beinformed/ui 1.50.4 → 1.52.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 +15 -0
- package/esm/hooks/useModularUI.js +2 -2
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +1 -4
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +15 -1
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptTypeDetailModel.js +29 -0
- package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/esm/models/links/LinkCollection.js +14 -0
- package/esm/models/links/LinkCollection.js.map +1 -1
- package/esm/models/user/UserServicesModel.js.map +1 -1
- package/lib/hooks/useModularUI.js +2 -2
- package/lib/hooks/useModularUI.js.flow +2 -2
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +0 -3
- package/lib/hooks/useModularUIBasic.js.flow +1 -4
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +15 -1
- package/lib/models/concepts/ConceptDetailModel.js.flow +15 -1
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptTypeDetailModel.js +29 -0
- package/lib/models/concepts/ConceptTypeDetailModel.js.flow +34 -0
- package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/lib/models/concepts/__mock__/concepttype_hierarchy.js.flow +13 -0
- package/lib/models/concepts/__tests__/ConceptTypeDetailModel.spec.js.flow +40 -2
- package/lib/models/links/LinkCollection.js +14 -0
- package/lib/models/links/LinkCollection.js.flow +14 -0
- package/lib/models/links/LinkCollection.js.map +1 -1
- package/lib/models/user/UserServicesModel.js.flow +1 -1
- package/lib/models/user/UserServicesModel.js.map +1 -1
- package/package.json +19 -19
- package/src/hooks/useModularUI.js +2 -2
- package/src/hooks/useModularUIBasic.js +1 -4
- package/src/models/concepts/ConceptDetailModel.js +15 -1
- package/src/models/concepts/ConceptTypeDetailModel.js +34 -0
- package/src/models/concepts/__mock__/concepttype_hierarchy.js +13 -0
- package/src/models/concepts/__mock__/concepttype_hierarchy.json +42 -0
- package/src/models/concepts/__tests__/ConceptTypeDetailModel.spec.js +40 -2
- package/src/models/links/LinkCollection.js +14 -0
- package/src/models/user/UserServicesModel.js +1 -1
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import ResourceModel from "../base/ResourceModel";
|
|
3
3
|
|
|
4
4
|
import type ModularUIResponse from "../../modularui/ModularUIResponse";
|
|
5
|
+
import type LinkCollection from "../links/LinkCollection";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Model for concept details, available through modelcatalog
|
|
@@ -41,6 +42,12 @@ class ConceptTypeDetailModel extends ResourceModel {
|
|
|
41
42
|
return this.getData("label", "");
|
|
42
43
|
}
|
|
43
44
|
|
|
45
|
+
/**
|
|
46
|
+
*/
|
|
47
|
+
get isCoreTaxonomy(): boolean {
|
|
48
|
+
return this.getData("coreTaxonomy", "false") === "true";
|
|
49
|
+
}
|
|
50
|
+
|
|
44
51
|
/**
|
|
45
52
|
* Get concept type icon
|
|
46
53
|
*/
|
|
@@ -96,6 +103,33 @@ class ConceptTypeDetailModel extends ResourceModel {
|
|
|
96
103
|
get sectionReferenceTypes(): Array<Object> {
|
|
97
104
|
return this.getData("sectionReferenceTypes", []);
|
|
98
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
*/
|
|
109
|
+
get conceptTypeHierarchy(): LinkCollection {
|
|
110
|
+
return this.links.getLinksByGroup("conceptTypeHierarchy");
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
*/
|
|
115
|
+
isOfConceptType(conceptTypeId: string): boolean {
|
|
116
|
+
return (
|
|
117
|
+
this.conceptTypeHierarchy?.hasLinkByKey(conceptTypeId) ||
|
|
118
|
+
this.conceptTypeHierarchy?.hasLinkByHref(conceptTypeId) ||
|
|
119
|
+
this.selfhref.equals(conceptTypeId)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Indicates if the given metamodel functional identifier exists in the hierarchy of concept types
|
|
125
|
+
*/
|
|
126
|
+
hasMetamodelIdInHierarchy(metamodelId: string): boolean {
|
|
127
|
+
return (
|
|
128
|
+
this.conceptTypeHierarchy?.all.some((link) =>
|
|
129
|
+
link.key.startsWith(metamodelId + "#"),
|
|
130
|
+
) || false
|
|
131
|
+
);
|
|
132
|
+
}
|
|
99
133
|
}
|
|
100
134
|
|
|
101
135
|
export default ConceptTypeDetailModel;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import ConceptTypeDetailModel from "../ConceptTypeDetailModel";
|
|
2
|
+
import ModularUIResponse from "../../../modularui/ModularUIResponse";
|
|
3
|
+
|
|
4
|
+
import data from "./concepttype_hierarchy.json";
|
|
5
|
+
import contributions from "./concepttype_contributions.json";
|
|
6
|
+
|
|
7
|
+
const response = ModularUIResponse.create({
|
|
8
|
+
key: "concepttype",
|
|
9
|
+
data,
|
|
10
|
+
contributions,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export default new ConceptTypeDetailModel(response);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"concepttype": {
|
|
3
|
+
"_links": {
|
|
4
|
+
"self": {
|
|
5
|
+
"href": "/concepttypes/bundle-com.beinformed.fs.demo.metamodels/Advice%20and%20request%20business%20scenarios.bixml/ScenarioStep_Advice"
|
|
6
|
+
},
|
|
7
|
+
"api_doc": {
|
|
8
|
+
"href": "/api-docs/v3/concepttypes/(knowledge-model-type-identifier)/(concept-type-identifier)"
|
|
9
|
+
},
|
|
10
|
+
"contributions": {
|
|
11
|
+
"href": "/contributions/concepttypes/(knowledge-model-type-identifier)/(concept-type-identifier)"
|
|
12
|
+
},
|
|
13
|
+
"conceptTypeHierarchy": [
|
|
14
|
+
{
|
|
15
|
+
"href": "/concepttypes/bundle-com.beinformed.fs.demo.metamodels/Advice%20and%20request%20business%20scenarios.bixml/ScenarioStep_Advice",
|
|
16
|
+
"name": "Adviceandrequestbusinessscenarios#ScenarioStep_Advice"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"href": "/concepttypes/bundle-com.beinformed.fs.demo.metamodels/Business%20scenarios.bixml/ScenarioStep",
|
|
20
|
+
"name": "BusinessScenarios#ScenarioStep"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
},
|
|
24
|
+
"_id": "ScenarioStep_Advice",
|
|
25
|
+
"label": "Advice scenario step",
|
|
26
|
+
"icon": "/resource/bundle-com.beinformed.fs.demo.metamodels/Icons/Library/Metamodels/Business%20scenarios/_Icons/advice_24x24.png",
|
|
27
|
+
"textColor": "#000000",
|
|
28
|
+
"lineColor": "#000000",
|
|
29
|
+
"backgroundColor": "#FFFF3C",
|
|
30
|
+
"coreTaxonomy": "false",
|
|
31
|
+
"textFragmentTypes": [
|
|
32
|
+
{
|
|
33
|
+
"_id": "Definition",
|
|
34
|
+
"label": "Definition"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"_id": "Description",
|
|
38
|
+
"label": "Description"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,10 +1,48 @@
|
|
|
1
1
|
import ConceptTypeDetailModel from "../ConceptTypeDetailModel";
|
|
2
2
|
|
|
3
|
+
import conceptTypeDetail from "../__mock__/concepttype_hierarchy";
|
|
4
|
+
|
|
3
5
|
describe("conceptTypeDetailModel", () => {
|
|
4
6
|
it("should be able to create an empty ConceptTypeDetailModel object", () => {
|
|
5
|
-
const conceptTypeDetail = new ConceptTypeDetailModel();
|
|
6
|
-
|
|
7
7
|
expect(conceptTypeDetail).toBeInstanceOf(ConceptTypeDetailModel);
|
|
8
|
+
|
|
8
9
|
expect(conceptTypeDetail.type).toBe("ConceptTypeDetail");
|
|
10
|
+
expect(ConceptTypeDetailModel.modelName).toBe("ConceptTypeDetailModel");
|
|
11
|
+
expect(conceptTypeDetail.key).toBe("ScenarioStep_Advice");
|
|
12
|
+
expect(conceptTypeDetail.label).toBe("Advice scenario step");
|
|
13
|
+
expect(conceptTypeDetail.isCoreTaxonomy).toBe(false);
|
|
14
|
+
expect(conceptTypeDetail.icon).toBe(
|
|
15
|
+
"/resource/bundle-com.beinformed.fs.demo.metamodels/Icons/Library/Metamodels/Business%20scenarios/_Icons/advice_24x24.png",
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect(conceptTypeDetail.textColor).toBe("#000000");
|
|
19
|
+
expect(conceptTypeDetail.backgroundColor).toBe("#FFFF3C");
|
|
20
|
+
expect(conceptTypeDetail.borderColor).toBe("#000000");
|
|
21
|
+
|
|
22
|
+
expect(conceptTypeDetail.conceptTypeHierarchy.length).toBe(2);
|
|
23
|
+
expect(
|
|
24
|
+
conceptTypeDetail.isOfConceptType(
|
|
25
|
+
"Adviceandrequestbusinessscenarios#ScenarioStep_Advice",
|
|
26
|
+
),
|
|
27
|
+
).toBe(true);
|
|
28
|
+
expect(
|
|
29
|
+
conceptTypeDetail.isOfConceptType("BusinessScenarios#ScenarioStep"),
|
|
30
|
+
).toBe(true);
|
|
31
|
+
expect(conceptTypeDetail.isOfConceptType("BEI_CaseManagement#Case")).toBe(
|
|
32
|
+
false,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(
|
|
36
|
+
conceptTypeDetail.isOfConceptType(
|
|
37
|
+
"/concepttypes/bundle-com.beinformed.fs.demo.metamodels/Business%20scenarios.bixml/ScenarioStep",
|
|
38
|
+
),
|
|
39
|
+
).toBe(true);
|
|
40
|
+
|
|
41
|
+
expect(
|
|
42
|
+
conceptTypeDetail.hasMetamodelIdInHierarchy("BusinessScenarios"),
|
|
43
|
+
).toBe(true);
|
|
44
|
+
expect(
|
|
45
|
+
conceptTypeDetail.hasMetamodelIdInHierarchy("BEI_CaseManagement"),
|
|
46
|
+
).toBe(false);
|
|
9
47
|
});
|
|
10
48
|
});
|
|
@@ -44,6 +44,13 @@ export default class LinkCollection extends BaseCollection<LinkModel> {
|
|
|
44
44
|
return this.links.find((link) => link.key === key) || null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Indicate if a link by key exists
|
|
49
|
+
*/
|
|
50
|
+
hasLinkByKey(key: string): boolean {
|
|
51
|
+
return this.all.some((link) => link.key === key);
|
|
52
|
+
}
|
|
53
|
+
|
|
47
54
|
/**
|
|
48
55
|
* Get a link by it's Href
|
|
49
56
|
*/
|
|
@@ -51,6 +58,13 @@ export default class LinkCollection extends BaseCollection<LinkModel> {
|
|
|
51
58
|
return this.links.find((link) => link.href.equals(href)) || null;
|
|
52
59
|
}
|
|
53
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Indicate if a link by href exists
|
|
63
|
+
*/
|
|
64
|
+
hasLinkByHref(href: Href | string): boolean {
|
|
65
|
+
return this.all.some((link) => link.href.equals(href));
|
|
66
|
+
}
|
|
67
|
+
|
|
54
68
|
/**
|
|
55
69
|
* Getting the links by group key. For instance getting all 'tab' links of the web application.
|
|
56
70
|
*/
|
|
@@ -47,7 +47,7 @@ class UserServicesModel extends ResourceModel {
|
|
|
47
47
|
*/
|
|
48
48
|
setChildModels(models: Array<ModularUIModel>, errors: Array<ErrorResponse>) {
|
|
49
49
|
this.mustChangePassword = Array.isArray(errors)
|
|
50
|
-
? errors.some((error) => error.isChangePassword) ?? false
|
|
50
|
+
? (errors.some((error) => error.isChangePassword) ?? false)
|
|
51
51
|
: false;
|
|
52
52
|
this.user = models.find((model) => model.type === "User");
|
|
53
53
|
}
|