@beinformed/ui 1.25.5 → 1.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/esm/hooks/useModularUIModel.js +7 -0
  3. package/esm/hooks/useModularUIModel.js.map +1 -1
  4. package/esm/hooks/useModularUIRequest.js +7 -5
  5. package/esm/hooks/useModularUIRequest.js.map +1 -1
  6. package/esm/models/attributes/ChoiceAttributeOptionCollection.js +3 -12
  7. package/esm/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  8. package/esm/modularui/ModularUIRequest.js +31 -0
  9. package/esm/modularui/ModularUIRequest.js.map +1 -1
  10. package/esm/react-server/serverNoSSR.js +2 -1
  11. package/esm/react-server/serverNoSSR.js.map +1 -1
  12. package/esm/react-server/serverUtil.js +31 -5
  13. package/esm/react-server/serverUtil.js.map +1 -1
  14. package/esm/redux/_modularui/ModularUIActions.js +7 -0
  15. package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
  16. package/esm/redux/_modularui/ModularUIReducer.js +21 -1
  17. package/esm/redux/_modularui/ModularUIReducer.js.map +1 -1
  18. package/esm/redux/_modularui/types.js.map +1 -1
  19. package/esm/redux/store/configureStore.js +1 -1
  20. package/esm/redux/store/configureStore.js.map +1 -1
  21. package/esm/redux/types.js.map +1 -1
  22. package/lib/hooks/useModularUIModel.js +9 -1
  23. package/lib/hooks/useModularUIModel.js.flow +8 -0
  24. package/lib/hooks/useModularUIModel.js.map +1 -1
  25. package/lib/hooks/useModularUIRequest.js +7 -5
  26. package/lib/hooks/useModularUIRequest.js.flow +10 -11
  27. package/lib/hooks/useModularUIRequest.js.map +1 -1
  28. package/lib/models/attributes/ChoiceAttributeOptionCollection.js +3 -12
  29. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.flow +3 -17
  30. package/lib/models/attributes/ChoiceAttributeOptionCollection.js.map +1 -1
  31. package/lib/modularui/ModularUIRequest.js +31 -0
  32. package/lib/modularui/ModularUIRequest.js.flow +39 -0
  33. package/lib/modularui/ModularUIRequest.js.map +1 -1
  34. package/lib/react-server/serverNoSSR.js +1 -0
  35. package/lib/react-server/serverNoSSR.js.flow +5 -0
  36. package/lib/react-server/serverNoSSR.js.map +1 -1
  37. package/lib/react-server/serverUtil.js +32 -5
  38. package/lib/react-server/serverUtil.js.flow +40 -6
  39. package/lib/react-server/serverUtil.js.map +1 -1
  40. package/lib/redux/_modularui/ModularUIActions.js +9 -1
  41. package/lib/redux/_modularui/ModularUIActions.js.flow +10 -0
  42. package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
  43. package/lib/redux/_modularui/ModularUIReducer.js +21 -1
  44. package/lib/redux/_modularui/ModularUIReducer.js.flow +22 -0
  45. package/lib/redux/_modularui/ModularUIReducer.js.map +1 -1
  46. package/lib/redux/_modularui/types.js.flow +8 -0
  47. package/lib/redux/_modularui/types.js.map +1 -1
  48. package/lib/redux/store/configureStore.js +1 -1
  49. package/lib/redux/store/configureStore.js.flow +1 -1
  50. package/lib/redux/store/configureStore.js.map +1 -1
  51. package/lib/redux/types.js.flow +2 -0
  52. package/lib/redux/types.js.map +1 -1
  53. package/package.json +2 -2
  54. package/src/hooks/useModularUIModel.js +8 -0
  55. package/src/hooks/useModularUIRequest.js +10 -11
  56. package/src/models/attributes/ChoiceAttributeOptionCollection.js +3 -17
  57. package/src/modularui/ModularUIRequest.js +39 -0
  58. package/src/react-server/serverNoSSR.js +5 -0
  59. package/src/react-server/serverUtil.js +40 -6
  60. package/src/redux/_modularui/ModularUIActions.js +10 -0
  61. package/src/redux/_modularui/ModularUIReducer.js +22 -0
  62. package/src/redux/_modularui/types.js +8 -0
  63. package/src/redux/store/configureStore.js +1 -1
  64. package/src/redux/types.js +2 -0
  65. package/types/models/attributes/ChoiceAttributeOptionCollection.d.ts +0 -3
  66. package/types/modularui/ModularUIRequest.d.ts +18 -3
  67. package/types/redux/_modularui/types.d.ts +8 -0
  68. package/types/redux/types.d.ts +1 -1
  69. package/types/utils/fetch/types.d.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"serverUtil.js","names":["createMemoryHistory","has","deepmerge","configureStore","availableLocales","Locales","getPreferredLocale","setLocales","setServerPreference","setThemePreference","setPreference","setAllContentInDataSetting","setLoginPreferences","getSetting","IllegalArgumentException","createReduxStore","requestHref","customReducers","history","initialEntries","toString","store","setI18n","locales","request","Array","isArray","mergedLocales","locale","code","customLocale","custLocale","forEach","some","push","enabledLocales","localesInstance","preferredLocale","dispatch","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreferences","preferencesProvider","isStudioContext","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","dataFetcher","fetch","Error","handleErrors","state","getState","error","shouldThrowOnServer","dehydrate","modularui","key","status","model","undefined","filteredState","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getSetting(\"ENABLED_LOCALES\").includes(locale.code)\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`\n );\n }\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: { [key: string]: { status: string, model: ?Object } } = {};\n for (const key in state.modularui) {\n const status = state.modularui[key].status;\n const model = state.modularui[key].model;\n\n if (model) {\n modularui[key] = {\n status,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setServerPreferences,\n setConfigurationTheme,\n createHead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,IAAIH,aAAa,EAAE;IACjB,OAAO;MACL,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAED,SACE5D,gBAAgB,EAChBO,OAAO,EACPuB,oBAAoB,EACpBG,qBAAqB,EACrBqB,UAAU,EACVb,YAAY,EACZK,SAAS"}
1
+ {"version":3,"file":"serverUtil.js","names":["createMemoryHistory","has","deepmerge","configureStore","availableLocales","Locales","getPreferredLocale","setLocales","setServerPreference","setThemePreference","setPreference","setAllContentInDataSetting","setLoginPreferences","getSetting","IllegalArgumentException","initModels","getLocale","ModularUIRequest","createReduxStore","requestHref","customReducers","initialState","history","initialEntries","toString","store","setI18n","locales","request","Array","isArray","mergedLocales","locale","code","customLocale","custLocale","forEach","some","push","enabledLocales","localesInstance","preferredLocale","dispatch","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreferences","preferencesProvider","isStudioContext","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","dataFetcher","fetch","Error","setApplication","getState","application","fetchSync","key","model","e","console","info","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","undefined","filteredState","replace","createHead","sheet","UUID","helmetContext","style","getStyleTags","meta","helmet"],"sources":["../../src/react-server/serverUtil.js"],"sourcesContent":["// @flow\nimport { createMemoryHistory } from \"history\";\nimport { has } from \"../utils/helpers/objects\";\nimport deepmerge from \"deepmerge\";\n\nimport configureStore from \"../redux/store/configureStore\";\n\nimport { availableLocales } from \"../i18n/Locales\";\nimport Locales from \"../i18n/Locales\";\n\nimport { getPreferredLocale } from \"./requestInformation\";\nimport { setLocales } from \"../redux/_i18n/I18nActions\";\n\nimport {\n setServerPreference,\n setThemePreference,\n setPreference,\n setAllContentInDataSetting,\n setLoginPreferences,\n} from \"../redux/actions/Preferences\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport { IllegalArgumentException } from \"../exceptions\";\n\nimport { initModels } from \"../redux\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\n\nimport type { LocaleConfiguration } from \"../i18n/types\";\nimport type { ReduxState, ReduxStore } from \"../redux/types\";\nimport type Href from \"../models/href/Href\";\nimport type { RouterHistory } from \"react-router\";\n\nexport type PreferenceValue = {\n name: string,\n defaultValue?: string | null,\n type?: string,\n};\n\n/**\n */\nconst createReduxStore = (\n requestHref: Href,\n customReducers: Object,\n initialState?: $Shape<ReduxState>\n): ReduxStore => {\n // $FlowExpectedError\n const history: RouterHistory = createMemoryHistory({\n initialEntries: [requestHref.toString()],\n });\n\n const { store } = configureStore(history, customReducers, initialState);\n\n return store;\n};\n\n/**\n */\nconst setI18n = (\n store: ReduxStore,\n locales: Array<LocaleConfiguration> = [],\n request: HttpServletRequestJava\n) => {\n if (!Array.isArray(locales)) {\n throw new IllegalArgumentException(\"locales must be an array of objects\");\n }\n if (!request) {\n throw new IllegalArgumentException(\"missing request argument\");\n }\n\n const mergedLocales = availableLocales.map((locale) => {\n const code = locale.code;\n const customLocale = locales.find((custLocale) => custLocale.code === code);\n\n if (customLocale) {\n return deepmerge(locale, customLocale);\n }\n\n return locale;\n });\n\n locales.forEach((customLocale) => {\n if (!mergedLocales.some((locale) => locale.code === customLocale.code)) {\n mergedLocales.push(customLocale);\n }\n });\n\n const enabledLocales = mergedLocales.filter((locale: LocaleConfiguration) =>\n getSetting(\"ENABLED_LOCALES\").includes(locale.code)\n );\n\n const localesInstance = new Locales(enabledLocales);\n const preferredLocale = getPreferredLocale(request, localesInstance);\n store.dispatch(setLocales(localesInstance, preferredLocale ?? \"en\"));\n};\n\nconst setServerPreferencesFromArray = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n serverPreferences.forEach((serverPreference) => {\n if (typeof serverPreference === \"object\") {\n const { name, defaultValue, type } = serverPreference;\n store.dispatch(setServerPreference(name, defaultValue, type));\n } else {\n store.dispatch(setServerPreference(serverPreference, null));\n }\n });\n};\n\n/**\n * Server preferences can be suplied by an array of preference names,\n * or an array of objects which has the name, an optional default value and an optional type.<br>\n * When the type is set to string, a comma separated value is not converted to an array:\n *\n * @example\n * // value becomes an array [default1, default2]\n * { name: \"prefName\", defaultValue: \"default1, default2\" }\n * // value remains a string \"default1, default2\"\n * { name: \"prefName\", defaultValue: \"default1, default2\", type: \"string\" }\n *\n * @param store\n * @param serverPreferences\n */\nconst setServerPreferences = (\n store: ReduxStore,\n serverPreferences: Array<string | PreferenceValue>\n) => {\n if (Array.isArray(serverPreferences)) {\n setServerPreferencesFromArray(store, serverPreferences);\n }\n\n store.dispatch(setAllContentInDataSetting());\n store.dispatch(setLoginPreferences());\n\n if (\n preferencesProvider &&\n preferencesProvider.isStudioContext &&\n preferencesProvider.isStudioContext()\n ) {\n store.dispatch(setPreference(\"isStudioContext\", true));\n }\n};\n\n/**\n */\nconst setConfigurationTheme = (store: ReduxStore) => {\n let configTheme = null;\n\n const configFileLocation = preferencesProvider.getLayoutConfigFileLocation();\n if (typeof configFileLocation === \"string\") {\n const configFilePath = configFileLocation.startsWith(\"/\")\n ? `/resource${configFileLocation}`\n : `/resource/${configFileLocation}`;\n\n configTheme = dataFetcher.fetch(configFilePath);\n\n if (configTheme) {\n store.dispatch(setThemePreference(configTheme));\n } else {\n throw new Error(\n `Could not read theme configuration file from: ${configFilePath}`\n );\n }\n }\n};\n\n/**\n */\nconst setApplication = (store: ReduxStore) => {\n try {\n const locale = getLocale(store.getState());\n const application = new ModularUIRequest(\"/\", {\n locale: locale,\n }).fetchSync();\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ])\n );\n } catch (e) {\n // eslint-disable-next-line no-console\n console.info(\"Could not load webapplication on server\");\n }\n};\n\n/**\n */\nconst handleErrors = (store: ReduxStore) => {\n const state = store.getState();\n\n if (\n state.error &&\n (state.error.shouldThrowOnServer ||\n !has(state.error, \"shouldThrowOnServer\"))\n ) {\n throw state.error;\n }\n};\n\n/**\n */\nconst dehydrate = (store: ReduxStore): string => {\n const state = store.getState();\n\n const modularui: {\n [key: string]: { status: string, lastModification: number, model: ?Object },\n } = {};\n\n for (const key in state.modularui) {\n const { status, model, lastModification } = state.modularui[key];\n\n if (model) {\n modularui[key] = {\n status,\n lastModification,\n model: model.dehydrate(),\n };\n } else {\n modularui[key] = {\n status,\n lastModification,\n model: undefined,\n };\n }\n }\n\n const filteredState = {\n ...state,\n modularui,\n };\n\n return JSON.stringify(filteredState).replace(/</g, \"\\\\u003c\");\n};\n\n/**\n */\nconst createHead = (\n sheet: any,\n UUID: string,\n helmetContext?: Object\n): Object => {\n const style = sheet.getStyleTags();\n const meta = helmetContext ? [...helmetContext.helmet.meta] : [];\n\n if (helmetContext) {\n return {\n ...helmetContext.helmet,\n style,\n meta,\n };\n }\n\n return {\n style,\n meta,\n };\n};\n\nexport {\n createReduxStore,\n setI18n,\n setApplication,\n setServerPreferences,\n setConfigurationTheme,\n createHead,\n handleErrors,\n dehydrate,\n};\n"],"mappings":";;;;;;AACA,SAASA,mBAAmB,QAAQ,SAAS;AAC7C,SAASC,GAAG,QAAQ,0BAA0B;AAC9C,OAAOC,SAAS,MAAM,WAAW;AAEjC,OAAOC,cAAc,MAAM,+BAA+B;AAE1D,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,OAAOC,OAAO,MAAM,iBAAiB;AAErC,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SAASC,UAAU,QAAQ,4BAA4B;AAEvD,SACEC,mBAAmB,EACnBC,kBAAkB,EAClBC,aAAa,EACbC,0BAA0B,EAC1BC,mBAAmB,QACd,8BAA8B;AAErC,SAASC,UAAU,QAAQ,uBAAuB;AAElD,SAASC,wBAAwB,QAAQ,eAAe;AAExD,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,SAAS,QAAQ,yBAAyB;AAEnD,OAAOC,gBAAgB,MAAM,+BAA+B;AAa5D;AAC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AAC,GAAG,EAAE;EAEhE,IAAIH,aAAa,EAAE;IACjB,OAAO;MACL,GAAGA,aAAa,CAACI,MAAM;MACvBH,KAAK;MACLE;IACF,CAAC;EACH;EAEA,OAAO;IACLF,KAAK;IACLE;EACF,CAAC;AACH,CAAC;AAED,SACEpE,gBAAgB,EAChBQ,OAAO,EACPkC,cAAc,EACdX,oBAAoB,EACpBG,qBAAqB,EACrB4B,UAAU,EACVX,YAAY,EACZI,SAAS"}
@@ -18,6 +18,13 @@ export const setModel = (key, model) => {
18
18
  };
