@beinformed/ui 1.25.6 → 1.26.0

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 (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/esm/models/attributes/ChoiceAttributeOptionCollection.js +3 -12
  3. package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  4. package/esm/modularui/ModularUIRequest.js +31 -0
  5. package/esm/modularui/ModularUIRequest.js.map +1 -1
  6. package/esm/react-server/serverNoSSR.js +2 -1
  7. package/esm/react-server/serverNoSSR.js.map +1 -1
  8. package/esm/react-server/serverUtil.js +31 -5
  9. package/esm/react-server/serverUtil.js.map +1 -1
  10. package/esm/redux/_modularui/ModularUIActions.js +7 -0
  11. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  12. package/esm/redux/_modularui/ModularUIReducer.js +21 -1
  13. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  14. package/esm/redux/_modularui/types.js.map +1 -1
  15. package/esm/redux/store/configureStore.js +1 -1
  16. package/esm/redux/store/configureStore.js.map +1 -1
  17. package/esm/redux/types.js.map +1 -1
  18. package/lib/models/attributes/ChoiceAttributeOptionCollection.js +3 -12
  19. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.flow +3 -17
  20. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  21. package/lib/modularui/ModularUIRequest.js +31 -0
  22. package/lib/modularui/ModularUIRequest.js.flow +39 -0
  23. package/lib/modularui/ModularUIRequest.js.map +1 -1
  24. package/lib/react-server/serverNoSSR.js +1 -0
  25. package/lib/react-server/serverNoSSR.js.flow +5 -0
  26. package/lib/react-server/serverNoSSR.js.map +1 -1
  27. package/lib/react-server/serverUtil.js +32 -5
  28. package/lib/react-server/serverUtil.js.flow +40 -6
  29. package/lib/react-server/serverUtil.js.map +1 -1
  30. package/lib/redux/_modularui/ModularUIActions.js +9 -1
  31. package/lib/redux/_modularui/ModularUIActions.js.flow +10 -0
  32. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  33. package/lib/redux/_modularui/ModularUIReducer.js +21 -1
  34. package/lib/redux/_modularui/ModularUIReducer.js.flow +22 -0
  35. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  36. package/lib/redux/_modularui/types.js.flow +8 -0
  37. package/lib/redux/_modularui/types.js.map +1 -1
  38. package/lib/redux/store/configureStore.js +1 -1
  39. package/lib/redux/store/configureStore.js.flow +1 -1
  40. package/lib/redux/store/configureStore.js.map +1 -1
  41. package/lib/redux/types.js.flow +2 -0
  42. package/lib/redux/types.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/models/attributes/ChoiceAttributeOptionCollection.js +3 -17
  45. package/src/modularui/ModularUIRequest.js +39 -0
  46. package/src/react-server/serverNoSSR.js +5 -0
  47. package/src/react-server/serverUtil.js +40 -6
  48. package/src/redux/_modularui/ModularUIActions.js +10 -0
  49. package/src/redux/_modularui/ModularUIReducer.js +22 -0
  50. package/src/redux/_modularui/types.js +8 -0
  51. package/src/redux/store/configureStore.js +1 -1
  52. package/src/redux/types.js +2 -0
  53. package/types/models/attributes/ChoiceAttributeOptionCollection.d.ts +0 -3
  54. package/types/modularui/ModularUIRequest.d.ts +18 -3
  55. package/types/redux/_modularui/types.d.ts +8 -0
  56. package/types/redux/types.d.ts +1 -1
  57. package/types/utils/fetch/types.d.ts +1 -0
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.ModularUIReducer = void 0;
8
+ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
8
9
  var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
9
10
  var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
10
- var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
11
11
  var _exceptions = require("../../exceptions");
12
12
  var _Constants = require("../../constants/Constants");
13
13
  var _models = require("../../models");
@@ -55,6 +55,24 @@ const setModel = (state, _ref2) => {
55
55
  throw new _exceptions.IllegalArgumentException("No model for setModel");
56
56
  };
57
57
 
58
+ /**
59
+ */
60
+ const initModularUI = (state, models) => {
61
+ const newState = (0, _assign.default)({}, state);
62
+ models.forEach(_ref3 => {
63
+ let {
64
+ key,
65
+ model
66
+ } = _ref3;
67
+ newState[key] = {
68
+ status: _Constants.MODULARUI_STATUS.FINISHED,
69
+ lastModification: Date.now(),
70
+ model
71
+ };
72
+ });
73
+ return newState;
74
+ };
75
+
58
76
  /**
59
77
  */
60
78
  const getModelKey = (state, model) => {
@@ -112,6 +130,8 @@ const ModularUIReducer = function () {
112
130
  return state;
113
131
  }
114
132
  switch (action.type) {
133
+ case "MODULARUI/INIT":
134
+ return initModularUI(state, action.payload);
115
135
  case "MODULARUI/RESET":
116
136
  return resetModularUI(state);
117
137
  case "MODULARUI/STATUS":
@@ -53,6 +53,25 @@ const setModel = (
53
53
  throw new IllegalArgumentException("No model for setModel");
54
54
  };
55
55
 
56
+ /**
57
+ */
58
+ const initModularUI = (
59
+ state: ModularUIState,
60
+ models: Array<{ key: string, model: ModularUIModel }>
61
+ ) => {
62
+ const newState = Object.assign({}, state);
63
+
64
+ models.forEach(({ key, model }) => {
65
+ newState[key] = {
66
+ status: MODULARUI_STATUS.FINISHED,
67
+ lastModification: Date.now(),
68
+ model,
69
+ };
70
+ });
71
+
72
+ return newState;
73
+ };
74
+
56
75
  /**
57
76
  */
58
77
  const getModelKey = (state: ModularUIState, model: ModularUIModel) =>
@@ -112,6 +131,9 @@ export const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (
112
131
  }
113
132
 
114
133
  switch (action.type) {
134
+ case "MODULARUI/INIT":
135
+ return initModularUI(state, action.payload);
136
+
115
137
  case "MODULARUI/RESET":
116
138
  return resetModularUI(state);
117
139
 
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIReducer.js","names":["updateStatus","state","key","status","MODULARUI_STATUS","LOADING","lastModification","Date","now","setModel","model","IllegalArgumentException","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","newState","resetModularUI","ApplicationModel","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":"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"}
1
+ {"version":3,"file":"ModularUIReducer.js","names":["updateStatus","state","key","status","MODULARUI_STATUS","LOADING","lastModification","Date","now","setModel","model","IllegalArgumentException","initModularUI","models","newState","forEach","FINISHED","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","ApplicationModel","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":"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"}
@@ -36,6 +36,14 @@ export type SetModelAction = {
36
36
  },
37
37
  };
38
38
 
39
+ export type InitModelAction = {
40
+ type: "MODULARUI/INIT",
41
+ payload: Array<{
42
+ key: string,
43
+ model: ModularUIModel,
44
+ }>,
45
+ };
46
+
39
47
  export type UpdateModelAction = {
40
48
  type: "MODULARUI/UPDATE",
41
49
  payload: ModularUIModel,
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: string | { [key: string]: string },\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: string | { [key: string]: string },\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
@@ -25,7 +25,7 @@ const configureStore = (history, customReducers, initialState) => {
25
25
  const middleware = (0, _redux.applyMiddleware)(_ModularUIMiddleware.modularUIMiddleware, (0, _RouterMiddleware.routerMiddleware)(history), _reduxThunk.default);
26
26
  const enhancers = composeEnhancers(middleware);
27
27
  const store = (0, _redux.createStore)(combinedReducers, initialState, enhancers);
28
- if (!initialState) {
28
+ if (!initialState?.router) {
29
29
  store.dispatch((0, _RouterActions.locationChange)(history.location, "PUSH"));
30
30
  }
31
31
  return {
@@ -49,7 +49,7 @@ const configureStore = (
49
49
  enhancers
50
50
  );
51
51
 
52
- if (!initialState) {
52
+ if (!initialState?.router) {
53
53
  store.dispatch(locationChange(history.location, "PUSH"));
54
54
  }
55
55
  return { history, store };
@@ -1 +1 @@
1
- {"version":3,"file":"configureStore.js","names":["configureStore","history","customReducers","initialState","composeEnhancers","compose","process","env","NODE_ENV","window","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","combinedReducers","combineReducers","createReducer","middleware","applyMiddleware","modularUIMiddleware","routerMiddleware","thunk","enhancers","store","createReduxStore","dispatch","locationChange","location"],"sources":["../../../src/redux/store/configureStore.js"],"sourcesContent":["// @flow\nimport {\n applyMiddleware,\n compose,\n combineReducers,\n createStore as createReduxStore,\n} from \"redux\";\nimport thunk from \"redux-thunk\";\n\nimport { routerMiddleware } from \"../_router/RouterMiddleware\";\nimport { modularUIMiddleware } from \"../_modularui/ModularUIMiddleware\";\n\nimport { createReducer } from \"../reducers/createReducer\";\nimport { locationChange } from \"../_router/RouterActions\";\n\nimport type { RouterHistory } from \"react-router\";\nimport type { ReduxAction, ReduxState, ReduxStore } from \"../types\";\nimport type { Reducer } from \"redux\";\n\n/**\n */\nconst configureStore = (\n history: RouterHistory,\n customReducers?: Object,\n initialState?: $Shape<ReduxState>\n): { history: RouterHistory, store: ReduxStore } => {\n let composeEnhancers = compose;\n\n if (process.env.NODE_ENV !== \"production\" && typeof window !== \"undefined\") {\n composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;\n }\n\n const combinedReducers: Reducer<ReduxState, ReduxAction> = combineReducers({\n ...customReducers,\n ...createReducer(),\n });\n\n const middleware = applyMiddleware(\n modularUIMiddleware,\n routerMiddleware(history),\n thunk\n );\n\n const enhancers = composeEnhancers(middleware);\n\n const store: ReduxStore = createReduxStore(\n combinedReducers,\n initialState,\n enhancers\n );\n\n if (!initialState) {\n store.dispatch(locationChange(history.location, \"PUSH\"));\n }\n return { history, store };\n};\n\nexport default configureStore;\n"],"mappings":";;;;;;;AACA;AAMA;AAEA;AACA;AAEA;AACA;AAMA;AACA;AACA,MAAMA,cAAc,GAAG,CACrBC,OAAsB,EACtBC,cAAuB,EACvBC,YAAiC,KACiB;EAClD,IAAIC,gBAAgB,GAAGC,cAAO;EAE9B,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IAC1EL,gBAAgB,GAAGK,MAAM,CAACC,oCAAoC,IAAIL,cAAO;EAC3E;EAEA,MAAMM,gBAAkD,GAAG,IAAAC,sBAAe,EAAC;IACzE,GAAGV,cAAc;IACjB,GAAG,IAAAW,4BAAa;EAClB,CAAC,CAAC;EAEF,MAAMC,UAAU,GAAG,IAAAC,sBAAe,EAChCC,wCAAmB,EACnB,IAAAC,kCAAgB,EAAChB,OAAO,CAAC,EACzBiB,mBAAK,CACN;EAED,MAAMC,SAAS,GAAGf,gBAAgB,CAACU,UAAU,CAAC;EAE9C,MAAMM,KAAiB,GAAG,IAAAC,kBAAgB,EACxCV,gBAAgB,EAChBR,YAAY,EACZgB,SAAS,CACV;EAED,IAAI,CAAChB,YAAY,EAAE;IACjBiB,KAAK,CAACE,QAAQ,CAAC,IAAAC,6BAAc,EAACtB,OAAO,CAACuB,QAAQ,EAAE,MAAM,CAAC,CAAC;EAC1D;EACA,OAAO;IAAEvB,OAAO;IAAEmB;EAAM,CAAC;AAC3B,CAAC;AAAC,eAEapB,cAAc;AAAA"}
1
+ {"version":3,"file":"configureStore.js","names":["configureStore","history","customReducers","initialState","composeEnhancers","compose","process","env","NODE_ENV","window","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","combinedReducers","combineReducers","createReducer","middleware","applyMiddleware","modularUIMiddleware","routerMiddleware","thunk","enhancers","store","createReduxStore","router","dispatch","locationChange","location"],"sources":["../../../src/redux/store/configureStore.js"],"sourcesContent":["// @flow\nimport {\n applyMiddleware,\n compose,\n combineReducers,\n createStore as createReduxStore,\n} from \"redux\";\nimport thunk from \"redux-thunk\";\n\nimport { routerMiddleware } from \"../_router/RouterMiddleware\";\nimport { modularUIMiddleware } from \"../_modularui/ModularUIMiddleware\";\n\nimport { createReducer } from \"../reducers/createReducer\";\nimport { locationChange } from \"../_router/RouterActions\";\n\nimport type { RouterHistory } from \"react-router\";\nimport type { ReduxAction, ReduxState, ReduxStore } from \"../types\";\nimport type { Reducer } from \"redux\";\n\n/**\n */\nconst configureStore = (\n history: RouterHistory,\n customReducers?: Object,\n initialState?: $Shape<ReduxState>\n): { history: RouterHistory, store: ReduxStore } => {\n let composeEnhancers = compose;\n\n if (process.env.NODE_ENV !== \"production\" && typeof window !== \"undefined\") {\n composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;\n }\n\n const combinedReducers: Reducer<ReduxState, ReduxAction> = combineReducers({\n ...customReducers,\n ...createReducer(),\n });\n\n const middleware = applyMiddleware(\n modularUIMiddleware,\n routerMiddleware(history),\n thunk\n );\n\n const enhancers = composeEnhancers(middleware);\n\n const store: ReduxStore = createReduxStore(\n combinedReducers,\n initialState,\n enhancers\n );\n\n if (!initialState?.router) {\n store.dispatch(locationChange(history.location, \"PUSH\"));\n }\n return { history, store };\n};\n\nexport default configureStore;\n"],"mappings":";;;;;;;AACA;AAMA;AAEA;AACA;AAEA;AACA;AAMA;AACA;AACA,MAAMA,cAAc,GAAG,CACrBC,OAAsB,EACtBC,cAAuB,EACvBC,YAAiC,KACiB;EAClD,IAAIC,gBAAgB,GAAGC,cAAO;EAE9B,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IAC1EL,gBAAgB,GAAGK,MAAM,CAACC,oCAAoC,IAAIL,cAAO;EAC3E;EAEA,MAAMM,gBAAkD,GAAG,IAAAC,sBAAe,EAAC;IACzE,GAAGV,cAAc;IACjB,GAAG,IAAAW,4BAAa;EAClB,CAAC,CAAC;EAEF,MAAMC,UAAU,GAAG,IAAAC,sBAAe,EAChCC,wCAAmB,EACnB,IAAAC,kCAAgB,EAAChB,OAAO,CAAC,EACzBiB,mBAAK,CACN;EAED,MAAMC,SAAS,GAAGf,gBAAgB,CAACU,UAAU,CAAC;EAE9C,MAAMM,KAAiB,GAAG,IAAAC,kBAAgB,EACxCV,gBAAgB,EAChBR,YAAY,EACZgB,SAAS,CACV;EAED,IAAI,CAAChB,YAAY,EAAEmB,MAAM,EAAE;IACzBF,KAAK,CAACG,QAAQ,CAAC,IAAAC,6BAAc,EAACvB,OAAO,CAACwB,QAAQ,EAAE,MAAM,CAAC,CAAC;EAC1D;EACA,OAAO;IAAExB,OAAO;IAAEmB;EAAM,CAAC;AAC3B,CAAC;AAAC,eAEapB,cAAc;AAAA"}
@@ -23,6 +23,7 @@ import type {
23
23
  UpdateModelAction,
24
24
  RemoveModelByKeyAction,
25
25
  ResetModularUIAction,
26
+ InitModelAction,
26
27
  } from "./_modularui/types";
27
28
  import type {
28
29
  RouterState,
@@ -135,6 +136,7 @@ export type UpdateAutosaveAction = {
135
136
  export type ReduxAction =
136
137
  | UpdateStatusAction
137
138
  | SetModelAction
139
+ | InitModelAction
138
140
  | UpdateModelAction
139
141
  | RemoveModelByKeyAction
140
142
  | ResetModularUIAction
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/redux/types.js"],"sourcesContent":["// @flow\nimport type { Store, DispatchAPI } from \"redux\";\n\nimport type ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport type FormModel from \"../models/form/FormModel\";\nimport typeof {\n NOTIFICATION_TYPES,\n AUTOSAVE_STATUS,\n} from \"../constants/Constants\";\n\nimport type { MessageObject } from \"../i18n/types\";\nimport type {\n I18nState,\n UpdateLocaleAction,\n SetLocalesAction,\n} from \"./_i18n/types\";\nimport type {\n ModularUIState,\n ModularUIAction,\n UpdateStatusAction,\n SetModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n} from \"./_modularui/types\";\nimport type {\n RouterState,\n LocationChangeAction,\n PushAction,\n ReplaceAction,\n GoAction,\n GoBackAction,\n GoForwardAction,\n} from \"./_router/types\";\n\nexport type PreferenceValue =\n | null\n | string\n | boolean\n | { [key: string]: any }\n | Array<PreferenceValue>;\n\nexport type UpdateFormOptions = {\n autosubmit: boolean,\n autosave: boolean,\n forceUpdate?: boolean,\n /** Default true: Activate/deactivate the form object validate by an update */\n validate?: boolean,\n};\n\nexport type NoAction = {\n type: \"NO_ACTION\",\n};\n\nexport type SaveErrorAction = {\n type: \"SAVE_ERROR\",\n payload: ErrorResponse,\n};\n\nexport type ShowModalAction = {\n type: \"SHOW_MODAL\",\n payload: string,\n};\n\nexport type CloseModalAction = {\n type: \"CLOSE_MODAL\",\n payload: string,\n};\n\nexport type DismissNotificationAction = {\n type: \"DISMISS_NOTIFICATION\",\n};\nexport type ShowNotificationAction = {\n type: \"SHOW_NOTIFICATION\",\n payload: {\n type: $Keys<NOTIFICATION_TYPES>,\n message: MessageObject,\n error: ?ErrorResponse,\n },\n};\n\nexport type SetPreferenceAction = {\n type: \"SET_PREFERENCE\",\n payload: { [name: string]: PreferenceValue },\n};\nexport type SetPreferencesAction = {\n type: \"SET_PREFERENCES\",\n payload: { [name: string]: PreferenceValue },\n};\n\nexport type StartProgressAction = {\n type: \"START_PROGRESS\",\n};\nexport type FinishProgressAction = {\n type: \"FINISH_PROGRESS\",\n};\nexport type ResetProgressAction = {\n type: \"RESET_PROGRESS\",\n};\nexport type UpdateProgressAction = {\n type: \"UPDATE_PROGRESS\",\n payload: { percentComplete: number },\n};\n\nexport type SendAuthenticationErrorAction = {\n type: \"AUTHENTICATION_ERROR\",\n payload: string,\n};\n\nexport type ResetAuthErrorsAction = {\n type: \"AUTHENTICATION_RESET_ERRORS\",\n};\n\nexport type LoginSuccessAction = {\n type: \"AUTHENTICATION_SUCCESS\",\n};\n\nexport type ChangePasswordAction = {\n type: \"CHANGE_PASSWORD\",\n};\n\nexport type LogoutSuccessAction = {\n type: \"AUTHENTICATION_LOGOUT\",\n};\n\nexport type UpdateAutosaveAction = {\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status: $Keys<AUTOSAVE_STATUS>,\n model: FormModel,\n },\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | UpdateModelAction\n | RemoveModelByKeyAction\n | ResetModularUIAction\n | SaveErrorAction\n | UpdateLocaleAction\n | SetLocalesAction\n | ShowModalAction\n | CloseModalAction\n | DismissNotificationAction\n | ShowNotificationAction\n | SetPreferenceAction\n | SetPreferencesAction\n | StartProgressAction\n | FinishProgressAction\n | ResetProgressAction\n | UpdateProgressAction\n | ResetAuthErrorsAction\n | SendAuthenticationErrorAction\n | LoginSuccessAction\n | ChangePasswordAction\n | LogoutSuccessAction\n | UpdateAutosaveAction\n | LocationChangeAction\n | PushAction\n | ReplaceAction\n | GoAction\n | GoBackAction\n | GoForwardAction\n | ModularUIAction\n | NoAction;\n\n// Redux state\nexport type AuthState = {\n +mustChangePassword: boolean,\n +error: ?string,\n};\n\nexport type ErrorState = null | ErrorResponse;\n\nexport type ModalState = {\n +key: string,\n +visible: boolean,\n +size?: string,\n};\n\nexport type ModalsState = {\n +modals: Array<ModalState>,\n};\n\nexport type NotificationState = {\n +render: boolean,\n +messageType: string | null,\n +message: MessageObject | null,\n +error: ?ErrorResponse | null,\n};\n\nexport type PreferencesState = {\n +[name: string]: PreferenceValue,\n};\n\nexport type ProgressIndicatorState = {\n +count: number,\n +timestamp: number,\n +percentComplete: number,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +error: ErrorState,\n +modals: ModalsState,\n +notification: NotificationState,\n +progressindicator: ProgressIndicatorState,\n +preferences: PreferencesState,\n ...\n};\n\nexport type GetState = () => ReduxState;\nexport type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;\nexport type PromiseAction = Promise<PossibleAction>;\nexport type Dispatch = DispatchAPI<PossibleAction>;\nexport type ReduxStore = Store<ReduxState, ReduxAction, Dispatch>;\n\nexport type PossibleAction = ReduxAction | ThunkAction | PromiseAction;\n\nexport type CustomReducers = { [reducerKey: string]: any };\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/redux/types.js"],"sourcesContent":["// @flow\nimport type { Store, DispatchAPI } from \"redux\";\n\nimport type ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport type FormModel from \"../models/form/FormModel\";\nimport typeof {\n NOTIFICATION_TYPES,\n AUTOSAVE_STATUS,\n} from \"../constants/Constants\";\n\nimport type { MessageObject } from \"../i18n/types\";\nimport type {\n I18nState,\n UpdateLocaleAction,\n SetLocalesAction,\n} from \"./_i18n/types\";\nimport type {\n ModularUIState,\n ModularUIAction,\n UpdateStatusAction,\n SetModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n InitModelAction,\n} from \"./_modularui/types\";\nimport type {\n RouterState,\n LocationChangeAction,\n PushAction,\n ReplaceAction,\n GoAction,\n GoBackAction,\n GoForwardAction,\n} from \"./_router/types\";\n\nexport type PreferenceValue =\n | null\n | string\n | boolean\n | { [key: string]: any }\n | Array<PreferenceValue>;\n\nexport type UpdateFormOptions = {\n autosubmit: boolean,\n autosave: boolean,\n forceUpdate?: boolean,\n /** Default true: Activate/deactivate the form object validate by an update */\n validate?: boolean,\n};\n\nexport type NoAction = {\n type: \"NO_ACTION\",\n};\n\nexport type SaveErrorAction = {\n type: \"SAVE_ERROR\",\n payload: ErrorResponse,\n};\n\nexport type ShowModalAction = {\n type: \"SHOW_MODAL\",\n payload: string,\n};\n\nexport type CloseModalAction = {\n type: \"CLOSE_MODAL\",\n payload: string,\n};\n\nexport type DismissNotificationAction = {\n type: \"DISMISS_NOTIFICATION\",\n};\nexport type ShowNotificationAction = {\n type: \"SHOW_NOTIFICATION\",\n payload: {\n type: $Keys<NOTIFICATION_TYPES>,\n message: MessageObject,\n error: ?ErrorResponse,\n },\n};\n\nexport type SetPreferenceAction = {\n type: \"SET_PREFERENCE\",\n payload: { [name: string]: PreferenceValue },\n};\nexport type SetPreferencesAction = {\n type: \"SET_PREFERENCES\",\n payload: { [name: string]: PreferenceValue },\n};\n\nexport type StartProgressAction = {\n type: \"START_PROGRESS\",\n};\nexport type FinishProgressAction = {\n type: \"FINISH_PROGRESS\",\n};\nexport type ResetProgressAction = {\n type: \"RESET_PROGRESS\",\n};\nexport type UpdateProgressAction = {\n type: \"UPDATE_PROGRESS\",\n payload: { percentComplete: number },\n};\n\nexport type SendAuthenticationErrorAction = {\n type: \"AUTHENTICATION_ERROR\",\n payload: string,\n};\n\nexport type ResetAuthErrorsAction = {\n type: \"AUTHENTICATION_RESET_ERRORS\",\n};\n\nexport type LoginSuccessAction = {\n type: \"AUTHENTICATION_SUCCESS\",\n};\n\nexport type ChangePasswordAction = {\n type: \"CHANGE_PASSWORD\",\n};\n\nexport type LogoutSuccessAction = {\n type: \"AUTHENTICATION_LOGOUT\",\n};\n\nexport type UpdateAutosaveAction = {\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status: $Keys<AUTOSAVE_STATUS>,\n model: FormModel,\n },\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | InitModelAction\n | UpdateModelAction\n | RemoveModelByKeyAction\n | ResetModularUIAction\n | SaveErrorAction\n | UpdateLocaleAction\n | SetLocalesAction\n | ShowModalAction\n | CloseModalAction\n | DismissNotificationAction\n | ShowNotificationAction\n | SetPreferenceAction\n | SetPreferencesAction\n | StartProgressAction\n | FinishProgressAction\n | ResetProgressAction\n | UpdateProgressAction\n | ResetAuthErrorsAction\n | SendAuthenticationErrorAction\n | LoginSuccessAction\n | ChangePasswordAction\n | LogoutSuccessAction\n | UpdateAutosaveAction\n | LocationChangeAction\n | PushAction\n | ReplaceAction\n | GoAction\n | GoBackAction\n | GoForwardAction\n | ModularUIAction\n | NoAction;\n\n// Redux state\nexport type AuthState = {\n +mustChangePassword: boolean,\n +error: ?string,\n};\n\nexport type ErrorState = null | ErrorResponse;\n\nexport type ModalState = {\n +key: string,\n +visible: boolean,\n +size?: string,\n};\n\nexport type ModalsState = {\n +modals: Array<ModalState>,\n};\n\nexport type NotificationState = {\n +render: boolean,\n +messageType: string | null,\n +message: MessageObject | null,\n +error: ?ErrorResponse | null,\n};\n\nexport type PreferencesState = {\n +[name: string]: PreferenceValue,\n};\n\nexport type ProgressIndicatorState = {\n +count: number,\n +timestamp: number,\n +percentComplete: number,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +error: ErrorState,\n +modals: ModalsState,\n +notification: NotificationState,\n +progressindicator: ProgressIndicatorState,\n +preferences: PreferencesState,\n ...\n};\n\nexport type GetState = () => ReduxState;\nexport type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;\nexport type PromiseAction = Promise<PossibleAction>;\nexport type Dispatch = DispatchAPI<PossibleAction>;\nexport type ReduxStore = Store<ReduxState, ReduxAction, Dispatch>;\n\nexport type PossibleAction = ReduxAction | ThunkAction | PromiseAction;\n\nexport type CustomReducers = { [reducerKey: string]: any };\n"],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.25.6",
3
+ "version": "1.26.0",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "http://support.beinformed.com",
@@ -166,17 +166,6 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
166
166
  });
167
167
  }
168
168
 
169
- /**
170
- */
171
- getDefaultValueForOption(value: any, contributions: Object): string {
172
- const layouthints = contributions.layouthint ?? [];
173
-
174
- const requireDefaultValue =
175
- layouthints.includes("checkbox") || layouthints.includes("toggle");
176
-
177
- return requireDefaultValue ? "false" : "";
178
- }
179
-
180
169
  /**
181
170
  * Create two static options for true and false,
182
171
  * there might be alternative labels configured for each option value
@@ -185,13 +174,10 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
185
174
  value: any,
186
175
  contributions: Object
187
176
  ): ChoiceAttributeOptionCollection {
188
- const optionValue =
189
- value == null
190
- ? this.getDefaultValueForOption(value, contributions)
191
- : value.toString();
177
+ const optionValue = value == null ? [] : [value.toString()];
192
178
 
193
- this.addBooleanOption("true", "Yes", [optionValue], contributions.options);
194
- this.addBooleanOption("false", "No", [optionValue], contributions.options);
179
+ this.addBooleanOption("true", "Yes", optionValue, contributions.options);
180
+ this.addBooleanOption("false", "No", optionValue, contributions.options);
195
181
 
196
182
  return this;
197
183
  }
@@ -763,6 +763,45 @@ class ModularUIRequest {
763
763
  return form.update(response);
764
764
  });
765
765
  }
766
+
767
+ /**
768
+ * Simplified synchronous version of fetch (returns the model, not a Promise)
769
+ * This can be used on the server to retrieve a model. It only loads the request url and it's child models
770
+ */
771
+ fetchSync(): ModularUIModel {
772
+ const options = { headers: { "Accept-Language": this.locale } };
773
+
774
+ const dataString = dataFetcher.fetch(this.href.toString(), options);
775
+ if (dataString == null) {
776
+ throw new Error(`No data received for ${this.href.toString()}`);
777
+ }
778
+
779
+ this.processDataService(JSON.parse(dataString));
780
+
781
+ const contributionsString = dataFetcher.fetch(
782
+ this.contributionsHref.toString(),
783
+ options
784
+ );
785
+ if (contributionsString == null) {
786
+ throw new Error(
787
+ `No constributions received for ${this.contributionsHref.toString()}`
788
+ );
789
+ }
790
+ this.processContributionsService(JSON.parse(contributionsString));
791
+
792
+ const model = this.createModel();
793
+
794
+ const childModelLinks = model.getInitialChildModelLinks();
795
+
796
+ const childModels = childModelLinks.map((childModelLink) => {
797
+ return new ModularUIRequest(childModelLink.href, {
798
+ locale: this.locale,
799
+ }).fetchSync();
800
+ });
801
+ model.addChildModels(childModels);
802
+
803
+ return model;
804
+ }
766
805
  }
767
806
 
768
807
  export default ModularUIRequest;
@@ -7,6 +7,7 @@ import { getFullRequestHref } from "./requestInformation";
7
7
  import {
8
8
  createReduxStore,
9
9
  setI18n,
10
+ setApplication,
10
11
  setServerPreferences,
11
12
  setConfigurationTheme,
12
13
  handleErrors,
@@ -23,6 +24,7 @@ import type { BeforeRenderHook } from "../redux/store/beforeRenderHooks";
23
24
  import type { PreferenceValue } from "./serverUtil";
24
25
  import type { LocaleConfiguration } from "../i18n/types";
25
26
  import type { Theme } from "../react-theme/types";
27
+
26
28
  type serverProps = {
27
29
  request: HttpServletRequestJava,
28
30
  locales?: Array<LocaleConfiguration>,
@@ -50,6 +52,7 @@ const serverNoSSR = ({
50
52
  __webpack_nonce__ = UUID; // NOSONAR
51
53
 
52
54
  const requestHref = getFullRequestHref(request);
55
+
53
56
  const store = createReduxStore(requestHref, customReducers);
54
57
 
55
58
  setServerPreferences(store, serverPreferences);
@@ -63,6 +66,8 @@ const serverNoSSR = ({
63
66
 
64
67
  setI18n(store, locales, request);
65
68
 
69
+ setApplication(store);
70
+
66
71
  handleErrors(store);
67
72
 
68
73
  handleBeforeRenderHooks(beforeRenderHooks, { store, request });
@@ -23,8 +23,13 @@ import { getSetting } from "../constants/Settings";
23
23
 
24
24
  import { IllegalArgumentException } from "../exceptions";
25
25
 
26
+ import { initModels } from "../redux";
27
+ import { getLocale } from "../redux/selectors/i18n";
28
+
29
+ import ModularUIRequest from "../modularui/ModularUIRequest";
30
+
26
31
  import type { LocaleConfiguration } from "../i18n/types";
27
- import type { ReduxStore } from "../redux/types";
32
+ import type { ReduxState, ReduxStore } from "../redux/types";
28
33
  import type Href from "../models/href/Href";
29
34
  import type { RouterHistory } from "react-router";
30
35
 
@@ -38,14 +43,15 @@ export type PreferenceValue = {
38
43
  */
39
44
  const createReduxStore = (
40
45
  requestHref: Href,
41
- customReducers: Object
46
+ customReducers: Object,
47
+ initialState?: $Shape<ReduxState>
42
48
  ): ReduxStore => {
43
49
  // $FlowExpectedError
44
50
  const history: RouterHistory = createMemoryHistory({
45
51
  initialEntries: [requestHref.toString()],
46
52
  });
47
53
 
48
- const { store } = configureStore(history, customReducers);
54
+ const { store } = configureStore(history, customReducers, initialState);
49
55
 
50
56
  return store;
51
57
  };
@@ -161,6 +167,29 @@ const setConfigurationTheme = (store: ReduxStore) => {
161
167
  }
162
168
  };
163
169
 
170
+ /**
171
+ */
172
+ const setApplication = (store: ReduxStore) => {
173
+ try {
174
+ const locale = getLocale(store.getState());
175
+ const application = new ModularUIRequest("/", {
176
+ locale: locale,
177
+ }).fetchSync();
178
+
179
+ store.dispatch(
180
+ initModels([
181
+ {
182
+ key: `application(/)(${locale})`,
183
+ model: application,
184
+ },
185
+ ])
186
+ );
187
+ } catch (e) {
188
+ // eslint-disable-next-line no-console
189
+ console.info("Could not load webapplication on server");
190
+ }
191
+ };
192
+
164
193
  /**
165
194
  */
166
195
  const handleErrors = (store: ReduxStore) => {
@@ -180,19 +209,23 @@ const handleErrors = (store: ReduxStore) => {
180
209
  const dehydrate = (store: ReduxStore): string => {
181
210
  const state = store.getState();
182
211
 
183
- const modularui: { [key: string]: { status: string, model: ?Object } } = {};
212
+ const modularui: {
213
+ [key: string]: { status: string, lastModification: number, model: ?Object },
214
+ } = {};
215
+
184
216
  for (const key in state.modularui) {
185
- const status = state.modularui[key].status;
186
- const model = state.modularui[key].model;
217
+ const { status, model, lastModification } = state.modularui[key];
187
218
 
188
219
  if (model) {
189
220
  modularui[key] = {
190
221
  status,
222
+ lastModification,
191
223
  model: model.dehydrate(),
192
224
  };
193
225
  } else {
194
226
  modularui[key] = {
195
227
  status,
228
+ lastModification,
196
229
  model: undefined,
197
230
  };
198
231
  }
@@ -233,6 +266,7 @@ const createHead = (
233
266
  export {
234
267
  createReduxStore,
235
268
  setI18n,
269
+ setApplication,
236
270
  setServerPreferences,
237
271
  setConfigurationTheme,
238
272
  createHead,
@@ -10,6 +10,7 @@ import type { Dispatch, ThunkAction } from "../types";
10
10
  import type {
11
11
  ModularUIAction,
12
12
  SetModelAction,
13
+ InitModelAction,
13
14
  UpdateModelAction,
14
15
  RemoveModelByKeyAction,
15
16
  ResetModularUIAction,
@@ -34,6 +35,15 @@ export const setModel = (
34
35
  };
35
36
  };
36
37
 
38
+ /**
39
+ */
40
+ export const initModels = (
41
+ models: Array<{ key: string, model: ModularUIModel }>
42
+ ): InitModelAction => ({
43
+ type: "MODULARUI/INIT",
44
+ payload: models,
45
+ });
46
+
37
47
  /**
38
48
  */
39
49
  export const updateModel = (model: ModularUIModel): UpdateModelAction => ({
@@ -53,6 +53,25 @@ const setModel = (
53
53
  throw new IllegalArgumentException("No model for setModel");
54
54
  };
55
55
 
56
+ /**
57
+ */
58
+ const initModularUI = (
59
+ state: ModularUIState,
60
+ models: Array<{ key: string, model: ModularUIModel }>
61
+ ) => {
62
+ const newState = Object.assign({}, state);
63
+
64
+ models.forEach(({ key, model }) => {
65
+ newState[key] = {
66
+ status: MODULARUI_STATUS.FINISHED,
67
+ lastModification: Date.now(),
68
+ model,
69
+ };
70
+ });
71
+
72
+ return newState;
73
+ };
74
+
56
75
  /**
57
76
  */
58
77
  const getModelKey = (state: ModularUIState, model: ModularUIModel) =>
@@ -112,6 +131,9 @@ export const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (
112
131
  }
113
132
 
114
133
  switch (action.type) {
134
+ case "MODULARUI/INIT":
135
+ return initModularUI(state, action.payload);
136
+
115
137
  case "MODULARUI/RESET":
116
138
  return resetModularUI(state);
117
139
 
@@ -36,6 +36,14 @@ export type SetModelAction = {
36
36
  },
37
37
  };
38
38
 
39
+ export type InitModelAction = {
40
+ type: "MODULARUI/INIT",
41
+ payload: Array<{
42
+ key: string,
43
+ model: ModularUIModel,
44
+ }>,
45
+ };
46
+
39
47
  export type UpdateModelAction = {
40
48
  type: "MODULARUI/UPDATE",
41
49
  payload: ModularUIModel,
@@ -49,7 +49,7 @@ const configureStore = (
49
49
  enhancers
50
50
  );
51
51
 
52
- if (!initialState) {
52
+ if (!initialState?.router) {
53
53
  store.dispatch(locationChange(history.location, "PUSH"));
54
54
  }
55
55
  return { history, store };
@@ -23,6 +23,7 @@ import type {
23
23
  UpdateModelAction,
24
24
  RemoveModelByKeyAction,
25
25
  ResetModularUIAction,
26
+ InitModelAction,
26
27
  } from "./_modularui/types";
27
28
  import type {
28
29
  RouterState,
@@ -135,6 +136,7 @@ export type UpdateAutosaveAction = {
135
136
  export type ReduxAction =
136
137
  | UpdateStatusAction
137
138
  | SetModelAction
139
+ | InitModelAction
138
140
  | UpdateModelAction
139
141
  | RemoveModelByKeyAction
140
142
  | ResetModularUIAction
@@ -30,9 +30,6 @@ declare class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceA
30
30
  /**
31
31
  */
32
32
  addBooleanOption(code: "true" | "false", defaultLabel: string, data: string | Array<string>, options?: Array<Object>): void;
33
- /**
34
- */
35
- getDefaultValueForOption(value: any, contributions: Object): string;
36
33
  /**
37
34
  * Create two static options for true and false,
38
35
  * there might be alternative labels configured for each option value
@@ -11,11 +11,13 @@ declare class ModularUIRequest {
11
11
  _href: Href;
12
12
  _options: RequestModularUIOptions;
13
13
  _targetModel: TargetModel | null;
14
+ _forceTargetModel: boolean;
14
15
  _contributionsHref: string;
15
16
  _locale: string;
16
17
  _method: $Keys<{
17
18
  POST: string;
18
- GET: string;
19
+ GET: string; /**
20
+ */
19
21
  }>;
20
22
  _progressEvent: ProgressEventHandler;
21
23
  /**
@@ -46,13 +48,15 @@ declare class ModularUIRequest {
46
48
  */
47
49
  set method(arg: $Keys<{
48
50
  POST: string;
49
- GET: string;
51
+ GET: string; /**
52
+ */
50
53
  }>);
51
54
  /**
52
55
  */
53
56
  get method(): $Keys<{
54
57
  POST: string;
55
- GET: string;
58
+ GET: string; /**
59
+ */
56
60
  }>;
57
61
  /**
58
62
  */
@@ -69,6 +73,12 @@ declare class ModularUIRequest {
69
73
  /**
70
74
  */
71
75
  get withChildModels(): boolean;
76
+ /**
77
+ */
78
+ set forceTargetModel(arg: boolean);
79
+ /**
80
+ */
81
+ get forceTargetModel(): boolean;
72
82
  /**
73
83
  */
74
84
  resolveModel(): Class<ModularUIModel>;
@@ -174,6 +184,11 @@ declare class ModularUIRequest {
174
184
  * @returns {Promise<FormModel>}
175
185
  */
176
186
  postForm(form: FormModel): Promise<FormModel>;
187
+ /**
188
+ * Simplified synchronous version of fetch (returns the model, not a Promise)
189
+ * This can be used on the server to retrieve a model. It only loads the request url and it's child models
190
+ */
191
+ fetchSync(): ModularUIModel;
177
192
  }
178
193
  import ModularUIResponse from "./ModularUIResponse";
179
194
  import Href from "../models/href/Href";
@@ -12,6 +12,13 @@ type SetModelAction = {
12
12
  model: ModularUIModel;
13
13
  };
14
14
  };
15
+ type InitModelAction = {
16
+ type: "MODULARUI/INIT";
17
+ payload: {
18
+ key: string;
19
+ model: ModularUIModel;
20
+ }[];
21
+ };
15
22
  type UpdateModelAction = {
16
23
  type: "MODULARUI/UPDATE";
17
24
  payload: ModularUIModel;
@@ -29,6 +36,7 @@ type ModularUIAction = {
29
36
  locale: string;
30
37
  childmodels?: boolean;
31
38
  targetModel?: any;
39
+ forceTargetModel?: boolean;
32
40
  successAction: (model: ModularUIModel) => SetModelAction | UpdateModelAction;
33
41
  errorAction?: ErrorAction;
34
42
  };
@@ -84,7 +84,7 @@ type UpdateAutosaveAction = {
84
84
  model: FormModel;
85
85
  };
86
86
  };
87
- type ReduxAction = UpdateLocaleAction | SetLocalesAction | SetModelAction | UpdateModelAction | UpdateStatusAction | RemoveModelByKeyAction | NoAction | ModularUIAction | ResetModularUIAction | LocationChangeAction | PushAction | ReplaceAction | GoAction | GoBackAction | GoForwardAction | SaveErrorAction | ShowModalAction | CloseModalAction | DismissNotificationAction | ShowNotificationAction | SetPreferenceAction | SetPreferencesAction | StartProgressAction | FinishProgressAction | ResetProgressAction | UpdateProgressAction | SendAuthenticationErrorAction | ResetAuthErrorsAction | LoginSuccessAction | ChangePasswordAction | LogoutSuccessAction | UpdateAutosaveAction;
87
+ type ReduxAction = UpdateLocaleAction | SetLocalesAction | SetModelAction | InitModelAction | UpdateModelAction | UpdateStatusAction | RemoveModelByKeyAction | NoAction | ModularUIAction | ResetModularUIAction | LocationChangeAction | PushAction | ReplaceAction | GoAction | GoBackAction | GoForwardAction | SaveErrorAction | ShowModalAction | CloseModalAction | DismissNotificationAction | ShowNotificationAction | SetPreferenceAction | SetPreferencesAction | StartProgressAction | FinishProgressAction | ResetProgressAction | UpdateProgressAction | SendAuthenticationErrorAction | ResetAuthErrorsAction | LoginSuccessAction | ChangePasswordAction | LogoutSuccessAction | UpdateAutosaveAction;
88
88
  type AuthState = {};
89
89
  type ErrorState = ErrorResponse;
90
90
  type ModalState = {};