@beinformed/ui 1.52.2 → 1.54.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/esm/hooks/useModelCatalog.js +57 -9
  3. package/esm/hooks/useModelCatalog.js.map +1 -1
  4. package/esm/hooks/useModularUIBasic.js +5 -1
  5. package/esm/hooks/useModularUIBasic.js.map +1 -1
  6. package/esm/redux/_modularui/ModularUIActions.js +1 -0
  7. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  8. package/esm/redux/_modularui/ModularUIMiddleware.js +2 -1
  9. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  10. package/esm/redux/_modularui/types.js.map +1 -1
  11. package/lib/hooks/useModelCatalog.js +60 -9
  12. package/lib/hooks/useModelCatalog.js.flow +69 -1
  13. package/lib/hooks/useModelCatalog.js.map +1 -1
  14. package/lib/hooks/useModularUIBasic.js +5 -1
  15. package/lib/hooks/useModularUIBasic.js.flow +7 -1
  16. package/lib/hooks/useModularUIBasic.js.map +1 -1
  17. package/lib/redux/_modularui/ModularUIActions.js +1 -0
  18. package/lib/redux/_modularui/ModularUIActions.js.flow +1 -0
  19. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  20. package/lib/redux/_modularui/ModularUIMiddleware.js +2 -1
  21. package/lib/redux/_modularui/ModularUIMiddleware.js.flow +2 -0
  22. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  23. package/lib/redux/_modularui/types.js.flow +1 -0
  24. package/lib/redux/_modularui/types.js.map +1 -1
  25. package/package.json +15 -15
  26. package/src/hooks/useModelCatalog.js +69 -1
  27. package/src/hooks/useModularUIBasic.js +7 -1
  28. package/src/redux/_modularui/ModularUIActions.js +1 -0
  29. package/src/redux/_modularui/ModularUIMiddleware.js +2 -0
  30. package/src/redux/_modularui/types.js +1 -0
  31. package/types/models/concepts/ConceptDetailModel.d.ts +9 -1
  32. package/types/models/concepts/ConceptLinkModel.d.ts +8 -0
  33. package/types/models/concepts/ConceptTypeDetailModel.d.ts +19 -0
  34. package/types/models/content/ContentIndexModel.d.ts +3 -0
  35. package/types/models/links/LinkCollection.d.ts +8 -0
  36. package/types/redux/_modularui/types.d.ts +1 -0
@@ -14,12 +14,23 @@ import ContentModel from "../models/content/ContentModel";
14
14
  import { useModularUIBasic } from "./useModularUIBasic";
15
15
  import { ContentTypeModel } from "../models";
16
16
 
17
+ import type { UseModularUIBasicOptions } from "./useModularUIBasic";
18
+ export type SearchFilter = {
19
+ index?: string,
20
+ label?: string,
21
+ type?: string | Array<string>,
22
+ entryDate?: string,
23
+ };
24
+
17
25
  /**
18
26
  */
19
- export const useModelCatalog = (): ?ModelCatalogModel =>
27
+ export const useModelCatalog = (
28
+ options?: UseModularUIBasicOptions<ModelCatalogModel>,
29
+ ): ?ModelCatalogModel =>
20
30
  useModularUIBasic("modelcatalog", "/modelcatalog", {
21
31
  expectedModels: ["ModelCatalog"],
22
32
  targetModel: ModelCatalogModel,
33
+ ...options,
23
34
  });
24
35
 