19
19
  };
20
20
 
21
+ /**
22
+ */
23
+ export const initModels = models => ({
24
+ type: "MODULARUI/INIT",
25
+ payload: models
26
+ });
27
+
21
28
  /**
22
29
  */
23
30
  export const updateModel = model => ({
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","updateModel","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"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 UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type { RequestModularUIOptions } 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 updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\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 modelToUpdate: ?ModularUIModel\n): UpdateModelAction | SetModelAction => {\n if (modelToUpdate) {\n // $FlowFixMe[prop-missing]\n if (typeof modelToUpdate[\"update\"] === \"function\") {\n const clonedModel = modelToUpdate.clone();\n clonedModel.update(model);\n\n return updateModel(clonedModel);\n }\n\n throw new Error(\n `loadModel action: updateModel is set as option for ${key}, but the model is missing an update methode`\n );\n }\n\n return setModel(key, model);\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 href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateModel),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\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) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\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,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAc9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,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;AACA,OAAO,MAAMI,WAAW,GAAIJ,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMK,gBAAgB,GAAIN,GAAW,KAA8B;E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AAQ,CAACpC,WAAW,CAAC8B,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMc,WAAW,GAAG,CACzBzC,KAAqB,EACrBiB,OAAiC,KAEjCe,aAAa,CAAChC,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC0C,QAAQ,EAAE;EAC9C,GAAGzB,OAAO;EACV0B,QAAQ,EAAE;AACZ,CAAC,CAAC"}
1
+ {"version":3,"file":"ModularUIActions.js","names":["HTTP_METHODS","MODULARUI_STATUS","Href","ErrorResponse","finishProgress","startProgress","handleError","setModel","key","model","connectKey","type","payload","initModels","models","updateModel","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","method","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","isChangePassword","isResourceNotFoundAfterReload","ERROR","loadModularUI","dispatch","LOADING","loadModelPromise","resolve","then","response","FINISHED","catch","reloadModel","selfhref","isReload"],"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 RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type { RequestModularUIOptions } 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 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 modelToUpdate: ?ModularUIModel\n): UpdateModelAction | SetModelAction => {\n if (modelToUpdate) {\n // $FlowFixMe[prop-missing]\n if (typeof modelToUpdate[\"update\"] === \"function\") {\n const clonedModel = modelToUpdate.clone();\n clonedModel.update(model);\n\n return updateModel(clonedModel);\n }\n\n throw new Error(\n `loadModel action: updateModel is set as option for ${key}, but the model is missing an update methode`\n );\n }\n\n return setModel(key, model);\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 href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateModel),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\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) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\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,SAASA,YAAY,EAAEC,gBAAgB,QAAQ,2BAA2B;AAC1E,OAAOC,IAAI,MAAM,wBAAwB;AACzC,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,SAASC,cAAc,EAAEC,aAAa,QAAQ,8BAA8B;AAC5E,SAASC,WAAW,QAAQ,kBAAkB;AAe9C;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,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;AACA,OAAO,MAAMI,UAAU,GACrBC,MAAqD,KAChC;EACrBH,IAAI,EAAE,gBAAgB;EACtBC,OAAO,EAAEE;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMC,WAAW,GAAIN,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AACA,OAAO,MAAMO,g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D+C,KAAK,CAAEb,KAAK,IAAKM,QAAQ,CAACtC,WAAW,CAACgC,KAAK,CAAC,CAAC,CAAC;AACnD,CAAC;;AAEH;AACA;AACA,OAAO,MAAMc,WAAW,GAAG,CACzB3C,KAAqB,EACrBmB,OAAiC,KAEjCe,aAAa,CAAClC,KAAK,CAACC,UAAU,EAAED,KAAK,CAAC4C,QAAQ,EAAE;EAC9C,GAAGzB,OAAO;EACV0B,QAAQ,EAAE;AACZ,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
+ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
1
2
  import _findInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/find";
2
3
  import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
3
- import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
4
4
  import { IllegalArgumentException } from "../../exceptions";
5
5
  import { MODULARUI_STATUS } from "../../constants/Constants";
6
6
  import { ApplicationModel } from "../../models";
@@ -48,6 +48,24 @@ const setModel = (state, _ref2) => {
48
48
  throw new IllegalArgumentException("No model for setModel");
49
49
  };
50
50
 
51
+ /**
52
+ */
53
+ const initModularUI = (state, models) => {
54
+ const newState = _Object$assign({}, state);
55
+ models.forEach(_ref3 => {
56
+ let {
57
+ key,
58
+ model
59
+ } = _ref3;
60
+ newState[key] = {
61
+ status: MODULARUI_STATUS.FINISHED,
62
+ lastModification: Date.now(),
63
+ model
64
+ };
65
+ });
66
+ return newState;
67
+ };
68
+
51
69
  /**
52
70
  */
53
71
  const getModelKey = (state, model) => {
@@ -105,6 +123,8 @@ export const ModularUIReducer = function () {
105
123
  return state;
106
124
  }
107
125
  switch (action.type) {
126
+ case "MODULARUI/INIT":
127
+ return initModularUI(state, action.payload);
108
128
  case "MODULARUI/RESET":
109
129
  return resetModularUI(state);
110
130
  case "MODULARUI/STATUS":
@@ -1 +1 @@
1
- {"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","key","status","LOADING","lastModification","Date","now","setModel","model","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","newState","resetModularUI","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,wBAAwB,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAG,CACnBC,KAAqB,WAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC;EAExE;EACA,IAAIA,MAAM,KAAKL,gBAAgB,CAACM,OAAO,IAAI,CAACH,KAAK,CAACC,GAAG,CAAC,EAAE;IACtD,OAAOD,KAAK;EACd;EAEA,OAAO;IACL,GAAGA,KAAK;IACR,CAACC,GAAG,GAAG;MACL,GAAGD,KAAK,CAACC,GAAG,CAAC;MACbC,MAAM;MACNE,gBAAgB,EAAEC,IAAI,CAACC,GAAG;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,MAAMC,QAAQ,GAAG,CACfP,KAAqB,YAElB;EAAA,IADH;IAAEC,GAAG;IAAEO;EAA+C,CAAC;EAEvD,IAAI,CAACR,KAAK,CAACC,GAAG,CAAC,EAAE;IACf,OAAOD,KAAK;EACd;EAEA,IAAIQ,KAAK,EAAE;IACT,OAAO;MACL,GAAGR,KAAK;MACR,CAACC,GAAG,GAAG;QACL,GAAGD,KAAK,C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,GAAG;QAAE,GAAGD,KAAK,CAACC,GAAG;MAAE,CAAC;IACnC;EACF;EAEA,OAAOc,QAAQ;AACjB,CAAC;AAED,MAAME,YAA4B,GAAG,CAAC,CAAC;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,gBAAsD,GAAG,YAGjE;EAAA,IAFHlB,KAAK,uEAAGiB,YAAY;EAAA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAOnB,KAAK;EACd;EAEA,QAAQmB,MAAM,CAACC,IAAI;IACjB,KAAK,iBAAiB;MACpB,OAAOJ,cAAc,CAAChB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEmB,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOd,QAAQ,CAACP,KAAK,EAAEmB,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;MACrB,OAAOV,WAAW,CAACX,KAAK,EAAEmB,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAOP,SAAS,CAACK,MAAM,CAACE,OAAO,EAAErB,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC"}
1
+ {"version":3,"file":"ModularUIReducer.js","names":["IllegalArgumentException","MODULARUI_STATUS","ApplicationModel","updateStatus","state","key","status","LOADING","lastModification","Date","now","setModel","model","initModularUI","models","newState","forEach","FINISHED","getModelKey","connectKey","updateModel","modelKey","Error","removeKey","resetModularUI","initialState","ModularUIReducer","action","type","payload"],"sources":["../../../src/redux/_modularui/ModularUIReducer.js"],"sourcesContent":["// @flow\nimport { IllegalArgumentException } from \"../../exceptions\";\nimport { MODULARUI_STATUS } from \"../../constants/Constants\";\nimport { ApplicationModel } from \"../../models\";\n\nimport type { Reducer } from \"redux\";\nimport type { ReduxAction } from \"../types\";\nimport type { ModularUIState } from \"./types\";\nimport type { ModularUIModel } from \"../../models\";\n\n/**\n */\nconst updateStatus = (\n state: ModularUIState,\n { key, status }: { key: string, status: $Keys<typeof MODULARUI_STATUS> }\n) => {\n // model should always be available when status is not loading\n if (status !== MODULARUI_STATUS.LOADING && !state[key]) {\n return state;\n }\n\n return {\n ...state,\n [key]: {\n ...state[key],\n status,\n lastModification: Date.now(),\n },\n };\n};\n\n/**\n */\nconst setModel = (\n state: ModularUIState,\n { key, model }: { key: string, model: ?ModularUIModel }\n) => {\n if (!state[key]) {\n return state;\n }\n\n if (model) {\n return {\n ...state,\n [key]: {\n ...state[key],\n model,\n lastModification: Date.now(),\n },\n };\n }\n\n throw new IllegalArgumentException(\"No model for setModel\");\n};\n\n/**\n */\nconst initModularUI = (\n state: ModularUIState,\n models: Array<{ key: string, model: ModularUIModel }>\n) => {\n const newState = Object.assign({}, state);\n\n models.forEach(({ key, model }) => {\n newState[key] = {\n status: MODULARUI_STATUS.FINISHED,\n lastModification: Date.now(),\n model,\n };\n });\n\n return newState;\n};\n\n/**\n */\nconst getModelKey = (state: ModularUIState, model: ModularUIModel) =>\n Object.keys(state).find((key) => {\n const connectKey = state[key]?.model?.connectKey ?? \"\";\n return connectKey === model.connectKey;\n });\n\n/**\n */\nconst updateModel = (state: ModularUIState, model: ModularUIModel) => {\n const modelKey = getModelKey(state, model);\n\n if (modelKey) {\n return setModel(state, { key: modelKey, model });\n }\n\n throw new Error(\n `ModularUIReducer: Cannot update model with key ${model.connectKey}`\n );\n};\n\n/**\n */\nconst removeKey = (modelKey: string, state: ModularUIState): ModularUIState => {\n const newState = Object.assign({}, state);\n delete newState[modelKey];\n return newState;\n};\n\n/**\n * Remove all but application models\n */\nconst resetModularUI = (state: ModularUIState) => {\n const newState: ModularUIState = {};\n\n for (const key in state) {\n if (state[key].model instanceof ApplicationModel) {\n newState[key] = { ...state[key] };\n }\n }\n\n return newState;\n};\n\nconst initialState: ModularUIState = {};\n\n/**\n * Modular UI Reducer\n */\nexport const ModularUIReducer: Reducer<ModularUIState, ReduxAction> = (\n state = initialState,\n action\n) => {\n if (!action) {\n return state;\n }\n\n switch (action.type) {\n case \"MODULARUI/INIT\":\n return initModularUI(state, action.payload);\n\n case \"MODULARUI/RESET\":\n return resetModularUI(state);\n\n case \"MODULARUI/STATUS\":\n return updateStatus(state, action.payload);\n\n case \"MODULARUI/SET\":\n return setModel(state, action.payload);\n\n case \"MODULARUI/UPDATE\":\n return updateModel(state, action.payload);\n\n case \"MODULARUI/REMOVE_KEY\":\n return removeKey(action.payload, state);\n\n default:\n return state;\n }\n};\n"],"mappings":";;;AACA,SAASA,wBAAwB,QAAQ,kBAAkB;AAC3D,SAASC,gBAAgB,QAAQ,2BAA2B;AAC5D,SAASC,gBAAgB,QAAQ,cAAc;AAO/C;AACA;AACA,MAAMC,YAAY,GAAG,CACnBC,KAAqB,WAElB;EAAA,IADH;IAAEC,GAAG;IAAEC;EAAgE,CAAC;EAExE;EACA,IAAIA,MAAM,KAAKL,gBAAgB,CAACM,OAAO,IAAI,CAACH,KAAK,CAACC,GAAG,CAAC,EAAE;IACtD,OAAOD,KAAK;EACd;EAEA,OAAO;IACL,GAAGA,KAAK;IACR,CAACC,GAAG,GAAG;MACL,GAAGD,KAAK,CAACC,GAAG,CAAC;MACbC,MAAM;MACNE,gBAAgB,EAAEC,IAAI,CAACC,GAAG;IAC5B;EACF,CAAC;AACH,CAAC;;AAED;AACA;AACA,MAAMC,QAAQ,GAAG,CACfP,KAAqB,YAElB;EAAA,IADH;IAAEC,GAAG;IAAEO;EAA+C,CAAC;EAEvD,IAAI,CAACR,KAAK,CAACC,GAAG,CAAC,EAAE;IACf,OAAOD,KAAK;EACd;EAEA,IAAIQ,KAAK,EAAE;IACT,OAAO;MACL,GAAGR,KAAK;MACR,CAACC,GAAG,GAAG;QACL,GAAGD,KAAK,CAACC,GAAG,CAAC;QACbO,KAAK;QACLJ,gBAAgB,EAAEC,IAAI,CAACC,GAAG;MAC5B;IACF,CAAC;EACH;EAEA,MAAM,IAAIV,wBAAwB,CAAC,uBAAuB,CA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AAC;EACzB,OAAON,QAAQ;AACjB,CAAC;;AAED;AACA;AACA;AACA,MAAMS,cAAc,GAAIpB,KAAqB,IAAK;EAChD,MAAMW,QAAwB,GAAG,CAAC,CAAC;EAEnC,KAAK,MAAMV,GAAG,IAAID,KAAK,EAAE;IACvB,IAAIA,KAAK,CAACC,GAAG,CAAC,CAACO,KAAK,YAAYV,gBAAgB,EAAE;MAChDa,QAAQ,CAACV,GAAG,CAAC,GAAG;QAAE,GAAGD,KAAK,CAACC,GAAG;MAAE,CAAC;IACnC;EACF;EAEA,OAAOU,QAAQ;AACjB,CAAC;AAED,MAAMU,YAA4B,GAAG,CAAC,CAAC;;AAEvC;AACA;AACA;AACA,OAAO,MAAMC,gBAAsD,GAAG,YAGjE;EAAA,IAFHtB,KAAK,uEAAGqB,YAAY;EAAA,IACpBE,MAAM;EAEN,IAAI,CAACA,MAAM,EAAE;IACX,OAAOvB,KAAK;EACd;EAEA,QAAQuB,MAAM,CAACC,IAAI;IACjB,KAAK,gBAAgB;MACnB,OAAOf,aAAa,CAACT,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE7C,KAAK,iBAAiB;MACpB,OAAOL,cAAc,CAACpB,KAAK,CAAC;IAE9B,KAAK,kBAAkB;MACrB,OAAOD,YAAY,CAACC,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE5C,KAAK,eAAe;MAClB,OAAOlB,QAAQ,CAACP,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAExC,KAAK,kBAAkB;MACrB,OAAOT,WAAW,CAAChB,KAAK,EAAEuB,MAAM,CAACE,OAAO,CAAC;IAE3C,KAAK,sBAAsB;MACzB,OAAON,SAAS,CAACI,MAAM,CAACE,OAAO,EAAEzB,KAAK,CAAC;IAEzC;MACE,OAAOA,KAAK;EAAC;AAEnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: string | { [key: string]: string },\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type InitModelAction = {\n type: \"MODULARUI/INIT\",\n payload: Array<{\n key: string,\n model: ModularUIModel,\n }>,\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: string | { [key: string]: string },\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
@@ -18,7 +18,7 @@ const configureStore = (history, customReducers, initialState) => {
18
18
  const middleware = applyMiddleware(modularUIMiddleware, routerMiddleware(history), thunk);
19
19
  const enhancers = composeEnhancers(middleware);
20
20
  const store = createReduxStore(combinedReducers, initialState, enhancers);
21
- if (!initialState) {
21
+ if (!initialState?.router) {
22
22
  store.dispatch(locationChange(history.location, "PUSH"));
23
23
  }
24
24
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"configureStore.js","names":["applyMiddleware","compose","combineReducers","createStore","createReduxStore","thunk","routerMiddleware","modularUIMiddleware","createReducer","locationChange","configureStore","history","customReducers","initialState","composeEnhancers","process","env","NODE_ENV","window","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","combinedReducers","middleware","enhancers","store","dispatch","location"],"sources":["../../../src/redux/store/configureStore.js"],"sourcesContent":["// @flow\nimport {\n applyMiddleware,\n compose,\n combineReducers,\n createStore as createReduxStore,\n} from \"redux\";\nimport thunk from \"redux-thunk\";\n\nimport { routerMiddleware } from \"../_router/RouterMiddleware\";\nimport { modularUIMiddleware } from \"../_modularui/ModularUIMiddleware\";\n\nimport { createReducer } from \"../reducers/createReducer\";\nimport { locationChange } from \"../_router/RouterActions\";\n\nimport type { RouterHistory } from \"react-router\";\nimport type { ReduxAction, ReduxState, ReduxStore } from \"../types\";\nimport type { Reducer } from \"redux\";\n\n/**\n */\nconst configureStore = (\n history: RouterHistory,\n customReducers?: Object,\n initialState?: $Shape<ReduxState>\n): { history: RouterHistory, store: ReduxStore } => {\n let composeEnhancers = compose;\n\n if (process.env.NODE_ENV !== \"production\" && typeof window !== \"undefined\") {\n composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;\n }\n\n const combinedReducers: Reducer<ReduxState, ReduxAction> = combineReducers({\n ...customReducers,\n ...createReducer(),\n });\n\n const middleware = applyMiddleware(\n modularUIMiddleware,\n routerMiddleware(history),\n thunk\n );\n\n const enhancers = composeEnhancers(middleware);\n\n const store: ReduxStore = createReduxStore(\n combinedReducers,\n initialState,\n enhancers\n );\n\n if (!initialState) {\n store.dispatch(locationChange(history.location, \"PUSH\"));\n }\n return { history, store };\n};\n\nexport default configureStore;\n"],"mappings":"AACA,SACEA,eAAe,EACfC,OAAO,EACPC,eAAe,EACfC,WAAW,IAAIC,gBAAgB,QAC1B,OAAO;AACd,OAAOC,KAAK,MAAM,aAAa;AAE/B,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,mBAAmB,QAAQ,mCAAmC;AAEvE,SAASC,aAAa,QAAQ,2BAA2B;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AAMzD;AACA;AACA,MAAMC,cAAc,GAAG,CACrBC,OAAsB,EACtBC,cAAuB,EACvBC,YAAiC,KACiB;EAClD,IAAIC,gBAAgB,GAAGb,OAAO;EAE9B,IAAIc,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IAC1EJ,gBAAgB,GAAGI,MAAM,CAACC,oCAAoC,IAAIlB,OAAO;EAC3E;EAEA,MAAMmB,gBAAkD,GAAGlB,eAAe,CAAC;IACzE,GAAGU,cAAc;IACjB,GAAGJ,aAAa;EAClB,CAAC,CAAC;EAEF,MAAMa,UAAU,GAAGrB,eAAe,CAChCO,mBAAmB,EACnBD,gBAAgB,CAACK,OAAO,CAAC,EACzBN,KAAK,CACN;EAED,MAAMiB,SAAS,GAAGR,gBAAgB,CAACO,UAAU,CAAC;EAE9C,MAAME,KAAiB,GAAGnB,gBAAgB,CACxCgB,gBAAgB,EAChBP,YAAY,EACZS,SAAS,CACV;EAED,IAAI,CAACT,YAAY,EAAE;IACjBU,KAAK,CAACC,QAAQ,CAACf,cAAc,CAACE,OAAO,CAACc,QAAQ,EAAE,MAAM,CAAC,CAAC;EAC1D;EACA,OAAO;IAAEd,OAAO;IAAEY;EAAM,CAAC;AAC3B,CAAC;AAED,eAAeb,cAAc"}
1
+ {"version":3,"file":"configureStore.js","names":["applyMiddleware","compose","combineReducers","createStore","createReduxStore","thunk","routerMiddleware","modularUIMiddleware","createReducer","locationChange","configureStore","history","customReducers","initialState","composeEnhancers","process","env","NODE_ENV","window","__REDUX_DEVTOOLS_EXTENSION_COMPOSE__","combinedReducers","middleware","enhancers","store","router","dispatch","location"],"sources":["../../../src/redux/store/configureStore.js"],"sourcesContent":["// @flow\nimport {\n applyMiddleware,\n compose,\n combineReducers,\n createStore as createReduxStore,\n} from \"redux\";\nimport thunk from \"redux-thunk\";\n\nimport { routerMiddleware } from \"../_router/RouterMiddleware\";\nimport { modularUIMiddleware } from \"../_modularui/ModularUIMiddleware\";\n\nimport { createReducer } from \"../reducers/createReducer\";\nimport { locationChange } from \"../_router/RouterActions\";\n\nimport type { RouterHistory } from \"react-router\";\nimport type { ReduxAction, ReduxState, ReduxStore } from \"../types\";\nimport type { Reducer } from \"redux\";\n\n/**\n */\nconst configureStore = (\n history: RouterHistory,\n customReducers?: Object,\n initialState?: $Shape<ReduxState>\n): { history: RouterHistory, store: ReduxStore } => {\n let composeEnhancers = compose;\n\n if (process.env.NODE_ENV !== \"production\" && typeof window !== \"undefined\") {\n composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;\n }\n\n const combinedReducers: Reducer<ReduxState, ReduxAction> = combineReducers({\n ...customReducers,\n ...createReducer(),\n });\n\n const middleware = applyMiddleware(\n modularUIMiddleware,\n routerMiddleware(history),\n thunk\n );\n\n const enhancers = composeEnhancers(middleware);\n\n const store: ReduxStore = createReduxStore(\n combinedReducers,\n initialState,\n enhancers\n );\n\n if (!initialState?.router) {\n store.dispatch(locationChange(history.location, \"PUSH\"));\n }\n return { history, store };\n};\n\nexport default configureStore;\n"],"mappings":"AACA,SACEA,eAAe,EACfC,OAAO,EACPC,eAAe,EACfC,WAAW,IAAIC,gBAAgB,QAC1B,OAAO;AACd,OAAOC,KAAK,MAAM,aAAa;AAE/B,SAASC,gBAAgB,QAAQ,6BAA6B;AAC9D,SAASC,mBAAmB,QAAQ,mCAAmC;AAEvE,SAASC,aAAa,QAAQ,2BAA2B;AACzD,SAASC,cAAc,QAAQ,0BAA0B;AAMzD;AACA;AACA,MAAMC,cAAc,GAAG,CACrBC,OAAsB,EACtBC,cAAuB,EACvBC,YAAiC,KACiB;EAClD,IAAIC,gBAAgB,GAAGb,OAAO;EAE9B,IAAIc,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,OAAOC,MAAM,KAAK,WAAW,EAAE;IAC1EJ,gBAAgB,GAAGI,MAAM,CAACC,oCAAoC,IAAIlB,OAAO;EAC3E;EAEA,MAAMmB,gBAAkD,GAAGlB,eAAe,CAAC;IACzE,GAAGU,cAAc;IACjB,GAAGJ,aAAa;EAClB,CAAC,CAAC;EAEF,MAAMa,UAAU,GAAGrB,eAAe,CAChCO,mBAAmB,EACnBD,gBAAgB,CAACK,OAAO,CAAC,EACzBN,KAAK,CACN;EAED,MAAMiB,SAAS,GAAGR,gBAAgB,CAACO,UAAU,CAAC;EAE9C,MAAME,KAAiB,GAAGnB,gBAAgB,CACxCgB,gBAAgB,EAChBP,YAAY,EACZS,SAAS,CACV;EAED,IAAI,CAACT,YAAY,EAAEW,MAAM,EAAE;IACzBD,KAAK,CAACE,QAAQ,CAAChB,cAAc,CAACE,OAAO,CAACe,QAAQ,EAAE,MAAM,CAAC,CAAC;EAC1D;EACA,OAAO;IAAEf,OAAO;IAAEY;EAAM,CAAC;AAC3B,CAAC;AAED,eAAeb,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/redux/types.js"],"sourcesContent":["// @flow\nimport type { Store, DispatchAPI } from \"redux\";\n\nimport type ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport type FormModel from \"../models/form/FormModel\";\nimport typeof {\n NOTIFICATION_TYPES,\n AUTOSAVE_STATUS,\n} from \"../constants/Constants\";\n\nimport type { MessageObject } from \"../i18n/types\";\nimport type {\n I18nState,\n UpdateLocaleAction,\n SetLocalesAction,\n} from \"./_i18n/types\";\nimport type {\n ModularUIState,\n ModularUIAction,\n UpdateStatusAction,\n SetModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n} from \"./_modularui/types\";\nimport type {\n RouterState,\n LocationChangeAction,\n PushAction,\n ReplaceAction,\n GoAction,\n GoBackAction,\n GoForwardAction,\n} from \"./_router/types\";\n\nexport type PreferenceValue =\n | null\n | string\n | boolean\n | { [key: string]: any }\n | Array<PreferenceValue>;\n\nexport type UpdateFormOptions = {\n autosubmit: boolean,\n autosave: boolean,\n forceUpdate?: boolean,\n /** Default true: Activate/deactivate the form object validate by an update */\n validate?: boolean,\n};\n\nexport type NoAction = {\n type: \"NO_ACTION\",\n};\n\nexport type SaveErrorAction = {\n type: \"SAVE_ERROR\",\n payload: ErrorResponse,\n};\n\nexport type ShowModalAction = {\n type: \"SHOW_MODAL\",\n payload: string,\n};\n\nexport type CloseModalAction = {\n type: \"CLOSE_MODAL\",\n payload: string,\n};\n\nexport type DismissNotificationAction = {\n type: \"DISMISS_NOTIFICATION\",\n};\nexport type ShowNotificationAction = {\n type: \"SHOW_NOTIFICATION\",\n payload: {\n type: $Keys<NOTIFICATION_TYPES>,\n message: MessageObject,\n error: ?ErrorResponse,\n },\n};\n\nexport type SetPreferenceAction = {\n type: \"SET_PREFERENCE\",\n payload: { [name: string]: PreferenceValue },\n};\nexport type SetPreferencesAction = {\n type: \"SET_PREFERENCES\",\n payload: { [name: string]: PreferenceValue },\n};\n\nexport type StartProgressAction = {\n type: \"START_PROGRESS\",\n};\nexport type FinishProgressAction = {\n type: \"FINISH_PROGRESS\",\n};\nexport type ResetProgressAction = {\n type: \"RESET_PROGRESS\",\n};\nexport type UpdateProgressAction = {\n type: \"UPDATE_PROGRESS\",\n payload: { percentComplete: number },\n};\n\nexport type SendAuthenticationErrorAction = {\n type: \"AUTHENTICATION_ERROR\",\n payload: string,\n};\n\nexport type ResetAuthErrorsAction = {\n type: \"AUTHENTICATION_RESET_ERRORS\",\n};\n\nexport type LoginSuccessAction = {\n type: \"AUTHENTICATION_SUCCESS\",\n};\n\nexport type ChangePasswordAction = {\n type: \"CHANGE_PASSWORD\",\n};\n\nexport type LogoutSuccessAction = {\n type: \"AUTHENTICATION_LOGOUT\",\n};\n\nexport type UpdateAutosaveAction = {\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status: $Keys<AUTOSAVE_STATUS>,\n model: FormModel,\n },\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | UpdateModelAction\n | RemoveModelByKeyAction\n | ResetModularUIAction\n | SaveErrorAction\n | UpdateLocaleAction\n | SetLocalesAction\n | ShowModalAction\n | CloseModalAction\n | DismissNotificationAction\n | ShowNotificationAction\n | SetPreferenceAction\n | SetPreferencesAction\n | StartProgressAction\n | FinishProgressAction\n | ResetProgressAction\n | UpdateProgressAction\n | ResetAuthErrorsAction\n | SendAuthenticationErrorAction\n | LoginSuccessAction\n | ChangePasswordAction\n | LogoutSuccessAction\n | UpdateAutosaveAction\n | LocationChangeAction\n | PushAction\n | ReplaceAction\n | GoAction\n | GoBackAction\n | GoForwardAction\n | ModularUIAction\n | NoAction;\n\n// Redux state\nexport type AuthState = {\n +mustChangePassword: boolean,\n +error: ?string,\n};\n\nexport type ErrorState = null | ErrorResponse;\n\nexport type ModalState = {\n +key: string,\n +visible: boolean,\n +size?: string,\n};\n\nexport type ModalsState = {\n +modals: Array<ModalState>,\n};\n\nexport type NotificationState = {\n +render: boolean,\n +messageType: string | null,\n +message: MessageObject | null,\n +error: ?ErrorResponse | null,\n};\n\nexport type PreferencesState = {\n +[name: string]: PreferenceValue,\n};\n\nexport type ProgressIndicatorState = {\n +count: number,\n +timestamp: number,\n +percentComplete: number,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +error: ErrorState,\n +modals: ModalsState,\n +notification: NotificationState,\n +progressindicator: ProgressIndicatorState,\n +preferences: PreferencesState,\n ...\n};\n\nexport type GetState = () => ReduxState;\nexport type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;\nexport type PromiseAction = Promise<PossibleAction>;\nexport type Dispatch = DispatchAPI<PossibleAction>;\nexport type ReduxStore = Store<ReduxState, ReduxAction, Dispatch>;\n\nexport type PossibleAction = ReduxAction | ThunkAction | PromiseAction;\n\nexport type CustomReducers = { [reducerKey: string]: any };\n"],"mappings":""}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/redux/types.js"],"sourcesContent":["// @flow\nimport type { Store, DispatchAPI } from \"redux\";\n\nimport type ErrorResponse from \"../models/error/ErrorResponse\";\n\nimport type FormModel from \"../models/form/FormModel\";\nimport typeof {\n NOTIFICATION_TYPES,\n AUTOSAVE_STATUS,\n} from \"../constants/Constants\";\n\nimport type { MessageObject } from \"../i18n/types\";\nimport type {\n I18nState,\n UpdateLocaleAction,\n SetLocalesAction,\n} from \"./_i18n/types\";\nimport type {\n ModularUIState,\n ModularUIAction,\n UpdateStatusAction,\n SetModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n InitModelAction,\n} from \"./_modularui/types\";\nimport type {\n RouterState,\n LocationChangeAction,\n PushAction,\n ReplaceAction,\n GoAction,\n GoBackAction,\n GoForwardAction,\n} from \"./_router/types\";\n\nexport type PreferenceValue =\n | null\n | string\n | boolean\n | { [key: string]: any }\n | Array<PreferenceValue>;\n\nexport type UpdateFormOptions = {\n autosubmit: boolean,\n autosave: boolean,\n forceUpdate?: boolean,\n /** Default true: Activate/deactivate the form object validate by an update */\n validate?: boolean,\n};\n\nexport type NoAction = {\n type: \"NO_ACTION\",\n};\n\nexport type SaveErrorAction = {\n type: \"SAVE_ERROR\",\n payload: ErrorResponse,\n};\n\nexport type ShowModalAction = {\n type: \"SHOW_MODAL\",\n payload: string,\n};\n\nexport type CloseModalAction = {\n type: \"CLOSE_MODAL\",\n payload: string,\n};\n\nexport type DismissNotificationAction = {\n type: \"DISMISS_NOTIFICATION\",\n};\nexport type ShowNotificationAction = {\n type: \"SHOW_NOTIFICATION\",\n payload: {\n type: $Keys<NOTIFICATION_TYPES>,\n message: MessageObject,\n error: ?ErrorResponse,\n },\n};\n\nexport type SetPreferenceAction = {\n type: \"SET_PREFERENCE\",\n payload: { [name: string]: PreferenceValue },\n};\nexport type SetPreferencesAction = {\n type: \"SET_PREFERENCES\",\n payload: { [name: string]: PreferenceValue },\n};\n\nexport type StartProgressAction = {\n type: \"START_PROGRESS\",\n};\nexport type FinishProgressAction = {\n type: \"FINISH_PROGRESS\",\n};\nexport type ResetProgressAction = {\n type: \"RESET_PROGRESS\",\n};\nexport type UpdateProgressAction = {\n type: \"UPDATE_PROGRESS\",\n payload: { percentComplete: number },\n};\n\nexport type SendAuthenticationErrorAction = {\n type: \"AUTHENTICATION_ERROR\",\n payload: string,\n};\n\nexport type ResetAuthErrorsAction = {\n type: \"AUTHENTICATION_RESET_ERRORS\",\n};\n\nexport type LoginSuccessAction = {\n type: \"AUTHENTICATION_SUCCESS\",\n};\n\nexport type ChangePasswordAction = {\n type: \"CHANGE_PASSWORD\",\n};\n\nexport type LogoutSuccessAction = {\n type: \"AUTHENTICATION_LOGOUT\",\n};\n\nexport type UpdateAutosaveAction = {\n type: \"UPDATE_AUTOSAVE_STATUS\",\n payload: {\n status: $Keys<AUTOSAVE_STATUS>,\n model: FormModel,\n },\n};\n\nexport type ReduxAction =\n | UpdateStatusAction\n | SetModelAction\n | InitModelAction\n | UpdateModelAction\n | RemoveModelByKeyAction\n | ResetModularUIAction\n | SaveErrorAction\n | UpdateLocaleAction\n | SetLocalesAction\n | ShowModalAction\n | CloseModalAction\n | DismissNotificationAction\n | ShowNotificationAction\n | SetPreferenceAction\n | SetPreferencesAction\n | StartProgressAction\n | FinishProgressAction\n | ResetProgressAction\n | UpdateProgressAction\n | ResetAuthErrorsAction\n | SendAuthenticationErrorAction\n | LoginSuccessAction\n | ChangePasswordAction\n | LogoutSuccessAction\n | UpdateAutosaveAction\n | LocationChangeAction\n | PushAction\n | ReplaceAction\n | GoAction\n | GoBackAction\n | GoForwardAction\n | ModularUIAction\n | NoAction;\n\n// Redux state\nexport type AuthState = {\n +mustChangePassword: boolean,\n +error: ?string,\n};\n\nexport type ErrorState = null | ErrorResponse;\n\nexport type ModalState = {\n +key: string,\n +visible: boolean,\n +size?: string,\n};\n\nexport type ModalsState = {\n +modals: Array<ModalState>,\n};\n\nexport type NotificationState = {\n +render: boolean,\n +messageType: string | null,\n +message: MessageObject | null,\n +error: ?ErrorResponse | null,\n};\n\nexport type PreferencesState = {\n +[name: string]: PreferenceValue,\n};\n\nexport type ProgressIndicatorState = {\n +count: number,\n +timestamp: number,\n +percentComplete: number,\n};\n\nexport type ReduxState = {\n +router: RouterState,\n +modularui: ModularUIState,\n +i18n: I18nState,\n +auth: AuthState,\n +error: ErrorState,\n +modals: ModalsState,\n +notification: NotificationState,\n +progressindicator: ProgressIndicatorState,\n +preferences: PreferencesState,\n ...\n};\n\nexport type GetState = () => ReduxState;\nexport type ThunkAction = (dispatch: Dispatch, getState: GetState) => any;\nexport type PromiseAction = Promise<PossibleAction>;\nexport type Dispatch = DispatchAPI<PossibleAction>;\nexport type ReduxStore = Store<ReduxState, ReduxAction, Dispatch>;\n\nexport type PossibleAction = ReduxAction | ThunkAction | PromiseAction;\n\nexport type CustomReducers = { [reducerKey: string]: any };\n"],"mappings":""}
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useUserProfile = exports.useTab = exports.useQuicksearch = exports.usePanel = exports.useListOrDetail = exports.useListDetail = exports.useList = exports.useGroupingPanel = exports.useDetailPanel = exports.useCaseView = exports.useApplication = void 0;
7
+ exports.useUserProfile = exports.useTab = exports.useSearch = exports.useQuicksearch = exports.usePanel = exports.useListOrDetail = exports.useListDetail = exports.useList = exports.useGroupingPanel = exports.useDetailPanel = exports.useCaseView = exports.useApplication = void 0;
8
8
  var _ApplicationModel = _interopRequireDefault(require("../models/application/ApplicationModel"));
9
9
  var _CaseViewModel = _interopRequireDefault(require("../models/caseview/CaseViewModel"));
10
10
  var _TabModel = _interopRequireDefault(require("../models/tab/TabModel"));
@@ -100,6 +100,14 @@ const useQuicksearch = href => (0, _useModularUIBasic.useModularUIBasic)("quicks
100
100
  /**
101
101
  */
102
102
  exports.useQuicksearch = useQuicksearch;
103
+ const useSearch = href => (0, _useModularUIBasic.useModularUIBasic)("search", href, {
104
+ expectedModels: ["CaseSearch"],
105
+ targetModel: _CaseSearchModel.default
106
+ });
107
+
108
+ /**
109
+ */
110
+ exports.useSearch = useSearch;
103
111
  const useUserProfile = href => (0, _useModularUIBasic.useModularUIBasic)("userprofile", href, {
104
112
  expectedModels: ["UserProfile"],
105
113
  targetModel: _UserProfileModel.default
@@ -96,6 +96,14 @@ export const useQuicksearch = (href: string): CaseSearchModel | null =>
96
96
  targetModel: CaseSearchModel,
97
97
  });
98
98
 
99
+ /**
100
+ */
101
+ export const useSearch = (href: string): CaseSearchModel | null =>
102
+ useModularUIBasic("search", href, {
103
+ expectedModels: ["CaseSearch"],
104
+ targetModel: CaseSearchModel,
105
+ });
106
+
99
107
  /**
100
108
  */
101
109
  export const useUserProfile = (href: string): UserProfileModel | null =>
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIModel.js","names":["useApplication","useModularUIBasic","expectedModels","targetModel","ApplicationModel","useTab","href","TabModel","useCaseView","CaseViewModel","usePanel","useList","ListModel","useListOrDetail","DetailModel","useListDetail","ListDetailModel","forceTargetModel","useGroupingPanel","GroupingPanelModel","useDetailPanel","useQuicksearch","CaseSearchModel","useUserProfile","UserProfileModel"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (): ApplicationModel | null =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string): TabModel | null =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (href: string): CaseViewModel | null =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n });\n\n/**\n */\nexport const usePanel = (\n href: string\n): ListModel | GroupingPanelModel | DetailModel | null =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n });\n\n/**\n */\nexport const useList = (href: string): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n });\n\n/**\n */\nexport const useListOrDetail = (href: string): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"Detail\"],\n targetModel: [ListModel, DetailModel],\n });\n\n/**\n */\nexport const useListDetail = (href: string): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n forceTargetModel: true,\n });\n\n/**\n */\nexport const useGroupingPanel = (href: string): GroupingPanelModel | null =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n });\n\n/**\n */\nexport const useDetailPanel = (href: string): DetailModel | null =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n });\n\n/**\n */\nexport const useQuicksearch = (href: string): CaseSearchModel | null =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useUserProfile = (href: string): UserProfileModel | null =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n });\n"],"mappings":";;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACO,MAAMA,cAAc,GAAG,MAC5B,IAAAC,oCAAiB,EAAC,aAAa,EAAE,GAAG,EAAE;EACpCC,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEC;AACf,CAAC,CAAC;;AAEJ;AACA;AACA;AAFA;AAGO,MAAMC,MAAM,GAAIC,IAAY,IACjC,IAAAL,oCAAiB,EAAC,KAAK,EAAEK,IAAI,EAAE;EAC7BJ,cAAc,EAAE,CAAC,KAAK,CAAC;EACvBC,WAAW,EAAEI;AACf,CAAC,CAAC;;AAEJ;AACA;AACA;AAFA;AAGO,MAAMC,WAAW,GAAIF,IAAY,IACtC,IAAAL,oCAAiB,EAAC,UAAU,EAAEK,IAAI,EAAE;EAClCJ,cAAc,EAAE,CAAC,UAAU,CAAC;EAC5BC,WAAW,EAAEM;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,QAAQ,GACnBJ,IAAY,IAEZ,IAAAL,oCAAiB,EAAC,OAAO,EAAEK,IAAI,EAAE;EAC/BJ,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ;AACpD,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMS,OAAO,GAAIL,IAAY,IAClC,IAAAL,oCAAiB,EAAC,MAAM,E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,EAAEqB;AACf,CAAC,CAAC;AAAC"}
1
+ {"version":3,"file":"useModularUIModel.js","names":["useApplication","useModularUIBasic","expectedModels","targetModel","ApplicationModel","useTab","href","TabModel","useCaseView","CaseViewModel","usePanel","useList","ListModel","useListOrDetail","DetailModel","useListDetail","ListDetailModel","forceTargetModel","useGroupingPanel","GroupingPanelModel","useDetailPanel","useQuicksearch","CaseSearchModel","useSearch","useUserProfile","UserProfileModel"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (): ApplicationModel | null =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string): TabModel | null =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (href: string): CaseViewModel | null =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n });\n\n/**\n */\nexport const usePanel = (\n href: string\n): ListModel | GroupingPanelModel | DetailModel | null =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n });\n\n/**\n */\nexport const useList = (href: string): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n });\n\n/**\n */\nexport const useListOrDetail = (href: string): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"Detail\"],\n targetModel: [ListModel, DetailModel],\n });\n\n/**\n */\nexport const useListDetail = (href: string): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n forceTargetModel: true,\n });\n\n/**\n */\nexport const useGroupingPanel = (href: string): GroupingPanelModel | null =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n });\n\n/**\n */\nexport const useDetailPanel = (href: string): DetailModel | null =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n });\n\n/**\n */\nexport const useQuicksearch = (href: string): CaseSearchModel | null =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useSearch = (href: string): CaseSearchModel | null =>\n useModularUIBasic(\"search\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useUserProfile = (href: string): UserProfileModel | null =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n });\n"],"mappings":";;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACO,MAAMA,cAAc,GAAG,MAC5B,IAAAC,oCAAiB,EAAC,aAAa,EAAE,GAAG,EAAE;EACpCC,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEC;AACf,CAAC,CAAC;;AAEJ;AACA;AACA;AAFA;AAGO,MAAMC,MAAM,GAAIC,IAAY,IACjC,IAAAL,oCAAiB,EAAC,KAAK,EAAEK,IAAI,EAAE;EAC7BJ,cAAc,EAAE,CAAC,KAAK,CAAC;EACvBC,WA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c,GAAId,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,QAAQ,CAAC;EAC1BC,WAAW,EAAEW;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMO,cAAc,GAAIf,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,YAAY,CAAC;EAC9BC,WAAW,EAAEmB;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,SAAS,GAAIjB,IAAY,IACpC,IAAAL,oCAAiB,EAAC,QAAQ,EAAEK,IAAI,EAAE;EAChCJ,cAAc,EAAE,CAAC,YAAY,CAAC;EAC9BC,WAAW,EAAEmB;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAME,cAAc,GAAIlB,IAAY,IACzC,IAAAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEsB;AACf,CAAC,CAAC;AAAC"}
@@ -9,15 +9,17 @@ var _reselect = require("reselect");
9
9
  var _reactRedux = require("react-redux");
