@beinformed/ui 1.25.1 → 1.25.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.
Files changed (254) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/esm/constants/Constants.js +5 -0
  3. package/esm/constants/Constants.js.map +1 -1
  4. package/esm/hooks/useAuthentication.js +5 -5
  5. package/esm/hooks/useAuthentication.js.map +1 -1
  6. package/esm/hooks/useModularUI.js.map +1 -1
  7. package/esm/hooks/useModularUIBasic.js +3 -0
  8. package/esm/hooks/useModularUIBasic.js.map +1 -1
  9. package/esm/hooks/useModularUIModel.js +7 -0
  10. package/esm/hooks/useModularUIModel.js.map +1 -1
  11. package/esm/hooks/useModularUIRequest.js +5 -7
  12. package/esm/hooks/useModularUIRequest.js.map +1 -1
  13. package/esm/models/application/ApplicationModel.js +9 -1
  14. package/esm/models/application/ApplicationModel.js.map +1 -1
  15. package/esm/models/base/BaseModel.js +11 -2
  16. package/esm/models/base/BaseModel.js.map +1 -1
  17. package/esm/models/base/ResourceModel.js +8 -1
  18. package/esm/models/base/ResourceModel.js.map +1 -1
  19. package/esm/models/caseview/CaseViewModel.js +6 -0
  20. package/esm/models/caseview/CaseViewModel.js.map +1 -1
  21. package/esm/models/concepts/BusinessScenarioModel.js +6 -0
  22. package/esm/models/concepts/BusinessScenarioModel.js.map +1 -1
  23. package/esm/models/concepts/ConceptDetailModel.js +6 -0
  24. package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
  25. package/esm/models/concepts/ConceptIndexModel.js +6 -0
  26. package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
  27. package/esm/models/concepts/ConceptTypeDetailModel.js +6 -0
  28. package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
  29. package/esm/models/content/ContentIndexModel.js +6 -0
  30. package/esm/models/content/ContentIndexModel.js.map +1 -1
  31. package/esm/models/content/ContentModel.js +6 -0
  32. package/esm/models/content/ContentModel.js.map +1 -1
  33. package/esm/models/content/ContentTOCModel.js +6 -0
  34. package/esm/models/content/ContentTOCModel.js.map +1 -1
  35. package/esm/models/content/ContentTypeModel.js +6 -0
  36. package/esm/models/content/ContentTypeModel.js.map +1 -1
  37. package/esm/models/detail/DetailModel.js +6 -0
  38. package/esm/models/detail/DetailModel.js.map +1 -1
  39. package/esm/models/form/FormModel.js +6 -0
  40. package/esm/models/form/FormModel.js.map +1 -1
  41. package/esm/models/form/FormObjectModel.js +45 -16
  42. package/esm/models/form/FormObjectModel.js.map +1 -1
  43. package/esm/models/list/ListDetailModel.js +6 -0
  44. package/esm/models/list/ListDetailModel.js.map +1 -1
  45. package/esm/models/list/ListModel.js +6 -0
  46. package/esm/models/list/ListModel.js.map +1 -1
  47. package/esm/models/lookup/LookupOptionsModel.js +6 -0
  48. package/esm/models/lookup/LookupOptionsModel.js.map +1 -1
  49. package/esm/models/modelcatalog/ModelCatalogModel.js +6 -0
  50. package/esm/models/modelcatalog/ModelCatalogModel.js.map +1 -1
  51. package/esm/models/panels/GroupingPanelModel.js +6 -0
  52. package/esm/models/panels/GroupingPanelModel.js.map +1 -1
  53. package/esm/models/resolveModel.js +4 -4
  54. package/esm/models/resolveModel.js.map +1 -1
  55. package/esm/models/search/CaseSearchModel.js +6 -0
  56. package/esm/models/search/CaseSearchModel.js.map +1 -1
  57. package/esm/models/tab/TabModel.js +6 -0
  58. package/esm/models/tab/TabModel.js.map +1 -1
  59. package/esm/models/taskgroup/TaskGroupModel.js +6 -0
  60. package/esm/models/taskgroup/TaskGroupModel.js.map +1 -1
  61. package/esm/models/types.js.map +1 -1
  62. package/esm/models/user/UserModel.js +6 -0
  63. package/esm/models/user/UserModel.js.map +1 -1
  64. package/esm/models/user/UserProfileModel.js +6 -0
  65. package/esm/models/user/UserProfileModel.js.map +1 -1
  66. package/esm/models/user/UserServicesModel.js +6 -0
  67. package/esm/models/user/UserServicesModel.js.map +1 -1
  68. package/esm/modularui/ModularUIRequest.js +38 -11
  69. package/esm/modularui/ModularUIRequest.js.map +1 -1
  70. package/esm/modularui/types.js +2 -0
  71. package/esm/modularui/types.js.map +1 -0
  72. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  73. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  74. package/esm/redux/_modularui/types.js.map +1 -1
  75. package/esm/redux/_modularui/withModularUI.js.map +1 -1
  76. package/esm/utils/fetch/types.js.map +1 -1
  77. package/lib/constants/Constants.js +7 -1
  78. package/lib/constants/Constants.js.flow +6 -0
  79. package/lib/constants/Constants.js.map +1 -1
  80. package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +1 -1
  81. package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +1 -1
  82. package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +2 -2
  83. package/lib/hooks/useAuthentication.js +4 -4
  84. package/lib/hooks/useAuthentication.js.flow +17 -5
  85. package/lib/hooks/useAuthentication.js.map +1 -1
  86. package/lib/hooks/useModularUI.js.flow +2 -2
  87. package/lib/hooks/useModularUI.js.map +1 -1
  88. package/lib/hooks/useModularUIBasic.js +3 -0
  89. package/lib/hooks/useModularUIBasic.js.flow +6 -3
  90. package/lib/hooks/useModularUIBasic.js.map +1 -1
  91. package/lib/hooks/useModularUIModel.js +9 -1
  92. package/lib/hooks/useModularUIModel.js.flow +18 -10
  93. package/lib/hooks/useModularUIModel.js.map +1 -1
  94. package/lib/hooks/useModularUIRequest.js +5 -7
  95. package/lib/hooks/useModularUIRequest.js.flow +12 -11
  96. package/lib/hooks/useModularUIRequest.js.map +1 -1
  97. package/lib/models/application/ApplicationModel.js +8 -1
  98. package/lib/models/application/ApplicationModel.js.flow +10 -1
  99. package/lib/models/application/ApplicationModel.js.map +1 -1
  100. package/lib/models/base/BaseModel.js +11 -2
  101. package/lib/models/base/BaseModel.js.flow +12 -3
  102. package/lib/models/base/BaseModel.js.map +1 -1
  103. package/lib/models/base/ResourceModel.js +8 -1
  104. package/lib/models/base/ResourceModel.js.flow +8 -1
  105. package/lib/models/base/ResourceModel.js.map +1 -1
  106. package/lib/models/caseview/CaseViewModel.js +6 -0
  107. package/lib/models/caseview/CaseViewModel.js.flow +6 -0
  108. package/lib/models/caseview/CaseViewModel.js.map +1 -1
  109. package/lib/models/concepts/BusinessScenarioModel.js +6 -0
  110. package/lib/models/concepts/BusinessScenarioModel.js.flow +6 -0
  111. package/lib/models/concepts/BusinessScenarioModel.js.map +1 -1
  112. package/lib/models/concepts/ConceptDetailModel.js +6 -0
  113. package/lib/models/concepts/ConceptDetailModel.js.flow +6 -0
  114. package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
  115. package/lib/models/concepts/ConceptIndexModel.js +6 -0
  116. package/lib/models/concepts/ConceptIndexModel.js.flow +6 -0
  117. package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
  118. package/lib/models/concepts/ConceptTypeDetailModel.js +6 -0
  119. package/lib/models/concepts/ConceptTypeDetailModel.js.flow +6 -0
  120. package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
  121. package/lib/models/content/ContentIndexModel.js +6 -0
  122. package/lib/models/content/ContentIndexModel.js.flow +6 -0
  123. package/lib/models/content/ContentIndexModel.js.map +1 -1
  124. package/lib/models/content/ContentModel.js +6 -0
  125. package/lib/models/content/ContentModel.js.flow +6 -0
  126. package/lib/models/content/ContentModel.js.map +1 -1
  127. package/lib/models/content/ContentTOCModel.js +6 -0
  128. package/lib/models/content/ContentTOCModel.js.flow +6 -0
  129. package/lib/models/content/ContentTOCModel.js.map +1 -1
  130. package/lib/models/content/ContentTypeModel.js +6 -0
  131. package/lib/models/content/ContentTypeModel.js.flow +6 -0
  132. package/lib/models/content/ContentTypeModel.js.map +1 -1
  133. package/lib/models/detail/DetailModel.js +6 -0
  134. package/lib/models/detail/DetailModel.js.flow +6 -0
  135. package/lib/models/detail/DetailModel.js.map +1 -1
  136. package/lib/models/form/FormModel.js +6 -0
  137. package/lib/models/form/FormModel.js.flow +6 -0
  138. package/lib/models/form/FormModel.js.map +1 -1
  139. package/lib/models/form/FormObjectModel.js +45 -16
  140. package/lib/models/form/FormObjectModel.js.flow +71 -24
  141. package/lib/models/form/FormObjectModel.js.map +1 -1
  142. package/lib/models/form/__tests__/FormModel.repeating.spec.js.flow +4 -0
  143. package/lib/models/list/ListDetailModel.js +6 -0
  144. package/lib/models/list/ListDetailModel.js.flow +6 -0
  145. package/lib/models/list/ListDetailModel.js.map +1 -1
  146. package/lib/models/list/ListModel.js +6 -0
  147. package/lib/models/list/ListModel.js.flow +6 -0
  148. package/lib/models/list/ListModel.js.map +1 -1
  149. package/lib/models/lookup/LookupOptionsModel.js +6 -0
  150. package/lib/models/lookup/LookupOptionsModel.js.flow +6 -0
  151. package/lib/models/lookup/LookupOptionsModel.js.map +1 -1
  152. package/lib/models/modelcatalog/ModelCatalogModel.js +6 -0
  153. package/lib/models/modelcatalog/ModelCatalogModel.js.flow +6 -0
  154. package/lib/models/modelcatalog/ModelCatalogModel.js.map +1 -1
  155. package/lib/models/panels/GroupingPanelModel.js +6 -0
  156. package/lib/models/panels/GroupingPanelModel.js.flow +6 -0
  157. package/lib/models/panels/GroupingPanelModel.js.map +1 -1
  158. package/lib/models/resolveModel.js +4 -3
  159. package/lib/models/resolveModel.js.flow +6 -4
  160. package/lib/models/resolveModel.js.map +1 -1
  161. package/lib/models/search/CaseSearchModel.js +6 -0
  162. package/lib/models/search/CaseSearchModel.js.flow +6 -0
  163. package/lib/models/search/CaseSearchModel.js.map +1 -1
  164. package/lib/models/tab/TabModel.js +6 -0
  165. package/lib/models/tab/TabModel.js.flow +6 -0
  166. package/lib/models/tab/TabModel.js.map +1 -1
  167. package/lib/models/taskgroup/TaskGroupModel.js +6 -0
  168. package/lib/models/taskgroup/TaskGroupModel.js.flow +6 -0
  169. package/lib/models/taskgroup/TaskGroupModel.js.map +1 -1
  170. package/lib/models/types.js.flow +1 -1
  171. package/lib/models/types.js.map +1 -1
  172. package/lib/models/user/UserModel.js +6 -0
  173. package/lib/models/user/UserModel.js.flow +6 -0
  174. package/lib/models/user/UserModel.js.map +1 -1
  175. package/lib/models/user/UserProfileModel.js +6 -0
  176. package/lib/models/user/UserProfileModel.js.flow +6 -0
  177. package/lib/models/user/UserProfileModel.js.map +1 -1
  178. package/lib/models/user/UserServicesModel.js +6 -0
  179. package/lib/models/user/UserServicesModel.js.flow +6 -0
  180. package/lib/models/user/UserServicesModel.js.map +1 -1
  181. package/lib/modularui/ModularUIRequest.js +38 -11
  182. package/lib/modularui/ModularUIRequest.js.flow +65 -17
  183. package/lib/modularui/ModularUIRequest.js.map +1 -1
  184. package/lib/modularui/__tests__/ModularUIRequest.spec.js.flow +4 -9
  185. package/lib/modularui/types.js +2 -0
  186. package/lib/modularui/types.js.flow +4 -0
  187. package/lib/modularui/types.js.map +1 -0
  188. package/lib/redux/_modularui/ModularUIActions.js.flow +4 -4
  189. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  190. package/lib/redux/_modularui/ModularUIMiddleware.js.flow +3 -2
  191. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  192. package/lib/redux/_modularui/types.js.flow +4 -3
  193. package/lib/redux/_modularui/types.js.map +1 -1
  194. package/lib/redux/_modularui/withModularUI.js.flow +2 -2
  195. package/lib/redux/_modularui/withModularUI.js.map +1 -1
  196. package/lib/utils/fetch/types.js.flow +12 -4
  197. package/lib/utils/fetch/types.js.map +1 -1
  198. package/package.json +7 -7
  199. package/src/constants/Constants.js +6 -0
  200. package/src/hooks/__tests__/UseModularUIModel.spec.js +1 -1
  201. package/src/hooks/__tests__/useModelCatalog.spec.js +1 -1
  202. package/src/hooks/__tests__/useModularUIBasic.spec.js +2 -2
  203. package/src/hooks/useAuthentication.js +17 -5
  204. package/src/hooks/useModularUI.js +2 -2
  205. package/src/hooks/useModularUIBasic.js +6 -3
  206. package/src/hooks/useModularUIModel.js +18 -10
  207. package/src/hooks/useModularUIRequest.js +12 -11
  208. package/src/models/application/ApplicationModel.js +10 -1
  209. package/src/models/base/BaseModel.js +12 -3
  210. package/src/models/base/ResourceModel.js +8 -1
  211. package/src/models/caseview/CaseViewModel.js +6 -0
  212. package/src/models/concepts/BusinessScenarioModel.js +6 -0
  213. package/src/models/concepts/ConceptDetailModel.js +6 -0
  214. package/src/models/concepts/ConceptIndexModel.js +6 -0
  215. package/src/models/concepts/ConceptTypeDetailModel.js +6 -0
  216. package/src/models/content/ContentIndexModel.js +6 -0
  217. package/src/models/content/ContentModel.js +6 -0
  218. package/src/models/content/ContentTOCModel.js +6 -0
  219. package/src/models/content/ContentTypeModel.js +6 -0
  220. package/src/models/detail/DetailModel.js +6 -0
  221. package/src/models/form/FormModel.js +6 -0
  222. package/src/models/form/FormObjectModel.js +71 -24
  223. package/src/models/form/__tests__/FormModel.repeating.spec.js +4 -0
  224. package/src/models/list/ListDetailModel.js +6 -0
  225. package/src/models/list/ListModel.js +6 -0
  226. package/src/models/lookup/LookupOptionsModel.js +6 -0
  227. package/src/models/modelcatalog/ModelCatalogModel.js +6 -0
  228. package/src/models/panels/GroupingPanelModel.js +6 -0
  229. package/src/models/resolveModel.js +6 -4
  230. package/src/models/search/CaseSearchModel.js +6 -0
  231. package/src/models/tab/TabModel.js +6 -0
  232. package/src/models/taskgroup/TaskGroupModel.js +6 -0
  233. package/src/models/types.js +1 -1
  234. package/src/models/user/UserModel.js +6 -0
  235. package/src/models/user/UserProfileModel.js +6 -0
  236. package/src/models/user/UserServicesModel.js +6 -0
  237. package/src/modularui/ModularUIRequest.js +65 -17
  238. package/src/modularui/__tests__/ModularUIRequest.spec.js +4 -9
  239. package/src/modularui/types.js +4 -0
  240. package/src/redux/_modularui/ModularUIActions.js +4 -4
  241. package/src/redux/_modularui/ModularUIMiddleware.js +3 -2
  242. package/src/redux/_modularui/types.js +4 -3
  243. package/src/redux/_modularui/withModularUI.js +2 -2
  244. package/src/utils/fetch/types.js +12 -4
  245. package/types/constants/Constants.d.ts +5 -0
  246. package/types/models/base/BaseModel.d.ts +12 -3
  247. package/types/models/base/ResourceModel.d.ts +5 -1
  248. package/types/models/form/FormObjectModel.d.ts +28 -0
  249. package/types/models/resolveModel.d.ts +1 -1
  250. package/types/models/types.d.ts +1 -1
  251. package/types/modularui/ModularUIRequest.d.ts +15 -7
  252. package/types/modularui/types.d.ts +2 -0
  253. package/types/redux/_modularui/types.d.ts +2 -2
  254. package/types/utils/fetch/types.d.ts +8 -5
