@beinformed/ui 1.58.0 → 1.58.2
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 +14 -0
- package/esm/react-client/rehydrate.js +1 -1
- package/esm/react-client/rehydrate.js.map +1 -1
- package/esm/redux/reducers/ModelCatalogReducer.js +1 -8
- package/esm/redux/reducers/ModelCatalogReducer.js.map +1 -1
- package/esm/redux/types.js.map +1 -1
- package/lib/react-client/rehydrate.js +1 -1
- package/lib/react-client/rehydrate.js.flow +6 -1
- package/lib/react-client/rehydrate.js.map +1 -1
- package/lib/redux/reducers/ModelCatalogReducer.js +1 -8
- package/lib/redux/reducers/ModelCatalogReducer.js.flow +5 -11
- package/lib/redux/reducers/ModelCatalogReducer.js.map +1 -1
- package/lib/redux/types.js.flow +1 -1
- package/lib/redux/types.js.map +1 -1
- package/package.json +1 -1
- package/src/react-client/rehydrate.js +6 -1
- package/src/redux/reducers/ModelCatalogReducer.js +5 -11
- package/src/redux/types.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.58.2](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.58.1...v1.58.2) (2024-11-20)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **modelcatalog:** no initial state entrydate on server ([0171277](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/01712777768bab8b85ce29b9a1761fc1d16e5f83))
|
|
11
|
+
|
|
12
|
+
## [1.58.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.58.0...v1.58.1) (2024-11-20)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **modelcatalog:** no initial state entrydate on server ([fb91f5f](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/fb91f5feaa860cbf1ce284509c07229316afeff5))
|
|
18
|
+
|
|
5
19
|
## [1.58.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.57.5...v1.58.0) (2024-11-19)
|
|
6
20
|
|
|
7
21
|
|
|
@@ -42,7 +42,7 @@ const rehydratedValue = (stateKey, stateValue) => {
|
|
|
42
42
|
locale: stateValue?.locale
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
const noFurtherRehydration = ["preferences", "router", "progressindicator"];
|
|
45
|
+
const noFurtherRehydration = ["preferences", "router", "progressindicator", "modelcatalog"];
|
|
46
46
|
if (_includesInstanceProperty(noFurtherRehydration).call(noFurtherRehydration, stateKey)) {
|
|
47
47
|
return stateValue;
|
|
48
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehydrate.js","names":["has","Locales","resolveModel","ModularUIResponse","recreateModel","data","modelData","rehydrate","Model","_context","model","childModels","_mapInstanceProperty","call","childModel","addChildModels","isModularUIModelData","rehydratedValue","stateKey","stateValue","Array","isArray","stateItem","locales","locale","noFurtherRehydration","_includesInstanceProperty","state","mappedState","_Object$keys","forEach"],"sources":["../../src/react-client/rehydrate.js"],"sourcesContent":["// @flow\nimport { has } from \"../utils/helpers/objects\";\nimport Locales from \"../i18n/Locales\";\n\nimport resolveModel from \"../models/resolveModel\";\n\nimport ModularUIResponse from \"../modularui/ModularUIResponse\";\n\n/**\n * Recreate a model from dehydrated data obtained after a server render.\n */\nconst recreateModel = (data: Object) => {\n const modelData = ModularUIResponse.rehydrate(data);\n\n const Model = resolveModel(modelData);\n\n if (Model) {\n const model = new Model(modelData);\n model.rehydrate(data);\n\n const childModels = data.childModels.map((childModel) =>\n recreateModel(childModel),\n );\n\n model.addChildModels(childModels, []);\n\n return model;\n }\n\n return data;\n};\n\n/**\n */\nconst isModularUIModelData = (data: any) =>\n data != null &&\n typeof data === \"object\" &&\n has(data, \"data\") &&\n has(data, \"contributions\");\n\n/**\n */\nconst rehydratedValue = (stateKey: string, stateValue: any) => {\n if (Array.isArray(stateValue)) {\n return stateValue.map((stateItem) => rehydrate(stateItem)); // NOSONAR\n }\n\n if (isModularUIModelData(stateValue)) {\n return recreateModel(stateValue);\n }\n\n if (\n stateKey === \"i18n\" &&\n has(stateValue, \"locales\") &&\n has(stateValue, \"locale\")\n ) {\n return {\n locales: Locales.rehydrate(stateValue.locales),\n locale: stateValue?.locale,\n };\n }\n\n const noFurtherRehydration = [\"preferences\"
|
|
1
|
+
{"version":3,"file":"rehydrate.js","names":["has","Locales","resolveModel","ModularUIResponse","recreateModel","data","modelData","rehydrate","Model","_context","model","childModels","_mapInstanceProperty","call","childModel","addChildModels","isModularUIModelData","rehydratedValue","stateKey","stateValue","Array","isArray","stateItem","locales","locale","noFurtherRehydration","_includesInstanceProperty","state","mappedState","_Object$keys","forEach"],"sources":["../../src/react-client/rehydrate.js"],"sourcesContent":["// @flow\nimport { has } from \"../utils/helpers/objects\";\nimport Locales from \"../i18n/Locales\";\n\nimport resolveModel from \"../models/resolveModel\";\n\nimport ModularUIResponse from \"../modularui/ModularUIResponse\";\n\n/**\n * Recreate a model from dehydrated data obtained after a server render.\n */\nconst recreateModel = (data: Object) => {\n const modelData = ModularUIResponse.rehydrate(data);\n\n const Model = resolveModel(modelData);\n\n if (Model) {\n const model = new Model(modelData);\n model.rehydrate(data);\n\n const childModels = data.childModels.map((childModel) =>\n recreateModel(childModel),\n );\n\n model.addChildModels(childModels, []);\n\n return model;\n }\n\n return data;\n};\n\n/**\n */\nconst isModularUIModelData = (data: any) =>\n data != null &&\n typeof data === \"object\" &&\n has(data, \"data\") &&\n has(data, \"contributions\");\n\n/**\n */\nconst rehydratedValue = (stateKey: string, stateValue: any) => {\n if (Array.isArray(stateValue)) {\n return stateValue.map((stateItem) => rehydrate(stateItem)); // NOSONAR\n }\n\n if (isModularUIModelData(stateValue)) {\n return recreateModel(stateValue);\n }\n\n if (\n stateKey === \"i18n\" &&\n has(stateValue, \"locales\") &&\n has(stateValue, \"locale\")\n ) {\n return {\n locales: Locales.rehydrate(stateValue.locales),\n locale: stateValue?.locale,\n };\n }\n\n const noFurtherRehydration = [\n \"preferences\",\n \"router\",\n \"progressindicator\",\n \"modelcatalog\",\n ];\n if (noFurtherRehydration.includes(stateKey)) {\n return stateValue;\n }\n\n if (stateValue !== null && typeof stateValue === \"object\") {\n return rehydrate(stateValue); // NOSONAR\n }\n\n return stateValue;\n};\n\n/**\n * Maps dehydrated state to models that can be used to rehydrated the application.\n */\nconst rehydrate = (state: Object): { ... } => {\n const mappedState: { [string]: any } = {};\n\n Object.keys(state).forEach((stateKey) => {\n const stateValue = state[stateKey];\n mappedState[stateKey] = rehydratedValue(stateKey, stateValue);\n });\n\n return mappedState;\n};\n\nexport default rehydrate;\n"],"mappings":";;;AACA,SAASA,GAAG,QAAQ,0BAA0B;AAC9C,OAAOC,OAAO,MAAM,iBAAiB;AAErC,OAAOC,YAAY,MAAM,wBAAwB;AAEjD,OAAOC,iBAAiB,MAAM,gCAAgC;;AAE9D;AACA;AACA;AACA,MAAMC,aAAa,GAAIC,IAAY,IAAK;EACtC,MAAMC,SAAS,GAAGH,iBAAiB,CAACI,SAAS,CAACF,IAAI,CAAC;EAEnD,MAAMG,KAAK,GAAGN,YAAY,CAACI,SAAS,CAAC;EAErC,IAAIE,KAAK,EAAE;IAAA,IAAAC,QAAA;IACT,MAAMC,KAAK,GAAG,IAAIF,KAAK,CAACF,SAAS,CAAC;IAClCI,KAAK,CAACH,SAAS,CAACF,IAAI,CAAC;IAErB,MAAMM,WAAW,GAAGC,oBAAA,CAAAH,QAAA,GAAAJ,IAAI,CAACM,WAAW,EAAAE,IAAA,CAAAJ,QAAA,EAAMK,UAAU,IAClDV,aAAa,CAACU,UAAU,CAC1B,CAAC;IAEDJ,KAAK,CAACK,cAAc,CAACJ,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C;;AAED;AACA;AACA;AACA,MAAMZ,SAAS,GAAIoB,KAAa,IAAc;EAC5C,MAAMC,WAA8B,GAAG,CAAC,CAAC;EAEzCC,YAAA,CAAYF,KAAK,CAAC,CAACG,OAAO,CAAEZ,QAAQ,IAAK;IACvC,MAAMC,UAAU,GAAGQ,KAAK,CAACT,QAAQ,CAAC;IAClCU,WAAW,CAACV,QAAQ,CAAC,GAAGD,eAAe,CAACC,QAAQ,EAAEC,UAAU,CAAC;EAC/D,CAAC,CAAC;EAEF,OAAOS,WAAW;AACpB,CAAC;AAED,eAAerB,SAAS","ignoreList":[]}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import _URLSearchParams from "@babel/runtime-corejs3/core-js-stable/url-search-params";
|
|
2
2
|
import { DateUtil } from "../../utils";
|
|
3
3
|
import Cache from "../../utils/browser/Cache";
|
|
4
|
-
const getQueryParam = paramName => {
|
|
5
|
-
if (typeof window !== "undefined") {
|
|
6
|
-
const urlParams = new _URLSearchParams(window.location?.search);
|
|
7
|
-
return urlParams.get(paramName);
|
|
8
|
-
}
|
|
9
|
-
return null;
|
|
10
|
-
};
|
|
11
4
|
const initialState = {
|
|
12
|
-
entryDate:
|
|
5
|
+
entryDate: typeof window !== "undefined" ? new _URLSearchParams(window.location?.search).get("entryDate") || Cache.getItem("ModelCatalogEntryDate") || DateUtil.now() : null
|
|
13
6
|
};
|
|
14
7
|
|
|
15
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelCatalogReducer.js","names":["DateUtil","Cache","
|
|
1
|
+
{"version":3,"file":"ModelCatalogReducer.js","names":["DateUtil","Cache","initialState","entryDate","window","_URLSearchParams","location","search","get","getItem","now","ModelCatalogReducer","state","arguments","length","undefined","action","type","addItem","payload"],"sources":["../../../src/redux/reducers/ModelCatalogReducer.js"],"sourcesContent":["// @flow\nimport { DateUtil } from \"../../utils\";\nimport Cache from \"../../utils/browser/Cache\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction, ModelCatalogState } from \"../types\";\n\nconst initialState: ModelCatalogState = {\n entryDate:\n typeof window !== \"undefined\"\n ? new URLSearchParams(window.location?.search).get(\"entryDate\") ||\n Cache.getItem(\"ModelCatalogEntryDate\") ||\n DateUtil.now()\n : null,\n};\n\n/**\n * Keep track of the entry date for the modelcatalog\n */\nconst ModelCatalogReducer: Reducer<ModelCatalogState, ReduxAction> = (\n state = initialState,\n action,\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"UPDATE_ENTRYDATE\":\n Cache.addItem(\"ModelCatalogEntryDate\", action.payload);\n return {\n ...state,\n entryDate: action.payload,\n };\n default:\n return state;\n }\n};\n\nexport default ModelCatalogReducer;\n"],"mappings":";AACA,SAASA,QAAQ,QAAQ,aAAa;AACtC,OAAOC,KAAK,MAAM,2BAA2B;AAK7C,MAAMC,YAA+B,GAAG;EACtCC,SAAS,EACP,OAAOC,MAAM,KAAK,WAAW,GACzB,IAAAC,gBAAA,CAAoBD,MAAM,CAACE,QAAQ,EAAEC,MAAM,CAAC,CAACC,GAAG,CAAC,WAAW,CAAC,IAC7DP,KAAK,CAACQ,OAAO,CAAC,uBAAuB,CAAC,IACtCT,QAAQ,CAACU,GAAG,CAAC,CAAC,GACd;AACR,CAAC;;AAED;AACA;AACA;AACA,MAAMC,mBAA4D,GAAG,SAAAA,CAAA,EAGhE;EAAA,IAFHC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGX,YAAY;EAAA,IACpBc,MAAM,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEN,IAAI,CAACC,MAAM,EAAE;IACX,OAAOJ,KAAK;EACd;EAEA,QAAQI,MAAM,CAACC,IAAI;IACjB,KAAK,kBAAkB;MACrBhB,KAAK,CAACiB,OAAO,CAAC,uBAAuB,EAAEF,MAAM,CAACG,OAAO,CAAC;MACtD,OAAO;QACL,GAAGP,KAAK;QACRT,SAAS,EAAEa,MAAM,CAACG;MACpB,CAAC;IACH;MACE,OAAOP,KAAK;EAChB;AACF,CAAC;AAED,eAAeD,mBAAmB","ignoreList":[]}
|
package/esm/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 UpdateFormAction,\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 autoupdate: 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 UpdateEntryDateAction = {\n type: \"UPDATE_ENTRYDATE\",\n payload: ISO_DATE,\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | InitModelAction\n | UpdateModelAction\n | UpdateFormAction\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 | UpdateEntryDateAction\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 ModelCatalogState = {\n entryDate: ISO_DATE,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +modelcatalog: ModelCatalogState,\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":"","ignoreList":[]}
|
|
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 UpdateFormAction,\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 autoupdate: 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 UpdateEntryDateAction = {\n type: \"UPDATE_ENTRYDATE\",\n payload: ISO_DATE,\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | InitModelAction\n | UpdateModelAction\n | UpdateFormAction\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 | UpdateEntryDateAction\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 ModelCatalogState = {\n entryDate: ISO_DATE | null,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +modelcatalog: ModelCatalogState,\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":"","ignoreList":[]}
|
|
@@ -48,7 +48,7 @@ const rehydratedValue = (stateKey, stateValue) => {
|
|
|
48
48
|
locale: stateValue?.locale
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
const noFurtherRehydration = ["preferences", "router", "progressindicator"];
|
|
51
|
+
const noFurtherRehydration = ["preferences", "router", "progressindicator", "modelcatalog"];
|
|
52
52
|
if ((0, _includes.default)(noFurtherRehydration).call(noFurtherRehydration, stateKey)) {
|
|
53
53
|
return stateValue;
|
|
54
54
|
}
|
|
@@ -60,7 +60,12 @@ const rehydratedValue = (stateKey: string, stateValue: any) => {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const noFurtherRehydration = [
|
|
63
|
+
const noFurtherRehydration = [
|
|
64
|
+
"preferences",
|
|
65
|
+
"router",
|
|
66
|
+
"progressindicator",
|
|
67
|
+
"modelcatalog",
|
|
68
|
+
];
|
|
64
69
|
if (noFurtherRehydration.includes(stateKey)) {
|
|
65
70
|
return stateValue;
|
|
66
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rehydrate.js","names":["_objects","require","_Locales","_interopRequireDefault","_resolveModel","_ModularUIResponse","recreateModel","data","modelData","ModularUIResponse","rehydrate","Model","resolveModel","_context","model","childModels","_map","default","call","childModel","addChildModels","isModularUIModelData","has","rehydratedValue","stateKey","stateValue","Array","isArray","stateItem","locales","Locales","locale","noFurtherRehydration","_includes","state","mappedState","_keys","forEach","_default","exports"],"sources":["../../src/react-client/rehydrate.js"],"sourcesContent":["// @flow\nimport { has } from \"../utils/helpers/objects\";\nimport Locales from \"../i18n/Locales\";\n\nimport resolveModel from \"../models/resolveModel\";\n\nimport ModularUIResponse from \"../modularui/ModularUIResponse\";\n\n/**\n * Recreate a model from dehydrated data obtained after a server render.\n */\nconst recreateModel = (data: Object) => {\n const modelData = ModularUIResponse.rehydrate(data);\n\n const Model = resolveModel(modelData);\n\n if (Model) {\n const model = new Model(modelData);\n model.rehydrate(data);\n\n const childModels = data.childModels.map((childModel) =>\n recreateModel(childModel),\n );\n\n model.addChildModels(childModels, []);\n\n return model;\n }\n\n return data;\n};\n\n/**\n */\nconst isModularUIModelData = (data: any) =>\n data != null &&\n typeof data === \"object\" &&\n has(data, \"data\") &&\n has(data, \"contributions\");\n\n/**\n */\nconst rehydratedValue = (stateKey: string, stateValue: any) => {\n if (Array.isArray(stateValue)) {\n return stateValue.map((stateItem) => rehydrate(stateItem)); // NOSONAR\n }\n\n if (isModularUIModelData(stateValue)) {\n return recreateModel(stateValue);\n }\n\n if (\n stateKey === \"i18n\" &&\n has(stateValue, \"locales\") &&\n has(stateValue, \"locale\")\n ) {\n return {\n locales: Locales.rehydrate(stateValue.locales),\n locale: stateValue?.locale,\n };\n }\n\n const noFurtherRehydration = [\"preferences\"
|
|
1
|
+
{"version":3,"file":"rehydrate.js","names":["_objects","require","_Locales","_interopRequireDefault","_resolveModel","_ModularUIResponse","recreateModel","data","modelData","ModularUIResponse","rehydrate","Model","resolveModel","_context","model","childModels","_map","default","call","childModel","addChildModels","isModularUIModelData","has","rehydratedValue","stateKey","stateValue","Array","isArray","stateItem","locales","Locales","locale","noFurtherRehydration","_includes","state","mappedState","_keys","forEach","_default","exports"],"sources":["../../src/react-client/rehydrate.js"],"sourcesContent":["// @flow\nimport { has } from \"../utils/helpers/objects\";\nimport Locales from \"../i18n/Locales\";\n\nimport resolveModel from \"../models/resolveModel\";\n\nimport ModularUIResponse from \"../modularui/ModularUIResponse\";\n\n/**\n * Recreate a model from dehydrated data obtained after a server render.\n */\nconst recreateModel = (data: Object) => {\n const modelData = ModularUIResponse.rehydrate(data);\n\n const Model = resolveModel(modelData);\n\n if (Model) {\n const model = new Model(modelData);\n model.rehydrate(data);\n\n const childModels = data.childModels.map((childModel) =>\n recreateModel(childModel),\n );\n\n model.addChildModels(childModels, []);\n\n return model;\n }\n\n return data;\n};\n\n/**\n */\nconst isModularUIModelData = (data: any) =>\n data != null &&\n typeof data === \"object\" &&\n has(data, \"data\") &&\n has(data, \"contributions\");\n\n/**\n */\nconst rehydratedValue = (stateKey: string, stateValue: any) => {\n if (Array.isArray(stateValue)) {\n return stateValue.map((stateItem) => rehydrate(stateItem)); // NOSONAR\n }\n\n if (isModularUIModelData(stateValue)) {\n return recreateModel(stateValue);\n }\n\n if (\n stateKey === \"i18n\" &&\n has(stateValue, \"locales\") &&\n has(stateValue, \"locale\")\n ) {\n return {\n locales: Locales.rehydrate(stateValue.locales),\n locale: stateValue?.locale,\n };\n }\n\n const noFurtherRehydration = [\n \"preferences\",\n \"router\",\n \"progressindicator\",\n \"modelcatalog\",\n ];\n if (noFurtherRehydration.includes(stateKey)) {\n return stateValue;\n }\n\n if (stateValue !== null && typeof stateValue === \"object\") {\n return rehydrate(stateValue); // NOSONAR\n }\n\n return stateValue;\n};\n\n/**\n * Maps dehydrated state to models that can be used to rehydrated the application.\n */\nconst rehydrate = (state: Object): { ... } => {\n const mappedState: { [string]: any } = {};\n\n Object.keys(state).forEach((stateKey) => {\n const stateValue = state[stateKey];\n mappedState[stateKey] = rehydratedValue(stateKey, stateValue);\n });\n\n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","ignoreList":[]}
|
|
@@ -8,15 +8,8 @@ exports.default = void 0;
|
|
|
8
8
|
var _urlSearchParams = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/url-search-params"));
|
|
9
9
|
var _utils = require("../../utils");
|
|
10
10
|
var _Cache = _interopRequireDefault(require("../../utils/browser/Cache"));
|
|
11
|
-
const getQueryParam = paramName => {
|
|
12
|
-
if (typeof window !== "undefined") {
|
|
13
|
-
const urlParams = new _urlSearchParams.default(window.location?.search);
|
|
14
|
-
return urlParams.get(paramName);
|
|
15
|
-
}
|
|
16
|
-
return null;
|
|
17
|
-
};
|
|
18
11
|
const initialState = {
|
|
19
|
-
entryDate:
|
|
12
|
+
entryDate: typeof window !== "undefined" ? new _urlSearchParams.default(window.location?.search).get("entryDate") || _Cache.default.getItem("ModelCatalogEntryDate") || _utils.DateUtil.now() : null
|
|
20
13
|
};
|
|
21
14
|
|
|
22
15
|
/**
|
|
@@ -5,19 +5,13 @@ import Cache from "../../utils/browser/Cache";
|
|
|
5
5
|
import type { Reducer } from "redux";
|
|
6
6
|
import type { ReduxAction, ModelCatalogState } from "../types";
|
|
7
7
|
|
|
8
|
-
const getQueryParam = (paramName: string): ?string => {
|
|
9
|
-
if (typeof window !== "undefined") {
|
|
10
|
-
const urlParams = new URLSearchParams(window.location?.search);
|
|
11
|
-
return urlParams.get(paramName);
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
8
|
const initialState: ModelCatalogState = {
|
|
17
9
|
entryDate:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
typeof window !== "undefined"
|
|
11
|
+
? new URLSearchParams(window.location?.search).get("entryDate") ||
|
|
12
|
+
Cache.getItem("ModelCatalogEntryDate") ||
|
|
13
|
+
DateUtil.now()
|
|
14
|
+
: null,
|
|
21
15
|
};
|
|
22
16
|
|
|
23
17
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModelCatalogReducer.js","names":["_utils","require","_Cache","_interopRequireDefault","
|
|
1
|
+
{"version":3,"file":"ModelCatalogReducer.js","names":["_utils","require","_Cache","_interopRequireDefault","initialState","entryDate","window","_urlSearchParams","default","location","search","get","Cache","getItem","DateUtil","now","ModelCatalogReducer","state","arguments","length","undefined","action","type","addItem","payload","_default","exports"],"sources":["../../../src/redux/reducers/ModelCatalogReducer.js"],"sourcesContent":["// @flow\nimport { DateUtil } from \"../../utils\";\nimport Cache from \"../../utils/browser/Cache\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction, ModelCatalogState } from \"../types\";\n\nconst initialState: ModelCatalogState = {\n entryDate:\n typeof window !== \"undefined\"\n ? new URLSearchParams(window.location?.search).get(\"entryDate\") ||\n Cache.getItem(\"ModelCatalogEntryDate\") ||\n DateUtil.now()\n : null,\n};\n\n/**\n * Keep track of the entry date for the modelcatalog\n */\nconst ModelCatalogReducer: Reducer<ModelCatalogState, ReduxAction> = (\n state = initialState,\n action,\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"UPDATE_ENTRYDATE\":\n Cache.addItem(\"ModelCatalogEntryDate\", action.payload);\n return {\n ...state,\n entryDate: action.payload,\n };\n default:\n return state;\n }\n};\n\nexport default ModelCatalogReducer;\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,MAAMG,YAA+B,GAAG;EACtCC,SAAS,EACP,OAAOC,MAAM,KAAK,WAAW,GACzB,IAAAC,gBAAA,CAAAC,OAAA,CAAoBF,MAAM,CAACG,QAAQ,EAAEC,MAAM,CAAC,CAACC,GAAG,CAAC,WAAW,CAAC,IAC7DC,cAAK,CAACC,OAAO,CAAC,uBAAuB,CAAC,IACtCC,eAAQ,CAACC,GAAG,CAAC,CAAC,GACd;AACR,CAAC;;AAED;AACA;AACA;AACA,MAAMC,mBAA4D,GAAG,SAAAA,CAAA,EAGhE;EAAA,IAFHC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGd,YAAY;EAAA,IACpBiB,MAAM,GAAAH,SAAA,CAAAC,MAAA,OAAAD,SAAA,MAAAE,SAAA;EAEN,IAAI,CAACC,MAAM,EAAE;IACX,OAAOJ,KAAK;EACd;EAEA,QAAQI,MAAM,CAACC,IAAI;IACjB,KAAK,kBAAkB;MACrBV,cAAK,CAACW,OAAO,CAAC,uBAAuB,EAAEF,MAAM,CAACG,OAAO,CAAC;MACtD,OAAO;QACL,GAAGP,KAAK;QACRZ,SAAS,EAAEgB,MAAM,CAACG;MACpB,CAAC;IACH;MACE,OAAOP,KAAK;EAChB;AACF,CAAC;AAAC,IAAAQ,QAAA,GAAAC,OAAA,CAAAlB,OAAA,GAEaQ,mBAAmB","ignoreList":[]}
|
package/lib/redux/types.js.flow
CHANGED
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 UpdateFormAction,\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 autoupdate: 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 UpdateEntryDateAction = {\n type: \"UPDATE_ENTRYDATE\",\n payload: ISO_DATE,\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | InitModelAction\n | UpdateModelAction\n | UpdateFormAction\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 | UpdateEntryDateAction\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 ModelCatalogState = {\n entryDate: ISO_DATE,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +modelcatalog: ModelCatalogState,\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":"","ignoreList":[]}
|
|
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 UpdateFormAction,\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 autoupdate: 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 UpdateEntryDateAction = {\n type: \"UPDATE_ENTRYDATE\",\n payload: ISO_DATE,\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | InitModelAction\n | UpdateModelAction\n | UpdateFormAction\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 | UpdateEntryDateAction\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 ModelCatalogState = {\n entryDate: ISO_DATE | null,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +modelcatalog: ModelCatalogState,\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":"","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -60,7 +60,12 @@ const rehydratedValue = (stateKey: string, stateValue: any) => {
|
|
|
60
60
|
};
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const noFurtherRehydration = [
|
|
63
|
+
const noFurtherRehydration = [
|
|
64
|
+
"preferences",
|
|
65
|
+
"router",
|
|
66
|
+
"progressindicator",
|
|
67
|
+
"modelcatalog",
|
|
68
|
+
];
|
|
64
69
|
if (noFurtherRehydration.includes(stateKey)) {
|
|
65
70
|
return stateValue;
|
|
66
71
|
}
|
|
@@ -5,19 +5,13 @@ import Cache from "../../utils/browser/Cache";
|
|
|
5
5
|
import type { Reducer } from "redux";
|
|
6
6
|
import type { ReduxAction, ModelCatalogState } from "../types";
|
|
7
7
|
|
|
8
|
-
const getQueryParam = (paramName: string): ?string => {
|
|
9
|
-
if (typeof window !== "undefined") {
|
|
10
|
-
const urlParams = new URLSearchParams(window.location?.search);
|
|
11
|
-
return urlParams.get(paramName);
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
8
|
const initialState: ModelCatalogState = {
|
|
17
9
|
entryDate:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
typeof window !== "undefined"
|
|
11
|
+
? new URLSearchParams(window.location?.search).get("entryDate") ||
|
|
12
|
+
Cache.getItem("ModelCatalogEntryDate") ||
|
|
13
|
+
DateUtil.now()
|
|
14
|
+
: null,
|
|
21
15
|
};
|
|
22
16
|
|
|
23
17
|
/**
|