10
10
  var _ModularUIRequest = _interopRequireDefault(require("../modularui/ModularUIRequest"));
11
11
  var _i18n = require("../redux/selectors/i18n");
12
- /**
13
- * Creates a ModularUIRequest with the locale as available in the redux store
14
- */
15
- const useModularUIRequest = () => (0, _reactRedux.useSelector)((0, _reselect.createSelector)([_i18n.getLocale], localeCode => {
12
+ const getModularUIRequest = (0, _reselect.createSelector)([_i18n.getLocale], localeCode => {
16
13
  return (href, options) => {
17
14
  const request = new _ModularUIRequest.default(href, options);
18
15
  request.locale = localeCode;
19
16
  return request;
20
17
  };
21
- }));
18
+ });
19
+
20
+ /**
21
+ * Creates a ModularUIRequest with the locale as available in the redux store
22
+ */
23
+ const useModularUIRequest = () => (0, _reactRedux.useSelector)(getModularUIRequest);
22
24
  exports.useModularUIRequest = useModularUIRequest;
23
25
  //# sourceMappingURL=useModularUIRequest.js.map
@@ -5,8 +5,16 @@ import { useSelector } from "react-redux";
5
5
  import ModularUIRequest from "../modularui/ModularUIRequest";
6
6
  import { getLocale } from "../redux/selectors/i18n";
