@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.
Files changed (84) hide show
  1. package/CHANGELOG.md +22 -2
  2. package/esm/constants/Constants.js +4 -0
  3. package/esm/constants/Constants.js.map +1 -1
  4. package/esm/constants/Settings.js +25 -1
  5. package/esm/constants/Settings.js.map +1 -1
  6. package/esm/hooks/useForm.js +1 -11
  7. package/esm/hooks/useForm.js.map +1 -1
  8. package/esm/i18n/Locale.js +2 -1
  9. package/esm/i18n/Locale.js.map +1 -1
  10. package/esm/models/attributes/AttributeContent.js +2 -0
  11. package/esm/models/attributes/AttributeContent.js.map +1 -1
  12. package/esm/models/content/SectionModel.js +2 -0
  13. package/esm/models/content/SectionModel.js.map +1 -1
  14. package/esm/modularui/Authenticate.js +9 -9
  15. package/esm/modularui/Authenticate.js.map +1 -1
  16. package/esm/react-client/client.js +3 -2
  17. package/esm/react-client/client.js.map +1 -1
  18. package/esm/react-server/serverUtil.js +2 -1
  19. package/esm/react-server/serverUtil.js.map +1 -1
  20. package/esm/redux/actions/FormAttributeSet.js +5 -11
  21. package/esm/redux/actions/FormAttributeSet.js.map +1 -1
  22. package/esm/redux/actions/Preferences.js +32 -2
  23. package/esm/redux/actions/Preferences.js.map +1 -1
  24. package/esm/redux/reducers/PreferencesReducer.js +5 -1
  25. package/esm/redux/reducers/PreferencesReducer.js.map +1 -1
  26. package/lib/constants/Constants.js +9 -1
  27. package/lib/constants/Constants.js.flow +5 -0
  28. package/lib/constants/Constants.js.map +1 -1
  29. package/lib/constants/Settings.js +37 -1
  30. package/lib/constants/Settings.js.flow +25 -1
  31. package/lib/constants/Settings.js.map +1 -1
  32. package/lib/hooks/useForm.js +2 -15
  33. package/lib/hooks/useForm.js.flow +0 -10
  34. package/lib/hooks/useForm.js.map +1 -1
  35. package/lib/i18n/Locale.js +2 -1
  36. package/lib/i18n/Locale.js.flow +4 -2
  37. package/lib/i18n/Locale.js.map +1 -1
  38. package/lib/i18n/__tests__/Locale.spec.js.flow +3 -2
  39. package/lib/models/attributes/AttributeContent.js +2 -0
  40. package/lib/models/attributes/AttributeContent.js.flow +2 -0
  41. package/lib/models/attributes/AttributeContent.js.map +1 -1
  42. package/lib/models/content/SectionModel.js +2 -0
  43. package/lib/models/content/SectionModel.js.flow +2 -0
  44. package/lib/models/content/SectionModel.js.map +1 -1
  45. package/lib/modularui/Authenticate.js +10 -10
  46. package/lib/modularui/Authenticate.js.flow +11 -7
  47. package/lib/modularui/Authenticate.js.map +1 -1
  48. package/lib/react-client/client.js +2 -1
  49. package/lib/react-client/client.js.flow +5 -1
  50. package/lib/react-client/client.js.map +1 -1
  51. package/lib/react-server/__tests__/serverUtil.spec.js.flow +18 -0
  52. package/lib/react-server/serverUtil.js +1 -0
  53. package/lib/react-server/serverUtil.js.flow +2 -0
  54. package/lib/react-server/serverUtil.js.map +1 -1
  55. package/lib/redux/actions/FormAttributeSet.js +6 -15
  56. package/lib/redux/actions/FormAttributeSet.js.flow +3 -16
  57. package/lib/redux/actions/FormAttributeSet.js.map +1 -1
  58. package/lib/redux/actions/Preferences.js +41 -1
  59. package/lib/redux/actions/Preferences.js.flow +49 -2
  60. package/lib/redux/actions/Preferences.js.map +1 -1
  61. package/lib/redux/actions/__tests__/Preferences.spec.js.flow +11 -0
  62. package/lib/redux/reducers/PreferencesReducer.js +5 -1
  63. package/lib/redux/reducers/PreferencesReducer.js.flow +8 -1
  64. package/lib/redux/reducers/PreferencesReducer.js.map +1 -1
  65. package/lib/redux/reducers/__tests__/PreferencesReducer.spec.js.flow +12 -0
  66. package/lib/redux/types.js.flow +5 -0
  67. package/package.json +26 -24
  68. package/src/constants/Constants.js +5 -0
  69. package/src/constants/Settings.js +25 -1
  70. package/src/hooks/useForm.js +0 -10
  71. package/src/i18n/Locale.js +4 -2
  72. package/src/i18n/__tests__/Locale.spec.js +3 -2
  73. package/src/models/attributes/AttributeContent.js +2 -0
  74. package/src/models/content/SectionModel.js +2 -0
  75. package/src/modularui/Authenticate.js +11 -7
  76. package/src/react-client/client.js +5 -1
  77. package/src/react-server/__tests__/serverUtil.spec.js +18 -0
  78. package/src/react-server/serverUtil.js +2 -0
  79. package/src/redux/actions/FormAttributeSet.js +3 -16
  80. package/src/redux/actions/Preferences.js +49 -2
  81. package/src/redux/actions/__tests__/Preferences.spec.js +11 -0
  82. package/src/redux/reducers/PreferencesReducer.js +8 -1
  83. package/src/redux/reducers/__tests__/PreferencesReducer.spec.js +12 -0
  84. package/src/redux/types.js +5 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations","validateFormAttribute"],"mappings":";;;;;;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAOA;AACA;AACA;AACO,IAAMA,mBAAmB,GAC9B,SADWA,mBACX,CACEC,IADF,EAEEC,UAFF,EAGEC,SAHF,EAIEC,UAJF;AAAA,MAKEC,OALF,uEAK+B;AAC3BC,IAAAA,UAAU,EAAE,KADe;AAE3BC,IAAAA,QAAQ,EAAE,KAFiB;AAG3BC,IAAAA,WAAW,EAAE,KAHc;AAI3BC,IAAAA,QAAQ,EAAE;AAJiB,GAL/B;AAAA,SAYA,UAACC,QAAD,EAAwB;AACtB,QAAMC,OAAO,GAAGV,IAAI,CAACW,KAAL,EAAhB;;AAEA,QAAIP,OAAO,CAACI,QAAR,KAAqBI,SAAzB,EAAoC;AAClCR,MAAAA,OAAO,CAACI,QAAR,GAAmB,IAAnB;AACD;;AAED,QACEE,OAAO,CAACG,iBAAR,IACAH,OAAO,CAACG,iBAAR,CAA0BC,MAA1B,CAAiCb,UAAjC,CAFF,EAGE;AACAS,MAAAA,OAAO,CAACG,iBAAR,CAA0BE,eAA1B,CAA0Cb,SAA1C,EAAqDC,UAArD;AACD,KALD,MAKO;AACLO,MAAAA,OAAO,CAACM,oBAAR,CAA6BC,OAA7B,CAAqC,UAACC,cAAD,EAAoB;AACvD,YAAIA,cAAc,CAACJ,MAAf,CAAsBb,UAAtB,CAAJ,EAAuC;AACrCiB,UAAAA,cAAc,CAACH,eAAf,CAA+Bb,SAA/B,EAA0CC,UAA1C;AACD;AACF,OAJD;AAKD;;AAED,QAAIC,OAAO,CAACC,UAAR,IAAsBK,OAAO,CAACS,OAAlC,EAA2C;AACzC,UAAMC,gBAAgB,GAAG,0CACvBV,OADuB,EAEvBR,SAFuB,EAGvBE,OAAO,CAACG,WAHe,CAAzB;;AAKA,UAAIa,gBAAJ,EAAsB;AACpB,eAAOX,QAAQ,CAACW,gBAAD,CAAf;AACD;AACF;;AAED,QAAIhB,OAAO,CAACE,QAAR,IAAoBI,OAAO,CAACS,OAA5B,IAAuCT,OAAO,CAACW,SAAR,EAA3C,EAAgE;AAC9DZ,MAAAA,QAAQ,CAAC,sCAAmBC,OAAnB,CAAD,CAAR;AACD;;AAED,QACEA,OAAO,CAACG,iBAAR,IACAT,OAAO,CAACI,QADR,IAEAE,OAAO,CAACG,iBAAR,CAA0BS,qBAF1B,IAGA,0BAAW,+BAAX,CAJF,EAKE;AACAb,MAAAA,QAAQ,CAAC,yCAAmBC,OAAnB,CAAD,CAAR;AACD;;AAED,WAAOD,QAAQ,CAAC,0BAAYC,OAAZ,CAAD,CAAf;AACD,GAzDD;AAAA,CADK;AA4DP;AACA;AACA;;;;;AACO,IAAMa,qBAAqB,GAChC,SADWA,qBACX,CAACvB,IAAD;AAAA,SACA,UAACS,QAAD,EAAwB;AACtB,WAAOA,QAAQ,CAAC,yCAAmBT,IAAnB,CAAD,CAAf;AACD,GAHD;AAAA,CADK","sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/actions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\n\nimport type { Dispatch, ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\n\n/**\n * Update an attribute on a form\n */\nexport const updateFormAttribute =\n (\n form: FormModel,\n formObject: FormObjectModel,\n attribute: AttributeType,\n inputvalue: string,\n options: UpdateFormOptions = {\n autosubmit: false,\n autosave: false,\n forceUpdate: false,\n validate: true,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (options.validate === undefined) {\n options.validate = true;\n }\n\n if (\n newForm.currentFormObject &&\n newForm.currentFormObject.equals(formObject)\n ) {\n newForm.currentFormObject.updateAttribute(attribute, inputvalue);\n } else {\n newForm.completedFormObjects.forEach((completeObject) => {\n if (completeObject.equals(formObject)) {\n completeObject.updateAttribute(attribute, inputvalue);\n }\n });\n }\n\n if (options.autosubmit && newForm.isValid) {\n const autosubmitAction = autosubmitFormObject(\n newForm,\n attribute,\n options.forceUpdate\n );\n if (autosubmitAction) {\n return dispatch(autosubmitAction);\n }\n }\n\n if (options.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n newForm.currentFormObject &&\n options.validate &&\n newForm.currentFormObject.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n dispatch(validateFormObject(newForm));\n }\n\n return dispatch(updateModel(newForm));\n };\n\n/**\n * Validate an attribute on a form\n */\nexport const validateFormAttribute =\n (form: FormModel): ThunkAction =>\n (dispatch: Dispatch) => {\n return dispatch(validateFormObject(form));\n };\n"],"file":"FormAttributeSet.js"}
1
+ {"version":3,"sources":["../../../src/redux/actions/FormAttributeSet.js"],"names":["updateFormAttribute","form","formObject","attribute","inputvalue","options","autosubmit","autosave","forceUpdate","validate","dispatch","newForm","clone","undefined","currentFormObject","equals","updateAttribute","completedFormObjects","forEach","completeObject","isValid","autosubmitAction","isChanged","hasDynamicValidations"],"mappings":";;;;;;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AAOA;AACA;AACA;AACO,IAAMA,mBAAmB,GAC9B,SADWA,mBACX,CACEC,IADF,EAEEC,UAFF,EAGEC,SAHF,EAIEC,UAJF;AAAA,MAKEC,OALF,uEAK+B;AAC3BC,IAAAA,UAAU,EAAE,KADe;AAE3BC,IAAAA,QAAQ,EAAE,KAFiB;AAG3BC,IAAAA,WAAW,EAAE,KAHc;AAI3BC,IAAAA,QAAQ,EAAE;AAJiB,GAL/B;AAAA,SAYA,UAACC,QAAD,EAAwB;AAAA;;AACtB,QAAMC,OAAO,GAAGV,IAAI,CAACW,KAAL,EAAhB;;AAEA,QAAIP,OAAO,CAACI,QAAR,KAAqBI,SAAzB,EAAoC;AAClCR,MAAAA,OAAO,CAACI,QAAR,GAAmB,IAAnB;AACD;;AAED,iCAAIE,OAAO,CAACG,iBAAZ,kDAAI,sBAA2BC,MAA3B,CAAkCb,UAAlC,CAAJ,EAAmD;AACjDS,MAAAA,OAAO,CAACG,iBAAR,CAA0BE,eAA1B,CAA0Cb,SAA1C,EAAqDC,UAArD;AACD,KAFD,MAEO;AACLO,MAAAA,OAAO,CAACM,oBAAR,CAA6BC,OAA7B,CAAqC,UAACC,cAAD,EAAoB;AACvD,YAAIA,cAAc,CAACJ,MAAf,CAAsBb,UAAtB,CAAJ,EAAuC;AACrCiB,UAAAA,cAAc,CAACH,eAAf,CAA+Bb,SAA/B,EAA0CC,UAA1C;AACD;AACF,OAJD;AAKD;;AAED,QAAIC,OAAO,CAACC,UAAR,IAAsBK,OAAO,CAACS,OAAlC,EAA2C;AACzC,UAAMC,gBAAgB,GAAG,0CACvBV,OADuB,EAEvBR,SAFuB,EAGvBE,OAAO,CAACG,WAHe,CAAzB;;AAKA,UAAIa,gBAAJ,EAAsB;AACpB,eAAOX,QAAQ,CAACW,gBAAD,CAAf;AACD;AACF;;AAED,QAAIhB,OAAO,CAACE,QAAR,IAAoBI,OAAO,CAACS,OAA5B,IAAuCT,OAAO,CAACW,SAAR,EAA3C,EAAgE;AAC9DZ,MAAAA,QAAQ,CAAC,sCAAmBC,OAAnB,CAAD,CAAR;AACD;;AAED,QACEN,OAAO,CAACI,QAAR,8BACAE,OAAO,CAACG,iBADR,mDACA,uBAA2BS,qBAD3B,IAEA,0BAAW,+BAAX,CAHF,EAIE;AACA;AACAb,MAAAA,QAAQ,CAAC,yCAAmBC,OAAnB,CAAD,CAAR;AACD;;AACD,WAAOD,QAAQ,CAAC,0BAAYC,OAAZ,CAAD,CAAf;AACD,GArDD;AAAA,CADK","sourcesContent":["// @flow\nimport { updateModel } from \"../_modularui/actions\";\n\nimport { getSetting } from \"../../constants/Settings\";\n\nimport { validateFormObject } from \"./FormValidations\";\nimport { autosaveFormObject } from \"./FormAutosave\";\nimport { autosubmitFormObject } from \"./FormAutosubmit\";\n\nimport type { Dispatch, ThunkAction, UpdateFormOptions } from \"../types\";\nimport type { AttributeType } from \"../../models/types\";\nimport type FormModel from \"../../models/form/FormModel\";\nimport type FormObjectModel from \"../../models/form/FormObjectModel\";\n\n/**\n * Update an attribute on a form\n */\nexport const updateFormAttribute =\n (\n form: FormModel,\n formObject: FormObjectModel,\n attribute: AttributeType,\n inputvalue: string,\n options: UpdateFormOptions = {\n autosubmit: false,\n autosave: false,\n forceUpdate: false,\n validate: true,\n }\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n const newForm = form.clone();\n\n if (options.validate === undefined) {\n options.validate = true;\n }\n\n if (newForm.currentFormObject?.equals(formObject)) {\n newForm.currentFormObject.updateAttribute(attribute, inputvalue);\n } else {\n newForm.completedFormObjects.forEach((completeObject) => {\n if (completeObject.equals(formObject)) {\n completeObject.updateAttribute(attribute, inputvalue);\n }\n });\n }\n\n if (options.autosubmit && newForm.isValid) {\n const autosubmitAction = autosubmitFormObject(\n newForm,\n attribute,\n options.forceUpdate\n );\n if (autosubmitAction) {\n return dispatch(autosubmitAction);\n }\n }\n\n if (options.autosave && newForm.isValid && newForm.isChanged()) {\n dispatch(autosaveFormObject(newForm));\n }\n\n if (\n options.validate &&\n newForm.currentFormObject?.hasDynamicValidations &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\")\n ) {\n // server form validations happens async, don't wait for the form to return\n dispatch(validateFormObject(newForm));\n }\n return dispatch(updateModel(newForm));\n };\n"],"file":"FormAttributeSet.js"}
@@ -1,11 +1,21 @@
1
1
  "use strict";
2
2
 
3
+ var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
4
+
5
+ var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
6
+
7
+ var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
8
+
9
+ var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
10
+
11
+ var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
12
+
3
13
  var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
4
14
 
5
15
  Object.defineProperty(exports, "__esModule", {
6
16
  value: true
7
17
  });
8
- exports.setThemePreference = exports.setServerPreference = exports.setPreference = exports.setAllContentInDataSetting = void 0;
18
+ exports.setThemePreference = exports.setServerPreference = exports.setPreferences = exports.setPreference = exports.setLoginPreferences = exports.setAllContentInDataSetting = void 0;
9
19
 
10
20
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
11
21
 
@@ -23,6 +33,10 @@ var _Settings = require("../../constants/Settings");
23
33
 
24
34
  var _constants = require("../../constants");
25
35
 
36
+ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
37
+
38
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? Object.defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
39
+
26
40
  /**
27
41
  */
28
42
  var getServerPreferenceValue = function getServerPreferenceValue(preferenceName) {
@@ -77,6 +91,18 @@ var setPreference = function setPreference(propertyName) {
77
91
 
78
92
  exports.setPreference = setPreference;
79
93
 
94
+ var setPreferences = function setPreferences(preferences) {
95
+ return {
96
+ type: "SET_PREFERENCES",
97
+ payload: _objectSpread({}, preferences)
98
+ };
99
+ };
100
+ /**
101
+ */
102
+
103
+
104
+ exports.setPreferences = setPreferences;
105
+
80
106
  var setThemePreference = function setThemePreference(configTheme) {
81
107
  var themeData = {};
82
108
 
@@ -111,6 +137,20 @@ var setAllContentInDataSetting = function setAllContentInDataSetting(state) {
111
137
  (0, _Settings.setSetting)(_constants.ALL_CONTENT_IN_DATA_SETTING, !!allContentInDataSetting);
112
138
  return setPreference(_constants.ALL_CONTENT_IN_DATA_SETTING, allContentInDataSetting);
113
139
  };
140
+ /**
141
+ * Retrieves login settings from runtime preferences and sets them as setting in the preference reducer
142
+ */
143
+
114
144
 
115
145
  exports.setAllContentInDataSetting = setAllContentInDataSetting;
146
+
147
+ var setLoginPreferences = function setLoginPreferences(state) {
148
+ var _state$preferences$LO, _state$preferences$LO2, _state$preferences$LO3, _state$preferences$LO4, _loginSettings;
149
+
150
+ var loginSettings = (_loginSettings = {}, (0, _defineProperty2.default)(_loginSettings, _constants.LOGIN_PATH_SETTING, getServerPreferenceValue(_constants.LOGIN_PATH_SETTING, (_state$preferences$LO = state === null || state === void 0 ? void 0 : state.preferences[_constants.LOGIN_PATH_SETTING]) !== null && _state$preferences$LO !== void 0 ? _state$preferences$LO : "".concat(_constants.BASE, "/j_security_check"))), (0, _defineProperty2.default)(_loginSettings, _constants.LOGIN_USERNAME_SETTING, getServerPreferenceValue(_constants.LOGIN_USERNAME_SETTING, (_state$preferences$LO2 = state === null || state === void 0 ? void 0 : state.preferences[_constants.LOGIN_USERNAME_SETTING]) !== null && _state$preferences$LO2 !== void 0 ? _state$preferences$LO2 : "j_username")), (0, _defineProperty2.default)(_loginSettings, _constants.LOGIN_PASSWORD_SETTING, getServerPreferenceValue(_constants.LOGIN_PASSWORD_SETTING, (_state$preferences$LO3 = state === null || state === void 0 ? void 0 : state.preferences[_constants.LOGIN_PASSWORD_SETTING]) !== null && _state$preferences$LO3 !== void 0 ? _state$preferences$LO3 : "j_password")), (0, _defineProperty2.default)(_loginSettings, _constants.LOGOUT_PATH_SETTING, getServerPreferenceValue(_constants.LOGOUT_PATH_SETTING, (_state$preferences$LO4 = state === null || state === void 0 ? void 0 : state.preferences[_constants.LOGOUT_PATH_SETTING]) !== null && _state$preferences$LO4 !== void 0 ? _state$preferences$LO4 : "".concat(_constants.BASE, "/Logoff"))), _loginSettings);
151
+ (0, _Settings.setSettings)(loginSettings);
152
+ return setPreferences(loginSettings);
153
+ };
154
+
155
+ exports.setLoginPreferences = setLoginPreferences;
116
156
  //# sourceMappingURL=Preferences.js.map
@@ -2,14 +2,23 @@
2
2
  import { isPlainObject } from "../../utils/helpers/objects";
3
3
 
4
4
  import { JsonParseException } from "../../exceptions";
5
- import { setSettings, setSetting } from "../../constants/Settings";
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
- import { ALL_CONTENT_IN_DATA_SETTING } from "../../constants";
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
+ };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/actions/Preferences.js"],"names":["getServerPreferenceValue","preferenceName","defaultValue","type","value","preferencesProvider","getPreferenceByName","split","val","setServerPreference","propertyName","setPreference","propertyValue","payload","setThemePreference","configTheme","themeData","JSON","parse","error","JsonParseException","settings","setAllContentInDataSetting","state","allContentInDataSetting","getModularUIContentInData","preferences","ALL_CONTENT_IN_DATA_SETTING"],"mappings":";;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AAOA;;AAEA;AACA;AACA,IAAMA,wBAAwB,GAAG,SAA3BA,wBAA2B,CAC/BC,cAD+B,EAI5B;AAAA,MAFHC,YAEG,uEAF6B,IAE7B;AAAA,MADHC,IACG;AACH,MAAIC,KAAK,GAAG,IAAZ;;AACA,MAAI,OAAOC,mBAAP,KAA+B,WAAnC,EAAgD;AAC9CD,IAAAA,KAAK,GAAGC,mBAAmB,CAACC,mBAApB,CAAwCL,cAAxC,CAAR;AACD;;AAED,MAAIG,KAAK,IAAI,IAAb,EAAmB;AACjBA,IAAAA,KAAK,GAAGF,YAAR;AACD;;AAED,MAAI,OAAOE,KAAP,KAAiB,QAAjB,IAA6BD,IAAI,KAAK,QAAtC,IAAkD,uBAAAC,KAAK,MAAL,CAAAA,KAAK,EAAU,GAAV,CAA3D,EAA2E;AAAA;;AACzEA,IAAAA,KAAK,GAAG,6BAAAA,KAAK,CAACG,KAAN,CAAY,GAAZ,kBAAqB,UAACC,GAAD;AAAA,aAAS,mBAAAA,GAAG,MAAH,CAAAA,GAAG,CAAZ;AAAA,KAArB,CAAR;AACD;;AAED,SAAOJ,KAAP;AACD,CAnBD;AAqBA;AACA;;;AACO,IAAMK,mBAAmB,GAAG,SAAtBA,mBAAsB,CACjCC,YADiC,EAIT;AAAA,MAFxBR,YAEwB,uEAFQ,IAER;AAAA,MADxBC,IACwB;AACxB,MAAMC,KAAK,GAAGJ,wBAAwB,CAACU,YAAD,EAAeR,YAAf,EAA6BC,IAA7B,CAAt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D,EAA8BH,uBAA9B,CAApB;AACD,CAhBM","sourcesContent":["// @flow\nimport { isPlainObject } from \"../../utils/helpers/objects\";\n\nimport { JsonParseException } from \"../../exceptions\";\nimport { setSettings, setSetting } from \"../../constants/Settings\";\n\nimport type {\n PreferenceValue,\n ReduxState,\n SetPreferenceAction,\n} from \"../types\";\nimport { ALL_CONTENT_IN_DATA_SETTING } from \"../../constants\";\n\n/**\n */\nconst getServerPreferenceValue = (\n preferenceName: string,\n defaultValue: PreferenceValue = null,\n type?: string\n) => {\n let value = null;\n if (typeof preferencesProvider !== \"undefined\") {\n value = preferencesProvider.getPreferenceByName(preferenceName);\n }\n\n if (value == null) {\n value = defaultValue;\n }\n\n if (typeof value === \"string\" && type !== \"string\" && value.includes(\",\")) {\n value = value.split(\",\").map((val) => val.trim());\n }\n\n return value;\n};\n\n/**\n */\nexport const setServerPreference = (\n propertyName: string,\n defaultValue: PreferenceValue = null,\n type?: string\n): SetPreferenceAction => {\n const value = getServerPreferenceValue(propertyName, defaultValue, type);\n return setPreference(propertyName, value);\n};\n\n/**\n */\nexport const setPreference = (\n propertyName: string,\n propertyValue: PreferenceValue = null\n): SetPreferenceAction => ({\n type: \"SET_PREFERENCE\",\n payload: {\n [propertyName]: propertyValue,\n },\n});\n\n/**\n */\nexport const setThemePreference = (\n configTheme: string\n): SetPreferenceAction => {\n let themeData = {};\n\n try {\n themeData = configTheme ? JSON.parse(configTheme) : null;\n } catch (error) {\n throw new JsonParseException(`Theme file contains invalid JSON: ${error}`);\n }\n\n if (themeData && isPlainObject(themeData)) {\n setSettings(themeData.settings);\n }\n\n return setPreference(\"theme\", themeData);\n};\n\n/**\n * Make modular-ui-content-in-data preference available client side\n */\nexport const setAllContentInDataSetting = (\n state?: ReduxState\n): SetPreferenceAction => {\n let allContentInDataSetting = false;\n\n if (\n typeof preferencesProvider !== \"undefined\" &&\n typeof preferencesProvider.getModularUIContentInData !== \"undefined\"\n ) {\n allContentInDataSetting = preferencesProvider.getModularUIContentInData();\n } else if (typeof state !== \"undefined\") {\n allContentInDataSetting = state.preferences[ALL_CONTENT_IN_DATA_SETTING];\n }\n\n setSetting(ALL_CONTENT_IN_DATA_SETTING, !!allContentInDataSetting);\n return setPreference(ALL_CONTENT_IN_DATA_SETTING, allContentInDataSetting);\n};\n"],"file":"Preferences.js"}
1
+ {"version":3,"sources":["../../../src/redux/actions/Preferences.js"],"names":["getServerPreferenceValue","preferenceName","defaultValue","type","value","preferencesProvider","getPreferenceByName","split","val","setServerPreference","propertyName","setPreference","propertyValue","payload","setPreferences","preferences","setThemePreference","configTheme","themeData","JSON","parse","error","JsonParseException","settings","setAllContentInDataSetting","state","allContentInDataSetting","getModularUIContentInData","ALL_CONTENT_IN_DATA_SETTING","setLoginPreferences","loginSettings","LOGIN_PATH_SETTING","BASE","LOGIN_USERNAME_SETTING","LOGIN_PASSWORD_SETTING","LOGOUT_PATH_SETTING"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAEA;;AACA;;AASA;;;;;;AASA;AACA;AACA,IAAMA,wBAAwB,GAAG,SAA3BA,wBAA2B,CAC/BC,cAD+B,EAI5B;AAAA,MAFHC,YAEG,uEAF6B,IAE7B;AAAA,MADHC,IACG;AACH,MAAIC,KAAK,GAAG,IAAZ;;AACA,MAAI,OAAOC,mBAAP,KAA+B,WAAnC,EAAgD;AAC9CD,IAAAA,KAAK,GAAGC,mBAAmB,CAACC,mBAApB,CAAwCL,cAAxC,CAAR;AACD;;AAED,MAAIG,KAAK,IAAI,IAAb,EAAmB;AACjBA,IAAAA,KAAK,GAAGF,YAAR;AACD;;AAED,MAAI,OAAOE,KAAP,KAAiB,QAAjB,IAA6BD,IAAI,KAAK,QAAtC,IAAkD,uBAAAC,KAAK,MAAL,CAAAA,KAAK,EAAU,GAAV,CAA3D,EAA2E;AAAA;;AACzEA,IAAAA,KAAK,GAAG,6BAAAA,KAAK,CAACG,KAAN,CAAY,GAAZ,kBAAqB,UAACC,GAAD;AAAA,aAAS,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,CAF6C,qFAECH,eAFD,aAb9B,kBAAnB;AAmBA,6BAAYF,aAAZ;AACA,SAAOhB,cAAc,CAACgB,aAAD,CAArB;AACD,CAxBM","sourcesContent":["// @flow\nimport { isPlainObject } from \"../../utils/helpers/objects\";\n\nimport { JsonParseException } from \"../../exceptions\";\nimport { setSetting, setSettings } from \"../../constants/Settings\";\n\nimport type {\n PreferenceValue,\n ReduxState,\n SetPreferenceAction,\n SetPreferencesAction,\n} from \"../types\";\n\nimport {\n BASE,\n ALL_CONTENT_IN_DATA_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGOUT_PATH_SETTING,\n} from \"../../constants\";\n\n/**\n */\nconst getServerPreferenceValue = (\n preferenceName: string,\n defaultValue: PreferenceValue = null,\n type?: string\n) => {\n let value = null;\n if (typeof preferencesProvider !== \"undefined\") {\n value = preferencesProvider.getPreferenceByName(preferenceName);\n }\n\n if (value == null) {\n value = defaultValue;\n }\n\n if (typeof value === \"string\" && type !== \"string\" && value.includes(\",\")) {\n value = value.split(\",\").map((val) => val.trim());\n }\n\n return value;\n};\n\n/**\n */\nexport const setServerPreference = (\n propertyName: string,\n defaultValue: PreferenceValue = null,\n type?: string\n): SetPreferenceAction => {\n const value = getServerPreferenceValue(propertyName, defaultValue, type);\n return setPreference(propertyName, value);\n};\n\n/**\n */\nexport const setPreference = (\n propertyName: string,\n propertyValue: PreferenceValue = null\n): SetPreferenceAction => ({\n type: \"SET_PREFERENCE\",\n payload: {\n [propertyName]: propertyValue,\n },\n});\n\n/**\n */\nexport const setPreferences = (preferences: Object): SetPreferencesAction => ({\n type: \"SET_PREFERENCES\",\n payload: {\n ...preferences,\n },\n});\n\n/**\n */\nexport const setThemePreference = (\n configTheme: string\n): SetPreferenceAction => {\n let themeData = {};\n\n try {\n themeData = configTheme ? JSON.parse(configTheme) : null;\n } catch (error) {\n throw new JsonParseException(`Theme file contains invalid JSON: ${error}`);\n }\n\n if (themeData && isPlainObject(themeData)) {\n setSettings(themeData.settings);\n }\n\n return setPreference(\"theme\", themeData);\n};\n\n/**\n * Make modular-ui-content-in-data preference available client side\n */\nexport const setAllContentInDataSetting = (\n state?: ReduxState\n): SetPreferenceAction => {\n let allContentInDataSetting = false;\n\n if (\n typeof preferencesProvider !== \"undefined\" &&\n typeof preferencesProvider.getModularUIContentInData !== \"undefined\"\n ) {\n allContentInDataSetting = preferencesProvider.getModularUIContentInData();\n } else if (typeof state !== \"undefined\") {\n allContentInDataSetting = state.preferences[ALL_CONTENT_IN_DATA_SETTING];\n }\n\n setSetting(ALL_CONTENT_IN_DATA_SETTING, !!allContentInDataSetting);\n return setPreference(ALL_CONTENT_IN_DATA_SETTING, allContentInDataSetting);\n};\n\n/**\n * Retrieves login settings from runtime preferences and sets them as setting in the preference reducer\n */\nexport const setLoginPreferences = (\n state?: ReduxState\n): SetPreferencesAction => {\n const loginSettings = {\n [LOGIN_PATH_SETTING]: getServerPreferenceValue(\n LOGIN_PATH_SETTING,\n state?.preferences[LOGIN_PATH_SETTING] ?? `${BASE}/j_security_check`\n ),\n [LOGIN_USERNAME_SETTING]: getServerPreferenceValue(\n LOGIN_USERNAME_SETTING,\n state?.preferences[LOGIN_USERNAME_SETTING] ?? \"j_username\"\n ),\n [LOGIN_PASSWORD_SETTING]: getServerPreferenceValue(\n LOGIN_PASSWORD_SETTING,\n state?.preferences[LOGIN_PASSWORD_SETTING] ?? \"j_password\"\n ),\n [LOGOUT_PATH_SETTING]: getServerPreferenceValue(\n LOGOUT_PATH_SETTING,\n state?.preferences[LOGOUT_PATH_SETTING] ?? `${BASE}/Logoff`\n ),\n };\n\n setSettings(loginSettings);\n return setPreferences(loginSettings);\n};\n"],"file":"Preferences.js"}
@@ -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
 
@@ -32,7 +32,11 @@ var PreferencesReducer = function PreferencesReducer() {
32
32
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
33
33
  var action = arguments.length > 1 ? arguments[1] : undefined;
34
34
 
35
- if (action && action.type === "SET_PREFERENCE") {
35
+ if ((action === null || action === void 0 ? void 0 : action.type) === "SET_PREFERENCE") {
36
+ return _objectSpread(_objectSpread({}, state), action.payload);
37
+ }
38
+
39
+ if ((action === null || action === void 0 ? void 0 : action.type) === "SET_PREFERENCES") {
36
40
  return _objectSpread(_objectSpread({}, state), action.payload);
37
41
  }
38
42
 
@@ -11,7 +11,14 @@ const PreferencesReducer: Reducer<PreferencesState, ReduxAction> = (
11
11
  state = initialState,
12
12
  action
13
13
  ) => {
14
- if (action && action.type === "SET_PREFERENCE") {
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,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/redux/reducers/PreferencesReducer.js"],"names":["initialState","PreferencesReducer","state","action","type","payload"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,YAAsC,GAAG,EAA/C;AAEA;AACA;AACA;;AACA,IAAMC,kBAA0D,GAAG,SAA7DA,kBAA6D,GAG9D;AAAA,MAFHC,KAEG,uEAFKF,YAEL;AAAA,MADHG,MACG;;AACH,MAAIA,MAAM,IAAIA,MAAM,CAACC,IAAP,KAAgB,gBAA9B,EAAgD;AAC9C,2CACKF,KADL,GAEKC,MAAM,CAACE,OAFZ;AAID;;AAED,SAAOH,KAAP;AACD,CAZD;;eAceD,kB","sourcesContent":["// @flow\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction, PreferencesState } from \"../types\";\n\nconst initialState: $Shape<PreferencesState> = {};\n\n/**\n * Pref reducer\n */\nconst PreferencesReducer: Reducer<PreferencesState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (action && action.type === \"SET_PREFERENCE\") {\n return {\n ...state,\n ...action.payload,\n };\n }\n\n return state;\n};\n\nexport default PreferencesReducer;\n"],"file":"PreferencesReducer.js"}
1
+ {"version":3,"sources":["../../../src/redux/reducers/PreferencesReducer.js"],"names":["initialState","PreferencesReducer","state","action","type","payload"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAMA,YAAsC,GAAG,EAA/C;AAEA;AACA;AACA;;AACA,IAAMC,kBAA0D,GAAG,SAA7DA,kBAA6D,GAG9D;AAAA,MAFHC,KAEG,uEAFKF,YAEL;AAAA,MADHG,MACG;;AACH,MAAI,CAAAA,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEC,IAAR,MAAiB,gBAArB,EAAuC;AACrC,2CACKF,KADL,GAEKC,MAAM,CAACE,OAFZ;AAID;;AAED,MAAI,CAAAF,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEC,IAAR,MAAiB,iBAArB,EAAwC;AACtC,2CACKF,KADL,GAEKC,MAAM,CAACE,OAFZ;AAID;;AAED,SAAOH,KAAP;AACD,CAnBD;;eAqBeD,kB","sourcesContent":["// @flow\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction, PreferencesState } from \"../types\";\n\nconst initialState: $Shape<PreferencesState> = {};\n\n/**\n * Pref reducer\n */\nconst PreferencesReducer: Reducer<PreferencesState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (action?.type === \"SET_PREFERENCE\") {\n return {\n ...state,\n ...action.payload,\n };\n }\n\n if (action?.type === \"SET_PREFERENCES\") {\n return {\n ...state,\n ...action.payload,\n };\n }\n\n return state;\n};\n\nexport default PreferencesReducer;\n"],"file":"PreferencesReducer.js"}
@@ -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
  });
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.17.2",
3
+ "version": "1.18.1",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -78,7 +78,7 @@
78
78
  "styled-components": "^5.2.0"
79
79
  },
80
80
  "dependencies": {
81
- "@babel/runtime-corejs3": "^7.17.8",
81
+ "@babel/runtime-corejs3": "^7.17.9",
82
82
  "big.js": "^6.1.1",
83
83
  "date-fns": "^2.28.0",
84
84
  "deepmerge": "^4.2.2",
@@ -96,52 +96,54 @@
96
96
  },
97
97
  "devDependencies": {
98
98
  "@babel/cli": "^7.17.3",
99
- "@babel/core": "^7.17.8",
99
+ "@babel/core": "^7.17.9",
100
100
  "@babel/eslint-parser": "^7.17.0",
101
101
  "@babel/eslint-plugin": "^7.16.5",
102
+ "@babel/plugin-proposal-class-properties": "^7.16.7",
102
103
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
103
104
  "@babel/plugin-transform-runtime": "^7.17.0",
104
105
  "@babel/preset-env": "^7.16.11",
105
106
  "@babel/preset-flow": "^7.16.7",
106
107
  "@babel/preset-react": "^7.16.7",
107
- "@commitlint/cli": "^16.2.3",
108
- "@commitlint/config-conventional": "^16.2.1",
109
- "@testing-library/react-hooks": "^7.0.2",
110
- "auditjs": "^4.0.36",
111
- "babel-jest": "^27.5.1",
112
- "babel-plugin-styled-components": "^2.0.2",
108
+ "@commitlint/cli": "^16.2.4",
109
+ "@commitlint/config-conventional": "^16.2.4",
110
+ "@testing-library/react-hooks": "^8.0.0",
111
+ "auditjs": "^4.0.37",
112
+ "babel-jest": "^28.0.2",
113
+ "babel-plugin-styled-components": "^2.0.7",
113
114
  "cherry-pick": "^0.5.0",
114
115
  "cross-env": "^7.0.3",
115
116
  "documentation": "^13.2.5",
116
- "eslint": "^8.12.0",
117
+ "eslint": "^8.14.0",
117
118
  "eslint-config-prettier": "^8.3.0",
118
119
  "eslint-plugin-babel": "^5.3.1",
119
120
  "eslint-plugin-ft-flow": "^2.0.1",
120
- "eslint-plugin-import": "^2.25.4",
121
- "eslint-plugin-jest": "^26.1.3",
122
- "eslint-plugin-jsdoc": "^38.1.3",
121
+ "eslint-plugin-import": "^2.26.0",
122
+ "eslint-plugin-jest": "^26.1.5",
123
+ "eslint-plugin-jsdoc": "^39.2.9",
123
124
  "eslint-plugin-react": "^7.28.0",
124
- "eslint-plugin-react-hooks": "^4.3.0",
125
- "flow-bin": "^0.174.1",
125
+ "eslint-plugin-react-hooks": "^4.5.0",
126
+ "flow-bin": "^0.176.3",
126
127
  "flow-copy-source": "^2.0.9",
127
128
  "flow-typed": "^3.6.1",
128
- "glob": "^7.2.0",
129
+ "glob": "^8.0.1",
129
130
  "history": "^4.0.0",
130
131
  "husky": "^7.0.4",
131
- "jest": "^27.5.1",
132
- "jest-junit": "^13.0.0",
132
+ "jest": "^28.0.2",
133
+ "jest-environment-jsdom": "^28.0.2",
134
+ "jest-junit": "^13.2.0",
133
135
  "jest-sonar-reporter": "^2.0.0",
134
136
  "jscodeshift": "^0.13.1",
135
- "lint-staged": "^12.3.7",
136
- "polished": "^4.1.4",
137
- "prettier": "^2.6.1",
137
+ "lint-staged": "^12.4.1",
138
+ "polished": "^4.2.2",
139
+ "prettier": "^2.6.2",
138
140
  "react": "^17.0.2",
139
141
  "react-dom": "^17.0.2",
140
- "react-helmet-async": "^1.2.3",
141
- "react-redux": "^7.2.6",
142
+ "react-helmet-async": "^1.3.0",
143
+ "react-redux": "^7.2.8",
142
144
  "react-router": "^5.2.0",
143
145
  "react-test-renderer": "^17.0.2",
144
- "redux": "^4.1.2",
146
+ "redux": "^4.2.0",
145
147
  "redux-mock-store": "^1.5.4",
146
148
  "redux-thunk": "^2.4.1",
147
149
  "rimraf": "^3.0.2",
@@ -197,3 +197,8 @@ export const ATTRIBUTE_WIDTH = {
197
197
  };
198
198
 
199
199
  export const ALL_CONTENT_IN_DATA_SETTING = "hasAllContentInData";
200
+
201
+ export const LOGIN_PATH_SETTING = "FormClient.login_url";
202
+ export const LOGIN_USERNAME_SETTING = "FormClient.username_field_name";
203
+ export const LOGIN_PASSWORD_SETTING = "FormClient.password_field_name";
204
+ export const LOGOUT_PATH_SETTING = "FormClient.logout_url";
@@ -1,6 +1,13 @@
1
1
  // @flow
2
2
  import { isPlainObject, has } from "../utils/helpers/objects";
3
- import { ALL_CONTENT_IN_DATA_SETTING } from "./Constants";
3
+ import {
4
+ BASE,
5
+ ALL_CONTENT_IN_DATA_SETTING,
6
+ LOGIN_PATH_SETTING,
7
+ LOGIN_USERNAME_SETTING,
8
+ LOGIN_PASSWORD_SETTING,
9
+ LOGOUT_PATH_SETTING,
10
+ } from "./Constants";
4
11
 
5
12
  type Setting = boolean | string | number | Array<string>;
6
13
 
@@ -115,3 +122,20 @@ export const allSettings = (): { [name: string]: Setting } => settings;
115
122
  */
116
123
  export const hasAllContentInData = (): boolean =>
117
124
  getSetting(ALL_CONTENT_IN_DATA_SETTING, true);
125
+
126
+ /**
127
+ */
128
+ export const loginPath = (): string =>
129
+ getSetting(LOGIN_PATH_SETTING, `${BASE}/j_security_check`);
130
+ /**
131
+ */
132
+ export const loginUsernameField = (): string =>
133
+ getSetting(LOGIN_USERNAME_SETTING, "j_username");
134
+ /**
135
+ */
136
+ export const loginPasswordField = (): string =>
137
+ getSetting(LOGIN_PASSWORD_SETTING, "j_password");
138
+ /**
139
+ */
140
+ export const logoutPath = (): string =>
141
+ getSetting(LOGOUT_PATH_SETTING, `${BASE}/Logoff`);
@@ -16,7 +16,6 @@ import {
16
16
  removeRepeatableAttributeSet,
17
17
  showFormNotification,
18
18
  updateFormAttribute,
19
- validateFormAttribute,
20
19
  } from "../redux/actions";
21
20
 
22
21
  import FormModel from "../models/form/FormModel";
@@ -120,15 +119,6 @@ export const useAttributeUpdate = (
120
119
  ) => dispatch(updateFormAttribute(form, object, attribute, value, options));
121
120
  };
122
121
 
123
- /**
124
- * Validate attributes of a form
125
- */
126
- export const useAttributeValidate = (form: FormModel): AttributeUpdateHook => {
127
- const dispatch = useDispatch();
128
-
129
- return () => dispatch(validateFormAttribute(form));
130
- };
131
-
132
122
  /**
133
123
  * Attributeset actions
134
124
  */
@@ -107,9 +107,11 @@ class Locale {
107
107
  id &&
108
108
  getSetting("DEBUG_I18N_MESSAGE_NOT_FOUND")
109
109
  ) {
110
- console.warn(`Message with id ${id} not found for locale ${this.code}`);
110
+ // eslint-disable-next-line no-console
111
+ console.debug(
112
+ `Message with id ${id} not found for locale ${this.code} in layout translations`
113
+ );
111
114
  }
112
-
113
115
  return messageFromLocale || this.fixPlaceHolders(defaultMessage) || id;
114
116
  }
115
117
 
@@ -6,6 +6,7 @@ import { setSetting } from "../../constants";
6
6
 
7
7
  global.console = {
8
8
  warn: jest.fn(),
9
+ debug: jest.fn(),
9
10
  };
10
11
 
11
12
  jest.mock(
@@ -89,8 +90,8 @@ describe("locale", () => {
89
90
 
90
91
  const msg = locale.getMessage("non-existing");
91
92
  expect(msg).toBe("non-existing");
92
- expect(global.console.warn).toHaveBeenCalledWith(
93
- "Message with id non-existing not found for locale de"
93
+ expect(global.console.debug).toHaveBeenCalledWith(
94
+ "Message with id non-existing not found for locale de in layout translations"
94
95
  );
95
96
 
96
97
  const msgWithDefault = locale.getMessage("non-existing", "Default");
@@ -17,6 +17,8 @@ import type {
17
17
  } from "../types";
18
18
  import type SubSectionModel from "../content/SubSectionModel";
19
19
 
20
+ /**
21
+ */
20
22
  class AttributeContent {
21
23
  _content: ?ContentData;
22
24
 
@@ -9,6 +9,8 @@ import LinkModel from "../links/LinkModel";
9
9
  import type Href from "../href/Href";
10
10
  import { retrieveText } from "../../utils";
11
11
 
12
+ /**
13
+ */
12
14
  class SectionModel extends BaseModel {
13
15
  _entryDate: ISO_DATE | null;
14
16
  _selflink: ?LinkModel;
@@ -6,12 +6,12 @@ import Cache from "../utils/browser/Cache";
6
6
 
7
7
  import { UnauthorizedException } from "../exceptions";
8
8
  import type { RequestOptions } from "../utils/fetch/types";
9
-
10
- const LOGIN_PATH = `${BASE}/j_security_check`;
11
- const LOGOUT_PATH = `${BASE}/Logoff`;
12
-
13
- const usernameField = "j_username";
14
- const passwordField = "j_password";
9
+ import {
10
+ loginPasswordField,
11
+ loginPath,
12
+ loginUsernameField,
13
+ logoutPath,
14
+ } from "../constants";
15
15
 
16
16
  /**
17
17
  */
@@ -65,6 +65,10 @@ class Authenticate {
65
65
  /**
66
66
  */
67
67
  createLogin(username: string, password: string): $Shape<RequestOptions> {
68
+ const LOGIN_PATH = loginPath();
69
+ const usernameField = loginUsernameField();
70
+ const passwordField = loginPasswordField();
71
+
68
72
  const encodedUsername = encodeURIComponent(username);
69
73
  const encodedPassword = encodeURIComponent(password);
70
74
 
@@ -97,7 +101,7 @@ class Authenticate {
97
101
  */
98
102
  logout(): Promise<void> {
99
103
  return universalFetch({
100
- url: LOGOUT_PATH,
104
+ url: logoutPath(),
101
105
  }).then(() => {
102
106
  // clear cache because of cached contributions
103
107
  Cache.clear();
@@ -19,7 +19,10 @@ import configureStore from "../redux/store/configureStore";
19
19
  import rehydrate from "./rehydrate";
20
20
  import { BASE } from "../constants/Constants";
21
21
 
22
- import { setAllContentInDataSetting } from "../redux/actions/Preferences";
22
+ import {
23
+ setAllContentInDataSetting,
24
+ setLoginPreferences,
25
+ } from "../redux/actions/Preferences";
23
26
  import { showXHRErrorNotification } from "../redux/actions/Notification";
24
27
 
25
28
  import { handleError } from "../redux/actions/Error";
@@ -99,6 +102,7 @@ const client = ({
99
102
  );
100
103
 
101
104
  setAllContentInDataSetting(store.getState());
105
+ setLoginPreferences(store.getState());
102
106
 
103
107
  // load existing cache from other browser tabs
104
108
  Cache.loadOtherBrowserTabs(() => {
@@ -109,6 +109,15 @@ describe("serverUtil", () => {
109
109
  hasAllContentInData: false,
110
110
  },
111
111
  },
112
+ {
113
+ type: "SET_PREFERENCES",
114
+ payload: {
115
+ "FormClient.login_url": "/BeInformed/j_security_check",
116
+ "FormClient.logout_url": "/BeInformed/Logoff",
117
+ "FormClient.password_field_name": "j_password",
118
+ "FormClient.username_field_name": "j_username",
119
+ },
120
+ },
112
121
  ]);
113
122
  });
114
123
 
@@ -146,6 +155,15 @@ describe("serverUtil", () => {
146
155
  hasAllContentInData: false,
147
156
  },
148
157
  },
158
+ {
159
+ type: "SET_PREFERENCES",
160
+ payload: {
161
+ "FormClient.login_url": "/BeInformed/j_security_check",
162
+ "FormClient.logout_url": "/BeInformed/Logoff",
163
+ "FormClient.password_field_name": "j_password",
164
+ "FormClient.username_field_name": "j_username",
165
+ },
166
+ },
149
167
  ]);
150
168
  });
151
169
  });
@@ -16,6 +16,7 @@ import {
16
16
  setThemePreference,
17
17
  setPreference,
18
18
  setAllContentInDataSetting,
19
+ setLoginPreferences,
19
20
  } from "../redux/actions/Preferences";
20
21
 
21
22
  import { getSetting } from "../constants/Settings";
@@ -126,6 +127,7 @@ const setServerPreferences = (
126
127
  }
127
128
 
128
129
  store.dispatch(setAllContentInDataSetting());
130
+ store.dispatch(setLoginPreferences());
129
131
 
130
132
  if (
131
133
  preferencesProvider &&