@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.
- package/CHANGELOG.md +12 -0
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js +3 -12
- package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +31 -0
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/react-server/serverNoSSR.js +2 -1
- package/esm/react-server/serverNoSSR.js.map +1 -1
- package/esm/react-server/serverUtil.js +31 -5
- package/esm/react-server/serverUtil.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +7 -0
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIReducer.js +21 -1
- package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/store/configureStore.js +1 -1
- package/esm/redux/store/configureStore.js.map +1 -1
- package/esm/redux/types.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js +3 -12
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.flow +3 -17
- package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +31 -0
- package/lib/modularui/ModularUIRequest.js.flow +39 -0
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/react-server/serverNoSSR.js +1 -0
- package/lib/react-server/serverNoSSR.js.flow +5 -0
- package/lib/react-server/serverNoSSR.js.map +1 -1
- package/lib/react-server/serverUtil.js +32 -5
- package/lib/react-server/serverUtil.js.flow +40 -6
- package/lib/react-server/serverUtil.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +9 -1
- package/lib/redux/_modularui/ModularUIActions.js.flow +10 -0
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIReducer.js +21 -1
- package/lib/redux/_modularui/ModularUIReducer.js.flow +22 -0
- package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
- package/lib/redux/_modularui/types.js.flow +8 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/store/configureStore.js +1 -1
- package/lib/redux/store/configureStore.js.flow +1 -1
- package/lib/redux/store/configureStore.js.map +1 -1
- package/lib/redux/types.js.flow +2 -0
- package/lib/redux/types.js.map +1 -1
- package/package.json +1 -1
- package/src/models/attributes/ChoiceAttributeOptionCollection.js +3 -17
- package/src/modularui/ModularUIRequest.js +39 -0
- package/src/react-server/serverNoSSR.js +5 -0
- package/src/react-server/serverUtil.js +40 -6
- package/src/redux/_modularui/ModularUIActions.js +10 -0
- package/src/redux/_modularui/ModularUIReducer.js +22 -0
- package/src/redux/_modularui/types.js +8 -0
- package/src/redux/store/configureStore.js +1 -1
- package/src/redux/types.js +2 -0
- package/types/models/attributes/ChoiceAttributeOptionCollection.d.ts +0 -3
- package/types/modularui/ModularUIRequest.d.ts +18 -3
- package/types/redux/_modularui/types.d.ts +8 -0
- package/types/redux/types.d.ts +1 -1
- 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","
|
|
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":";;;;;;;;;;AACA;AACA;AACA;AAOA;AACA;AACA,MAAMA,YAAY,GAAG,CACnBC,KAAqB,WAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC;EAExE;EACA,IAAIA,MAAM,KAAKC,2BAAgB,CAACC,OAAO,IAAI,CAACJ,KAAK,CAACC,GAAG,CAAC,EAAE;IACtD,OAAOD,KAAK;EACd;EAEA,OAAO;IACL,GAAGA,KAAK;IACR,CAACC,GAAG,GAAG;MACL,GAAGD,KAAK,CAACC,GAAG,CAAC;MACbC,MAAM;MACNG,gBAAgB,EAAEC,IAAI,CAACC,GAAG;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,MAAMC,QAAQ,GAAG,CACfR,KAAqB,YAElB;EAAA,IADH;IAAEC,GAAG;IAAEQ;EAA+C,CAAC;EAEvD,IAAI,CAACT,KAAK,CAACC,GAAG,CAAC,EAAE;IACf,OAAOD,KAAK;EACd;EAEA,IAAIS,KAAK,EAAE;IACT,OAAO;MACL,GAAGT,KAAK;MACR,CAACC,GAAG,GAAG;QACL,GAAGD,KAAK,CAACC,GAAG,CAAC;QACbQ,KAAK;QACLJ,gBAAgB,EAAEC,IAAI,CAACC,GAAG;MAC5B;IACF,CAAC;EACH;EAEA,MAAM,IAAIG,oCAAwB,CAAC,uBAAuB,CAAC;AAC7D,CAAC;;AAED;AACA;AACA,MAAMC,aAAa,GAAG,CACpBX,KAAqB,EACrBY,MAAqD,KAClD;EACH,MAAMC,QAAQ,GAAG,qBAAc,CAAC,CAAC,EAAEb,KAAK,CAAC;EAEzCY,MAAM,CAACE,OAAO,CAAC,SAAoB;IAAA,IAAnB;MAAEb,GAAG;MAAEQ;IAAM,CAAC;IAC5BI,QAAQ,CAACZ,GAAG,CAAC,GAAG;MACdC,MAAM,EAAEC,2BAAgB,CAACY,QAAQ;MACjCV,gBAAgB,EAAEC,IAAI,CAACC,GAAG,EAAE;MAC5BE;IACF,CAAC;EACH,CAAC,CAAC;EAEF,OAAOI,QAAQ;AACjB,CAAC;;AAED;AACA;AACA,MAAMG,WAAW,GAAG,CAAChB,KAAqB,EAAES,KAAqB;EAAA;EAAA,OAC/D,iDAAYT,KAAK,CAAC,iBAAOC,GAAG,IAAK;IAC/B,MAAMgB,UAAU,GAAGjB,KAAK,CAACC,GAAG,CAAC,EAAEQ,KAAK,EAAEQ,UAAU,IAAI,EAAE;IACtD,OAAOA,UAAU,KAAKR,KAAK,CAACQ,UAAU;EACxC,CAAC,CAAC;AAAA;;AAEJ;AACA;AACA,MAAMC,WAAW,GAAG,CAAClB,KAAqB,EAAES,KAAqB,KAAK;EACpE,MAAMU,QAAQ,GAAGH,WAAW,CAAChB,KAAK,EAAES,KAAK,CAAC;EAE1C,IAAIU,QAAQ,EAAE;IACZ,OAAOX,QAAQ,CAACR,KAAK,EAAE;MAAEC,GAAG,EAAEkB,QAAQ;MAAEV;IAAM,CAAC,CAAC;EAClD;EAEA,MAAM,IAAIW,KAAK,CACZ,kDAAiDX,KAAK,CAACQ,UAAW,EAAC,CACrE;AACH,CAAC;;AAED;AACA;AACA,MAAMI,SAAS,GAAG,CAACF,QAAgB,EAAEnB,KAAqB,KAAqB;EAC7E,MAAMa,QAAQ,GAAG,qBAAc,CAAC,CAAC,EAAEb,KAAK,CAAC;EACzC,OAAOa,QAAQ,CAACM,QAAQ,CAAC;EACzB,OAAON,QAAQ;AACjB,CAAC;;AAED;AACA;AACA;AACA,MAAMS,cAAc,GAAItB,KAAqB,IAAK;EAChD,MAAMa,QAAwB,GAAG,CAAC,CAAC;EAEnC,KAAK,MAAMZ,GAAG,IAAID,KAAK,EAAE;IACvB,IAAIA,KAAK,CAACC,GAAG,CAAC,CAACQ,KAAK,YAAYc,wBAAgB,EAAE;MAChDV,QAAQ,CAACZ,GAAG,CAAC,GAAG;QAAE,GAAGD,KAAK,CAACC,GAAG;MAAE,CAAC;IACnC;EACF;EAEA,OAAOY,QAAQ;AACjB,CAAC;AAED,MAAMW,YAA4B,GAAG,CAAC,CAAC;;AAEvC;AACA;AACA;AACO,MAAMC,gBAAsD,GAAG,YAGjE;EAAA,IAFHzB,KAAK,uEAAGwB,YAAY;EAAA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAO1B,KAAK;EACd;EAEA,QAAQ0B,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOhB,aAAa,CAACX,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAON,cAAc,CAACtB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOpB,QAAQ,CAACR,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;MACrB,OAAOV,WAAW,CAAClB,KAAK,EAAE0B,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOP,SAAS,CAACK,MAAM,CAACE,OAAO,EAAE5B,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC;AAAC"}
|
|
@@ -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 {
|
|
@@ -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;
|
|
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"}
|
package/lib/redux/types.js.flow
CHANGED
|
@@ -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
|
package/lib/redux/types.js.map
CHANGED
|
@@ -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
|
@@ -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",
|
|
194
|
-
this.addBooleanOption("false", "No",
|
|
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: {
|
|
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]
|
|
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,
|
package/src/redux/types.js
CHANGED
|
@@ -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
|
};
|
package/types/redux/types.d.ts
CHANGED
|
@@ -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 = {};
|