@beinformed/ui 1.60.4 → 1.60.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/esm/models/application/ApplicationModel.js +3 -1
  3. package/esm/models/application/ApplicationModel.js.map +1 -1
  4. package/esm/models/attributes/CompositeAttributeModel.js +6 -5
  5. package/esm/models/attributes/CompositeAttributeModel.js.map +1 -1
  6. package/esm/models/content/ContentTOCModel.js +2 -1
  7. package/esm/models/content/ContentTOCModel.js.map +1 -1
  8. package/esm/models/href/Href.js +12 -11
  9. package/esm/models/href/Href.js.map +1 -1
  10. package/esm/models/list/ListModel.js +2 -1
  11. package/esm/models/list/ListModel.js.map +1 -1
  12. package/esm/modularui/ModularUIRequest.js +6 -3
  13. package/esm/modularui/ModularUIRequest.js.map +1 -1
  14. package/esm/redux/_modularui/ModularUIActions.d.ts +2 -2
  15. package/esm/redux/_modularui/ModularUIActions.js +27 -10
  16. package/esm/redux/_modularui/ModularUIActions.js.flow +24 -5
  17. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  18. package/esm/redux/_modularui/ModularUIMiddleware.js +1 -1
  19. package/esm/redux/_modularui/ModularUIMiddleware.js.flow +1 -1
  20. package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  21. package/esm/redux/_modularui/ModularUIReducer.js +4 -2
  22. package/esm/redux/_modularui/ModularUIReducer.js.flow +10 -1
  23. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  24. package/esm/redux/_modularui/ModularUIUtils.js +3 -1
  25. package/esm/redux/_modularui/ModularUIUtils.js.map +1 -1
  26. package/esm/redux/_modularui/__tests__/actions.spec.js.flow +5 -1
  27. package/esm/redux/_modularui/types.d.ts +1 -0
  28. package/esm/redux/_modularui/types.js.flow +2 -0
  29. package/esm/redux/_modularui/types.js.map +1 -1
  30. package/lib/models/application/ApplicationModel.js +3 -1
  31. package/lib/models/application/ApplicationModel.js.map +1 -1
  32. package/lib/models/attributes/CompositeAttributeModel.js +6 -5
  33. package/lib/models/attributes/CompositeAttributeModel.js.map +1 -1
  34. package/lib/models/content/ContentTOCModel.js +2 -1
  35. package/lib/models/content/ContentTOCModel.js.map +1 -1
  36. package/lib/models/href/Href.js +12 -11
  37. package/lib/models/href/Href.js.map +1 -1
  38. package/lib/models/list/ListModel.js +2 -1
  39. package/lib/models/list/ListModel.js.map +1 -1
  40. package/lib/modularui/ModularUIRequest.js +6 -3
  41. package/lib/modularui/ModularUIRequest.js.map +1 -1
  42. package/lib/redux/_modularui/ModularUIActions.d.ts +2 -2
  43. package/lib/redux/_modularui/ModularUIActions.js +27 -10
  44. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  45. package/lib/redux/_modularui/ModularUIMiddleware.js +1 -1
  46. package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
  47. package/lib/redux/_modularui/ModularUIReducer.js +4 -2
  48. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  49. package/lib/redux/_modularui/ModularUIUtils.js +3 -1
  50. package/lib/redux/_modularui/ModularUIUtils.js.map +1 -1
  51. package/lib/redux/_modularui/types.d.ts +1 -0
  52. package/lib/redux/_modularui/types.js.map +1 -1
  53. package/package.json +22 -22
  54. package/src/redux/_modularui/ModularUIActions.js +24 -5
  55. package/src/redux/_modularui/ModularUIMiddleware.js +1 -1
  56. package/src/redux/_modularui/ModularUIReducer.js +10 -1
  57. package/src/redux/_modularui/__tests__/actions.spec.js +5 -1
  58. package/src/redux/_modularui/types.js +2 -0
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIActions.js","names":["_Constants","require","_Href","_interopRequireDefault","_ErrorResponse","_ProgressIndicator","_Error","setModel","key","model","connectKey","type","payload","exports","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","updateHandler","getRequestLocale","optionLocale","navigator","language","split","loadModel","href","options","origin","contextPath","Href","method","HTTP_METHODS","GET","params","data","timeout","headers","events","onProgress","locale","childmodels","targetModel","forceTargetModel","cache","isReload","withCredentials","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","getState","modularuiStore","modularui","LOADING","_promise","default","resolve","startProgress","loadModelPromise","then","finishProgress","catch","handleError","reloadModel","selfhref"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * Retrieve the preferred language for this request, falls back to the browser language or english\n */\nconst getRequestLocale = (optionLocale: ?string): string => {\n if (optionLocale) {\n return optionLocale;\n }\n\n if (typeof navigator !== \"undefined\" && navigator?.language) {\n return navigator.language.split(\"-\")[0] || \"en\";\n }\n\n return \"en\";\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n key,\n origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", {\n origin: options?.origin,\n contextPath: options?.contextPath,\n }),\n method: options?.method ?? HTTP_METHODS.GET,\n params: options?.params,\n data: options?.data,\n timeout: options?.timeout,\n headers: options?.headers,\n events: options?.events,\n onProgress: options?.onProgress,\n locale: getRequestLocale(options?.locale),\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n isReload: options?.isReload,\n withCredentials: options?.withCredentials,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key, {\n origin: options?.origin,\n contextPath: options?.contextPath,\n });\n if (\n errorResponse.isChangePassword ||\n errorResponse.isResourceNotFoundAfterReload\n ) {\n return removeModelByKey(key);\n }\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n ): ThunkAction =>\n (dispatch: Dispatch, getState) => {\n const modularuiStore = getState()?.modularui;\n if (\n modularuiStore &&\n modularuiStore[key]?.status === MODULARUI_STATUS.LOADING\n ) {\n return Promise.resolve();\n }\n\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then(() => dispatch(finishProgress()))\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";;;;;;;;AACA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,cAAA,GAAAD,sBAAA,CAAAF,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAmBA;AACA;AACO,MAAMM,QAAQ,GAAGA,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AADAI,OAAA,CAAAN,QAAA,GAAAA,QAAA;AAEO,MAAMO,UAAU,GACrBC,MAAqD,KAChC;EACrBJ,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEG;AACX,CAAC,CAAC;;AAEF;AACA;AADAF,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAEO,MAAME,WAAW,GAAIP,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;A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AAqB,EACrBsB,OAAiC,KAEjC6B,aAAa,CAACnD,KAAK,CAACC,UAAU,EAAED,KAAK,CAACmE,QAAQ,EAAE;EAC9C,GAAG7C,OAAO;EACVkB,QAAQ,EAAE;AACZ,CAAC,CAAC;AAACpC,OAAA,CAAA8D,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIActions.js","names":["_Constants","require","_Href","_interopRequireDefault","_ErrorResponse","_ProgressIndicator","_Error","setModel","key","model","connectKey","type","payload","exports","initModels","models","updateModel","updateForm","removeModelByKey","resetModularUI","updateStatus","status","requestOptions","loadModelSuccessAction","updateHandler","getRequestLocale","optionLocale","navigator","language","split","loadModel","href","options","origin","contextPath","Href","method","HTTP_METHODS","GET","params","data","timeout","headers","events","onProgress","locale","childmodels","targetModel","forceTargetModel","cache","isReload","withCredentials","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","retryCount","arguments","length","undefined","retryDelay","dispatch","getState","modularuiStore","modularui","currentRequest","isLoading","LOADING","isDifferentRequest","toString","_promise","default","resolve","setTimeout","startProgress","loadModelPromise","then","finishProgress","catch","handleError","reloadModel","selfhref"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n InitModelAction,\n UpdateModelAction,\n UpdateFormAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type {\n RequestModularUIOptions,\n UpdateHandler,\n} from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel,\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const initModels = (\n models: Array<{ key: string, model: ModularUIModel }>,\n): InitModelAction => ({\n type: \"MODULARUI/INIT\",\n payload: models,\n});\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const updateForm = (model: ModularUIModel): UpdateFormAction => ({\n type: \"MODULARUI/UPDATE_FORM\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n requestOptions: any,\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status, requestOptions },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n updateHandler: UpdateHandler | void,\n): UpdateModelAction | SetModelAction => {\n if (updateHandler) {\n return updateModel(updateHandler(model));\n }\n return setModel(key, model);\n};\n\n/**\n * Retrieve the preferred language for this request, falls back to the browser language or english\n */\nconst getRequestLocale = (optionLocale: ?string): string => {\n if (optionLocale) {\n return optionLocale;\n }\n\n if (typeof navigator !== \"undefined\" && navigator?.language) {\n return navigator.language.split(\"-\")[0] || \"en\";\n }\n\n return \"en\";\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n key,\n origin: options?.origin,\n contextPath: options?.contextPath,\n href:\n href instanceof Href\n ? href\n : new Href(href, \"\", {\n origin: options?.origin,\n contextPath: options?.contextPath,\n }),\n method: options?.method ?? HTTP_METHODS.GET,\n params: options?.params,\n data: options?.data,\n timeout: options?.timeout,\n headers: options?.headers,\n events: options?.events,\n onProgress: options?.onProgress,\n locale: getRequestLocale(options?.locale),\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n cache: options?.cache,\n isReload: options?.isReload,\n withCredentials: options?.withCredentials,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateHandler),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key, {\n origin: options?.origin,\n contextPath: options?.contextPath,\n });\n if (\n errorResponse.isChangePassword ||\n errorResponse.isResourceNotFoundAfterReload\n ) {\n return removeModelByKey(key);\n }\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions,\n retryCount: number = 3,\n retryDelay: number = 200,\n ): ThunkAction =>\n (dispatch: Dispatch, getState) => {\n const modularuiStore = getState()?.modularui;\n const currentRequest = modularuiStore?.[key];\n\n const isLoading = currentRequest?.status === MODULARUI_STATUS.LOADING;\n\n if (isLoading) {\n const isDifferentRequest =\n currentRequest.requestOptions?.href?.toString() !== href.toString();\n if (isDifferentRequest && retryCount > 0) {\n return new Promise((resolve) => {\n setTimeout(() => {\n resolve(\n dispatch(\n loadModularUI(key, href, options, retryCount - 1, retryDelay),\n ),\n );\n }, retryDelay);\n });\n }\n\n // Same request is already loading — do nothing\n return Promise.resolve();\n }\n\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then(() => dispatch(finishProgress()))\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions,\n): ThunkAction =>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,OAAA,CAAQC,OAAO,CAACG,gBAAgB,CAAC,CACrCC,IAAI,CAAC,MAAMf,QAAQ,CAAC,IAAAgB,iCAAc,EAAC,CAAC,CAAC,CAAC,CACtCC,KAAK,CAAE9B,KAAK,IAAKa,QAAQ,CAAC,IAAAkB,kBAAW,EAAC/B,KAAK,CAAC,CAAC,CAAC;EACnD,CAAC;AAAA;;AAEH;AACA;AADAzC,OAAA,CAAAgD,aAAA,GAAAA,aAAA;AAEO,MAAMyB,WAAW,GAAGA,CACzB7E,KAAqB,EACrBuB,OAAiC,KAEjC6B,aAAa,CAACpD,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC8E,QAAQ,EAAE;EAC9C,GAAGvD,OAAO;EACVkB,QAAQ,EAAE;AACZ,CAAC,CAAC;AAACrC,OAAA,CAAAyE,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -89,7 +89,7 @@ const handleFetch = (action, locale, dispatch, next) => {
89
89
  } = action.payload;
90
90
  requestOptions.locale = locale;
91
91
  const modularuiRequest = createRequest(requestOptions);
92
- dispatch((0, _ModularUIActions.updateStatus)(key, _Constants.MODULARUI_STATUS.LOADING));
92
+ dispatch((0, _ModularUIActions.updateStatus)(key, _Constants.MODULARUI_STATUS.LOADING, requestOptions));
93
93
  return modularuiRequest.fetch().then(model => responseHandler(next, dispatch, successAction, model)).catch(error => errorHandler(next, dispatch, errorAction, error));
94
94
  };
95
95
 
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIMiddleware.js","names":["_ModularUIRequest","_interopRequireDefault","require","_Constants","_ProgressIndicator","_Error","_ModularUIActions","createRequest","modularui","request","ModularUIRequest","href","method","HTTP_METHODS","GET","params","data","locale","childmodels","isReload","cache","headers","events","onProgress","origin","contextPath","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_promise","default","then","result","catch","error","handleError","Error","finishProgress","errorHandler","errorAction","err","errorResult","handleFetch","action","startProgress","key","requestOptions","payload","modularuiRequest","updateStatus","MODULARUI_STATUS","LOADING","fetch","modularUIMiddleware","api","type","getState","i18n","exports"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport { updateStatus } from \"./ModularUIActions\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n withCredentials?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n params: modularui.params || \"\",\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n headers: modularui.headers,\n events: modularui.events,\n onProgress: modularui.onProgress,\n });\n\n if (modularui.origin) {\n request.origin = modularui.origin;\n }\n\n if (modularui.contextPath) {\n request.contextPath = modularui.contextPath;\n }\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { key, successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next,\n );\n }\n\n return next(action);\n };\n"],"mappings":";;;;;;;;AACA,IAAAA,iBA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,EAAC,CAAC,CAAC;EAEzB,MAAM;IAAEC,GAAG;IAAEnB,aAAa;IAAEa,WAAW;IAAE,GAAGO;EAAe,CAAC,GAAGH,MAAM,CAACI,OAAO;EAC7ED,cAAc,CAAClC,MAAM,GAAGA,MAAM;EAE9B,MAAMoC,gBAAgB,GAAG9C,aAAa,CAAC4C,cAAc,CAAC;EAEtDrB,QAAQ,CAAC,IAAAwB,8BAAY,EAACJ,GAAG,EAAEK,2BAAgB,CAACC,OAAO,CAAC,CAAC;EAErD,OAAOH,gBAAgB,CACpBI,KAAK,CAAC,CAAC,CACPrB,IAAI,CAAEJ,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEM,KAAK,CAAEC,KAAK,IAAKI,YAAY,CAACd,IAAI,EAAEC,QAAQ,EAAEc,WAAW,EAAEL,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACO,MAAMmB,mBAIZ,GACEC,GAAqD,IACrD9B,IAAc,IACdmB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACY,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOb,WAAW;IAChB;IACAC,MAAM,EACNW,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAAC7C,MAAM,EAC1B0C,GAAG,CAAC7B,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACmB,MAAM,CAAC;AACrB,CAAC;AAACe,OAAA,CAAAL,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIMiddleware.js","names":["_ModularUIRequest","_interopRequireDefault","require","_Constants","_ProgressIndicator","_Error","_ModularUIActions","createRequest","modularui","request","ModularUIRequest","href","method","HTTP_METHODS","GET","params","data","locale","childmodels","isReload","cache","headers","events","onProgress","origin","contextPath","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","_promise","default","then","result","catch","error","handleError","Error","finishProgress","errorHandler","errorAction","err","errorResult","handleFetch","action","startProgress","key","requestOptions","payload","modularuiRequest","updateStatus","MODULARUI_STATUS","LOADING","fetch","modularUIMiddleware","api","type","getState","i18n","exports"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport { updateStatus } from \"./ModularUIActions\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n cache?: boolean,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n withCredentials?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n params: modularui.params || \"\",\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n cache: modularui.cache,\n headers: modularui.headers,\n events: modularui.events,\n onProgress: modularui.onProgress,\n });\n\n if (modularui.origin) {\n request.origin = modularui.origin;\n }\n\n if (modularui.contextPath) {\n request.contextPath = modularui.contextPath;\n }\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel,\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`,\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any,\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch,\n) => {\n dispatch(startProgress());\n\n const { key, successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING, requestOptions));\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch,\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n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CAClBC,MAAuB,EACvB/B,MAAc,EACda,QAAkB,EAClBD,IAAc,KACX;EACHC,QAAQ,CAAC,IAAAmB,gCAAa,EAAC,CAAC,CAAC;EAEzB,MAAM;IAAEC,GAAG;IAAEnB,aAAa;IAAEa,WAAW;IAAE,GAAGO;EAAe,CAAC,GAAGH,MAAM,CAACI,OAAO;EAC7ED,cAAc,CAAClC,MAAM,GAAGA,MAAM;EAE9B,MAAMoC,gBAAgB,GAAG9C,aAAa,CAAC4C,cAAc,CAAC;EAEtDrB,QAAQ,CAAC,IAAAwB,8BAAY,EAACJ,GAAG,EAAEK,2BAAgB,CAACC,OAAO,EAAEL,cAAc,CAAC,CAAC;EAErE,OAAOE,gBAAgB,CACpBI,KAAK,CAAC,CAAC,CACPrB,IAAI,CAAEJ,KAAK,IAAKJ,eAAe,CAACC,IAAI,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,KAAK,CAAC,CAAC,CACtEM,KAAK,CAAEC,KAAK,IAAKI,YAAY,CAACd,IAAI,EAAEC,QAAQ,EAAEc,WAAW,EAAEL,KAAK,CAAC,CAAC;AACvE,CAAC;;AAED;AACA;AACO,MAAMmB,mBAIZ,GACEC,GAAqD,IACrD9B,IAAc,IACdmB,MAAsB,IAAK;EAC1B,IAAIA,MAAM,CAACY,IAAI,KAAK,iBAAiB,EAAE;IACrC,OAAOb,WAAW;IAChB;IACAC,MAAM,EACNW,GAAG,CAACE,QAAQ,CAAC,CAAC,CAACC,IAAI,CAAC7C,MAAM,EAC1B0C,GAAG,CAAC7B,QAAQ,EACZD,IACF,CAAC;EACH;EAEA,OAAOA,IAAI,CAACmB,MAAM,CAAC;AACrB,CAAC;AAACe,OAAA,CAAAL,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -15,7 +15,8 @@ var _models = require("../../models");
15
15
  const updateStatus = (state, _ref) => {
16
16
  let {
17
17
  key,
18
- status
18
+ status,
19
+ requestOptions
19
20
  } = _ref;
20
21
  // model should always be available when status is not loading
21
22
  if (status !== _Constants.MODULARUI_STATUS.LOADING && !state[key]) {
@@ -26,7 +27,8 @@ const updateStatus = (state, _ref) => {
26
27
  [key]: {
27
28
  ...state[key],
28
29
  status,
29
- lastModification: Date.now()
30
+ lastModification: Date.now(),
31
+ requestOptions: requestOptions || state[key]?.requestOptions
30
32
  }
31
33
  };
32
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIReducer.js","names":["_Constants","require","_models","updateStatus","state","_ref","key","status","MODULARUI_STATUS","LOADING","lastModification","Date","now","setModel","_ref2","model","FINISHED","console","debug","initModularUI","models","newState","_assign","default","forEach","_ref3","getModelKey","_context","_find","_keys","call","connectKey","updateModel","modelKey","removeKey","resetModularUI","ApplicationModel","initialState","ModularUIReducer","arguments","length","undefined","action","type","payload","exports"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\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 status: MODULARUI_STATUS.FINISHED,\n },\n };\n }\n\n // eslint-disable-next-line no-console\n console.debug(\"No model for setModel\");\n return state;\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 // eslint-disable-next-line no-console\n console.debug(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`,\n );\n return state;\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 case \"MODULARUI/UPDATE_FORM\":\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,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAOA;AACA;AACA,MAAME,YAAY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ignoreList":[]}
1
+ {"version":3,"file":"ModularUIReducer.js","names":["_Constants","require","_models","updateStatus","state","_ref","key","status","requestOptions","MODULARUI_STATUS","LOADING","lastModification","Date","now","setModel","_ref2","model","FINISHED","console","debug","initModularUI","models","newState","_assign","default","forEach","_ref3","getModelKey","_context","_find","_keys","call","connectKey","updateModel","modelKey","removeKey","resetModularUI","ApplicationModel","initialState","ModularUIReducer","arguments","length","undefined","action","type","payload","exports"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\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 {\n key,\n status,\n requestOptions,\n }: {\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>,\n requestOptions: any,\n },\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 requestOptions: requestOptions || state[key]?.requestOptions,\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 status: MODULARUI_STATUS.FINISHED,\n },\n };\n }\n\n // eslint-disable-next-line no-console\n console.debug(\"No model for setModel\");\n return state;\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 // eslint-disable-next-line no-console\n console.debug(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`,\n );\n return state;\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 case \"MODULARUI/UPDATE_FORM\":\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,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAOA;AACA;AACA,MAAME,YAAY,GAAGA,CACnBC,KAAqB,EAAAC,IAAA,KAUlB;EAAA,IATH;IACEC,GAAG;IACHC,MAAM;IACNC;EAKF,CAAC,GAAAH,IAAA;EAED;EACA,IAAIE,MAAM,KAA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(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.useUrl = exports.useReload = exports.getKey = void 0;
8
+ var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with"));
8
9
  var _react = require("react");
9
10
  var _utils = require("../../react/utils");
10
11
  var _Constants = require("../../constants/Constants");
@@ -23,6 +24,7 @@ const getUrl = (resource, props) => {
23
24
  /**
24
25
  */
25
26
  const useUrl = (resource, props) => {
27
+ var _context;
26
28
  const [previousUrl, setPreviousUrl] = (0, _react.useState)(null);
27
29
  const [previousExact, setPreviousExact] = (0, _react.useState)(false);
28
30
  const url = getUrl(resource, props);
@@ -45,7 +47,7 @@ const useUrl = (resource, props) => {
45
47
  // Always create an url when the match is exact
46
48
  // Or when the match is not exact AND the original match also was not exact
47
49
  // Or when the new start uri is different from the previous url --> different resource for same panel
48
- if (match.isExact === true || previousExact === match.isExact || !previousUrl?.startsWith(match.url)) {
50
+ if (match.isExact === true || previousExact === match.isExact || !((_context = previousUrl) == null ? void 0 : Function.call.bind((0, _startsWith.default)(_context), _context))?.(match.url)) {
49
51
  setPreviousUrl(url);
50
52
  setPreviousExact(match.isExact);
51
53
  return url;
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIUtils.js","names":["_react","require","_utils","_Constants","_Href","_interopRequireDefault","getUrl","resource","props","url","Href","useUrl","previousUrl","setPreviousUrl","useState","previousExact","setPreviousExact","match","equalsWithParameters","isExact","startsWith","exports","getKey","WrappedComponent","name","getDisplayName","split","useReload","modelEntry","reload","arguments","length","undefined","isFullyLoaded","status","MODULARUI_STATUS","FINISHED","lastModification"],"sources":["../../../src/redux/_modularui/ModularUIUtils.js"],"sourcesContent":["// @flow\nimport { useState } from \"react\";\n\nimport { getDisplayName } from \"../../react/utils\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\n\nimport type { ComponentType } from \"react\";\n\n/**\n * Generate modular ui url\n */\nconst getUrl = (resource: string | Function | Href, props: Object): Href => {\n const url = typeof resource === \"function\" ? resource(props) : resource;\n\n if (url instanceof Href) {\n return url;\n }\n\n return new Href(url);\n};\n\n/**\n */\nexport const useUrl = (\n resource: string | Function | Href,\n props: Object,\n): Href => {\n const [previousUrl, setPreviousUrl] = useState(null);\n const [previousExact, setPreviousExact] = useState(false);\n\n const url = getUrl(resource, props);\n\n if (url == null && previousUrl == null) {\n return new Href(\"\");\n }\n\n const { match } = props;\n\n // when match is not available through props,\n // this is a direct call to the modular ui hoc, not using a route\n if (!match) {\n return url;\n }\n\n if (url.equalsWithParameters(previousUrl)) {\n return previousUrl || url;\n }\n\n // Always create an url when the match is exact\n // Or when the match is not exact AND the original match also was not exact\n // Or when the new start uri is different from the previous url --> different resource for same panel\n if (\n match.isExact === true ||\n previousExact === match.isExact ||\n !previousUrl?.startsWith(match.url)\n ) {\n setPreviousUrl(url);\n setPreviousExact(match.isExact);\n\n return url;\n }\n\n return previousUrl || new Href(\"\");\n};\n\n/**\n * Create key for modularui request based on component name and requested url\n */\nexport const getKey = (\n WrappedComponent: ComponentType<any>,\n name: string,\n url: string,\n): string => {\n if (url) {\n return `${getDisplayName(WrappedComponent, name)}(${url.split(\"?\")[0]})`;\n }\n\n return getDisplayName(WrappedComponent, name);\n};\n\n/**\n * Check if the model corresponding to a modular ui service should be reloaded\n */\nexport const useReload = (modelEntry: Object, reload: number = 0): boolean => {\n if (reload > 0) {\n const isFullyLoaded = modelEntry?.status === MODULARUI_STATUS.FINISHED;\n const lastModification = modelEntry?.lastModification ?? 0;\n\n if (isFullyLoaded && lastModification < reload) {\n return true;\n }\n }\n\n return false;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAIA;AACA;AACA;AACA,MAAMK,MAAM,GAAGA,CAACC,QAAkC,EAAEC,KAAa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AAAA,MAAA;AAGO,MAAMW,MAAM,GAAGA,CACpBC,gBAAoC,EACpCC,IAAY,EACZf,GAAW,KACA;EACX,IAAIA,GAAG,EAAE;IACP,OAAO,GAAG,IAAAgB,qBAAc,EAACF,gBAAgB,EAAEC,IAAI,CAAC,IAAIf,GAAG,CAACiB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;EAC1E;EAEA,OAAO,IAAAD,qBAAc,EAACF,gBAAgB,EAAEC,IAAI,CAAC;AAC/C,CAAC;;AAED;AACA;AACA;AAFAH,OAAA,CAAAC,MAAA,GAAAA,MAAA;AAGO,MAAMK,SAAS,GAAG,SAAAA,CAACC,UAAkB,EAAkC;EAAA,IAAhCC,MAAc,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAC9D,IAAID,MAAM,GAAG,CAAC,EAAE;IACd,MAAMI,aAAa,GAAGL,UAAU,EAAEM,MAAM,KAAKC,2BAAgB,CAACC,QAAQ;IACtE,MAAMC,gBAAgB,GAAGT,UAAU,EAAES,gBAAgB,IAAI,CAAC;IAE1D,IAAIJ,aAAa,IAAII,gBAAgB,GAAGR,MAAM,EAAE;MAC9C,OAAO,IAAI;IACb;EACF;EAEA,OAAO,KAAK;AACd,CAAC;AAACR,OAAA,CAAAM,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"file":"ModularUIUtils.js","names":["_react","require","_utils","_Constants","_Href","_interopRequireDefault","getUrl","resource","props","url","Href","useUrl","_context","previousUrl","setPreviousUrl","useState","previousExact","setPreviousExact","match","equalsWithParameters","isExact","Function","call","bind","_startsWith","default","exports","getKey","WrappedComponent","name","getDisplayName","split","useReload","modelEntry","reload","arguments","length","undefined","isFullyLoaded","status","MODULARUI_STATUS","FINISHED","lastModification"],"sources":["../../../src/redux/_modularui/ModularUIUtils.js"],"sourcesContent":["// @flow\nimport { useState } from \"react\";\n\nimport { getDisplayName } from \"../../react/utils\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\n\nimport type { ComponentType } from \"react\";\n\n/**\n * Generate modular ui url\n */\nconst getUrl = (resource: string | Function | Href, props: Object): Href => {\n const url = typeof resource === \"function\" ? resource(props) : resource;\n\n if (url instanceof Href) {\n return url;\n }\n\n return new Href(url);\n};\n\n/**\n */\nexport const useUrl = (\n resource: string | Function | Href,\n props: Object,\n): Href => {\n const [previousUrl, setPreviousUrl] = useState(null);\n const [previousExact, setPreviousExact] = useState(false);\n\n const url = getUrl(resource, props);\n\n if (url == null && previousUrl == null) {\n return new Href(\"\");\n }\n\n const { match } = props;\n\n // when match is not available through props,\n // this is a direct call to the modular ui hoc, not using a route\n if (!match) {\n return url;\n }\n\n if (url.equalsWithParameters(previousUrl)) {\n return previousUrl || url;\n }\n\n // Always create an url when the match is exact\n // Or when the match is not exact AND the original match also was not exact\n // Or when the new start uri is different from the previous url --> different resource for same panel\n if (\n match.isExact === true ||\n previousExact === match.isExact ||\n !previousUrl?.startsWith(match.url)\n ) {\n setPreviousUrl(url);\n setPreviousExact(match.isExact);\n\n return url;\n }\n\n return previousUrl || new Href(\"\");\n};\n\n/**\n * Create key for modularui request based on component name and requested url\n */\nexport const getKey = (\n WrappedComponent: ComponentType<any>,\n name: string,\n url: string,\n): string => {\n if (url) {\n return `${getDisplayName(WrappedComponent, name)}(${url.split(\"?\")[0]})`;\n }\n\n return getDisplayName(WrappedComponent, name);\n};\n\n/**\n * Check if the model corresponding to a modular ui service should be reloaded\n */\nexport const useReload = (modelEntry: Object, reload: number = 0): boolean => {\n if (reload > 0) {\n const isFullyLoaded = modelEntry?.status === MODULARUI_STATUS.FINISHED;\n const lastModification = modelEntry?.lastModification ?? 0;\n\n if (isFullyLoaded && lastModification < reload) {\n return true;\n }\n }\n\n return false;\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IA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any;
80
81
  };
81
82
  };
82
83
  type ModularUIConnector = (Component: ComponentType<any>) => ComponentType<any>;
@@ -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 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 UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\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 key: string,\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n isReload?: boolean,\n withCredentials?: 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":"","ignoreList":[]}
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 +requestOptions?: any,\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 UpdateFormAction = {\n type: \"MODULARUI/UPDATE_FORM\",\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 key: string,\n origin?: string,\n contextPath?: string,\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: any,\n timeout?: number,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n cache?: boolean,\n isReload?: boolean,\n withCredentials?: 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 requestOptions: any,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>,\n) => ComponentType<any>;\n"],"mappings":"","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beinformed/ui",
3
- "version": "1.60.4",
3
+ "version": "1.60.6",
4
4
  "description": "Toolbox for be informed javascript layouts",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "bugs": "https://support.beinformed.com",
@@ -68,7 +68,7 @@
68
68
  "styled-components": "^5.0.0"
69
69
  },
70
70
  "dependencies": {
71
- "@babel/runtime-corejs3": "^7.26.9",
71
+ "@babel/runtime-corejs3": "^7.27.0",
72
72
  "@date-fns/tz": "^1.2.0",
73
73
  "big.js": "^6.2.2",
74
74
  "date-fns": "^4.1.0",
@@ -76,7 +76,7 @@
76
76
  "dequal": "^2.0.3",
77
77
  "file-size": "^1.0.0",
78
78
  "format-message": "^6.2.4",
79
- "html-entities": "^2.5.2",
79
+ "html-entities": "^2.6.0",
80
80
  "iban": "^0.0.14",
81
81
  "js-cookie": "^3.0.5",
82
82
  "klona": "^2.0.6",
@@ -86,62 +86,62 @@
86
86
  "timezone-soft": "^1.5.2"
87
87
  },
88
88
  "devDependencies": {
89
- "@babel/cli": "^7.26.4",
90
- "@babel/core": "^7.26.9",
91
- "@babel/eslint-parser": "^7.26.8",
92
- "@babel/eslint-plugin": "^7.25.9",
89
+ "@babel/cli": "^7.27.0",
90
+ "@babel/core": "^7.26.10",
91
+ "@babel/eslint-parser": "^7.27.0",
92
+ "@babel/eslint-plugin": "^7.27.0",
93
93
  "@babel/plugin-proposal-class-properties": "^7.18.6",
94
94
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
95
- "@babel/plugin-transform-runtime": "^7.26.9",
95
+ "@babel/plugin-transform-runtime": "^7.26.10",
96
96
  "@babel/preset-env": "^7.26.9",
97
97
  "@babel/preset-flow": "^7.25.9",
98
98
  "@babel/preset-react": "^7.26.3",
99
- "@commitlint/cli": "^19.7.1",
100
- "@commitlint/config-conventional": "^19.7.1",
99
+ "@commitlint/cli": "^19.8.0",
100
+ "@commitlint/config-conventional": "^19.8.0",
101
101
  "@testing-library/dom": "^10.4.0",
102
- "@testing-library/react": "^16.2.0",
102
+ "@testing-library/react": "^16.3.0",
103
103
  "auditjs": "^4.0.46",
104
104
  "babel-jest": "^29.7.0",
105
105
  "babel-plugin-styled-components": "^2.1.4",
106
106
  "cherry-pick": "^0.5.0",
107
- "commit-and-tag-version": "^12.5.0",
107
+ "commit-and-tag-version": "^12.5.1",
108
108
  "cross-env": "^7.0.3",
109
109
  "documentation": "^14.0.2",
110
110
  "eslint": "^8.57.0",
111
- "eslint-config-prettier": "^10.0.2",
111
+ "eslint-config-prettier": "^10.1.2",
112
112
  "eslint-plugin-babel": "^5.3.1",
113
113
  "eslint-plugin-ft-flow": "^3.0.11",
114
114
  "eslint-plugin-jest": "^28.11.0",
115
- "eslint-plugin-jsdoc": "^50.6.3",
116
- "eslint-plugin-react": "^7.37.4",
115
+ "eslint-plugin-jsdoc": "^50.6.9",
116
+ "eslint-plugin-react": "^7.37.5",
117
117
  "eslint-plugin-react-hooks": "^5.2.0",
118
118
  "eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
119
119
  "flow-bin": "^0.200.1",
120
120
  "flow-copy-source": "^2.0.9",
121
121
  "flow-typed": "^3.9.0",
122
- "hermes-eslint": "^0.26.0",
122
+ "hermes-eslint": "^0.28.0",
123
123
  "history": "^4.0.0",
124
124
  "husky": "^9.1.7",
125
125
  "jest": "^29.7.0",
126
126
  "jest-environment-jsdom": "^29.7.0",
127
127
  "jest-junit": "^16.0.0",
128
128
  "jest-sonar-reporter": "^2.0.0",
129
- "jscodeshift": "^17.1.2",
130
- "lint-staged": "^15.4.3",
129
+ "jscodeshift": "^17.3.0",
130
+ "lint-staged": "^15.5.1",
131
131
  "polished": "^4.0.0",
132
132
  "prettier": "^3.5.3",
133
- "react": "^19.0.0",
134
- "react-dom": "^19.0.0",
133
+ "react": "^19.1.0",
134
+ "react-dom": "^19.1.0",
135
135
  "react-helmet-async": "^2.0.5",
136
136
  "react-redux": "^8.1.3",
137
137
  "react-router": "^5.0.0",
138
- "react-test-renderer": "^19.0.0",
138
+ "react-test-renderer": "^19.1.0",
139
139
  "redux": "^4.2.1",
140
140
  "redux-mock-store": "^1.5.5",
141
141
  "redux-thunk": "^2.4.2",
142
142
  "rimraf": "^6.0.1",
143
143
  "styled-components": "^5.3.11",
144
- "typescript": "^5.8.2",
144
+ "typescript": "^5.8.3",
145
145
  "xhr-mock": "^2.5.1"
146
146
  },
147
147
  "scarfSettings": {
@@ -81,9 +81,10 @@ export const resetModularUI = (): ResetModularUIAction => ({
81
81
  export const updateStatus = (
82
82
  key: string,
83
83
  status: $Keys<typeof MODULARUI_STATUS>,
84
+ requestOptions: any,
84
85
  ): UpdateStatusAction => ({
85
86
  type: "MODULARUI/STATUS",
86
- payload: { key, status },
87
+ payload: { key, status, requestOptions },
87
88
  });
88
89
 
89
90
  /**
@@ -177,13 +178,31 @@ export const loadModularUI =
177
178
  key: string,
178
179
  href: Href | string,
179
180
  options?: RequestModularUIOptions,
181
+ retryCount: number = 3,
182
+ retryDelay: number = 200,
180
183
  ): ThunkAction =>
181
184
  (dispatch: Dispatch, getState) => {
182
185
  const modularuiStore = getState()?.modularui;
183
- if (
184
- modularuiStore &&
185
- modularuiStore[key]?.status === MODULARUI_STATUS.LOADING
186
- ) {
186
+ const currentRequest = modularuiStore?.[key];
187
+
188
+ const isLoading = currentRequest?.status === MODULARUI_STATUS.LOADING;
189
+
190
+ if (isLoading) {
191
+ const isDifferentRequest =
192
+ currentRequest.requestOptions?.href?.toString() !== href.toString();
193
+ if (isDifferentRequest && retryCount > 0) {
194
+ return new Promise((resolve) => {
195
+ setTimeout(() => {
196
+ resolve(
197
+ dispatch(
198
+ loadModularUI(key, href, options, retryCount - 1, retryDelay),
199
+ ),
200
+ );
201
+ }, retryDelay);
202
+ });
203
+ }
204
+
205
+ // Same request is already loading — do nothing
187
206
  return Promise.resolve();
188
207
  }
189
208
 
@@ -150,7 +150,7 @@ const handleFetch = (
150
150
 
151
151
  const modularuiRequest = createRequest(requestOptions);
152
152
 
153
- dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));
153
+ dispatch(updateStatus(key, MODULARUI_STATUS.LOADING, requestOptions));
154
154
 
155
155
  return modularuiRequest
156
156
  .fetch()
@@ -11,7 +11,15 @@ import type { ModularUIModel } from "../../models";
11
11
  */
12
12
  const updateStatus = (
13
13
  state: ModularUIState,
14
- { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> },
14
+ {
15
+ key,
16
+ status,
17
+ requestOptions,
18
+ }: {
19
+ key: string,
20
+ status: $Keys<typeof MODULARUI_STATUS>,
21
+ requestOptions: any,
22
+ },
15
23
  ) => {
16
24
  // model should always be available when status is not loading
17
25
  if (status !== MODULARUI_STATUS.LOADING && !state[key]) {
@@ -24,6 +32,7 @@ const updateStatus = (
24
32
  ...state[key],
25
33
  status,
26
34
  lastModification: Date.now(),
35
+ requestOptions: requestOptions || state[key]?.requestOptions,
27
36
  },
28
37
  };
29
38
  };
@@ -72,7 +72,11 @@ describe("modularui actions", () => {
72
72
  expect(store.getActions()).toStrictEqual([
73
73
  {
74
74
  type: "MODULARUI/STATUS",
75
- payload: { key: "application", status: MODULARUI_STATUS.LOADING },
75
+ payload: {
76
+ key: "application",
77
+ status: MODULARUI_STATUS.LOADING,
78
+ requestOptions: undefined,
79
+ },
76
80
  },
77
81
  ]);
78
82
  });
@@ -21,6 +21,7 @@ export type ModelEntry = {
21
21
  +status: string,
22
22
  +model: ModularUIModel,
23
23
  +lastModification: number,
24
+ +requestOptions?: any,
24
25
  };
25
26
 
26
27
  export type ModularUIState = {
@@ -111,6 +112,7 @@ export type UpdateStatusAction = {
111
112
  payload: {
112
113
  key: string,
113
114
  status: $Keys<MODULARUI_STATUS>,
115
+ requestOptions: any,
114
116
  },
115
117
  };
116
118