25
36
  /**
@@ -27,11 +38,13 @@ export const useModelCatalog = (): ?ModelCatalogModel =>
27
38
  export const useConceptIndex = (
28
39
  href: string,
29
40
  key?: string = "conceptindex",
41
+ options?: UseModularUIBasicOptions<ConceptIndexModel>,
30
42
  ): ?ConceptIndexModel => {
31
43
  const url = filterParameters(href, ["entryDate", "index", "label", "type"]);
32
44
  return useModularUIBasic(key, url, {
33
45
  expectedModels: ["ConceptIndex"],
34
46
  targetModel: ConceptIndexModel,
47
+ ...options,
35
48
  });
36
49
  };
37
50
 
@@ -40,12 +53,16 @@ export const useConceptIndex = (
40
53
  export const useConceptDetail = (
41
54
  concept: string,
42
55
  key?: string = "conceptdetail",
56
+ options?: UseModularUIBasicOptions<
57
+ ConceptDetailModel | BusinessScenarioModel,
58
+ >,
43
59
  ): ?ConceptDetailModel | ?BusinessScenarioModel => {
44
60
  const location = useLocation();
45
61
 
46
62
  const href = createHref("concepts", concept, location, ["entryDate"]);
47
63
  return useModularUIBasic(key, href, {
48
64
  expectedModels: ["ConceptDetail", "BusinessScenario"],
65
+ ...options,
49
66
  });
50
67
  };
51
68
 
@@ -54,11 +71,13 @@ export const useConceptDetail = (
54
71
  export const useContentIndex = (
55
72
  href: string,
56
73
  key?: string = "contentindex",
74
+ options?: UseModularUIBasicOptions<ContentIndexModel>,
57
75
  ): ?ContentIndexModel => {
58
76
  const url = filterParameters(href, ["index", "label", "type"]);
59
77
  return useModularUIBasic(key, url, {
60
78
  expectedModels: ["ContentIndex"],
61
79
  targetModel: ContentIndexModel,
80
+ ...options,
62
81
  });
63
82
  };
64
83
 
@@ -67,12 +86,14 @@ export const useContentIndex = (
67
86
  export const useContentTOC = (
68
87
  content: string,
69
88
  key?: string = "contenttoc",
89
+ options?: UseModularUIBasicOptions<ContentTOCModel>,
70
90
  ): ?ContentTOCModel => {
71
91
  const location = useLocation();
72
92
  const href = createHref("content", content, location, ["entryDate"]);
73
93
  return useModularUIBasic(key, href, {
74
94
  expectedModels: ["ContentTOC"],
75
95
  targetModel: ContentTOCModel,
96
+ ...options,
76
97
  });
77
98
  };
78
99
 
@@ -81,11 +102,13 @@ export const useContentTOC = (
81
102
  export const useContent = (
82
103
  contentSection: string,
83
104
  key?: string = "content",
105
+ options?: UseModularUIBasicOptions<ContentModel>,
84
106
  ): ?ContentModel => {
85
107
  const href = createHref("content", contentSection, null, ["entryDate"]);
86
108
  return useModularUIBasic(key, href, {
87
109
  expectedModels: ["Content"],
88
110
  targetModel: ContentModel,
111
+ ...options,
89
112
  });
90
113
  };
91
114
 
@@ -94,10 +117,55 @@ export const useContent = (
94
117
  export const useContentType = (
95
118
  contentType: string,
96
119
  key?: string = "contenttypes",
120
+ options?: UseModularUIBasicOptions<ContentTypeModel>,
97
121
  ): ?ContentTypeModel => {
98
122
  const href = createHref("contenttypes", contentType, null, ["entryDate"]);
99
123
  return useModularUIBasic(key, href, {
100
124
  expectedModels: ["ContentType"],
101
125
  targetModel: ContentTypeModel,
126
+ ...options,
102
127
  });
103
128
  };
129
+
130
+ /**
131
+ */
132
+ const getSearchHref = (uri: string, filters: SearchFilter): string => {
133
+ const filterString = [];
134
+
135
+ for (const key of Object.keys(filters)) {
136
+ const filterValue = filters[key];
137
+ if (filterValue) {
138
+ let value: string = Array.isArray(filterValue)
139
+ ? filterValue.join(",")
140
+ : filterValue;
141
+ if (key === "type") {
142
+ value = value.replace("#", "%23"); // handles un-encoded #
143
+ }
144
+ filterString.push(`${key}=${value}`);
145
+ }
146
+ }
147
+
148
+ return filterString.length ? `${uri}?${filterString.join("&")}` : uri;
149
+ };
150
+
151
+ /**
152
+ */
153
+ export const useConceptSearch = (
154
+ filters: SearchFilter,
155
+ key?: string = "conceptSearch",
156
+ options?: UseModularUIBasicOptions<ConceptIndexModel>,
157
+ ): ?ConceptIndexModel => {
158
+ const href = getSearchHref("/concepts", filters);
159
+ return useConceptIndex(href, key, options);
160
+ };
161
+
162
+ /**
163
+ */
164
+ export const useContentSearch = (
165
+ filters: SearchFilter,
166
+ key?: string = "contentSearch",
167
+ options?: UseModularUIBasicOptions<ContentIndexModel>,
168
+ ): ?ContentIndexModel => {
169
+ const href = getSearchHref("/content", filters);
170
+ return useContentIndex(href, key, options);
171
+ };
@@ -7,10 +7,11 @@ import { IllegalStateException } from "../exceptions";
7
7
 