@@ -5,7 +5,11 @@ import { getApplication } from "../redux/_modularui/ModularUISelectors";
5
5
  import { login, logout, resetAuthErrors } from "../redux/actions";
6
6
 
7
7
  import Cache from "../utils/browser/Cache";
8
- import { BASE, getSetting } from "../constants";
8
+ import {
9
+ BASE,
10
+ fallbackDefaultAuthenticationType,
11
+ getSetting,
12
+ } from "../constants";
9
13
 
10
14
  import type { ResetAuthErrorsAction } from "../redux/types";
11
15
  import type { AuthenticationType } from "../models/types";
@@ -38,7 +42,9 @@ export const useLogin = (): LoginHook => {
38
42
 
39
43
  return {
40
44
  isAuthenticated,
41
- authenticationTypes: application?.authenticationTypes ?? [],
45
+ authenticationTypes: application?.authenticationTypes ?? [
46
+ fallbackDefaultAuthenticationType,
47
+ ],
42
48
  errorMessage: auth.error,
43
49
  resetErrors: () => dispatch(resetAuthErrors()),
44
50
  login: (username: string, password: string) =>
@@ -47,13 +53,17 @@ export const useLogin = (): LoginHook => {
47
53
  if (Cache.getItem("isRedirectLogin")) {
48
54
  // prevent endless loop in redirects when authentication type can't be redirected
49
55
  throw new IllegalStateException(
50
- `Could not redirect to '${authenticationType.authentication}' using url: '${authenticationType.redirectUri}'`
56
+ `Could not redirect to '${
57
+ authenticationType.authentication
58
+ }' using url: '${authenticationType.redirectUri ?? ""}'`
51
59
  );
52
60
  }
53
61
 
54
62
  if (!isAuthenticated) {
55
63
  Cache.setItem("isRedirectLogin", true);
56
- window.location.assign(`${BASE}${authenticationType.redirectUri}`);
64
+ window.location.assign(
65
+ `${BASE}${authenticationType.redirectUri ?? ""}`
66
+ );
57
67
  }
58
68
  },
59
69
  };
@@ -70,7 +80,9 @@ export const useLogout = (): LogoutHook => {
70
80
  const isAuthenticated = application?.isLoggedIn ?? false;
71
81
  return {
72
82
  isAuthenticated,
73
- authenticationTypes: application?.authenticationTypes ?? [],
83
+ authenticationTypes: application?.authenticationTypes ?? [
84
+ fallbackDefaultAuthenticationType,
85
+ ],
74
86
  logout: () => {
75
87
  if (Cache.getItem("isRedirectLogin")) {
76
88
  const origin = window.location.origin;
@@ -1 +1 @@
1
- {"version":3,"file":"useAuthentication.js","names":["useLogin","Cache","setItem","dispatch","useDispatch","application","useSelector","getApplication","auth","state","isAuthenticated","isLoggedIn","authenticationTypes","errorMessage","error","resetErrors","resetAuthErrors","login","username","password","redirectLogin","authenticationType","getItem","IllegalStateException","authentication","redirectUri","window","location","assign","BASE","useLogout","LOGOUT_PATH","getSetting","logout","origin","url"],"sources":["../../src/hooks/useAuthentication.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\n\nimport { getApplication } from \"../redux/_modularui/ModularUISelectors\";\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport { BASE, getSetting } from \"../constants\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\nimport { IllegalStateException } from \"../exceptions\";\ntype LoginHook = {\n isAuthenticated: boolean,\n authenticationTypes: Array<AuthenticationType>,\n errorMessage: ?string,\n resetErrors: () => ResetAuthErrorsAction,\n login: (username: string, password: string) => void,\n redirectLogin: (authenticationType: AuthenticationType) => void,\n};\ntype LogoutHook = {\n isAuthenticated: boolean,\n authenticationTypes: Array<AuthenticationType>,\n logout: () => void,\n};\n\n/**\n */\nexport const useLogin = (): LoginHook => {\n Cache.setItem(\"isRedirectLogin\", false);\n\n const dispatch = useDispatch();\n\n const application = useSelector(getApplication);\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [],\n errorMessage: auth.error,\n resetErrors: () => dispatch(resetAuthErrors()),\n login: (username: string, password: string) =>\n dispatch(login(username, password)),\n redirectLogin: (authenticationType: AuthenticationType) => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n // prevent endless loop in redirects when authentication type can't be redirected\n throw new IllegalStateException(\n `Could not redirect to '${authenticationType.authentication}' using url: '${authenticationType.redirectUri}'`\n );\n }\n\n if (!isAuthenticated) {\n Cache.setItem(\"isRedirectLogin\", true);\n window.location.assign(`${BASE}${authenticationType.redirectUri}`);\n }\n },\n };\n};\n\n/**\n */\nexport const useLogout = (): LogoutHook => {\n const dispatch = useDispatch();\n const application = useSelector(getApplication);\n\n const LOGOUT_PATH = getSetting(\"LOGOUT_PATH\", \"/signout\");\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [],\n logout: () => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n const origin = window.location.origin;\n const url = `${origin}${BASE}/logout?url=${origin}${BASE}${LOGOUT_PATH}`;\n Cache.setItem(\"isRedirectLogin\", false);\n window.location.assign(url);\n } else {\n return dispatch(logout());\n }\n },\n };\n};\n"],"mappings":";;;;;;;AACA;AAEA;AACA;AAEA;AACA;AAIA;AAeA;AACA;AACO,MAAMA,QAAQ,GAAG,MAAiB;EACvCC,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;EAEvC,MAAMC,QAAQ,GAAG,IAAAC,uBAAW,GAAE;EAE9B,MAAMC,WAAW,GAAG,IAAAC,uBAAW,EAACC,kCAAc,CAAC;EAC/C,MAAMC,IAAI,GAAG,IAAAF,uBAAW,EAAEG,KAAK,IAAKA,KAAK,CAACD,IAAI,CAAC;EAE/C,MAAME,eAAe,GAAGL,WAAW,EAAEM,UAAU,IAAI,KAAK;EAExD,OAAO;IACLD,eAAe;IACfE,mBAAmB,EAAEP,WAAW,EAAEO,mBAAmB,IAAI,EAAE;IAC3DC,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EL,eAAK,GAAEE,WAAY,EAAC;QACxE9B,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;QACvCwB,MAAM,CAACC,QAAQ,CAACC,MAAM,CAACO,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,OAAOhC,QAAQ,CAAC,IAAA8B,eAAM,GAAE,CAAC;MAC3B;IACF;EACF,CAAC;AACH,CAAC;AAAC"}
1
+ {"version":3,"file":"useAuthentication.js","names":["useLogin","Cache","setItem","dispatch","useDispatch","application","useSelector","getApplication","auth","state","isAuthenticated","isLoggedIn","authenticationTypes","fallbackDefaultAuthenticationType","errorMessage","error","resetErrors","resetAuthErrors","login","username","password","redirectLogin","authenticationType","getItem","IllegalStateException","authentication","redirectUri","window","location","assign","BASE","useLogout","LOGOUT_PATH","getSetting","logout","origin","url"],"sources":["../../src/hooks/useAuthentication.js"],"sourcesContent":["// @flow\nimport { useSelector, useDispatch } from \"react-redux\";\n\nimport { getApplication } from \"../redux/_modularui/ModularUISelectors\";\nimport { login, logout, resetAuthErrors } from \"../redux/actions\";\n\nimport Cache from \"../utils/browser/Cache\";\nimport {\n BASE,\n fallbackDefaultAuthenticationType,\n getSetting,\n} from \"../constants\";\n\nimport type { ResetAuthErrorsAction } from \"../redux/types\";\nimport type { AuthenticationType } from \"../models/types\";\nimport { IllegalStateException } from \"../exceptions\";\ntype LoginHook = {\n isAuthenticated: boolean,\n authenticationTypes: Array<AuthenticationType>,\n errorMessage: ?string,\n resetErrors: () => ResetAuthErrorsAction,\n login: (username: string, password: string) => void,\n redirectLogin: (authenticationType: AuthenticationType) => void,\n};\ntype LogoutHook = {\n isAuthenticated: boolean,\n authenticationTypes: Array<AuthenticationType>,\n logout: () => void,\n};\n\n/**\n */\nexport const useLogin = (): LoginHook => {\n Cache.setItem(\"isRedirectLogin\", false);\n\n const dispatch = useDispatch();\n\n const application = useSelector(getApplication);\n const auth = useSelector((state) => state.auth);\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n fallbackDefaultAuthenticationType,\n ],\n errorMessage: auth.error,\n resetErrors: () => dispatch(resetAuthErrors()),\n login: (username: string, password: string) =>\n dispatch(login(username, password)),\n redirectLogin: (authenticationType: AuthenticationType) => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n // prevent endless loop in redirects when authentication type can't be redirected\n throw new IllegalStateException(\n `Could not redirect to '${\n authenticationType.authentication\n }' using url: '${authenticationType.redirectUri ?? \"\"}'`\n );\n }\n\n if (!isAuthenticated) {\n Cache.setItem(\"isRedirectLogin\", true);\n window.location.assign(\n `${BASE}${authenticationType.redirectUri ?? \"\"}`\n );\n }\n },\n };\n};\n\n/**\n */\nexport const useLogout = (): LogoutHook => {\n const dispatch = useDispatch();\n const application = useSelector(getApplication);\n\n const LOGOUT_PATH = getSetting(\"LOGOUT_PATH\", \"/signout\");\n\n const isAuthenticated = application?.isLoggedIn ?? false;\n return {\n isAuthenticated,\n authenticationTypes: application?.authenticationTypes ?? [\n fallbackDefaultAuthenticationType,\n ],\n logout: () => {\n if (Cache.getItem(\"isRedirectLogin\")) {\n const origin = window.location.origin;\n const url = `${origin}${BASE}/logout?url=${origin}${BASE}${LOGOUT_PATH}`;\n Cache.setItem(\"isRedirectLogin\", false);\n window.location.assign(url);\n } else {\n return dispatch(logout());\n }\n },\n };\n};\n"],"mappings":";;;;;;;AACA;AAEA;AACA;AAEA;AACA;AAQA;AAeA;AACA;AACO,MAAMA,QAAQ,GAAG,MAAiB;EACvCC,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;EAEvC,MAAMC,QAAQ,GAAG,IAAAC,uBAAW,GAAE;EAE9B,MAAMC,WAAW,GAAG,IAAAC,uBAAW,EAACC,kCAAc,CAAC;EAC/C,MAAMC,IAAI,GAAG,IAAAF,uBAAW,EAAEG,KAAK,IAAKA,KAAK,CAACD,IAAI,CAAC;EAE/C,MAAME,eAAe,GAAGL,WAAW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sB,OAAO,CAAC,iBAAiB,CAAC,EAAE;QACpC,MAAMY,MAAM,GAAGR,MAAM,CAACC,QAAQ,CAACO,MAAM;QACrC,MAAMC,GAAG,GAAI,GAAED,MAAO,GAAEL,eAAK,eAAcK,MAAO,GAAEL,eAAK,GAAEE,WAAY,EAAC;QACxE/B,cAAK,CAACC,OAAO,CAAC,iBAAiB,EAAE,KAAK,CAAC;QACvCyB,MAAM,CAACC,QAAQ,CAACC,MAAM,CAACO,GAAG,CAAC;MAC7B,CAAC,MAAM;QACL,OAAOjC,QAAQ,CAAC,IAAA+B,eAAM,GAAE,CAAC;MAC3B;IACF;EACF,CAAC;AACH,CAAC;AAAC"}
@@ -13,7 +13,7 @@ import useDeepCompareEffect from "./useDeepCompareEffect";
13
13
  import { useLocale } from "./useI18n";
14
14
 
15
15
  import type Href from "../models/href/Href";
16
- import type { RequestBaseOptions } from "../utils";
16
+ import type { RequestModularUIOptions } from "../utils";
17
17
 
18
18
  /**
19
19
  */
@@ -28,7 +28,7 @@ const useKeyForHook = (modelKey: string, url: string) => {
28
28
  export const useModularUI = (
29
29
  modelKey: string,
30
30
  url: string | Href,
31
- options: RequestBaseOptions = {
31
+ options: RequestModularUIOptions = {
32
32
  method: HTTP_METHODS.GET,
33
33
  removeOnUnmount: false,
34
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUI.js","names":["useKeyForHook","modelKey","url","locale","useLocale","split","useModularUI","options","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","prevOptions","useRef","prevHref","useDeepCompareEffect","isOldReload","current","isReload","loadModularUI","useEffect","removeModelByKey","useSelector","state","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\n\nimport type Href from \"../models/href/Href\";\nimport type { RequestBaseOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestBaseOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n }\n): any => {\n const dispatch = useDispatch();\n const href = url.toString();\n const key = useKeyForHook(modelKey, href);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n if (!isOldReload) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n }, [key, href, options]);\n\n const { removeOnUnmount = false } = options;\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(key));\n }\n };\n }, [dispatch, key, removeOnUnmount]);\n\n // retrieve current model from modularui reducer\n return useSelector((state) => {\n return state.modularui[key];\n });\n};\n"],"mappings":";;;;;;;AACA;AACA;AAEA;AACA;AAKA;AAEA;AAKA;AACA;AACA,MAAMA,aAAa,GAAG,CAACC,QAAgB,EAAEC,GAAW,KAAK;EACvD,MAAMC,MAAM,GAAG,IAAAC,kBAAS,GAAE;EAC1B,OAAQ,GAAEH,QAAS,IAAGC,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAE,KAAIF,MAAO,GAAE;AACvD,CAAC;;AAED;AACA;AACA;AACO,MAAMG,YAAY,GAAG,UAC1BL,QAAgB,EAChBC,GAAkB,EAKV;EAAA,IAJRK,OAA2B,uEAAG;IAC5BC,MAAM,EAAEC,uBAAY,CAACC,GAA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Key","url","locale","useLocale","split","useModularUI","options","method","HTTP_METHODS","GET","removeOnUnmount","dispatch","useDispatch","href","toString","key","prevOptions","useRef","prevHref","useDeepCompareEffect","isOldReload","current","isReload","loadModularUI","useEffect","removeModelByKey","useSelector","state","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\n\nimport type Href from \"../models/href/Href\";\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n }\n): any => {\n const dispatch = useDispatch();\n const href = url.toString();\n const key = useKeyForHook(modelKey, href);\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n if (!isOldReload) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n }, [key, href, options]);\n\n const { removeOnUnmount = false } = options;\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(key));\n }\n };\n }, [dispatch, key, removeOnUnmount]);\n\n // retrieve current model from modularui reducer\n return useSelector((state) => {\n return state.modularui[key];\n });\n};\n"],"mappings":";;;;;;;AACA;AACA;AAEA;AACA;AAKA;AAEA;AA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ACd,OAAO,MAAM;MACX,IAAId,eAAe,EAAE;QACnBC,QAAQ,CAAC,IAAAc,kCAAgB,EAACV,GAAG,CAAC,CAAC;MACjC;IACF,CAAC;EACH,CAAC,EAAE,CAACJ,QAAQ,EAAEI,GAAG,EAAEL,eAAe,CAAC,CAAC;;EAEpC;EACA,OAAO,IAAAgB,uBAAW,EAAEC,KAAK,IAAK;IAC5B,OAAOA,KAAK,CAACC,SAAS,CAACb,GAAG,CAAC;EAC7B,CAAC,CAAC;AACJ,CAAC;AAAC"}
@@ -33,6 +33,8 @@ const useModularUIBasic = function (key, href) {
33
33
  if (location.state?.reload && (0, _startsWith.default)(_context = location.pathname).call(_context, href.toString())) {
34
34
  useModularUIOptions.isReload = true;
35
35
  }
36
+
37
+ // $FlowFixMe[incompatible-call]
36
38
  const modularUI = (0, _useModularUI.useModularUI)(key, href, useModularUIOptions);
37
39
  if (modularUI?.model) {
38
40
  const {
@@ -49,6 +51,7 @@ const useModularUIBasic = function (key, href) {
49
51
  }
50
52
  return model;
51
53
  }
54
+ return null;
52
55
  };
53
56
  exports.useModularUIBasic = useModularUIBasic;
54
57
  //# sourceMappingURL=useModularUIBasic.js.map
@@ -7,9 +7,9 @@ import { IllegalArgumentException, IllegalStateException } from "../exceptions";
7
7
 
8
8
  import type { ModularUIModel, Href } from "../models";
9
9
 
10
- type UseModularUIBasicOptions<T> = {
10
+ type UseModularUIBasicOptions<T: ModularUIModel> = {
11
11
  expectedModels: Array<string>,
12
- targetModel?: Class<T>,
12
+ targetModel?: Class<T> | Array<Class<T>>,
13
13
  };
14
14
 
15
15
  /**
@@ -21,7 +21,7 @@ export const useModularUIBasic = <T: ModularUIModel>(
21
21
  expectedModels: [],
22
22
  targetModel: undefined,
23
23
  }
24
- ): ?T => {
24
+ ): T | null => {
25
25
  const location = useLocation();
26
26
  if (!href) {
27
27
  throw new IllegalArgumentException("Missing href");
@@ -37,6 +37,7 @@ export const useModularUIBasic = <T: ModularUIModel>(
37
37
  useModularUIOptions.isReload = true;
38
38
  }
39
39
 
40
+ // $FlowFixMe[incompatible-call]
40
41
  const modularUI = useModularUI(key, href, useModularUIOptions);
41
42
 
42
43
  if (modularUI?.model) {
@@ -54,4 +55,6 @@ export const useModularUIBasic = <T: ModularUIModel>(
54
55
 
55
56
  return model;
56
57
  }
58
+
59
+ return null;
57
60
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIBasic.js","names":["useModularUIBasic","key","href","options","expectedModels","targetModel","undefined","location","useLocation","IllegalArgumentException","useModularUIOptions","isReload","state","reload","pathname","toString","modularUI","useModularUI","model","length","isCorrectModel","some","expectedModel","type","console","error","IllegalStateException"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\ntype UseModularUIBasicOptions<T> = {\n expectedModels: Array<string>,\n targetModel?: Class<T>,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n }\n): ?T => {\n const location = useLocation();\n if (!href) {\n throw new IllegalArgumentException(\"Missing href\");\n }\n\n const useModularUIOptions = { targetModel: undefined, isReload: false };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n if (options.expectedModels.length > 0) {\n const isCorrectModel = options.expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", options.expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\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;MACtE;IACF;IAEA,OAAOR,KAAK;EACd;AACF,CAAC;AAAC"}
1
+ {"version":3,"file":"useModularUIBasic.js","names":["useModularUIBasic","key","href","options","expectedModels","targetModel","undefined","location","useLocation","IllegalArgumentException","useModularUIOptions","isReload","state","reload","pathname","toString","modularUI","useModularUI","model","length","isCorrectModel","some","expectedModel","type","console","error","IllegalStateException"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\ntype UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n }\n): T | null => {\n const location = useLocation();\n if (!href) {\n throw new IllegalArgumentException(\"Missing href\");\n }\n\n const useModularUIOptions = { targetModel: undefined, isReload: false };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n if (options.expectedModels.length > 0) {\n const isCorrectModel = options.expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", options.expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";;;;;;;;AACA;AAEA;AAEA;AASA;AACA;AACO,MAAMA,iBAAiB,GAAG,UAC/BC,GAAW,EACXC,IAAmB,EAKN;EAAA;EAAA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ime-corejs3/helpers/interopRequ
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useUserProfile = exports.useTab = exports.useQuicksearch = exports.usePanel = exports.useListDetail = exports.useList = exports.useGroupingPanel = exports.useDetailPanel = exports.useCaseView = exports.useApplication = void 0;
7
+ exports.useUserProfile = exports.useTab = exports.useQuicksearch = exports.usePanel = exports.useListOrDetail = exports.useListDetail = exports.useList = exports.useGroupingPanel = exports.useDetailPanel = exports.useCaseView = exports.useApplication = void 0;
8
8
  var _ApplicationModel = _interopRequireDefault(require("../models/application/ApplicationModel"));
9
9
  var _CaseViewModel = _interopRequireDefault(require("../models/caseview/CaseViewModel"));
10
10
  var _TabModel = _interopRequireDefault(require("../models/tab/TabModel"));
@@ -59,6 +59,14 @@ const useList = href => (0, _useModularUIBasic.useModularUIBasic)("list", href,
59
59
  /**
60
60
  */
61
61
  exports.useList = useList;
62
+ const useListOrDetail = href => (0, _useModularUIBasic.useModularUIBasic)("list", href, {
63
+ expectedModels: ["List", "Detail"],
64
+ targetModel: [_ListModel.default, _DetailModel.default]
65
+ });
66
+
67
+ /**
68
+ */
69
+ exports.useListOrDetail = useListOrDetail;
62
70
  const useListDetail = href => (0, _useModularUIBasic.useModularUIBasic)("listdetail", href, {
63
71
  expectedModels: ["ListDetail"],
64
72
  targetModel: _ListDetailModel.default
@@ -14,7 +14,7 @@ import { useModularUIBasic } from "./useModularUIBasic";
14
14
  /**
15
15
  * Load application
16
16
  */
17
- export const useApplication = (): ?ApplicationModel =>
17
+ export const useApplication = (): ApplicationModel | null =>
18
18
  useModularUIBasic("application", "/", {
19
19
  expectedModels: ["Application"],
20
20
  targetModel: ApplicationModel,
@@ -23,7 +23,7 @@ export const useApplication = (): ?ApplicationModel =>
23
23
  /**
24
24
  * Load a tab by href
25
25
  */
26
- export const useTab = (href: string): ?TabModel =>
26
+ export const useTab = (href: string): TabModel | null =>
27
27
  useModularUIBasic("tab", href, {
28
28
  expectedModels: ["Tab"],
29
29
  targetModel: TabModel,
@@ -32,7 +32,7 @@ export const useTab = (href: string): ?TabModel =>
32
32
  /**
33
33
  * Load caseview by href
34
34
  */
35
- export const useCaseView = (href: string): ?CaseViewModel =>
35
+ export const useCaseView = (href: string): CaseViewModel | null =>
36
36
  useModularUIBasic("caseview", href, {
37
37
  expectedModels: ["CaseView"],
38
38
  targetModel: CaseViewModel,
@@ -42,14 +42,14 @@ export const useCaseView = (href: string): ?CaseViewModel =>
42
42
  */
43
43
  export const usePanel = (
44
44
  href: string
45
- ): ?ListModel | ?GroupingPanelModel | ?DetailModel =>
45
+ ): ListModel | GroupingPanelModel | DetailModel | null =>
46
46
  useModularUIBasic("panel", href, {
47
47
  expectedModels: ["List", "GroupingPanel", "Detail"],
48
48
  });
49
49
 
50
50
  /**
51
51
  */
52
- export const useList = (href: string): ?ListModel =>
52
+ export const useList = (href: string): ListModel | null =>
53
53
  useModularUIBasic("list", href, {
54
54
  expectedModels: ["List"],
55
55
  targetModel: ListModel,
@@ -57,7 +57,15 @@ export const useList = (href: string): ?ListModel =>
57
57
 
58
58
  /**
59
59
  */
60
- export const useListDetail = (href: string): ?ListDetailModel =>
60
+ export const useListOrDetail = (href: string): ListModel | DetailModel | null =>
61
+ useModularUIBasic("list", href, {
62
+ expectedModels: ["List", "Detail"],
63
+ targetModel: [ListModel, DetailModel],
64
+ });
65
+
66
+ /**
67
+ */
68
+ export const useListDetail = (href: string): ListDetailModel | null =>
61
69
  useModularUIBasic("listdetail", href, {
62
70
  expectedModels: ["ListDetail"],
63
71
  targetModel: ListDetailModel,
@@ -65,7 +73,7 @@ export const useListDetail = (href: string): ?ListDetailModel =>
65
73
 
66
74
  /**
67
75
  */
68
- export const useGroupingPanel = (href: string): ?GroupingPanelModel =>
76
+ export const useGroupingPanel = (href: string): GroupingPanelModel | null =>
69
77
  useModularUIBasic("groupingpanel", href, {
70
78
  expectedModels: ["GroupingPanel"],
71
79
  targetModel: GroupingPanelModel,
@@ -73,7 +81,7 @@ export const useGroupingPanel = (href: string): ?GroupingPanelModel =>
73
81
 
74
82
  /**
75
83
  */
76
- export const useDetailPanel = (href: string): ?DetailModel =>
84
+ export const useDetailPanel = (href: string): DetailModel | null =>
77
85
  useModularUIBasic("detailpanel", href, {
78
86
  expectedModels: ["Detail"],
79
87
  targetModel: DetailModel,
@@ -81,7 +89,7 @@ export const useDetailPanel = (href: string): ?DetailModel =>
81
89
 
82
90
  /**
83
91
  */
84
- export const useQuicksearch = (href: string): ?CaseSearchModel =>
92
+ export const useQuicksearch = (href: string): CaseSearchModel | null =>
85
93
  useModularUIBasic("quicksearch", href, {
86
94
  expectedModels: ["CaseSearch"],
87
95
  targetModel: CaseSearchModel,
@@ -89,7 +97,7 @@ export const useQuicksearch = (href: string): ?CaseSearchModel =>
89
97
 
90
98
  /**
91
99
  */
92
- export const useUserProfile = (href: string): ?UserProfileModel =>
100
+ export const useUserProfile = (href: string): UserProfileModel | null =>
93
101
  useModularUIBasic("userprofile", href, {
94
102
  expectedModels: ["UserProfile"],
95
103
  targetModel: UserProfileModel,
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIModel.js","names":["useApplication","useModularUIBasic","expectedModels","targetModel","ApplicationModel","useTab","href","TabModel","useCaseView","CaseViewModel","usePanel","useList","ListModel","useListDetail","ListDetailModel","useGroupingPanel","GroupingPanelModel","useDetailPanel","DetailModel","useQuicksearch","CaseSearchModel","useUserProfile","UserProfileModel"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (): ?ApplicationModel =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string): ?TabModel =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (href: string): ?CaseViewModel =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n });\n\n/**\n */\nexport const usePanel = (\n href: string\n): ?ListModel | ?GroupingPanelModel | ?DetailModel =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n });\n\n/**\n */\nexport const useList = (href: string): ?ListModel =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n });\n\n/**\n */\nexport const useListDetail = (href: string): ?ListDetailModel =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n });\n\n/**\n */\nexport const useGroupingPanel = (href: string): ?GroupingPanelModel =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n });\n\n/**\n */\nexport const useDetailPanel = (href: string): ?DetailModel =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n });\n\n/**\n */\nexport const useQuicksearch = (href: string): ?CaseSearchModel =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useUserProfile = (href: string): ?UserProfileModel =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n });\n"],"mappings":";;;;;;;AACA;AACA;AACA;AAC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,cAAc,EAAE,CAAC,eAAe,CAAC;EACjCC,WAAW,EAAEa;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,cAAc,GAAIX,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,QAAQ,CAAC;EAC1BC,WAAW,EAAEe;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,cAAc,GAAIb,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,YAAY,CAAC;EAC9BC,WAAW,EAAEiB;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,cAAc,GAAIf,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEmB;AACf,CAAC,CAAC;AAAC"}
1
+ {"version":3,"file":"useModularUIModel.js","names":["useApplication","useModularUIBasic","expectedModels","targetModel","ApplicationModel","useTab","href","TabModel","useCaseView","CaseViewModel","usePanel","useList","ListModel","useListOrDetail","DetailModel","useListDetail","ListDetailModel","useGroupingPanel","GroupingPanelModel","useDetailPanel","useQuicksearch","CaseSearchModel","useUserProfile","UserProfileModel"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (): ApplicationModel | null =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string): TabModel | null =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (href: string): CaseViewModel | null =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n });\n\n/**\n */\nexport const usePanel = (\n href: string\n): ListModel | GroupingPanelModel | DetailModel | null =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n });\n\n/**\n */\nexport const useList = (href: string): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n });\n\n/**\n */\nexport const useListOrDetail = (href: string): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"Detail\"],\n targetModel: [ListModel, DetailModel],\n });\n\n/**\n */\nexport const useListDetail = (href: string): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n });\n\n/**\n */\nexport const useGroupingPanel = (href: string): GroupingPanelModel | null =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n });\n\n/**\n */\nexport const useDetailPanel = (href: string): DetailModel | null =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n });\n\n/**\n */\nexport const useQuicksearch = (href: string): CaseSearchModel | null =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useUserProfile = (href: string): UserProfileModel | null =>\n useModularUIBasic(\"userprofile\",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CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,aAAa,GAAIT,IAAY,IACxC,IAAAL,oCAAiB,EAAC,YAAY,EAAEK,IAAI,EAAE;EACpCJ,cAAc,EAAE,CAAC,YAAY,CAAC;EAC9BC,WAAW,EAAEa;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,gBAAgB,GAAIX,IAAY,IAC3C,IAAAL,oCAAiB,EAAC,eAAe,EAAEK,IAAI,EAAE;EACvCJ,cAAc,EAAE,CAAC,eAAe,CAAC;EACjCC,WAAW,EAAEe;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,cAAc,GAAIb,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,QAAQ,CAAC;EAC1BC,WAAW,EAAEW;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMM,cAAc,GAAId,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,YAAY,CAAC;EAC9BC,WAAW,EAAEkB;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,cAAc,GAAIhB,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEoB;AACf,CAAC,CAAC;AAAC"}
@@ -9,17 +9,15 @@ var _reselect = require("reselect");
9
9
  var _reactRedux = require("react-redux");
10
10
  var _ModularUIRequest = _interopRequireDefault(require("../modularui/ModularUIRequest"));
11
11
  var _i18n = require("../redux/selectors/i18n");
12
- const getModularUIRequest = (0, _reselect.createSelector)([_i18n.getLocale], localeCode => {
12
+ /**
13
+ * Creates a ModularUIRequest with the locale as available in the redux store
14
+ */
15
+ const useModularUIRequest = () => (0, _reactRedux.useSelector)((0, _reselect.createSelector)([_i18n.getLocale], localeCode => {
13
16
  return (href, options) => {
14
17
  const request = new _ModularUIRequest.default(href, options);
15
18
  request.locale = localeCode;
16
19
  return request;
17
20
  };
18
- });
19
-
20
- /**
21
- * Creates a ModularUIRequest with the locale as available in the redux store
22
- */
23
- const useModularUIRequest = () => (0, _reactRedux.useSelector)(getModularUIRequest);
21
+ }));
24
22
  exports.useModularUIRequest = useModularUIRequest;
25
23
  //# sourceMappingURL=useModularUIRequest.js.map
@@ -5,21 +5,22 @@ import { useSelector } from "react-redux";
5
5
  import ModularUIRequest from "../modularui/ModularUIRequest";
6
6
  import { getLocale } from "../redux/selectors/i18n";
7
7
 
8
- import type { RequestBaseOptions } from "../utils";
9
8
  import type Href from "../models/href/Href";
10
-
11
- const getModularUIRequest = createSelector([getLocale], (localeCode) => {
12
- return (href: Href, options?: $Shape<RequestBaseOptions>) => {
13
- const request = new ModularUIRequest(href, options);
14
- request.locale = localeCode;
15
- return request;
16
- };
17
- });
9
+ import type { RequestModularUIOptions } from "../utils";
18
10
 
19
11
  /**
20
12
  * Creates a ModularUIRequest with the locale as available in the redux store
21
13
  */
22
14
  export const useModularUIRequest = (): ((
23
15
  href: Href,
24
- options?: $Shape<RequestBaseOptions>
25
- ) => ModularUIRequest) => useSelector(getModularUIRequest);
16
+ options?: $Shape<RequestModularUIOptions>
17
+ ) => ModularUIRequest) =>
18
+ useSelector(
19
+ createSelector([getLocale], (localeCode) => {
20
+ return (href: Href, options?: $Shape<RequestModularUIOptions>) => {
21
+ const request = new ModularUIRequest(href, options);
22
+ request.locale = localeCode;
23
+ return request;
24
+ };
25
+ })
26
+ );
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIRequest.js","names":["getModularUIRequest","createSelector","getLocale","localeCode","href","options","request","ModularUIRequest","locale","useModularUIRequest","useSelector"],"sources":["../../src/hooks/useModularUIRequest.js"],"sourcesContent":["// @flow\nimport { createSelector } from \"reselect\";\nimport { useSelector } from \"react-redux\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport type { RequestBaseOptions } from \"../utils\";\nimport type Href from \"../models/href/Href\";\n\nconst getModularUIRequest = createSelector([getLocale], (localeCode) => {\n return (href: Href, options?: $Shape<RequestBaseOptions>) => {\n const request = new ModularUIRequest(href, options);\n request.locale = localeCode;\n return request;\n };\n});\n\n/**\n * Creates a ModularUIRequest with the locale as available in the redux store\n */\nexport const useModularUIRequest = (): ((\n href: Href,\n options?: $Shape<RequestBaseOptions>\n) => ModularUIRequest) => useSelector(getModularUIRequest);\n"],"mappings":";;;;;;;AACA;AACA;AAEA;AACA;AAKA,MAAMA,mBAAmB,GAAG,IAAAC,wBAAc,EAAC,CAACC,eAAS,CAAC,EAAGC,UAAU,IAAK;EACtE,OAAO,CAACC,IAAU,EAAEC,OAAoC,KAAK;IAC3D,MAAMC,OAAO,GAAG,IAAIC,yBAAgB,CAACH,IAAI,EAAEC,OAAO,CAAC;IACnDC,OAAO,CAACE,MAAM,GAAGL,UAAU;IAC3B,OAAOG,OAAO;EAChB,CAAC;AACH,CAAC,CAAC;;AAEF;AACA;AACA;AACO,MAAMG,mBAAmB,GAAG,MAGT,IAAAC,uBAAW,EAACV,mBAAmB,CAAC;AAAC"}
1
+ {"version":3,"file":"useModularUIRequest.js","names":["useModularUIRequest","useSelector","createSelector","getLocale","localeCode","href","options","request","ModularUIRequest","locale"],"sources":["../../src/hooks/useModularUIRequest.js"],"sourcesContent":["// @flow\nimport { createSelector } from \"reselect\";\nimport { useSelector } from \"react-redux\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport type Href from \"../models/href/Href\";\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n * Creates a ModularUIRequest with the locale as available in the redux store\n */\nexport const useModularUIRequest = (): ((\n href: Href,\n options?: $Shape<RequestModularUIOptions>\n) => ModularUIRequest) =>\n useSelector(\n createSelector([getLocale], (localeCode) => {\n return (href: Href, options?: $Shape<RequestModularUIOptions>) => {\n const request = new ModularUIRequest(href, options);\n request.locale = localeCode;\n return request;\n };\n })\n );\n"],"mappings":";;;;;;;AACA;AACA;AAEA;AACA;AAKA;AACA;AACA;AACO,MAAMA,mBAAmB,GAAG,MAIjC,IAAAC,uBAAW,EACT,IAAAC,wBAAc,EAAC,CAACC,eAAS,CAAC,EAAGC,UAAU,IAAK;EAC1C,OAAO,CAACC,IAAU,EAAEC,OAAyC,KAAK;IAChE,MAAMC,OAAO,GAAG,IAAIC,yBAAgB,CAACH,IAAI,EAAEC,OAAO,CAAC;IACnDC,OAAO,CAACE,MAAM,GAAGL,UAAU;IAC3B,OAAOG,OAAO;EAChB,CAAC;AACH,CAAC,CAAC,CACH;AAAC"}
@@ -11,6 +11,7 @@ var _ResourceModel = _interopRequireDefault(require("../base/ResourceModel"));
11
11
  var _LinkModel = _interopRequireDefault(require("../links/LinkModel"));
12
12
  var _UserServicesModel = _interopRequireDefault(require("../user/UserServicesModel"));
13
13
  var _exceptions = require("../../exceptions");
14
+ var _constants = require("../../constants");
14
15
  /**
15
16
  * The Application model
16
17
  */
@@ -26,6 +27,12 @@ class ApplicationModel extends _ResourceModel.default {
26
27
  return "Application";
27
28
  }
28
29
 
30
+ /**
31
+ */
32
+ static get modelName() {
33
+ return "ApplicationModel";
34
+ }
35
+
29
36
  /**
30
37
  */
31
38
  static isApplicableModel(data) {
@@ -62,7 +69,7 @@ class ApplicationModel extends _ResourceModel.default {
62
69
  * Getting the authentication types of the application
63
70
  */
64
71
  get authenticationTypes() {
65
- const authenticationTypes = this.getContribution("security", []);
72
+ const authenticationTypes = this.getContribution("security", [_constants.fallbackDefaultAuthenticationType]);
66
73
 
67
74
  //put primary first
68
75
  return authenticationTypes?.sort((a, b) => a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1);
@@ -9,6 +9,7 @@ import type { ModularUIModel, AuthenticationType } from "../types";
9
9
  import type { ModularUIResponse } from "../../modularui";
10
10
  import type LinkCollection from "../links/LinkCollection";
11
11
  import type Href from "../href/Href";
12
+ import { fallbackDefaultAuthenticationType } from "../../constants";
12
13
 
13
14
  /**
14
15
  * The Application model
@@ -23,6 +24,12 @@ export default class ApplicationModel extends ResourceModel {
23
24
  return "Application";
24
25
  }
25
26
 
27
+ /**
28
+ */
29
+ static get modelName(): string {
30
+ return "ApplicationModel";
31
+ }
32
+
26
33
  /**
27
34
  */
28
35
  static isApplicableModel(data: ModularUIResponse): boolean {
@@ -68,7 +75,9 @@ export default class ApplicationModel extends ResourceModel {
68
75
  * Getting the authentication types of the application
69
76
  */
70
77
  get authenticationTypes(): Array<AuthenticationType> {
71
- const authenticationTypes = this.getContribution("security", []);
78
+ const authenticationTypes = this.getContribution("security", [
79
+ fallbackDefaultAuthenticationType,
80
+ ]);
72
81
 
73
82
  //put primary first
74
83
  return authenticationTypes?.sort(
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationModel.js","names":["ApplicationModel","ResourceModel","type","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","NotAllowedUriException","setChildModels","models","userServiceModel","model","userServices","label","getContribution","authenticationTypes","sort","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","LinkModel","create","_userServices","UserServicesModel","isLoggedIn","userHref","userLink"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", []);\n\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1\n );\n }\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AACA;AACA;AACA;AAEA;AAOA;AACA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GAAG,CAAC,CACzD;EACH;EACA;AACF;AACA;EACE,IAAIC,IAAI,GAAmB;IACzB,OAAO,IAAI,CAACjB,KAAK,CAACkB,eAAe,CAAC,KAAK,CAAC;EAC1C;;EAEA;AACF;AACA;EACE,IAAIC,YAAY,GAAc;IAC5B,OAAOC,kBAAS,CAACC,MAAM,CAAC,cAAc,EAAE,eAAe,EAAE,eAAe,CAAC;EAC3E;;EAEA;AACF;AACA;EACE,IAAIZ,YAAY,CAACD,KAAsB,EAAE;IACvC,IAAI,CAACc,aAAa,GAAGd,KAAK,YAAYe,0BAAiB,GAAGf,KAAK,GAAG,IAAI;EACxE;;EAEA;AACF;AACA;EACE,IAAIC,YAAY,GAAuB;IACrC,OAAO,IAAI,CAACa,aAAa,GAAG,IAAI,CAACA,aAAa,GAAG,IAAI;EACvD;;EAEA;AACF;AACA;EACE,IAAIE,UAAU,GAAY;IACxB,OAAO,IAAI,CAACf,YAAY,EAAEe,UAAU,IAAI,KAAK;EAC/C;;EAEA;AACF;AACA;AACA;EACE,IAAIC,QAAQ,GAAgB;IAC1B,IAAI,IAAI,CAAChB,YAAY,IAAI,IAAI,IAAI,IAAI,CAACA,YAAY,CAACiB,QAAQ,IAAI,IAAI,EAAE;MACnE,OAAO,IAAI,CAACjB,YAAY,CAACiB,QAAQ,CAACxB,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;AACF;AAAC"}
1
+ {"version":3,"file":"ApplicationModel.js","names":["ApplicationModel","ResourceModel","type","modelName","isApplicableModel","data","contributions","resourcetype","getInitialChildModelLinks","userService","links","getLinkByKey","href","path","NotAllowedUriException","setChildModels","models","userServiceModel","model","userServices","label","getContribution","authenticationTypes","fallbackDefaultAuthenticationType","sort","a","b","isPrimary","tabs","getLinksByGroup","modelcatalog","LinkModel","create","_userServices","UserServicesModel","isLoggedIn","userHref","userLink"],"sources":["../../../src/models/application/ApplicationModel.js"],"sourcesContent":["// @flow\nimport ResourceModel from \"../base/ResourceModel\";\nimport LinkModel from \"../links/LinkModel\";\nimport UserServicesModel from \"../user/UserServicesModel\";\n\nimport { NotAllowedUriException } from \"../../exceptions\";\n\nimport type { ModularUIModel, AuthenticationType } from \"../types\";\nimport type { ModularUIResponse } from \"../../modularui\";\nimport type LinkCollection from \"../links/LinkCollection\";\nimport type Href from \"../href/Href\";\nimport { fallbackDefaultAuthenticationType } from \"../../constants\";\n\n/**\n * The Application model\n */\nexport default class ApplicationModel extends ResourceModel {\n _userServices: ?UserServicesModel;\n\n /**\n * Retrieve type of model\n */\n get type(): string {\n return \"Application\";\n }\n\n /**\n */\n static get modelName(): string {\n return \"ApplicationModel\";\n }\n\n /**\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n return (\n data.contributions.resourcetype &&\n data.contributions.resourcetype === \"Application\"\n );\n }\n\n /**\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n const userService = this.links.getLinkByKey(\"UserServices\");\n if (userService && userService.href.path === \"/login\") {\n throw new NotAllowedUriException(\n \"The user service (Login panel) should not have the uri '/login', use a different URI because this uri matches the login service.\"\n );\n }\n\n return userService ? [userService] : [];\n }\n\n /**\n */\n setChildModels(models: Array<ModularUIModel>) {\n const userServiceModel = models.find(\n (model) => model.type === \"UserServices\"\n );\n\n if (userServiceModel) {\n this.userServices = userServiceModel;\n }\n }\n\n /**\n * Getting the label of the application\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the authentication types of the application\n */\n get authenticationTypes(): Array<AuthenticationType> {\n const authenticationTypes = this.getContribution(\"security\", [\n fallbackDefaultAuthenticationType,\n ]);\n\n //put primary first\n return authenticationTypes?.sort(\n (a: AuthenticationType, b: AuthenticationType) =>\n a.isPrimary === b.isPrimary ? 0 : a.isPrimary ? -1 : 1\n );\n }\n /**\n * Getting the tab links\n */\n get tabs(): LinkCollection {\n return this.links.getLinksByGroup(\"tab\");\n }\n\n /**\n * Get modelcatalog link\n */\n get modelcatalog(): LinkModel {\n return LinkModel.create(\"modelcatalog\", \"/modelcatalog\", \"Model catalog\");\n }\n\n /**\n * Set the userservices for this application\n */\n set userServices(model: ?ModularUIModel) {\n this._userServices = model instanceof UserServicesModel ? model : null;\n }\n\n /**\n * returns the userservices configured for this application\n */\n get userServices(): ?UserServicesModel {\n return this._userServices ? this._userServices : null;\n }\n\n /**\n * Indicates if the user is logged in\n */\n get isLoggedIn(): boolean {\n return this.userServices?.isLoggedIn ?? false;\n }\n\n /**\n * Retrieve link to the user information,\n * only available when the user services are available\n */\n get userHref(): Href | null {\n if (this.userServices != null && this.userServices.userLink != null) {\n return this.userServices.userLink.href;\n }\n\n return null;\n }\n}\n"],"mappings":";;;;;;;;;AACA;AACA;AACA;AAEA;AAMA;AAEA;AACA;AACA;AACe,MAAMA,gBAAgB,SAASC,sBAAa,CAAC;EAAA;IAAA;IAAA;EAAA;EAG1D;AACF;AACA;EACE,IAAIC,IAAI,GAAW;IACjB,OAAO,aAAa;EACtB;;EAEA;AACF;EACE,WAAWC,SAAS,GAAW;IAC7B,OAAO,kBAAkB;EAC3B;;EAEA;AACF;EACE,OAAOC,iBAAiB,CAACC,IAAuB,EAAW;IACzD,OACEA,IAAI,CAACC,aAAa,CAACC,YAAY,IAC/BF,IAAI,CAACC,aAAa,CAACC,YAAY,KAAK,aAAa;EAErD;;EAEA;AACF;EACEC,yBAAyB,GAAqB;IAC5C,MAAMC,WAAW,GAAG,IAAI,CAACC,KAAK,CAACC,YAAY,CAAC,cAAc,CAAC;IAC3D,IAAIF,WAAW,IAAIA,WAAW,CAACG,IAAI,CAACC,IAAI,KAAK,QAAQ,EAAE;MACrD,MAAM,IAAIC,kCAAsB,CAC9B,kIAAkI,CACnI;IACH;IAEA,OAAOL,WAAW,GAAG,CAACA,WAAW,CAAC,GAAG,EAAE;EACzC;;EAEA;AACF;EACEM,cAAc,CAACC,MAA6B,EAAE;IAC5C,MAAMC,gBAAgB,GAAG,mBAAAD,MAAM,OAANA,MAAM,EAC5BE,KAAK,IAAKA,KAAK,CAAChB,IAAI,KAA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AI,IAAI,CAACA,YAAY,CAACkB,QAAQ,IAAI,IAAI,EAAE;MACnE,OAAO,IAAI,CAAClB,YAAY,CAACkB,QAAQ,CAACzB,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;AACF;AAAC"}
@@ -11,7 +11,10 @@ var _clone = _interopRequireDefault(require("lodash/clone"));
11
11
  var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
12
12
  var _LayoutHintCollection = _interopRequireDefault(require("../layouthint/LayoutHintCollection"));
13
13
  /**
14
- * Base model
14
+ * Base model, this is the foundation of a model,
15
+ * it contains data that is needed for all models like, data, contributions and layout hint
16
+ *
17
+ * Extend this for non modular ui resources, for modular ui resource start with the resourceModel
15
18
  */
16
19
  class BaseModel {
17
20
  /**
@@ -35,6 +38,7 @@ class BaseModel {
35
38
  }
36
39
 
37
40
  /**
41
+ * Retrieve property from the data object of the model, mostly used internal
38
42
  */
39
43
  getData(propName) {
40
44
  let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
@@ -49,6 +53,7 @@ class BaseModel {
49
53
  }
50
54
 
51
55
  /**
56
+ * Retrieve property from the contributions of the model, mostly used internal
52
57
  */
53
58
  getContribution(propName) {
54
59
  let defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
@@ -77,18 +82,21 @@ class BaseModel {
77
82
  }
78
83
 
79
84
  /**
85
+ * Set the unique key for this model
80
86
  */
81
87
  set connectKey(key) {
82
88
  this._connectKey = key;
83
89
  }
84
90
 
85
91
  /**
92
+ * Get the unique key of this model
86
93
  */
87
94
  get connectKey() {
88
95
  return this._connectKey;
89
96
  }
90
97
 
91
98
  /**
99
+ * Dehydrate internal data, returns the information that is needed to recreate the model
92
100
  */
93
101
  dehydrate() {
94
102
  return {
@@ -99,13 +107,14 @@ class BaseModel {
99
107
  }
100
108
 
101
109
  /**
110
+ * Recreate the model with the given data
102
111
  */
103
112
  rehydrate(data) {
104
113
  this._connectKey = data.connectKey;
105
114
  }
106
115
 
107
116
  /**
108
- * Returns a clone of the model (this is not a deep copy)
117
+ * Returns a clone of the model
109
118
  */
110
119
  clone() {
111
120
  let deepcopy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;