7
7
 
8
- import type Href from "../models/href/Href";
9
8
  import type { RequestModularUIOptions } from "../utils";
9
+ import type Href from "../models/href/Href";
10
+
11
+ const getModularUIRequest = createSelector([getLocale], (localeCode) => {
12
+ return (href: Href, options?: $Shape<RequestModularUIOptions>) => {
13
+ const request = new ModularUIRequest(href, options);
14
+ request.locale = localeCode;
15
+ return request;
16
+ };
17
+ });
10
18
 
11
19
  /**
12
20
  * Creates a ModularUIRequest with the locale as available in the redux store
@@ -14,13 +22,4 @@ import type { RequestModularUIOptions } from "../utils";
14
22
  export const useModularUIRequest = (): ((
15
23
  href: Href,
16
24
  options?: $Shape<RequestModularUIOptions>
17
- ) => ModularUIRequest) =>
18
- useSelector(
19
- createSelector([getLocale], (localeCode) => {
20
- return (href: Href, options?: $Shape<RequestModularUIOptions>) => {
21
- const request = new ModularUIRequest(href, options);
22
- request.locale = localeCode;
23
- return request;
24
- };
25
- })
26
- );
25
+ ) => ModularUIRequest) => useSelector(getModularUIRequest);
@@ -1 +1 @@
1
- {"version":3,"file":"useModularUIRequest.js","names":["useModularUIRequest","useSelector","createSelector","getLocale","localeCode","href","options","request","ModularUIRequest","locale"],"sources":["../../src/hooks/useModularUIRequest.js"],"sourcesContent":["// @flow\nimport { createSelector } from \"reselect\";\nimport { useSelector } from \"react-redux\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport type Href from \"../models/href/Href\";\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n * Creates a ModularUIRequest with the locale as available in the redux store\n */\nexport const useModularUIRequest = (): ((\n href: Href,\n options?: $Shape<RequestModularUIOptions>\n) => ModularUIRequest) =>\n useSelector(\n createSelector([getLocale], (localeCode) => {\n return (href: Href, options?: $Shape<RequestModularUIOptions>) => {\n const request = new ModularUIRequest(href, options);\n request.locale = localeCode;\n return request;\n };\n })\n );\n"],"mappings":";;;;;;;AACA;AACA;AAEA;AACA;AAKA;AACA;AACA;AACO,MAAMA,mBAAmB,GAAG,MAIjC,IAAAC,uBAAW,EACT,IAAAC,wBAAc,EAAC,CAACC,eAAS,CAAC,EAAGC,UAAU,IAAK;EAC1C,OAAO,CAACC,IAAU,EAAEC,OAAyC,KAAK;IAChE,MAAMC,OAAO,GAAG,IAAIC,yBAAgB,CAACH,IAAI,EAAEC,OAAO,CAAC;IACnDC,OAAO,CAACE,MAAM,GAAGL,UAAU;IAC3B,OAAOG,OAAO;EAChB,CAAC;AACH,CAAC,CAAC,CACH;AAAC"}
1
+ {"version":3,"file":"useModularUIRequest.js","names":["getModularUIRequest","createSelector","getLocale","localeCode","href","options","request","ModularUIRequest","locale","useModularUIRequest","useSelector"],"sources":["../../src/hooks/useModularUIRequest.js"],"sourcesContent":["// @flow\nimport { createSelector } from \"reselect\";\nimport { useSelector } from \"react-redux\";\n\nimport ModularUIRequest from \"../modularui/ModularUIRequest\";\nimport { getLocale } from \"../redux/selectors/i18n\";\n\nimport type { RequestModularUIOptions } from \"../utils\";\nimport type Href from \"../models/href/Href\";\n\nconst getModularUIRequest = createSelector([getLocale], (localeCode) => {\n return (href: Href, options?: $Shape<RequestModularUIOptions>) => {\n const request = new ModularUIRequest(href, options);\n request.locale = localeCode;\n return request;\n };\n});\n\n/**\n * Creates a ModularUIRequest with the locale as available in the redux store\n */\nexport const useModularUIRequest = (): ((\n href: Href,\n options?: $Shape<RequestModularUIOptions>\n) => ModularUIRequest) => useSelector(getModularUIRequest);\n"],"mappings":";;;;;;;AACA;AACA;AAEA;AACA;AAKA,MAAMA,mBAAmB,GAAG,IAAAC,wBAAc,EAAC,CAACC,eAAS,CAAC,EAAGC,UAAU,IAAK;EACtE,OAAO,CAACC,IAAU,EAAEC,OAAyC,KAAK;IAChE,MAAMC,OAAO,GAAG,IAAIC,yBAAgB,CAACH,IAAI,EAAEC,OAAO,CAAC;IACnDC,OAAO,CAACE,MAAM,GAAGL,UAAU;IAC3B,OAAOG,OAAO;EAChB,CAAC;AACH,CAAC,CAAC;;AAEF;AACA;AACA;AACO,MAAMG,mBAAmB,GAAG,MAGT,IAAAC,uBAAW,EAACV,mBAAmB,CAAC;AAAC"}
@@ -9,7 +9,6 @@ var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stabl
9
9
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
10
10
  var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
