@beinformed/ui 1.17.2 → 1.18.1
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 +22 -2
- package/esm/constants/Constants.js +4 -0
- package/esm/constants/Constants.js.map +1 -1
- package/esm/constants/Settings.js +25 -1
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js +1 -11
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/i18n/Locale.js +2 -1
- package/esm/i18n/Locale.js.map +1 -1
- package/esm/models/attributes/AttributeContent.js +2 -0
- package/esm/models/attributes/AttributeContent.js.map +1 -1
- package/esm/models/content/SectionModel.js +2 -0
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/modularui/Authenticate.js +9 -9
- package/esm/modularui/Authenticate.js.map +1 -1
- package/esm/react-client/client.js +3 -2
- package/esm/react-client/client.js.map +1 -1
- package/esm/react-server/serverUtil.js +2 -1
- package/esm/react-server/serverUtil.js.map +1 -1
- package/esm/redux/actions/FormAttributeSet.js +5 -11
- package/esm/redux/actions/FormAttributeSet.js.map +1 -1
- package/esm/redux/actions/Preferences.js +32 -2
- package/esm/redux/actions/Preferences.js.map +1 -1
- package/esm/redux/reducers/PreferencesReducer.js +5 -1
- package/esm/redux/reducers/PreferencesReducer.js.map +1 -1
- package/lib/constants/Constants.js +9 -1
- package/lib/constants/Constants.js.flow +5 -0
- package/lib/constants/Constants.js.map +1 -1
- package/lib/constants/Settings.js +37 -1
- package/lib/constants/Settings.js.flow +25 -1
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/useForm.js +2 -15
- package/lib/hooks/useForm.js.flow +0 -10
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/i18n/Locale.js +2 -1
- package/lib/i18n/Locale.js.flow +4 -2
- package/lib/i18n/Locale.js.map +1 -1
- package/lib/i18n/__tests__/Locale.spec.js.flow +3 -2
- package/lib/models/attributes/AttributeContent.js +2 -0
- package/lib/models/attributes/AttributeContent.js.flow +2 -0
- package/lib/models/attributes/AttributeContent.js.map +1 -1
- package/lib/models/content/SectionModel.js +2 -0
- package/lib/models/content/SectionModel.js.flow +2 -0
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/modularui/Authenticate.js +10 -10
- package/lib/modularui/Authenticate.js.flow +11 -7
- package/lib/modularui/Authenticate.js.map +1 -1
- package/lib/react-client/client.js +2 -1
- package/lib/react-client/client.js.flow +5 -1
- package/lib/react-client/client.js.map +1 -1
- package/lib/react-server/__tests__/serverUtil.spec.js.flow +18 -0
- package/lib/react-server/serverUtil.js +1 -0
- package/lib/react-server/serverUtil.js.flow +2 -0
- package/lib/react-server/serverUtil.js.map +1 -1
- package/lib/redux/actions/FormAttributeSet.js +6 -15
- package/lib/redux/actions/FormAttributeSet.js.flow +3 -16
- package/lib/redux/actions/FormAttributeSet.js.map +1 -1
- package/lib/redux/actions/Preferences.js +41 -1
- package/lib/redux/actions/Preferences.js.flow +49 -2
- package/lib/redux/actions/Preferences.js.map +1 -1
- package/lib/redux/actions/__tests__/Preferences.spec.js.flow +11 -0
- package/lib/redux/reducers/PreferencesReducer.js +5 -1
- package/lib/redux/reducers/PreferencesReducer.js.flow +8 -1
- package/lib/redux/reducers/PreferencesReducer.js.map +1 -1
- package/lib/redux/reducers/__tests__/PreferencesReducer.spec.js.flow +12 -0
- package/lib/redux/types.js.flow +5 -0
- package/package.json +26 -24
- package/src/constants/Constants.js +5 -0
- package/src/constants/Settings.js +25 -1
- package/src/hooks/useForm.js +0 -10
- package/src/i18n/Locale.js +4 -2
- package/src/i18n/__tests__/Locale.spec.js +3 -2
- package/src/models/attributes/AttributeContent.js +2 -0
- package/src/models/content/SectionModel.js +2 -0
- package/src/modularui/Authenticate.js +11 -7
- package/src/react-client/client.js +5 -1
- package/src/react-server/__tests__/serverUtil.spec.js +18 -0
- package/src/react-server/serverUtil.js +2 -0
- package/src/redux/actions/FormAttributeSet.js +3 -16
- package/src/redux/actions/Preferences.js +49 -2
- package/src/redux/actions/__tests__/Preferences.spec.js +11 -0
- package/src/redux/reducers/PreferencesReducer.js +8 -1
- package/src/redux/reducers/__tests__/PreferencesReducer.spec.js +12 -0
- package/src/redux/types.js +5 -0
|
@@ -35,10 +35,7 @@ export const updateFormAttribute =
|
|
|
35
35
|
options.validate = true;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (
|
|
39
|
-
newForm.currentFormObject &&
|
|
40
|
-
newForm.currentFormObject.equals(formObject)
|
|
41
|
-
) {
|
|
38
|
+
if (newForm.currentFormObject?.equals(formObject)) {
|
|
42
39
|
newForm.currentFormObject.updateAttribute(attribute, inputvalue);
|
|
43
40
|
} else {
|
|
44
41
|
newForm.completedFormObjects.forEach((completeObject) => {
|
|
@@ -64,22 +61,12 @@ export const updateFormAttribute =
|
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
if (
|
|
67
|
-
newForm.currentFormObject &&
|
|
68
64
|
options.validate &&
|
|
69
|
-
newForm.currentFormObject
|
|
65
|
+
newForm.currentFormObject?.hasDynamicValidations &&
|
|
70
66
|
getSetting("USE_INSTANT_SERVER_VALIDATION")
|
|
71
67
|
) {
|
|
68
|
+
// server form validations happens async, don't wait for the form to return
|
|
72
69
|
dispatch(validateFormObject(newForm));
|
|
73
70
|
}
|
|
74
|
-
|
|
75
71
|
return dispatch(updateModel(newForm));
|
|
76
72
|
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Validate an attribute on a form
|
|
80
|
-
*/
|
|
81
|
-
export const validateFormAttribute =
|
|
82
|
-
(form: FormModel): ThunkAction =>
|
|
83
|
-
(dispatch: Dispatch) => {
|
|
84
|
-
return dispatch(validateFormObject(form));
|
|
85
|
-
};
|
|
@@ -2,14 +2,23 @@
|
|
|
2
2
|
import { isPlainObject } from "../../utils/helpers/objects";
|
|
3
3
|
|
|
4
4
|
import { JsonParseException } from "../../exceptions";
|
|
5
|
-
import {
|
|
5
|
+
import { setSetting, setSettings } from "../../constants/Settings";
|
|
6
6
|
|
|
7
7
|
import type {
|
|
8
8
|
PreferenceValue,
|
|
9
9
|
ReduxState,
|
|
10
10
|
SetPreferenceAction,
|
|
11
|
+
SetPreferencesAction,
|
|
11
12
|
} from "../types";
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
import {
|
|
15
|
+
BASE,
|
|
16
|
+
ALL_CONTENT_IN_DATA_SETTING,
|
|
17
|
+
LOGIN_PASSWORD_SETTING,
|
|
18
|
+
LOGIN_PATH_SETTING,
|
|
19
|
+
LOGIN_USERNAME_SETTING,
|
|
20
|
+
LOGOUT_PATH_SETTING,
|
|
21
|
+
} from "../../constants";
|
|
13
22
|
|
|
14
23
|
/**
|
|
15
24
|
*/
|
|
@@ -57,6 +66,15 @@ export const setPreference = (
|
|
|
57
66
|
},
|
|
58
67
|
});
|
|
59
68
|
|
|
69
|
+
/**
|
|
70
|
+
*/
|
|
71
|
+
export const setPreferences = (preferences: Object): SetPreferencesAction => ({
|
|
72
|
+
type: "SET_PREFERENCES",
|
|
73
|
+
payload: {
|
|
74
|
+
...preferences,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
60
78
|
/**
|
|
61
79
|
*/
|
|
62
80
|
export const setThemePreference = (
|
|
@@ -97,3 +115,32 @@ export const setAllContentInDataSetting = (
|
|
|
97
115
|
setSetting(ALL_CONTENT_IN_DATA_SETTING, !!allContentInDataSetting);
|
|
98
116
|
return setPreference(ALL_CONTENT_IN_DATA_SETTING, allContentInDataSetting);
|
|
99
117
|
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Retrieves login settings from runtime preferences and sets them as setting in the preference reducer
|
|
121
|
+
*/
|
|
122
|
+
export const setLoginPreferences = (
|
|
123
|
+
state?: ReduxState
|
|
124
|
+
): SetPreferencesAction => {
|
|
125
|
+
const loginSettings = {
|
|
126
|
+
[LOGIN_PATH_SETTING]: getServerPreferenceValue(
|
|
127
|
+
LOGIN_PATH_SETTING,
|
|
128
|
+
state?.preferences[LOGIN_PATH_SETTING] ?? `${BASE}/j_security_check`
|
|
129
|
+
),
|
|
130
|
+
[LOGIN_USERNAME_SETTING]: getServerPreferenceValue(
|
|
131
|
+
LOGIN_USERNAME_SETTING,
|
|
132
|
+
state?.preferences[LOGIN_USERNAME_SETTING] ?? "j_username"
|
|
133
|
+
),
|
|
134
|
+
[LOGIN_PASSWORD_SETTING]: getServerPreferenceValue(
|
|
135
|
+
LOGIN_PASSWORD_SETTING,
|
|
136
|
+
state?.preferences[LOGIN_PASSWORD_SETTING] ?? "j_password"
|
|
137
|
+
),
|
|
138
|
+
[LOGOUT_PATH_SETTING]: getServerPreferenceValue(
|
|
139
|
+
LOGOUT_PATH_SETTING,
|
|
140
|
+
state?.preferences[LOGOUT_PATH_SETTING] ?? `${BASE}/Logoff`
|
|
141
|
+
),
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
setSettings(loginSettings);
|
|
145
|
+
return setPreferences(loginSettings);
|
|
146
|
+
};
|
|
@@ -4,6 +4,7 @@ import thunk from "redux-thunk";
|
|
|
4
4
|
import {
|
|
5
5
|
setServerPreference,
|
|
6
6
|
setPreference,
|
|
7
|
+
setPreferences,
|
|
7
8
|
setThemePreference,
|
|
8
9
|
} from "../Preferences";
|
|
9
10
|
|
|
@@ -31,6 +32,16 @@ describe("preference actions", () => {
|
|
|
31
32
|
]);
|
|
32
33
|
});
|
|
33
34
|
|
|
35
|
+
it("set preferences", () => {
|
|
36
|
+
const store = mockStore({ preferences: {} });
|
|
37
|
+
|
|
38
|
+
store.dispatch(setPreferences({ name: "value" }));
|
|
39
|
+
|
|
40
|
+
expect(store.getActions()).toStrictEqual([
|
|
41
|
+
{ type: "SET_PREFERENCES", payload: { name: "value" } },
|
|
42
|
+
]);
|
|
43
|
+
});
|
|
44
|
+
|
|
34
45
|
it("theme settings", () => {
|
|
35
46
|
const store = mockStore({ preferences: {} });
|
|
36
47
|
|
|
@@ -11,7 +11,14 @@ const PreferencesReducer: Reducer<PreferencesState, ReduxAction> = (
|
|
|
11
11
|
state = initialState,
|
|
12
12
|
action
|
|
13
13
|
) => {
|
|
14
|
-
if (action
|
|
14
|
+
if (action?.type === "SET_PREFERENCE") {
|
|
15
|
+
return {
|
|
16
|
+
...state,
|
|
17
|
+
...action.payload,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (action?.type === "SET_PREFERENCES") {
|
|
15
22
|
return {
|
|
16
23
|
...state,
|
|
17
24
|
...action.payload,
|
|
@@ -16,4 +16,16 @@ describe("preferences reducer", () => {
|
|
|
16
16
|
name: "value",
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
|
+
|
|
20
|
+
it("should handle SET_PREFERENCES", () => {
|
|
21
|
+
expect(
|
|
22
|
+
PreferencesReducer([], {
|
|
23
|
+
type: "SET_PREFERENCES",
|
|
24
|
+
payload: { name: "value", name2: "value2" },
|
|
25
|
+
})
|
|
26
|
+
).toStrictEqual({
|
|
27
|
+
name: "value",
|
|
28
|
+
name2: "value2",
|
|
29
|
+
});
|
|
30
|
+
});
|
|
19
31
|
});
|
package/src/redux/types.js
CHANGED
|
@@ -84,6 +84,10 @@ export type SetPreferenceAction = {
|
|
|
84
84
|
type: "SET_PREFERENCE",
|
|
85
85
|
payload: { [name: string]: PreferenceValue },
|
|
86
86
|
};
|
|
87
|
+
export type SetPreferencesAction = {
|
|
88
|
+
type: "SET_PREFERENCES",
|
|
89
|
+
payload: { [name: string]: PreferenceValue },
|
|
90
|
+
};
|
|
87
91
|
|
|
88
92
|
export type StartProgressAction = {
|
|
89
93
|
type: "START_PROGRESS",
|
|
@@ -142,6 +146,7 @@ export type ReduxAction =
|
|
|
142
146
|
| DismissNotificationAction
|
|
143
147
|
| ShowNotificationAction
|
|
144
148
|
| SetPreferenceAction
|
|
149
|
+
| SetPreferencesAction
|
|
145
150
|
| StartProgressAction
|
|
146
151
|
| FinishProgressAction
|
|
147
152
|
| ResetProgressAction
|