@beinformed/ui 1.25.2 → 1.25.5
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 +18 -0
- package/esm/constants/Constants.js +5 -0
- package/esm/constants/Constants.js.map +1 -1
- package/esm/hooks/useAuthentication.js +5 -5
- package/esm/hooks/useAuthentication.js.map +1 -1
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +7 -1
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/hooks/useModularUIModel.js +9 -1
- package/esm/hooks/useModularUIModel.js.map +1 -1
- package/esm/hooks/useModularUIRequest.js +5 -7
- package/esm/hooks/useModularUIRequest.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +9 -1
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/models/base/ResourceModel.js +7 -0
- package/esm/models/base/ResourceModel.js.map +1 -1
- package/esm/models/caseview/CaseViewModel.js +6 -0
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/concepts/BusinessScenarioModel.js +6 -0
- package/esm/models/concepts/BusinessScenarioModel.js.map +1 -1
- package/esm/models/concepts/ConceptDetailModel.js +6 -0
- package/esm/models/concepts/ConceptDetailModel.js.map +1 -1
- package/esm/models/concepts/ConceptIndexModel.js +6 -0
- package/esm/models/concepts/ConceptIndexModel.js.map +1 -1
- package/esm/models/concepts/ConceptTypeDetailModel.js +6 -0
- package/esm/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/esm/models/content/ContentIndexModel.js +6 -0
- package/esm/models/content/ContentIndexModel.js.map +1 -1
- package/esm/models/content/ContentModel.js +6 -0
- package/esm/models/content/ContentModel.js.map +1 -1
- package/esm/models/content/ContentTOCModel.js +6 -0
- package/esm/models/content/ContentTOCModel.js.map +1 -1
- package/esm/models/content/ContentTypeModel.js +6 -0
- package/esm/models/content/ContentTypeModel.js.map +1 -1
- package/esm/models/detail/DetailModel.js +6 -0
- package/esm/models/detail/DetailModel.js.map +1 -1
- package/esm/models/form/FormModel.js +6 -0
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/list/ListDetailModel.js +6 -0
- package/esm/models/list/ListDetailModel.js.map +1 -1
- package/esm/models/list/ListModel.js +6 -0
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/lookup/LookupOptionsModel.js +6 -0
- package/esm/models/lookup/LookupOptionsModel.js.map +1 -1
- package/esm/models/modelcatalog/ModelCatalogModel.js +6 -0
- package/esm/models/modelcatalog/ModelCatalogModel.js.map +1 -1
- package/esm/models/panels/GroupingPanelModel.js +6 -0
- package/esm/models/panels/GroupingPanelModel.js.map +1 -1
- package/esm/models/resolveModel.js +4 -4
- package/esm/models/resolveModel.js.map +1 -1
- package/esm/models/search/CaseSearchModel.js +6 -0
- package/esm/models/search/CaseSearchModel.js.map +1 -1
- package/esm/models/tab/TabModel.js +6 -0
- package/esm/models/tab/TabModel.js.map +1 -1
- package/esm/models/taskgroup/TaskGroupModel.js +6 -0
- package/esm/models/taskgroup/TaskGroupModel.js.map +1 -1
- package/esm/models/types.js.map +1 -1
- package/esm/models/user/UserModel.js +6 -0
- package/esm/models/user/UserModel.js.map +1 -1
- package/esm/models/user/UserProfileModel.js +6 -0
- package/esm/models/user/UserProfileModel.js.map +1 -1
- package/esm/models/user/UserServicesModel.js +6 -0
- package/esm/models/user/UserServicesModel.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +54 -10
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/modularui/types.js +2 -0
- package/esm/modularui/types.js.map +1 -0
- package/esm/redux/_modularui/ModularUIActions.js +2 -0
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +1 -0
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/_modularui/withModularUI.js.map +1 -1
- package/esm/utils/fetch/types.js.map +1 -1
- package/lib/constants/Constants.js +7 -1
- package/lib/constants/Constants.js.flow +6 -0
- package/lib/constants/Constants.js.map +1 -1
- package/lib/hooks/__tests__/UseModularUIModel.spec.js.flow +1 -1
- package/lib/hooks/__tests__/useModelCatalog.spec.js.flow +1 -1
- package/lib/hooks/__tests__/useModularUIBasic.spec.js.flow +2 -2
- package/lib/hooks/useAuthentication.js +4 -4
- package/lib/hooks/useAuthentication.js.flow +17 -5
- package/lib/hooks/useAuthentication.js.map +1 -1
- package/lib/hooks/useModularUI.js.flow +2 -2
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +7 -1
- package/lib/hooks/useModularUIBasic.js.flow +14 -4
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/hooks/useModularUIModel.js +11 -2
- package/lib/hooks/useModularUIModel.js.flow +19 -10
- package/lib/hooks/useModularUIModel.js.map +1 -1
- package/lib/hooks/useModularUIRequest.js +5 -7
- package/lib/hooks/useModularUIRequest.js.flow +12 -11
- package/lib/hooks/useModularUIRequest.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +8 -1
- package/lib/models/application/ApplicationModel.js.flow +10 -1
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/base/ResourceModel.js +7 -0
- package/lib/models/base/ResourceModel.js.flow +7 -0
- package/lib/models/base/ResourceModel.js.map +1 -1
- package/lib/models/caseview/CaseViewModel.js +6 -0
- package/lib/models/caseview/CaseViewModel.js.flow +6 -0
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/concepts/BusinessScenarioModel.js +6 -0
- package/lib/models/concepts/BusinessScenarioModel.js.flow +6 -0
- package/lib/models/concepts/BusinessScenarioModel.js.map +1 -1
- package/lib/models/concepts/ConceptDetailModel.js +6 -0
- package/lib/models/concepts/ConceptDetailModel.js.flow +6 -0
- package/lib/models/concepts/ConceptDetailModel.js.map +1 -1
- package/lib/models/concepts/ConceptIndexModel.js +6 -0
- package/lib/models/concepts/ConceptIndexModel.js.flow +6 -0
- package/lib/models/concepts/ConceptIndexModel.js.map +1 -1
- package/lib/models/concepts/ConceptTypeDetailModel.js +6 -0
- package/lib/models/concepts/ConceptTypeDetailModel.js.flow +6 -0
- package/lib/models/concepts/ConceptTypeDetailModel.js.map +1 -1
- package/lib/models/content/ContentIndexModel.js +6 -0
- package/lib/models/content/ContentIndexModel.js.flow +6 -0
- package/lib/models/content/ContentIndexModel.js.map +1 -1
- package/lib/models/content/ContentModel.js +6 -0
- package/lib/models/content/ContentModel.js.flow +6 -0
- package/lib/models/content/ContentModel.js.map +1 -1
- package/lib/models/content/ContentTOCModel.js +6 -0
- package/lib/models/content/ContentTOCModel.js.flow +6 -0
- package/lib/models/content/ContentTOCModel.js.map +1 -1
- package/lib/models/content/ContentTypeModel.js +6 -0
- package/lib/models/content/ContentTypeModel.js.flow +6 -0
- package/lib/models/content/ContentTypeModel.js.map +1 -1
- package/lib/models/detail/DetailModel.js +6 -0
- package/lib/models/detail/DetailModel.js.flow +6 -0
- package/lib/models/detail/DetailModel.js.map +1 -1
- package/lib/models/form/FormModel.js +6 -0
- package/lib/models/form/FormModel.js.flow +6 -0
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/list/ListDetailModel.js +6 -0
- package/lib/models/list/ListDetailModel.js.flow +6 -0
- package/lib/models/list/ListDetailModel.js.map +1 -1
- package/lib/models/list/ListModel.js +6 -0
- package/lib/models/list/ListModel.js.flow +6 -0
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/lookup/LookupOptionsModel.js +6 -0
- package/lib/models/lookup/LookupOptionsModel.js.flow +6 -0
- package/lib/models/lookup/LookupOptionsModel.js.map +1 -1
- package/lib/models/modelcatalog/ModelCatalogModel.js +6 -0
- package/lib/models/modelcatalog/ModelCatalogModel.js.flow +6 -0
- package/lib/models/modelcatalog/ModelCatalogModel.js.map +1 -1
- package/lib/models/panels/GroupingPanelModel.js +6 -0
- package/lib/models/panels/GroupingPanelModel.js.flow +6 -0
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/resolveModel.js +4 -3
- package/lib/models/resolveModel.js.flow +6 -4
- package/lib/models/resolveModel.js.map +1 -1
- package/lib/models/search/CaseSearchModel.js +6 -0
- package/lib/models/search/CaseSearchModel.js.flow +6 -0
- package/lib/models/search/CaseSearchModel.js.map +1 -1
- package/lib/models/tab/TabModel.js +6 -0
- package/lib/models/tab/TabModel.js.flow +6 -0
- package/lib/models/tab/TabModel.js.map +1 -1
- package/lib/models/taskgroup/TaskGroupModel.js +6 -0
- package/lib/models/taskgroup/TaskGroupModel.js.flow +6 -0
- package/lib/models/taskgroup/TaskGroupModel.js.map +1 -1
- package/lib/models/types.js.flow +1 -1
- package/lib/models/types.js.map +1 -1
- package/lib/models/user/UserModel.js +6 -0
- package/lib/models/user/UserModel.js.flow +6 -0
- package/lib/models/user/UserModel.js.map +1 -1
- package/lib/models/user/UserProfileModel.js +6 -0
- package/lib/models/user/UserProfileModel.js.flow +6 -0
- package/lib/models/user/UserProfileModel.js.map +1 -1
- package/lib/models/user/UserServicesModel.js +6 -0
- package/lib/models/user/UserServicesModel.js.flow +6 -0
- package/lib/models/user/UserServicesModel.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +54 -10
- package/lib/modularui/ModularUIRequest.js.flow +83 -17
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/__tests__/ModularUIRequest.spec.js.flow +4 -9
- package/lib/modularui/types.js +2 -0
- package/lib/modularui/types.js.flow +4 -0
- package/lib/modularui/types.js.map +1 -0
- package/lib/redux/_modularui/ModularUIActions.js +2 -0
- package/lib/redux/_modularui/ModularUIActions.js.flow +6 -4
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +1 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.flow +5 -2
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/types.js.flow +5 -3
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/_modularui/withModularUI.js.flow +2 -2
- package/lib/redux/_modularui/withModularUI.js.map +1 -1
- package/lib/utils/fetch/types.js.flow +12 -4
- package/lib/utils/fetch/types.js.map +1 -1
- package/package.json +7 -7
- package/src/constants/Constants.js +6 -0
- package/src/hooks/__tests__/UseModularUIModel.spec.js +1 -1
- package/src/hooks/__tests__/useModelCatalog.spec.js +1 -1
- package/src/hooks/__tests__/useModularUIBasic.spec.js +2 -2
- package/src/hooks/useAuthentication.js +17 -5
- package/src/hooks/useModularUI.js +2 -2
- package/src/hooks/useModularUIBasic.js +14 -4
- package/src/hooks/useModularUIModel.js +19 -10
- package/src/hooks/useModularUIRequest.js +12 -11
- package/src/models/application/ApplicationModel.js +10 -1
- package/src/models/base/ResourceModel.js +7 -0
- package/src/models/caseview/CaseViewModel.js +6 -0
- package/src/models/concepts/BusinessScenarioModel.js +6 -0
- package/src/models/concepts/ConceptDetailModel.js +6 -0
- package/src/models/concepts/ConceptIndexModel.js +6 -0
- package/src/models/concepts/ConceptTypeDetailModel.js +6 -0
- package/src/models/content/ContentIndexModel.js +6 -0
- package/src/models/content/ContentModel.js +6 -0
- package/src/models/content/ContentTOCModel.js +6 -0
- package/src/models/content/ContentTypeModel.js +6 -0
- package/src/models/detail/DetailModel.js +6 -0
- package/src/models/form/FormModel.js +6 -0
- package/src/models/list/ListDetailModel.js +6 -0
- package/src/models/list/ListModel.js +6 -0
- package/src/models/lookup/LookupOptionsModel.js +6 -0
- package/src/models/modelcatalog/ModelCatalogModel.js +6 -0
- package/src/models/panels/GroupingPanelModel.js +6 -0
- package/src/models/resolveModel.js +6 -4
- package/src/models/search/CaseSearchModel.js +6 -0
- package/src/models/tab/TabModel.js +6 -0
- package/src/models/taskgroup/TaskGroupModel.js +6 -0
- package/src/models/types.js +1 -1
- package/src/models/user/UserModel.js +6 -0
- package/src/models/user/UserProfileModel.js +6 -0
- package/src/models/user/UserServicesModel.js +6 -0
- package/src/modularui/ModularUIRequest.js +83 -17
- package/src/modularui/__tests__/ModularUIRequest.spec.js +4 -9
- package/src/modularui/types.js +4 -0
- package/src/redux/_modularui/ModularUIActions.js +6 -4
- package/src/redux/_modularui/ModularUIMiddleware.js +5 -2
- package/src/redux/_modularui/types.js +5 -3
- package/src/redux/_modularui/withModularUI.js +2 -2
- package/src/utils/fetch/types.js +12 -4
- package/types/constants/Constants.d.ts +5 -0
- package/types/models/base/ResourceModel.d.ts +4 -0
- package/types/models/form/FormObjectModel.d.ts +28 -2
- package/types/models/resolveModel.d.ts +1 -1
- package/types/models/types.d.ts +1 -1
- package/types/modularui/ModularUIRequest.d.ts +15 -7
- package/types/modularui/types.d.ts +2 -0
- package/types/redux/_modularui/types.d.ts +2 -2
- package/types/utils/fetch/types.d.ts +8 -5
|
@@ -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 {
|
|
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:
|
|
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 {
|
|
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 { 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;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,OAAgC,uEAAG;IACjCC,MAAM,EAAEC,uBAAY,CAACC,GAAG;IACxBC,eAAe,EAAE;EACnB,CAAC;EAED,MAAMC,QAAQ,GAAG,IAAAC,uBAAW,GAAE;EAC9B,MAAMC,IAAI,GAAGZ,GAAG,CAACa,QAAQ,EAAE;EAC3B,MAAMC,GAAG,GAAGhB,aAAa,CAACC,QAAQ,EAAEa,IAAI,CAAC;EAEzC,MAAMG,WAAW,GAAG,IAAAC,aAAM,EAACX,OAAO,CAAC;EACnC,MAAMY,QAAQ,GAAG,IAAAD,aAAM,EAACJ,IAAI,CAAC;;EAE7B;EACA,IAAAM,6BAAoB,EAAC,MAAM;IACzB;IACA,MAAMC,WAAW,GACfF,QAAQ,CAACG,OAAO,KAAKR,IAAI,IACzBG,WAAW,CAACK,OAAO,CAACC,QAAQ,IAC5B,CAAChB,OAAO,CAACgB,QAAQ;IAEnB,IAAI,CAACF,WAAW,EAAE;MAChBT,QAAQ,CAAC,IAAAY,+BAAa,EAACR,GAAG,EAAEF,IAAI,EAAEP,OAAO,CAAC,CAAC;IAC7C;IAEAU,WAAW,CAACK,OAAO,GAAGf,OAAO;IAC7BY,QAAQ,CAACG,OAAO,GAAGR,IAAI;EACzB,CAAC,EAAE,CAACE,GAAG,EAAEF,IAAI,EAAEP,OAAO,CAAC,CAAC;EAExB,MAAM;IAAEI,eAAe,GAAG;EAAM,CAAC,GAAGJ,OAAO;EAC3C,IAAAkB,gBAAS,EAAC,MAAM;IACd,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"}
|
|
@@ -15,7 +15,8 @@ const useModularUIBasic = function (key, href) {
|
|
|
15
15
|
var _context;
|
|
16
16
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
17
17
|
expectedModels: [],
|
|
18
|
-
targetModel: undefined
|
|
18
|
+
targetModel: undefined,
|
|
19
|
+
forceTargetModel: false
|
|
19
20
|
};
|
|
20
21
|
const location = (0, _useRouter.useLocation)();
|
|
21
22
|
if (!href) {
|
|
@@ -23,16 +24,20 @@ const useModularUIBasic = function (key, href) {
|
|
|
23
24
|
}
|
|
24
25
|
const useModularUIOptions = {
|
|
25
26
|
targetModel: undefined,
|
|
27
|
+
forceTargetModel: undefined,
|
|
26
28
|
isReload: false
|
|
27
29
|
};
|
|
28
30
|
if (options.targetModel) {
|
|
29
31
|
useModularUIOptions.targetModel = options.targetModel;
|
|
32
|
+
useModularUIOptions.forceTargetModel = options.forceTargetModel;
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
// reload when the modular service starts with the current location
|
|
33
36
|
if (location.state?.reload && (0, _startsWith.default)(_context = location.pathname).call(_context, href.toString())) {
|
|
34
37
|
useModularUIOptions.isReload = true;
|
|
35
38
|
}
|
|
39
|
+
|
|
40
|
+
// $FlowFixMe[incompatible-call]
|
|
36
41
|
const modularUI = (0, _useModularUI.useModularUI)(key, href, useModularUIOptions);
|
|
37
42
|
if (modularUI?.model) {
|
|
38
43
|
const {
|
|
@@ -49,6 +54,7 @@ const useModularUIBasic = function (key, href) {
|
|
|
49
54
|
}
|
|
50
55
|
return model;
|
|
51
56
|
}
|
|
57
|
+
return null;
|
|
52
58
|
};
|
|
53
59
|
exports.useModularUIBasic = useModularUIBasic;
|
|
54
60
|
//# sourceMappingURL=useModularUIBasic.js.map
|
|
@@ -7,9 +7,10 @@ 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
|
+
forceTargetModel?: boolean,
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -20,16 +21,22 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
20
21
|
options: UseModularUIBasicOptions<T> = {
|
|
21
22
|
expectedModels: [],
|
|
22
23
|
targetModel: undefined,
|
|
24
|
+
forceTargetModel: false,
|
|
23
25
|
}
|
|
24
|
-
):
|
|
26
|
+
): T | null => {
|
|
25
27
|
const location = useLocation();
|
|
26
28
|
if (!href) {
|
|
27
29
|
throw new IllegalArgumentException("Missing href");
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
const useModularUIOptions = {
|
|
32
|
+
const useModularUIOptions = {
|
|
33
|
+
targetModel: undefined,
|
|
34
|
+
forceTargetModel: undefined,
|
|
35
|
+
isReload: false,
|
|
36
|
+
};
|
|
31
37
|
if (options.targetModel) {
|
|
32
38
|
useModularUIOptions.targetModel = options.targetModel;
|
|
39
|
+
useModularUIOptions.forceTargetModel = options.forceTargetModel;
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
// reload when the modular service starts with the current location
|
|
@@ -37,6 +44,7 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
37
44
|
useModularUIOptions.isReload = true;
|
|
38
45
|
}
|
|
39
46
|
|
|
47
|
+
// $FlowFixMe[incompatible-call]
|
|
40
48
|
const modularUI = useModularUI(key, href, useModularUIOptions);
|
|
41
49
|
|
|
42
50
|
if (modularUI?.model) {
|
|
@@ -54,4 +62,6 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
54
62
|
|
|
55
63
|
return model;
|
|
56
64
|
}
|
|
65
|
+
|
|
66
|
+
return null;
|
|
57
67
|
};
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"useModularUIBasic.js","names":["useModularUIBasic","key","href","options","expectedModels","targetModel","undefined","forceTargetModel","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 forceTargetModel?: boolean,\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 forceTargetModel: false,\n }\n): T | null => {\n const location = useLocation();\n if (!href) {\n throw new IllegalArgumentException(\"Missing href\");\n }\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\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;AAUA;AACA;AACO,MAAMA,iBAAiB,GAAG,UAC/BC,GAAW,EACXC,IAAmB,EAMN;EAAA;EAAA,IALbC,OAAoC,uEAAG;IACrCC,cAAc,EAAE,EAAE;IAClBC,WAAW,EAAEC,SAAS;IACtBC,gBAAgB,EAAE;EACpB,CAAC;EAED,MAAMC,QAAQ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3/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,9 +59,18 @@ 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
|
-
targetModel: _ListDetailModel.default
|
|
72
|
+
targetModel: _ListDetailModel.default,
|
|
73
|
+
forceTargetModel: true
|
|
65
74
|
});
|
|
66
75
|
|
|
67
76
|
/**
|
|
@@ -14,7 +14,7 @@ import { useModularUIBasic } from "./useModularUIBasic";
|
|
|
14
14
|
/**
|
|
15
15
|
* Load application
|
|
16
16
|
*/
|
|
17
|
-
export const useApplication = ():
|
|
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):
|
|
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):
|
|
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
|
-
):
|
|
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):
|
|
52
|
+
export const useList = (href: string): ListModel | null =>
|
|
53
53
|
useModularUIBasic("list", href, {
|
|
54
54
|
expectedModels: ["List"],
|
|
55
55
|
targetModel: ListModel,
|
|
@@ -57,15 +57,24 @@ export const useList = (href: string): ?ListModel =>
|
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
*/
|
|
60
|
-
export const
|
|
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,
|
|
72
|
+
forceTargetModel: true,
|
|
64
73
|
});
|
|
65
74
|
|
|
66
75
|
/**
|
|
67
76
|
*/
|
|
68
|
-
export const useGroupingPanel = (href: string):
|
|
77
|
+
export const useGroupingPanel = (href: string): GroupingPanelModel | null =>
|
|
69
78
|
useModularUIBasic("groupingpanel", href, {
|
|
70
79
|
expectedModels: ["GroupingPanel"],
|
|
71
80
|
targetModel: GroupingPanelModel,
|
|
@@ -73,7 +82,7 @@ export const useGroupingPanel = (href: string): ?GroupingPanelModel =>
|
|
|
73
82
|
|
|
74
83
|
/**
|
|
75
84
|
*/
|
|
76
|
-
export const useDetailPanel = (href: string):
|
|
85
|
+
export const useDetailPanel = (href: string): DetailModel | null =>
|
|
77
86
|
useModularUIBasic("detailpanel", href, {
|
|
78
87
|
expectedModels: ["Detail"],
|
|
79
88
|
targetModel: DetailModel,
|
|
@@ -81,7 +90,7 @@ export const useDetailPanel = (href: string): ?DetailModel =>
|
|
|
81
90
|
|
|
82
91
|
/**
|
|
83
92
|
*/
|
|
84
|
-
export const useQuicksearch = (href: string):
|
|
93
|
+
export const useQuicksearch = (href: string): CaseSearchModel | null =>
|
|
85
94
|
useModularUIBasic("quicksearch", href, {
|
|
86
95
|
expectedModels: ["CaseSearch"],
|
|
87
96
|
targetModel: CaseSearchModel,
|
|
@@ -89,7 +98,7 @@ export const useQuicksearch = (href: string): ?CaseSearchModel =>
|
|
|
89
98
|
|
|
90
99
|
/**
|
|
91
100
|
*/
|
|
92
|
-
export const useUserProfile = (href: string):
|
|
101
|
+
export const useUserProfile = (href: string): UserProfileModel | null =>
|
|
93
102
|
useModularUIBasic("userprofile", href, {
|
|
94
103
|
expectedModels: ["UserProfile"],
|
|
95
104
|
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","
|
|
1
|
+
{"version":3,"file":"useModularUIModel.js","names":["useApplication","useModularUIBasic","expectedModels","targetModel","ApplicationModel","useTab","href","TabModel","useCaseView","CaseViewModel","usePanel","useList","ListModel","useListOrDetail","DetailModel","useListDetail","ListDetailModel","forceTargetModel","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 forceTargetModel: true,\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\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n });\n"],"mappings":";;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACO,MAAMA,cAAc,GAAG,MAC5B,IAAAC,oCAAiB,EAAC,aAAa,EAAE,GAAG,EAAE;EACpCC,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC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,gBAAgB,GAAIZ,IAAY,IAC3C,IAAAL,oCAAiB,EAAC,eAAe,EAAEK,IAAI,EAAE;EACvCJ,cAAc,EAAE,CAAC,eAAe,CAAC;EACjCC,WAAW,EAAEgB;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,cAAc,GAAId,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,MAAMO,cAAc,GAAIf,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,YAAY,CAAC;EAC9BC,WAAW,EAAEmB;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,cAAc,GAAIjB,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEqB;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
|
-
|
|
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<
|
|
25
|
-
) => ModularUIRequest) =>
|
|
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":["
|
|
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;
|
|
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,KAAK,cAAc,CACzC;IAED,IAAIe,gBAAgB,EAAE;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,IAAI,EAAE;MACnE,OAAO,IAAI,CAAClB,YAAY,CAACkB,QAAQ,CAACzB,IAAI;IACxC;IAEA,OAAO,IAAI;EACb;AACF;AAAC"}
|
|
@@ -33,6 +33,13 @@ class ResourceModel extends _BaseModel.default {
|
|
|
33
33
|
this._lastServerUpdate = Date.now();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Property to render name of a model, is original name after transpilation
|
|
38
|
+
*/
|
|
39
|
+
static get modelName() {
|
|
40
|
+
throw new _exceptions.IllegalStateException(`No modelName set on the resource model`);
|
|
41
|
+
}
|
|
42
|
+
|
|
36
43
|
/**
|
|
37
44
|
* Returns true when the model is supported based on configuration found in contributions
|
|
38
45
|
*
|
|
@@ -37,6 +37,13 @@ class ResourceModel extends BaseModel implements IModelWithChildModels {
|
|
|
37
37
|
this._lastServerUpdate = Date.now();
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Property to render name of a model, is original name after transpilation
|
|
42
|
+
*/
|
|
43
|
+
static get modelName(): string {
|
|
44
|
+
throw new IllegalStateException(`No modelName set on the resource model`);
|
|
45
|
+
}
|
|
46
|
+
|
|
40
47
|
/**
|
|
41
48
|
* Returns true when the model is supported based on configuration found in contributions
|
|
42
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResourceModel.js","names":["ResourceModel","BaseModel","constructor","modularuiResponse","ModularUIResponse","data","contributions","_key","key","_locale","locale","_childModels","_lastServerUpdate","Date","now","isApplicableModel","IllegalArgumentException","Error","lastServerUpdate","type","
|
|
1
|
+
{"version":3,"file":"ResourceModel.js","names":["ResourceModel","BaseModel","constructor","modularuiResponse","ModularUIResponse","data","contributions","_key","key","_locale","locale","_childModels","_lastServerUpdate","Date","now","modelName","IllegalStateException","isApplicableModel","IllegalArgumentException","Error","lastServerUpdate","type","resourcetype","getContribution","label","links","_links","LinkCollection","Array","isArray","self","selflink","getLinkByKey","selfhref","href","getInitialChildModelLinks","childModels","addChildModels","models","flattenModels","setChildModels","dehydrate","childModel"],"sources":["../../../src/models/base/ResourceModel.js"],"sourcesContent":["// @flow\nimport ModularUIResponse from \"../../modularui/ModularUIResponse\";\n\nimport BaseModel from \"./BaseModel\";\nimport LinkCollection from \"../links/LinkCollection\";\n\nimport {\n IllegalArgumentException,\n IllegalStateException,\n} from \"../../exceptions\";\n\nimport type LinkModel from \"../links/LinkModel\";\nimport type Href from \"../href/Href\";\nimport type { ModularUIModel, IModelWithChildModels } from \"../types\";\n\n/**\n * Base model, this the foundation for models that represent modular ui services, e.g. application, tab, caseview, etc\n */\nclass ResourceModel extends BaseModel implements IModelWithChildModels {\n _key: string;\n _locale: string;\n _childModels: Array<ModularUIModel>;\n _links: LinkCollection;\n _lastServerUpdate: number;\n\n /**\n * constructor\n */\n constructor(modularuiResponse: ModularUIResponse = new ModularUIResponse()) {\n super(modularuiResponse.data, modularuiResponse.contributions);\n\n this._key = modularuiResponse.key;\n this._locale = modularuiResponse.locale;\n\n this._childModels = [];\n\n this._lastServerUpdate = Date.now();\n }\n\n /**\n * Property to render name of a model, is original name after transpilation\n */\n static get modelName(): string {\n throw new IllegalStateException(`No modelName set on the resource model`);\n }\n\n /**\n * Returns true when the model is supported based on configuration found in contributions\n *\n * @abstract\n */\n static isApplicableModel(data: ModularUIResponse): boolean {\n if (!(data instanceof ModularUIResponse)) {\n throw new IllegalArgumentException(\n \"Given argument for isApplicableModel is not a ModularUIResponse\"\n );\n }\n\n throw new Error(\"No isApplicableModel condition set on resourcemodel\");\n }\n\n /**\n */\n get lastServerUpdate(): number {\n return this._lastServerUpdate;\n }\n\n /**\n */\n set lastServerUpdate(lastServerUpdate: number) {\n this._lastServerUpdate = lastServerUpdate;\n }\n\n /**\n */\n get locale(): string {\n return this._locale;\n }\n\n /**\n * Retrieve key\n */\n get key(): string {\n return this._key;\n }\n\n /**\n * Get type of model\n *\n * @abstract\n */\n get type(): string {\n throw new IllegalStateException(\n `No type set on the resource model with key ${this.key}`\n );\n }\n\n /**\n * Retrieve type of resource\n */\n get resourcetype(): string {\n return this.getContribution(\"resourcetype\", \"unknown\");\n }\n\n /**\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the links of the resource\n */\n get links(): LinkCollection {\n if (!this._links) {\n this._links = new LinkCollection(\n Array.isArray(this.data._links)\n ? this.data._links[0]\n : this.data._links,\n {\n self: {\n resourcetype: this.resourcetype,\n },\n ...this.contributions._links,\n }\n );\n }\n return this._links;\n }\n\n /**\n */\n set links(links: LinkCollection) {\n this._links = links;\n }\n\n /**\n * Get self link of model\n */\n get selflink(): LinkModel {\n const selflink = this.links.getLinkByKey(\"self\");\n\n if (selflink === null) {\n throw new IllegalStateException(\n `Could not find self link for ${\n this.key === null ? \"unknown\" : this.key\n }`\n );\n }\n\n return selflink;\n }\n\n /**\n * Return default self link of resource\n */\n get selfhref(): Href {\n return this.selflink.href;\n }\n\n /**\n * Add links to expand on initialization of this model\n *\n * @abstract\n */\n getInitialChildModelLinks(): Array<LinkModel> {\n return [];\n }\n\n /**\n * Retrieve links of expanded child models\n */\n get childModels(): Array<ModularUIModel> {\n return this._childModels;\n }\n\n /**\n * Add child models to this model\n */\n addChildModels(models: Array<ModularUIModel>): this {\n const flattenModels = [].concat(...models);\n\n this._childModels = flattenModels;\n\n this.setChildModels(flattenModels);\n\n return this;\n }\n\n /**\n * Template to set expanded child models\n * Use this hook to separate the retrieved child models into the correct models.\n *\n * @abstract\n * @example <caption>Put all models of instance List and GroupingPanel into the panels property</caption>\n */\n setChildModels(models: Array<ModularUIModel>): void {\n if (!models) {\n throw new IllegalArgumentException(\"No models send to setChildModels\");\n }\n }\n\n /**\n */\n dehydrate(): Object {\n return {\n ...super.dehydrate(),\n key: this._key,\n locale: this._locale,\n // $FlowFixMe[missing-type-arg]\n childModels: this._childModels.map<ModularUIModel>(\n (childModel: ModularUIModel) => childModel.dehydrate()\n ),\n };\n }\n}\n\nexport default ResourceModel;\n"],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