11
11
  var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
12
- var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
13
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
14
13
  var _ResourceCollection = _interopRequireDefault(require("../base/ResourceCollection"));
15
14
  var _ChoiceAttributeOptionModel = _interopRequireDefault(require("./ChoiceAttributeOptionModel"));
@@ -142,22 +141,14 @@ class ChoiceAttributeOptionCollection extends _ResourceCollection.default {
142
141
  });
143
142
  }
144
143
 
145
- /**
146
- */
147
- getDefaultValueForOption(value, contributions) {
148
- const layouthints = contributions.layouthint ?? [];
149
- const requireDefaultValue = (0, _includes.default)(layouthints).call(layouthints, "checkbox") || (0, _includes.default)(layouthints).call(layouthints, "toggle");
150
- return requireDefaultValue ? "false" : "";
151
- }
152
-
153
144
  /**
154
145
  * Create two static options for true and false,
155
146
  * there might be alternative labels configured for each option value
156
147
  */
157
148
  addBooleanOptions(value, contributions) {
158
- const optionValue = value == null ? this.getDefaultValueForOption(value, contributions) : value.toString();
159
- this.addBooleanOption("true", "Yes", [optionValue], contributions.options);
160
- this.addBooleanOption("false", "No", [optionValue], contributions.options);
149
+ const optionValue = value == null ? [] : [value.toString()];
150
+ this.addBooleanOption("true", "Yes", optionValue, contributions.options);
151
+ this.addBooleanOption("false", "No", optionValue, contributions.options);
161
152
  return this;
162
153
  }