8
8
  import type { ModularUIModel, Href } from "../models";
9
9
 
10
- type UseModularUIBasicOptions<T: ModularUIModel> = {
10
+ export type UseModularUIBasicOptions<T: ModularUIModel> = {
11
11
  expectedModels: Array<string>,
12
12
  targetModel?: Class<T> | Array<Class<T>>,
13
13
  forceTargetModel?: boolean,
14
+ cache?: boolean,
14
15
  };
15
16
 
16
17
  /**
@@ -30,12 +31,17 @@ export const useModularUIBasic = <T: ModularUIModel>(
30
31
  targetModel: undefined,
31
32
  forceTargetModel: undefined,
32
33
  isReload: false,
34
+ cache: false,
33
35
  };
34
36
  if (options.targetModel) {
35
37
  useModularUIOptions.targetModel = options.targetModel;
36
38
  useModularUIOptions.forceTargetModel = options.forceTargetModel;
37
39
  }
38
40
 
41
+ if (options.cache) {
42
+ useModularUIOptions.cache = options.cache;
43
+ }
44
+
39
45
  // reload when the modular service starts with the current location
40
46
  if (location.state?.reload && location.pathname.startsWith(href.toString())) {
41
47
  useModularUIOptions.isReload = true;
@@ -116,6 +116,7 @@ export const loadModel = (
116
116
  childmodels: options?.childmodels,
117
117
  targetModel: options?.targetModel,
118
118
  forceTargetModel: options?.forceTargetModel,
119
+ cache: options?.cache,
119
120
  /**
120
121
  */
121
122
  successAction: (model) =>
@@ -27,6 +27,7 @@ type RequestOptions = {
27
27
  targetModel?: TargetModel,
28
28
  forceTargetModel?: boolean,
29
29
  isReload?: boolean,
30
+ cache?: boolean,
30
31
  };
31
32
 
32
33
  /**
@@ -39,6 +40,7 @@ const createRequest = (modularui: RequestOptions): ModularUIRequest => {
39
40
  locale: modularui.locale,
40
41
  childmodels: modularui.childmodels ?? true,
41
42
  isReload: modularui.isReload,
43
+ cache: modularui.cache,
42
44
  });
43
45
 
44
46
  if (modularui.targetModel) {
@@ -72,6 +72,7 @@ export type ModularUIAction = {
72
72
  childmodels?: boolean,
73
73
  targetModel?: TargetModel,
74
74
  forceTargetModel?: boolean,
75
+ cache?: boolean,
75
76
  successAction: (
76
77
  model: ModularUIModel,
77
78
  ) => UpdateModelAction | SetModelAction,
@@ -60,9 +60,17 @@ export default class ConceptDetailModel extends ResourceModel {
60
60
  */
61
61
  getSourceReferencesForCurrentLanguage(availableLocales: Array<string>): Array<Object>;
62
62
  /**
63
- * Retrieve entrydate of content toc
63
+ * Retrieve entrydate
64
64
  */
65
65
  get entryDate(): string;
66
+ /**
67
+ * Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept
68
+ */
69
+ isOfConceptType(conceptTypeId: string): boolean;
70
+ /**
71
+ * Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
72
+ */
73
+ hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean;
66
74
  }
