@beinformed/ui 1.65.10 → 1.65.12
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 +23 -0
- package/esm/hooks/useDeepCompareEffect.js +22 -8
- package/esm/hooks/useDeepCompareEffect.js.flow +26 -10
- package/esm/hooks/useDeepCompareEffect.js.map +1 -1
- package/esm/hooks/useList.js +12 -6
- package/esm/hooks/useList.js.flow +9 -6
- package/esm/hooks/useList.js.map +1 -1
- package/esm/hooks/useLookup.js +1 -1
- package/esm/hooks/useLookup.js.flow +1 -1
- package/esm/hooks/useLookup.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +10 -3
- package/esm/hooks/useModularUIBasic.js.flow +11 -1
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/hooks/usePanel.js.flow +1 -1
- package/esm/hooks/usePanel.js.map +1 -1
- package/esm/hooks/useRouter.js +12 -6
- package/esm/hooks/useRouter.js.flow +29 -23
- package/esm/hooks/useRouter.js.map +1 -1
- package/esm/models/href/Href.js +26 -1
- package/esm/models/href/Href.js.flow +28 -1
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/href/ListHref.js +12 -2
- package/esm/models/href/ListHref.js.flow +14 -2
- package/esm/models/href/ListHref.js.map +1 -1
- package/esm/models/list/ListModel.js +42 -16
- package/esm/models/list/ListModel.js.flow +33 -2
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/parameter/Parameter.js +6 -6
- package/esm/models/parameter/Parameter.js.flow +6 -6
- package/esm/models/parameter/Parameter.js.map +1 -1
- package/lib/hooks/useDeepCompareEffect.js +22 -11
- package/lib/hooks/useDeepCompareEffect.js.map +1 -1
- package/lib/hooks/useList.js +12 -6
- package/lib/hooks/useList.js.map +1 -1
- package/lib/hooks/useLookup.js +1 -1
- package/lib/hooks/useLookup.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +9 -2
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/hooks/usePanel.js.map +1 -1
- package/lib/hooks/useRouter.js +12 -6
- package/lib/hooks/useRouter.js.map +1 -1
- package/lib/models/href/Href.js +26 -1
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/href/ListHref.js +12 -2
- package/lib/models/href/ListHref.js.map +1 -1
- package/lib/models/list/ListModel.js +42 -16
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/parameter/Parameter.js +6 -6
- package/lib/models/parameter/Parameter.js.map +1 -1
- package/package.json +10 -10
- package/src/hooks/useDeepCompareEffect.js +26 -10
- package/src/hooks/useList.js +9 -6
- package/src/hooks/useLookup.js +1 -1
- package/src/hooks/useModularUIBasic.js +11 -1
- package/src/hooks/usePanel.js +1 -1
- package/src/hooks/useRouter.js +29 -23
- package/src/models/href/Href.js +28 -1
- package/src/models/href/ListHref.js +14 -2
- package/src/models/list/ListModel.js +33 -2
- package/src/models/parameter/Parameter.js +6 -6
|
@@ -55,13 +55,13 @@ class Parameter {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// parameter has the structure prefix~name=value
|
|
58
|
-
const namePart = parameter.
|
|
59
|
-
const value = parameter.
|
|
58
|
+
const namePart = parameter.substring(0, parameter.indexOf("="));
|
|
59
|
+
const value = parameter.substring(parameter.indexOf("=") + 1);
|
|
60
60
|
let prefix;
|
|
61
|
-
let name = namePart;
|
|
62
|
-
if ((0, _includes.default)(
|
|
63
|
-
prefix =
|
|
64
|
-
name =
|
|
61
|
+
let name = decodeURIComponent(namePart);
|
|
62
|
+
if ((0, _includes.default)(name).call(name, _Constants.PARAMETER_SEPARATOR)) {
|
|
63
|
+
prefix = name.substring(0, name.indexOf("~"));
|
|
64
|
+
name = name.substring(name.indexOf("~") + 1);
|
|
65
65
|
}
|
|
66
66
|
if (name === "") {
|
|
67
67
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Parameter.js","names":["_Constants","require","_Settings","Parameter","constructor","prefix","name","value","_defineProperty2","default","_prefix","_name","_value","fromString","parameter","_includes","call","namePart","
|
|
1
|
+
{"version":3,"file":"Parameter.js","names":["_Constants","require","_Settings","Parameter","constructor","prefix","name","value","_defineProperty2","default","_prefix","_name","_value","fromString","parameter","_includes","call","namePart","substring","indexOf","decodeURIComponent","PARAMETER_SEPARATOR","toString","withPrefix","toQuerystring","encodeURIComponent","isModUIParameter","_isModUIParameter","_context","uiParameterSetting","getSetting","DEFAULT_UI_PARAMETERS","_default","exports"],"sources":["../../../src/models/parameter/Parameter.js"],"sourcesContent":["// @flow\nimport {\n PARAMETER_SEPARATOR,\n DEFAULT_UI_PARAMETERS,\n} from \"../../constants/Constants\";\nimport { getSetting } from \"../../constants/Settings\";\n\n/**\n * Querystring parameter\n */\nclass Parameter {\n _prefix: ?string;\n _name: string;\n _value: ?string;\n _isModUIParameter: boolean | null = null;\n\n /**\n */\n constructor(prefix: ?string, name: string, value: ?string) {\n this._prefix = prefix;\n this._name = name;\n this._value = value;\n }\n\n /**\n * Getting prefix\n */\n get prefix(): ?string {\n return this._prefix;\n }\n\n /**\n * Getting name\n */\n get name(): string {\n return this._name;\n }\n\n /**\n * Getting value\n */\n get value(): ?string {\n return this._value;\n }\n\n /**\n * Create parameter from string input\n */\n static fromString(parameter: string): null | Parameter {\n if (parameter == null || parameter === \"\" || !parameter.includes(\"=\")) {\n return null;\n }\n\n // parameter has the structure prefix~name=value\n const namePart = parameter.substring(0, parameter.indexOf(\"=\"));\n const value = parameter.substring(parameter.indexOf(\"=\") + 1);\n\n let prefix;\n let name = decodeURIComponent(namePart);\n if (name.includes(PARAMETER_SEPARATOR)) {\n prefix = name.substring(0, name.indexOf(\"~\"));\n name = name.substring(name.indexOf(\"~\") + 1);\n }\n\n if (name === \"\") {\n return null;\n }\n\n return new Parameter(prefix, name, decodeURIComponent(value));\n }\n\n /**\n * Convert parameter to string\n */\n toString(withPrefix: boolean = true): string {\n if (!this.name) {\n return \"\";\n }\n\n const value = this.value == null ? \"\" : this.value;\n\n return withPrefix && this.prefix\n ? `${this.prefix}${PARAMETER_SEPARATOR}${this.name}=${value}`\n : `${this.name}=${value}`;\n }\n\n /**\n */\n toQuerystring(withPrefix: boolean = true): string {\n if (!this.name) {\n return \"\";\n }\n\n const value = this.value == null ? \"\" : encodeURIComponent(this.value);\n\n return withPrefix && this.prefix\n ? `${this.prefix}${PARAMETER_SEPARATOR}${this.name}=${value}`\n : `${this.name}=${value}`;\n }\n\n /**\n * Indicates if parameter can be send to the Be Informed modular UI\n */\n get isModUIParameter(): boolean {\n if (this._isModUIParameter == null) {\n const uiParameterSetting = getSetting(\"UI_PARAMETERS\", []);\n this._isModUIParameter = ![\n ...DEFAULT_UI_PARAMETERS,\n ...uiParameterSetting,\n ].includes(this.name);\n }\n\n return this._isModUIParameter;\n }\n}\n\nexport default Parameter;\n"],"mappings":";;;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA,MAAME,SAAS,CAAC;EAMd;AACF;EACEC,WAAWA,CAACC,MAAe,EAAEC,IAAY,EAAEC,KAAc,EAAE;IAAA,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA,6BAJvB,IAAI;IAKtC,IAAI,CAACC,OAAO,GAAGL,MAAM;IACrB,IAAI,CAACM,KAAK,GAAGL,IAAI;IACjB,IAAI,CAACM,MAAM,GAAGL,KAAK;EACrB;;EAEA;AACF;AACA;EACE,IAAIF,MAAMA,CAAA,EAAY;IACpB,OAAO,IAAI,CAACK,OAAO;EACrB;;EAEA;AACF;AACA;EACE,IAAIJ,IAAIA,CAAA,EAAW;IACjB,OAAO,IAAI,CAACK,KAAK;EACnB;;EAEA;AACF;AACA;EACE,IAAIJ,KAAKA,CAAA,EAAY;IACnB,OAAO,IAAI,CAACK,MAAM;EACpB;;EAEA;AACF;AACA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version": "1.65.12",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "https://support.beinformed.com",
|
|
@@ -69,9 +69,9 @@
|
|
|
69
69
|
"styled-components": "^5.0.0"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@babel/runtime-corejs3": "^7.28.
|
|
72
|
+
"@babel/runtime-corejs3": "^7.28.6",
|
|
73
73
|
"@date-fns/tz": "^1.4.1",
|
|
74
|
-
"baseline-browser-mapping": "^2.9.
|
|
74
|
+
"baseline-browser-mapping": "^2.9.14",
|
|
75
75
|
"big.js": "^7.0.1",
|
|
76
76
|
"date-fns": "^4.1.0",
|
|
77
77
|
"deepmerge": "^4.3.1",
|
|
@@ -89,18 +89,18 @@
|
|
|
89
89
|
"timezone-soft": "^1.5.2"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@babel/cli": "^7.28.
|
|
93
|
-
"@babel/core": "^7.28.
|
|
94
|
-
"@babel/eslint-parser": "^7.28.
|
|
92
|
+
"@babel/cli": "^7.28.6",
|
|
93
|
+
"@babel/core": "^7.28.6",
|
|
94
|
+
"@babel/eslint-parser": "^7.28.6",
|
|
95
95
|
"@babel/eslint-plugin": "^7.27.1",
|
|
96
96
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
97
97
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
98
98
|
"@babel/plugin-transform-runtime": "^7.28.5",
|
|
99
|
-
"@babel/preset-env": "^7.28.
|
|
99
|
+
"@babel/preset-env": "^7.28.6",
|
|
100
100
|
"@babel/preset-flow": "^7.27.1",
|
|
101
101
|
"@babel/preset-react": "^7.28.5",
|
|
102
|
-
"@commitlint/cli": "^20.3.
|
|
103
|
-
"@commitlint/config-conventional": "^20.3.
|
|
102
|
+
"@commitlint/cli": "^20.3.1",
|
|
103
|
+
"@commitlint/config-conventional": "^20.3.1",
|
|
104
104
|
"@testing-library/dom": "^10.4.1",
|
|
105
105
|
"@testing-library/react": "^16.3.1",
|
|
106
106
|
"auditjs": "^4.0.47",
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
"flow-bin": "^0.200.1",
|
|
123
123
|
"flow-copy-source": "^2.0.9",
|
|
124
124
|
"flow-typed": "^3.9.0",
|
|
125
|
-
"hermes-eslint": "^0.33.
|
|
125
|
+
"hermes-eslint": "^0.33.3",
|
|
126
126
|
"history": "^4.0.0",
|
|
127
127
|
"husky": "^9.1.7",
|
|
128
128
|
"jest": "^30.2.0",
|
|
@@ -1,34 +1,50 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import
|
|
2
|
+
import { useRef, useEffect } from "react";
|
|
3
3
|
import { dequal as deepEqual } from "dequal/lite";
|
|
4
4
|
|
|
5
5
|
type Callback = () => void | (() => void);
|
|
6
|
-
type DependencyList =
|
|
6
|
+
type DependencyList = $ReadOnlyArray<any>;
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
9
|
+
* Validates that dependencies are used correctly.
|
|
10
|
+
* Deep compare should not be used with empty arrays or no dependencies.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
function checkDeps(deps: DependencyList) {
|
|
13
|
+
if (process.env.NODE_ENV !== "production") {
|
|
14
|
+
if (!deps || deps.length === 0) {
|
|
15
|
+
console.warn(
|
|
16
|
+
"useDeepCompareEffect should not be used with no dependencies. Use React.useEffect instead.",
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const useDeepCompareMemoize = (value: DependencyList): DependencyList => {
|
|
23
|
+
const ref = useRef<DependencyList>(value);
|
|
15
24
|
|
|
25
|
+
// Only update the ref if the deep equality check fails
|
|
16
26
|
if (!deepEqual(value, ref.current)) {
|
|
17
27
|
ref.current = value;
|
|
18
|
-
signalRef.current += 1;
|
|
19
28
|
}
|
|
20
29
|
|
|
21
|
-
return
|
|
30
|
+
return ref.current;
|
|
22
31
|
};
|
|
23
32
|
|
|
24
33
|
/**
|
|
34
|
+
* A version of useEffect that accepts a deep comparison of dependencies.
|
|
25
35
|
*/
|
|
26
36
|
export function useDeepCompareEffect(
|
|
27
37
|
callback: Callback,
|
|
28
38
|
dependencies: DependencyList,
|
|
29
39
|
): void {
|
|
40
|
+
if (process.env.NODE_ENV !== "production") {
|
|
41
|
+
checkDeps(dependencies);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// We use the memoized ref as the dependency.
|
|
45
|
+
// React's shallow check will only trigger when the ref object itself changes.
|
|
30
46
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
-
|
|
47
|
+
useEffect(callback, useDeepCompareMemoize(dependencies));
|
|
32
48
|
}
|
|
33
49
|
|
|
34
50
|
export default useDeepCompareEffect;
|
package/src/hooks/useList.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import { useHistory } from "react-router";
|
|
3
2
|
import { useDispatch } from "react-redux";
|
|
4
3
|
|
|
5
4
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
@@ -7,6 +6,8 @@ import { HTTP_METHODS } from "../constants/Constants";
|
|
|
7
6
|
|
|
8
7
|
import { loadModularUI } from "../redux";
|
|
9
8
|
|
|
9
|
+
import { useNavigation } from "./useRouter";
|
|
10
|
+
|
|
10
11
|
import DetailModel from "../models/detail/DetailModel";
|
|
11
12
|
import ListModel from "../models/list/ListModel";
|
|
12
13
|
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
@@ -84,9 +85,11 @@ export const useListNavigation = ({
|
|
|
84
85
|
syncLocation = true,
|
|
85
86
|
historyAction = "push",
|
|
86
87
|
}: ListNavigationOptions = {}): ListNavigationHook => {
|
|
87
|
-
const
|
|
88
|
+
const { push, replace } = useNavigation();
|
|
88
89
|
const dispatch = useDispatch();
|
|
89
90
|
|
|
91
|
+
const navigate = historyAction === "push" ? push : replace;
|
|
92
|
+
|
|
90
93
|
const update = useCallback(
|
|
91
94
|
(list: ListModel, resetPage: boolean = false) => {
|
|
92
95
|
const listHref = list.selfhref;
|
|
@@ -96,9 +99,9 @@ export const useListNavigation = ({
|
|
|
96
99
|
|
|
97
100
|
if (list.requestMethod === HTTP_METHODS.POST) {
|
|
98
101
|
if (syncLocation) {
|
|
99
|
-
|
|
102
|
+
navigate({
|
|
100
103
|
search: listHref.getQuerystring(true),
|
|
101
|
-
state: list.formdata,
|
|
104
|
+
state: { formdata: list.formdata },
|
|
102
105
|
});
|
|
103
106
|
}
|
|
104
107
|
|
|
@@ -111,7 +114,7 @@ export const useListNavigation = ({
|
|
|
111
114
|
);
|
|
112
115
|
} else {
|
|
113
116
|
if (syncLocation) {
|
|
114
|
-
|
|
117
|
+
navigate({ search: listHref.getQuerystring(true) });
|
|
115
118
|
}
|
|
116
119
|
dispatch(
|
|
117
120
|
loadModularUI(list.connectKey, listHref, {
|
|
@@ -121,7 +124,7 @@ export const useListNavigation = ({
|
|
|
121
124
|
);
|
|
122
125
|
}
|
|
123
126
|
},
|
|
124
|
-
[dispatch,
|
|
127
|
+
[dispatch, navigate, syncLocation],
|
|
125
128
|
);
|
|
126
129
|
|
|
127
130
|
const updateFilters = useCallback(
|
package/src/hooks/useLookup.js
CHANGED
|
@@ -21,7 +21,7 @@ type UseLookupHook = {
|
|
|
21
21
|
export const useLookup = (
|
|
22
22
|
lookupLink: LinkModel,
|
|
23
23
|
filterInput: string = "",
|
|
24
|
-
minLength: number =
|
|
24
|
+
minLength: number = 1,
|
|
25
25
|
debounceMs: number = 300,
|
|
26
26
|
): UseLookupHook => {
|
|
27
27
|
const { start, finish } = useProgressIndicator();
|
|
@@ -4,7 +4,7 @@ import { useSelector } from "react-redux";
|
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { useModularUI } from "./useModularUI";
|
|
6
6
|
|
|
7
|
-
import { MODULARUI_STATUS } from "../constants";
|
|
7
|
+
import { HTTP_METHODS, MODULARUI_STATUS } from "../constants";
|
|
8
8
|
import { useModularUIKey } from "./useModularUIKey";
|
|
9
9
|
|
|
10
10
|
import type { ModularUIModel, Href } from "../models";
|
|
@@ -13,6 +13,7 @@ export type HookOptions = {
|
|
|
13
13
|
origin?: string,
|
|
14
14
|
contextPath?: string,
|
|
15
15
|
removeOnUnmount?: boolean,
|
|
16
|
+
formdata?: any,
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
export type UseModularUIBasicOptions<T: ModularUIModel> = {
|
|
@@ -25,6 +26,7 @@ export type UseModularUIBasicOptions<T: ModularUIModel> = {
|
|
|
25
26
|
key?: string,
|
|
26
27
|
isReload?: boolean,
|
|
27
28
|
removeOnUnmount?: boolean,
|
|
29
|
+
formdata?: any,
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
// Helper to create useModularUI options
|
|
@@ -41,6 +43,8 @@ const createUseModularUIOptions = <T: ModularUIModel>(
|
|
|
41
43
|
contextPath: undefined,
|
|
42
44
|
cache: false,
|
|
43
45
|
removeOnUnmount: false,
|
|
46
|
+
method: HTTP_METHODS.GET,
|
|
47
|
+
data: undefined,
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
// Handle targetModel and forceTargetModel
|
|
@@ -62,6 +66,11 @@ const createUseModularUIOptions = <T: ModularUIModel>(
|
|
|
62
66
|
baseOptions.removeOnUnmount = true;
|
|
63
67
|
}
|
|
64
68
|
|
|
69
|
+
if (options.formdata != null) {
|
|
70
|
+
baseOptions.method = HTTP_METHODS.POST;
|
|
71
|
+
baseOptions.data = options.formdata;
|
|
72
|
+
}
|
|
73
|
+
|
|
65
74
|
// Handle origin and contextPath options
|
|
66
75
|
baseOptions.origin = options.origin ?? baseOptions.origin;
|
|
67
76
|
baseOptions.contextPath = options.contextPath ?? baseOptions.contextPath;
|
|
@@ -94,6 +103,7 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
94
103
|
origin: undefined,
|
|
95
104
|
contextPath: undefined,
|
|
96
105
|
key: undefined,
|
|
106
|
+
formdata: undefined,
|
|
97
107
|
},
|
|
98
108
|
): T | null => {
|
|
99
109
|
const memoizedHref = useMemo(() => href.toString(), [href]);
|
package/src/hooks/usePanel.js
CHANGED
|
@@ -64,7 +64,7 @@ const useUrl = (href?: string | Href, fromRoute: boolean = false) => {
|
|
|
64
64
|
*/
|
|
65
65
|
export const usePanel = (
|
|
66
66
|
href?: string | Href,
|
|
67
|
-
options?: HookOptions
|
|
67
|
+
options?: { ...HookOptions, fromRoute?: boolean },
|
|
68
68
|
): ListModel | GroupingPanelModel | DetailModel | null => {
|
|
69
69
|
const { fromRoute, ...hookOptions } = options || { fromRoute: false };
|
|
70
70
|
|
package/src/hooks/useRouter.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @flow
|
|
2
|
+
import { useMemo } from "react";
|
|
2
3
|
import { useDispatch, useSelector } from "react-redux";
|
|
3
|
-
import type { Location, LocationShape } from "react-router";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
push,
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
goBack,
|
|
10
10
|
goForward,
|
|
11
11
|
} from "../redux/_router/RouterActions";
|
|
12
|
+
|
|
13
|
+
import type { Location, LocationShape } from "react-router";
|
|
12
14
|
import type {
|
|
13
15
|
GoAction,
|
|
14
16
|
GoBackAction,
|
|
@@ -17,48 +19,52 @@ import type {
|
|
|
17
19
|
ReplaceAction,
|
|
18
20
|
} from "../redux";
|
|
19
21
|
|
|
20
|
-
type
|
|
21
|
-
type UseLocationKeyHook = () => string;
|
|
22
|
-
type UseQuerystringHook = () => string;
|
|
23
|
-
type UsePathnameHook = () => string;
|
|
24
|
-
type UseNavigationHook = () => {
|
|
22
|
+
type NavigationAPI = {|
|
|
25
23
|
push: (location: LocationShape | string, state?: { ... }) => PushAction,
|
|
26
24
|
replace: (location: LocationShape | string, state?: { ... }) => ReplaceAction,
|
|
27
25
|
go: (delta: number) => GoAction,
|
|
28
26
|
goBack: () => GoBackAction,
|
|
29
27
|
goForward: () => GoForwardAction,
|
|
30
|
-
};
|
|
28
|
+
|};
|
|
31
29
|
|
|
32
30
|
/**
|
|
31
|
+
* Returns the full location object from the router state.
|
|
33
32
|
*/
|
|
34
|
-
export const useLocation
|
|
35
|
-
useSelector((state) => state.router
|
|
33
|
+
export const useLocation = (): Location =>
|
|
34
|
+
useSelector((state) => state.router?.location || {});
|
|
36
35
|
|
|
37
36
|
/**
|
|
37
|
+
* Returns the unique key of the current location.
|
|
38
38
|
*/
|
|
39
|
-
export const useLocationKey
|
|
40
|
-
|
|
39
|
+
export const useLocationKey = (): string =>
|
|
40
|
+
useSelector((state) => state.router?.location?.key ?? "");
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
+
* Returns the current search (querystring) portion of the URL.
|
|
43
44
|
*/
|
|
44
|
-
export const useQuerystring
|
|
45
|
+
export const useQuerystring = (): string =>
|
|
46
|
+
useSelector((state) => state.router?.location?.search ?? "");
|
|
45
47
|
|
|
46
48
|
/**
|
|
49
|
+
* Returns the current URL pathname.
|
|
47
50
|
*/
|
|
48
|
-
export const usePathname
|
|
51
|
+
export const usePathname = (): string =>
|
|
52
|
+
useSelector((state) => state.router?.location?.pathname ?? "");
|
|
49
53
|
|
|
50
54
|
/**
|
|
55
|
+
* Provides navigation methods.
|
|
51
56
|
*/
|
|
52
|
-
export const useNavigation
|
|
57
|
+
export const useNavigation = (): NavigationAPI => {
|
|
53
58
|
const dispatch = useDispatch();
|
|
54
59
|
|
|
55
|
-
return
|
|
56
|
-
|
|
57
|
-
dispatch(push(location, state)),
|
|
58
|
-
|
|
59
|
-
dispatch(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
return useMemo(
|
|
61
|
+
() => ({
|
|
62
|
+
push: (location, state) => dispatch(push(location, state)),
|
|
63
|
+
replace: (location, state) => dispatch(replace(location, state)),
|
|
64
|
+
go: (delta) => dispatch(go(delta)),
|
|
65
|
+
goBack: () => dispatch(goBack()),
|
|
66
|
+
goForward: () => dispatch(goForward()),
|
|
67
|
+
}),
|
|
68
|
+
[dispatch],
|
|
69
|
+
);
|
|
64
70
|
};
|
package/src/models/href/Href.js
CHANGED
|
@@ -336,6 +336,15 @@ class Href {
|
|
|
336
336
|
return this.getQuerystring(false);
|
|
337
337
|
}
|
|
338
338
|
|
|
339
|
+
/**
|
|
340
|
+
* Retrieve all parameters from the parameter collection in a querystring style prefix~name1=value1&prefix~name2=value2, with the prefix
|
|
341
|
+
* The prefix is used to identify parameters per component on a grouping panel
|
|
342
|
+
* @returns {string}
|
|
343
|
+
*/
|
|
344
|
+
get publicQuerystring(): string {
|
|
345
|
+
return this.getQuerystring(true);
|
|
346
|
+
}
|
|
347
|
+
|
|
339
348
|
/**
|
|
340
349
|
* Set the path of the Href, the part before the querystring question mark
|
|
341
350
|
*/
|
|
@@ -413,6 +422,23 @@ class Href {
|
|
|
413
422
|
return this;
|
|
414
423
|
}
|
|
415
424
|
|
|
425
|
+
/**
|
|
426
|
+
*/
|
|
427
|
+
set formdata(formdata: any) {
|
|
428
|
+
const currentState = this.state ?? {};
|
|
429
|
+
|
|
430
|
+
this.state = {
|
|
431
|
+
...currentState,
|
|
432
|
+
formdata,
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
*/
|
|
438
|
+
get formdata(): any {
|
|
439
|
+
return this.state?.formdata;
|
|
440
|
+
}
|
|
441
|
+
|
|
416
442
|
/**
|
|
417
443
|
* Set resourctype
|
|
418
444
|
*/
|
|
@@ -551,7 +577,8 @@ class Href {
|
|
|
551
577
|
toLocation(): LocationShape {
|
|
552
578
|
return {
|
|
553
579
|
pathname: this.path,
|
|
554
|
-
search:
|
|
580
|
+
search:
|
|
581
|
+
this.publicQuerystring.length > 0 ? `?${this.publicQuerystring}` : "",
|
|
555
582
|
hash: this.hash.length > 0 ? `#${this.hash}` : "",
|
|
556
583
|
state: {
|
|
557
584
|
origin: this.origin,
|
|
@@ -18,6 +18,7 @@ export default class ListHref extends Href {
|
|
|
18
18
|
_pagingName: string;
|
|
19
19
|
_pagesizeName: string;
|
|
20
20
|
_sortingName: string;
|
|
21
|
+
_lookupToken: ?string;
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
24
|
* Create a ListHref
|
|
@@ -28,7 +29,7 @@ export default class ListHref extends Href {
|
|
|
28
29
|
this._isPrefixed = isPrefixed;
|
|
29
30
|
|
|
30
31
|
if (list != null) {
|
|
31
|
-
this.
|
|
32
|
+
this.setParametersFromListModel(list);
|
|
32
33
|
} else if (href != null && href instanceof ListHref) {
|
|
33
34
|
this.setParameterNamesFromHref(href);
|
|
34
35
|
}
|
|
@@ -47,7 +48,7 @@ export default class ListHref extends Href {
|
|
|
47
48
|
/**
|
|
48
49
|
* Retrieve parameter names and settings from List model
|
|
49
50
|
*/
|
|
50
|
-
|
|
51
|
+
setParametersFromListModel(list: ListModel) {
|
|
51
52
|
this._prefix = this._isPrefixed ? list.key : null;
|
|
52
53
|
|
|
53
54
|
this._pagingName = list.paging ? list.paging.name : "";
|
|
@@ -65,6 +66,10 @@ export default class ListHref extends Href {
|
|
|
65
66
|
this.sort = list.sorting && list.sorting.param ? list.sorting.param : null;
|
|
66
67
|
|
|
67
68
|
this.filterCollection = list.filterCollection;
|
|
69
|
+
|
|
70
|
+
this.formdata = list.formdata;
|
|
71
|
+
|
|
72
|
+
this.lookupToken = list.lookupToken;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
/**
|
|
@@ -126,6 +131,13 @@ export default class ListHref extends Href {
|
|
|
126
131
|
this.setParameter(this.pagesizeName, pageSizeValue, this.prefix);
|
|
127
132
|
}
|
|
128
133
|
|
|
134
|
+
/**
|
|
135
|
+
* Set the lookup token
|
|
136
|
+
*/
|
|
137
|
+
set lookupToken(token: ?string) {
|
|
138
|
+
this.setParameter("lookupToken", token, this.prefix);
|
|
139
|
+
}
|
|
140
|
+
|
|
129
141
|
/**
|
|
130
142
|
* Add filter parameters to the parameter collection
|
|
131
143
|
*/
|
|
@@ -35,6 +35,18 @@ export default class ListModel extends ResourceModel {
|
|
|
35
35
|
_actionCollection: ActionCollection;
|
|
36
36
|
_listItemCollection: ListItemCollection;
|
|
37
37
|
_grouping: GroupingModel;
|
|
38
|
+
_lookupToken: ?string = null;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*/
|
|
42
|
+
constructor(modularuiResponse: ModularUIResponse) {
|
|
43
|
+
super(modularuiResponse);
|
|
44
|
+
|
|
45
|
+
const lookupToken = modularuiResponse?.parameters?.find(
|
|
46
|
+
(param) => param.name === "lookupToken",
|
|
47
|
+
);
|
|
48
|
+
this.lookupToken = lookupToken?.value;
|
|
49
|
+
}
|
|
38
50
|
|
|
39
51
|
/**
|
|
40
52
|
*/
|
|
@@ -109,6 +121,19 @@ export default class ListModel extends ResourceModel {
|
|
|
109
121
|
return this.contributions.label;
|
|
110
122
|
}
|
|
111
123
|
|
|
124
|
+
/**
|
|
125
|
+
* In case of a lookup list, the token being used to request the list
|
|
126
|
+
*/
|
|
127
|
+
get lookupToken(): ?string {
|
|
128
|
+
return this._lookupToken;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
*/
|
|
133
|
+
set lookupToken(lookupToken: ?string) {
|
|
134
|
+
this._lookupToken = lookupToken;
|
|
135
|
+
}
|
|
136
|
+
|
|
112
137
|
/**
|
|
113
138
|
* Getting the introduction text
|
|
114
139
|
*/
|
|
@@ -448,7 +473,13 @@ export default class ListModel extends ResourceModel {
|
|
|
448
473
|
|
|
449
474
|
/**
|
|
450
475
|
*/
|
|
451
|
-
get formdata(): string {
|
|
452
|
-
|
|
476
|
+
get formdata(): string | null {
|
|
477
|
+
const { formdata } = this.filterCollection;
|
|
478
|
+
|
|
479
|
+
if (formdata != null) {
|
|
480
|
+
return JSON.stringify(formdata);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
return null;
|
|
453
484
|
}
|
|
454
485
|
}
|
|
@@ -52,14 +52,14 @@ class Parameter {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// parameter has the structure prefix~name=value
|
|
55
|
-
const namePart = parameter.
|
|
56
|
-
const value = parameter.
|
|
55
|
+
const namePart = parameter.substring(0, parameter.indexOf("="));
|
|
56
|
+
const value = parameter.substring(parameter.indexOf("=") + 1);
|
|
57
57
|
|
|
58
58
|
let prefix;
|
|
59
|
-
let name = namePart;
|
|
60
|
-
if (
|
|
61
|
-
prefix =
|
|
62
|
-
name =
|
|
59
|
+
let name = decodeURIComponent(namePart);
|
|
60
|
+
if (name.includes(PARAMETER_SEPARATOR)) {
|
|
61
|
+
prefix = name.substring(0, name.indexOf("~"));
|
|
62
|
+
name = name.substring(name.indexOf("~") + 1);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (name === "") {
|