163
154
 
@@ -166,17 +166,6 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
166
166
  });
167
167
  }
168
168
 
169
- /**
170
- */
171
- getDefaultValueForOption(value: any, contributions: Object): string {
172
- const layouthints = contributions.layouthint ?? [];
173
-
174
- const requireDefaultValue =
175
- layouthints.includes("checkbox") || layouthints.includes("toggle");
176
-
177
- return requireDefaultValue ? "false" : "";
178
- }
179
-
180
169
  /**
181
170
  * Create two static options for true and false,
182
171
  * there might be alternative labels configured for each option value
@@ -185,13 +174,10 @@ class ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttribute
185
174
  value: any,
186
175
  contributions: Object
187
176
  ): ChoiceAttributeOptionCollection {
188
- const optionValue =
189
- value == null
190
- ? this.getDefaultValueForOption(value, contributions)
191
- : value.toString();
177
+ const optionValue = value == null ? [] : [value.toString()];
192
178
 
193
- this.addBooleanOption("true", "Yes", [optionValue], contributions.options);
194
- this.addBooleanOption("false", "No", [optionValue], contributions.options);
179
+ this.addBooleanOption("true", "Yes", optionValue, contributions.options);
180
+ this.addBooleanOption("false", "No", optionValue, contributions.options);
195
181
 
196
182
  return this;
197
183
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ChoiceAttributeOptionCollection.js","names":["ChoiceAttributeOptionCollection","ResourceCollection","sortOptions","_sortOptions","collection","forEach","option","children","create","data","contributions","referenceDate","DateUtil","now","type","addBooleanOptions","value","dynamicschema","addDynamicSchema","options","addOptions","addHeaders","all","a","b","label","localeCompare","getSelectedOptions","selectedOptions","Array","isArray","push","selected","key","toString","getOptionCount","code","foundOption","count","selectedValues","optionContributions","optionCode","addOption","optionDynamicschema","elementsContributions","addBooleanOption","defaultLabel","isBooleanType","hasAlternativeLabel","getDefaultValueForOption","layouthints","layouthint","requireDefaultValue","optionValue","optionModel","ChoiceAttributeOptionModel","add","deselectAll","newOption","clone","select","toggle","deselect","action","setReferenceDate","date","headers","_headers","child","ListHeaderModel","mergeOptions","withOptions","addNotExistingOptions","some","opt","withOption","mergeOption","callbackfn","thisArg","optionIndex","collectionArray","result"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n _headers: Array<ListHeaderModel> = [];\n _sortOptions: boolean = false;\n\n /**\n */\n set sortOptions(sortOptions: boolean) {\n this._sortOptions = sortOptions;\n\n this.collection.forEach((option) => {\n if (option.children) {\n option.children.sortOptions = sortOptions;\n }\n });\n }\n\n /**\n */\n get sortOptions(): boolean {\n return this._sortOptions;\n }\n\n /**\n */\n static create(\n data: Object = {},\n contributions: Object = {},\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n const collection = new ChoiceAttributeOptionCollection();\n\n if (contributions.type === \"boolean\") {\n collection.addBooleanOptions(data.value, contributions);\n } else if (data.dynamicschema != null) {\n collection.addDynamicSchema(data, contributions, referenceDate);\n } else if (contributions.options != null) {\n collection.addOptions(data, contributions, referenceDate);\n }\n\n if (contributions.children != null) {\n collection.addHeaders(contributions.children);\n }\n\n return collection;\n }\n\n /**\n * Retrieve all items in collection\n */\n get all(): Array<ChoiceAttributeOptionModel> {\n return this.sortOptions\n ? this.collection.sort((a, b) => a.label.localeCompare(b.label))\n : this.collection;\n }\n\n /**\n */\n getSelectedOptions(data: Object): Array<string> {\n const selectedOptions = [];\n\n if (Array.isArray(data.options)) {\n selectedOptions.push(\n ...data.options\n .filter((option) => option.selected)\n .map((option) => option.key)\n );\n } else if (Array.isArray(data.value)) {\n selectedOptions.push(...data.value);\n } else if (typeof data.value === \"boolean\") {\n selectedOptions.push(data.value.toString());\n } else {\n selectedOptions.push(data.value);\n }\n\n return selectedOptions;\n }\n\n /**\n */\n getOptionCount(code: string, options: Array<Object>): number | null {\n if (Array.isArray(options)) {\n const foundOption = options.find((option) => option.key === code);\n if (foundOption) {\n return foundOption.count;\n }\n }\n\n return null;\n }\n\n /**\n */\n addOptions(\n data: Object,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n\n contributions.options.forEach((optionContributions) => {\n const optionCode = optionContributions.code || optionContributions.key;\n\n this.addOption(\n selectedValues,\n {\n ...optionContributions,\n count: this.getOptionCount(optionCode, data.options),\n },\n referenceDate\n );\n });\n\n return this;\n }\n\n /**\n * Create options based on data and dynamischema\n */\n addDynamicSchema(\n data: Object,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n data.dynamicschema.forEach((optionDynamicschema) => {\n this.addOption(\n selectedValues,\n {\n ...optionDynamicschema,\n count: this.getOptionCount(optionDynamicschema.code, data.options),\n elementsContributions: contributions.children,\n },\n referenceDate\n );\n });\n\n return this;\n }\n\n /**\n */\n addBooleanOption(\n code: \"true\" | \"false\",\n defaultLabel: string,\n data: string | Array<string>,\n options: Array<Object> = []\n ) {\n const foundOption = options.find((option) => option.code === code);\n\n const label = foundOption ? foundOption.label : defaultLabel;\n\n this.addOption(data, {\n code,\n label,\n isBooleanType: true,\n hasAlternativeLabel: foundOption != null,\n });\n }\n\n /**\n */\n getDefaultValueForOption(value: any, contributions: Object): string {\n const layouthints = contributions.layouthint ?? [];\n\n const requireDefaultValue =\n layouthints.includes(\"checkbox\") || layouthints.includes(\"toggle\");\n\n return requireDefaultValue ? \"false\" : \"\";\n }\n\n /**\n * Create two static options for true and false,\n * there might be alternative labels configured for each option value\n */\n addBooleanOptions(\n value: any,\n contributions: Object\n ): ChoiceAttributeOptionCollection {\n const optionValue =\n value == null\n ? this.getDefaultValueForOption(value, contributions)\n : value.toString();\n\n this.addBooleanOption(\"true\", \"Yes\", [optionValue], contributions.options);\n this.addBooleanOption(\"false\", \"No\", [optionValue], contributions.options);\n\n return this;\n }\n\n /**\n */\n addOption(\n data: string | Array<string>,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n const optionModel = new ChoiceAttributeOptionModel(\n Array.isArray(data) ? data : [data],\n contributions,\n referenceDate\n );\n\n this.add(optionModel);\n\n return this;\n }\n\n /**\n * Get all options that have selected property true\n */\n get selected(): Array<ChoiceAttributeOptionModel> {\n const selectedOptions = [];\n\n this.collection.forEach((option: ChoiceAttributeOptionModel) => {\n if (option.selected && option.selected === true) {\n selectedOptions.push(option);\n }\n\n if (option.children) {\n selectedOptions.push(...option.children.selected);\n }\n });\n\n return selectedOptions;\n }\n\n /**\n * Deselect all options\n */\n deselectAll() {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n newOption.selected = false;\n\n if (newOption.children) {\n newOption.children.deselectAll();\n }\n\n return newOption;\n });\n }\n\n /**\n * Select an option by it's code\n */\n select(optionCode: string) {\n this.toggle(optionCode, \"select\");\n }\n\n /**\n * Deselect an option by it's code\n */\n deselect(optionCode: string) {\n this.toggle(optionCode, \"deselect\");\n }\n\n /**\n * Toggle an option by it's code\n */\n toggle(optionCode: string, action: \"select\" | \"deselect\") {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n if (newOption.code === optionCode) {\n newOption.selected = action === \"select\";\n } else if (newOption.children) {\n newOption.children.toggle(optionCode, action);\n }\n\n return newOption;\n });\n }\n\n /**\n */\n setReferenceDate(date: ISO_DATE): Array<ChoiceAttributeOptionModel> {\n return this.collection.map((option) => {\n option.referenceDate = date;\n if (option.children) {\n option.children.referenceDate = date;\n }\n\n return option;\n });\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this.collection = this.setReferenceDate(date);\n }\n\n /**\n */\n addHeaders(headers: Array<Object>) {\n this._headers = headers.map((child) => new ListHeaderModel(child));\n }\n\n /**\n */\n get headers(): Array<ListHeaderModel> {\n if (this._headers) {\n return this._headers;\n }\n\n return [];\n }\n\n /**\n */\n mergeOptions(\n withOptions: ChoiceAttributeOptionCollection,\n addNotExistingOptions: boolean = false\n ) {\n if (addNotExistingOptions) {\n this.collection = [\n ...this.collection,\n ...withOptions.filter(\n (option) => !this.collection.some((opt) => opt.code === option.code)\n ),\n ];\n }\n\n this.collection.forEach((option) => {\n const foundOption = withOptions.find(\n (withOption) => withOption.code === option.code\n );\n if (foundOption) {\n option.mergeOption(foundOption);\n }\n });\n }\n\n /**\n */\n some(\n callbackfn: (\n value: ChoiceAttributeOptionModel,\n index: number,\n array: Array<ChoiceAttributeOptionModel>\n ) => any,\n thisArg?: any\n ): boolean {\n return this.collection.some((option, optionIndex, collectionArray) => {\n const result = callbackfn(option, optionIndex, collectionArray);\n if (!result && option.children) {\n return option.children.some(callbackfn, thisArg);\n }\n return result;\n });\n }\n}\n\nexport default ChoiceAttributeOptionCollection;\n"],"mappings":";;;;;;;;;;;;;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA,MAAMA,+BAA+B,SAASC,2BAAkB,CAA6B;EAAA;IAAA;IAAA,gDACxD,EAAE;IAAA,oDACb,KAAK;EAAA;EAE7B;AACF;EACE,IAAIC,WAAW,CAACA,WAAoB,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGD,WAAW;IAE/B,IAAI,CAACE,UAAU,CAACC,OAAO,CAAEC,MAAM,IAAK;MAClC,IAAIA,MAAM,CAACC,QAAQ,EAAE;QACnBD,MAAM,CAACC,QAAQ,CAACL,WAAW,GAAGA,WAAW;MAC3C;IACF,CAAC,CAAC;EACJ;;EAEA;AACF;EACE,IAAIA,WAAW,GAAY;IACzB,OAAO,IAAI,CAACC,YAAY;EAC1B;;EAEA;AACF;E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,WAAW,EAAE;QACf/B,MAAM,CAACsE,WAAW,CAACvC,WAAW,CAAC;MACjC;IACF,CAAC,CAAC;EACJ;;EAEA;AACF;EACEoC,IAAI,CACFI,UAIQ,EACRC,OAAa,EACJ;IACT,OAAO,IAAI,CAAC1E,UAAU,CAACqE,IAAI,CAAC,CAACnE,MAAM,EAAEyE,WAAW,EAAEC,eAAe,KAAK;MACpE,MAAMC,MAAM,GAAGJ,UAAU,CAACvE,MAAM,EAAEyE,WAAW,EAAEC,eAAe,CAAC;MAC/D,IAAI,CAACC,MAAM,IAAI3E,MAAM,CAACC,QAAQ,EAAE;QAC9B,OAAOD,MAAM,CAACC,QAAQ,CAACkE,IAAI,CAACI,UAAU,EAAEC,OAAO,CAAC;MAClD;MACA,OAAOG,MAAM;IACf,CAAC,CAAC;EACJ;AACF;AAAC,eAEcjF,+BAA+B;AAAA"}
1
+ {"version":3,"file":"ChoiceAttributeOptionCollection.js","names":["ChoiceAttributeOptionCollection","ResourceCollection","sortOptions","_sortOptions","collection","forEach","option","children","create","data","contributions","referenceDate","DateUtil","now","type","addBooleanOptions","value","dynamicschema","addDynamicSchema","options","addOptions","addHeaders","all","a","b","label","localeCompare","getSelectedOptions","selectedOptions","Array","isArray","push","selected","key","toString","getOptionCount","code","foundOption","count","selectedValues","optionContributions","optionCode","addOption","optionDynamicschema","elementsContributions","addBooleanOption","defaultLabel","isBooleanType","hasAlternativeLabel","optionValue","optionModel","ChoiceAttributeOptionModel","add","deselectAll","newOption","clone","select","toggle","deselect","action","setReferenceDate","date","headers","_headers","child","ListHeaderModel","mergeOptions","withOptions","addNotExistingOptions","some","opt","withOption","mergeOption","callbackfn","thisArg","optionIndex","collectionArray","result"],"sources":["../../../src/models/attributes/ChoiceAttributeOptionCollection.js"],"sourcesContent":["// @flow\nimport ResourceCollection from \"../base/ResourceCollection\";\nimport ChoiceAttributeOptionModel from \"./ChoiceAttributeOptionModel\";\nimport ListHeaderModel from \"../list/ListHeaderModel\";\n\nimport { DateUtil } from \"../../utils/datetime/DateTimeUtil\";\n\n/**\n */\nclass ChoiceAttributeOptionCollection extends ResourceCollection<ChoiceAttributeOptionModel> {\n _headers: Array<ListHeaderModel> = [];\n _sortOptions: boolean = false;\n\n /**\n */\n set sortOptions(sortOptions: boolean) {\n this._sortOptions = sortOptions;\n\n this.collection.forEach((option) => {\n if (option.children) {\n option.children.sortOptions = sortOptions;\n }\n });\n }\n\n /**\n */\n get sortOptions(): boolean {\n return this._sortOptions;\n }\n\n /**\n */\n static create(\n data: Object = {},\n contributions: Object = {},\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n const collection = new ChoiceAttributeOptionCollection();\n\n if (contributions.type === \"boolean\") {\n collection.addBooleanOptions(data.value, contributions);\n } else if (data.dynamicschema != null) {\n collection.addDynamicSchema(data, contributions, referenceDate);\n } else if (contributions.options != null) {\n collection.addOptions(data, contributions, referenceDate);\n }\n\n if (contributions.children != null) {\n collection.addHeaders(contributions.children);\n }\n\n return collection;\n }\n\n /**\n * Retrieve all items in collection\n */\n get all(): Array<ChoiceAttributeOptionModel> {\n return this.sortOptions\n ? this.collection.sort((a, b) => a.label.localeCompare(b.label))\n : this.collection;\n }\n\n /**\n */\n getSelectedOptions(data: Object): Array<string> {\n const selectedOptions = [];\n\n if (Array.isArray(data.options)) {\n selectedOptions.push(\n ...data.options\n .filter((option) => option.selected)\n .map((option) => option.key)\n );\n } else if (Array.isArray(data.value)) {\n selectedOptions.push(...data.value);\n } else if (typeof data.value === \"boolean\") {\n selectedOptions.push(data.value.toString());\n } else {\n selectedOptions.push(data.value);\n }\n\n return selectedOptions;\n }\n\n /**\n */\n getOptionCount(code: string, options: Array<Object>): number | null {\n if (Array.isArray(options)) {\n const foundOption = options.find((option) => option.key === code);\n if (foundOption) {\n return foundOption.count;\n }\n }\n\n return null;\n }\n\n /**\n */\n addOptions(\n data: Object,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n\n contributions.options.forEach((optionContributions) => {\n const optionCode = optionContributions.code || optionContributions.key;\n\n this.addOption(\n selectedValues,\n {\n ...optionContributions,\n count: this.getOptionCount(optionCode, data.options),\n },\n referenceDate\n );\n });\n\n return this;\n }\n\n /**\n * Create options based on data and dynamischema\n */\n addDynamicSchema(\n data: Object,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n const selectedValues = this.getSelectedOptions(data);\n data.dynamicschema.forEach((optionDynamicschema) => {\n this.addOption(\n selectedValues,\n {\n ...optionDynamicschema,\n count: this.getOptionCount(optionDynamicschema.code, data.options),\n elementsContributions: contributions.children,\n },\n referenceDate\n );\n });\n\n return this;\n }\n\n /**\n */\n addBooleanOption(\n code: \"true\" | \"false\",\n defaultLabel: string,\n data: string | Array<string>,\n options: Array<Object> = []\n ) {\n const foundOption = options.find((option) => option.code === code);\n\n const label = foundOption ? foundOption.label : defaultLabel;\n\n this.addOption(data, {\n code,\n label,\n isBooleanType: true,\n hasAlternativeLabel: foundOption != null,\n });\n }\n\n /**\n * Create two static options for true and false,\n * there might be alternative labels configured for each option value\n */\n addBooleanOptions(\n value: any,\n contributions: Object\n ): ChoiceAttributeOptionCollection {\n const optionValue = value == null ? [] : [value.toString()];\n\n this.addBooleanOption(\"true\", \"Yes\", optionValue, contributions.options);\n this.addBooleanOption(\"false\", \"No\", optionValue, contributions.options);\n\n return this;\n }\n\n /**\n */\n addOption(\n data: string | Array<string>,\n contributions: Object,\n referenceDate: ISO_DATE = DateUtil.now()\n ): ChoiceAttributeOptionCollection {\n const optionModel = new ChoiceAttributeOptionModel(\n Array.isArray(data) ? data : [data],\n contributions,\n referenceDate\n );\n\n this.add(optionModel);\n\n return this;\n }\n\n /**\n * Get all options that have selected property true\n */\n get selected(): Array<ChoiceAttributeOptionModel> {\n const selectedOptions = [];\n\n this.collection.forEach((option: ChoiceAttributeOptionModel) => {\n if (option.selected && option.selected === true) {\n selectedOptions.push(option);\n }\n\n if (option.children) {\n selectedOptions.push(...option.children.selected);\n }\n });\n\n return selectedOptions;\n }\n\n /**\n * Deselect all options\n */\n deselectAll() {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n newOption.selected = false;\n\n if (newOption.children) {\n newOption.children.deselectAll();\n }\n\n return newOption;\n });\n }\n\n /**\n * Select an option by it's code\n */\n select(optionCode: string) {\n this.toggle(optionCode, \"select\");\n }\n\n /**\n * Deselect an option by it's code\n */\n deselect(optionCode: string) {\n this.toggle(optionCode, \"deselect\");\n }\n\n /**\n * Toggle an option by it's code\n */\n toggle(optionCode: string, action: \"select\" | \"deselect\") {\n this.collection = this.collection.map((option) => {\n const newOption = option.clone();\n\n if (newOption.code === optionCode) {\n newOption.selected = action === \"select\";\n } else if (newOption.children) {\n newOption.children.toggle(optionCode, action);\n }\n\n return newOption;\n });\n }\n\n /**\n */\n setReferenceDate(date: ISO_DATE): Array<ChoiceAttributeOptionModel> {\n return this.collection.map((option) => {\n option.referenceDate = date;\n if (option.children) {\n option.children.referenceDate = date;\n }\n\n return option;\n });\n }\n\n /**\n */\n set referenceDate(date: ISO_DATE) {\n this.collection = this.setReferenceDate(date);\n }\n\n /**\n */\n addHeaders(headers: Array<Object>) {\n this._headers = headers.map((child) => new ListHeaderModel(child));\n }\n\n /**\n */\n get headers(): Array<ListHeaderModel> {\n if (this._headers) {\n return this._headers;\n }\n\n return [];\n }\n\n /**\n */\n mergeOptions(\n withOptions: ChoiceAttributeOptionCollection,\n addNotExistingOptions: boolean = false\n ) {\n if (addNotExistingOptions) {\n this.collection = [\n ...this.collection,\n ...withOptions.filter(\n (option) => !this.collection.some((opt) => opt.code === option.code)\n ),\n ];\n }\n\n this.collection.forEach((option) => {\n const foundOption = withOptions.find(\n (withOption) => withOption.code === option.code\n );\n if (foundOption) {\n option.mergeOption(foundOption);\n }\n });\n }\n\n /**\n */\n some(\n callbackfn: (\n value: ChoiceAttributeOptionModel,\n index: number,\n array: Array<ChoiceAttributeOptionModel>\n ) => any,\n thisArg?: any\n ): boolean {\n return this.collection.some((option, optionIndex, collectionArray) => {\n const result = callbackfn(option, optionIndex, collectionArray);\n if (!result && option.children) {\n return option.children.some(callbackfn, thisArg);\n }\n return result;\n });\n }\n}\n\nexport default ChoiceAttributeOptionCollection;\n"],"mappings":";;;;;;;;;;;;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA,MAAMA,+BAA+B,SAASC,2BAAkB,CAA6B;EAAA;IAAA;IAAA,gDACxD,EAAE;IAAA,oDACb,KAAK;EAAA;EAE7B;AACF;EACE,IAAIC,WAAW,CAACA,WAAoB,EAAE;IACpC,IAAI,CAACC,YAAY,GAAGD,WAAW;IAE/B,IAAI,CAACE,UAAU,CAACC,OAAO,CAAEC,MAAM,IAAK;MAClC,IAAIA,MAAM,CAACC,QAAQ,EAAE;QACnBD,MAAM,CAACC,QAAQ,CAACL,WAAW,GAAGA,WAAW;MAC3C;IACF,CAAC,CAAC;EACJ;;EAEA;AACF;EACE,IAAIA,WAAW,GAAY;IACzB,OAAO,IAAI,CAACC,YAAY;EAC1B;;EAEA;AACF;EACE,OAAOK,MAAM,GAIsB;IAAA,IAHjCC,IAAY,uEAAG,CAAC,CAAC;IAAA,IACjBC,aAAqB,uEAAG,CAAC,CAAC;IAAA,IAC1BC,aAAuB,uEAAGC,sBAAQ,CAACC,GAAG,EAAE;IAExC,MAAMT,UAAU,GAAG,IAAIJ,+BAA+B,EAAE;IAExD,IAAIU,aAAa,CAACI,IAAI,KAAK,SAAS,EAAE;MACpCV,UAAU,CAACW,iBAAiB,CAACN,IAAI,CAACO,KAAK,EAAEN,aAAa,CAAC;IACzD,CAAC,MAAM,IAAID,IAAI,CAACQ,aAAa,IAAI,IAAI,EAAE;MACrCb,UAAU,CAACc,gBAAgB,CAACT,IAAI,EAAEC,aAAa,EAAEC,aAAa,CAAC;IACjE,CAAC,MAAM,IAAID,aAAa,CAACS,OAAO,IAAI,IAAI,EAAE;M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