67
75
  import ResourceModel from "../base/ResourceModel";
68
76
  import ConceptRelationCollection from "./ConceptRelationCollection";
@@ -56,6 +56,14 @@ export default class ConceptLinkModel extends BaseModel {
56
56
  /**
57
57
  */
58
58
  asLinkModel(): LinkModel;
59
+ /**
60
+ * Indicates if the given concept type id or href exists in the hierarchy of concept types for this concept
61
+ */
62
+ isOfConceptType(conceptTypeId: string): boolean;
63
+ /**
64
+ * Indicates if the given metamodel functional identifier exists in the hierarchy of concept types for this concept
65
+ */
66
+ hasMetamodelIdInConceptTypeHierarchy(metamodelId: string): boolean;
59
67
  }
60
68
  import BaseModel from "../base/BaseModel";
61
69
  import LinkCollection from "../links/LinkCollection";
@@ -3,6 +3,14 @@ export default ConceptTypeDetailModel;
3
3
  * Model for concept details, available through modelcatalog
4
4
  */
5
5
  declare class ConceptTypeDetailModel extends ResourceModel {
6
+ /**
7
+ * The name of the concept type consists of the functional id of the kmt and the functional id of the concept type separated by a #.<br>
8
+ * For example BEI_CaseManagement#Case
9
+ */
10
+ get name(): string;
11
+ /**
12
+ */
13
+ get isCoreTaxonomy(): boolean;
6
14
  /**
7
15
  * Get concept type icon
8
16
  */
@@ -35,5 +43,16 @@ declare class ConceptTypeDetailModel extends ResourceModel {
35
43
  * Get sectionReferenceTypes
36
44
  */
37
45
  get sectionReferenceTypes(): Object[];
46
+ /**
47
+ */
48
+ get conceptTypeHierarchy(): LinkCollection;
49
+ /**
50
+ */
51
+ isOfConceptType(conceptTypeId: string): boolean;
52
+ /**
53
+ * Indicates if the given metamodel functional identifier exists in the hierarchy of concept types
54
+ */
55
+ hasMetamodelIdInHierarchy(metamodelId: string): boolean;
38
56
  }
39
57
  import ResourceModel from "../base/ResourceModel";
58
+ import LinkCollection from "../links/LinkCollection";
@@ -19,6 +19,9 @@ export default class ContentIndexModel extends ResourceModel {
19
19
  /**
20
20
  */
21
21
  hasIndexFilter(): boolean;
22
+ /**
23
+ */
24
+ hasFiltersSet(): boolean;
22
25
  /**
23
26
  */
24
27
  hasNoFiltersSet(): boolean;
@@ -20,10 +20,18 @@ export default class LinkCollection extends BaseCollection<LinkModel> {
20
20
  * Get a link by it's key, handy for getting the self link
21
21
  */
22
22
  getLinkByKey(key: string): LinkModel | null;
23
+ /**
24
+ * Indicate if a link by key exists
25
+ */
26
+ hasLinkByKey(key: string): boolean;
23
27
  /**
24
28
  * Get a link by it's Href
25
29
  */
26
30
  getLinkByHref(href: Href | string): LinkModel | null;
31
+ /**
32
+ * Indicate if a link by href exists
33
+ */
34
+ hasLinkByHref(href: Href | string): boolean;
27
35
  /**
28
36
  * Getting the links by group key. For instance getting all 'tab' links of the web application.
29
37
  */
@@ -39,6 +39,7 @@ type ModularUIAction = {
39
39
  childmodels?: boolean;
40
40
  targetModel?: any;
41
41
  forceTargetModel?: boolean;
42
+ cache?: boolean;
42
43
  successAction: (model: ModularUIModel) => SetModelAction | UpdateModelAction;
43
44
  errorAction?: ErrorAction;
44
45
  };