@beinformed/ui 1.65.6 → 1.65.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/esm/hooks/__tests__/UseModularUIModel.spec.js.flow +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/index.js.flow +1 -0
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/useForm.js +3 -3
- package/esm/hooks/useForm.js.flow +7 -4
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useList.js +47 -3
- package/esm/hooks/useList.js.flow +74 -2
- package/esm/hooks/useList.js.map +1 -1
- package/esm/hooks/useLookup.js +62 -0
- package/esm/hooks/useLookup.js.flow +82 -0
- package/esm/hooks/useLookup.js.map +1 -0
- package/esm/hooks/usePanel.js +6 -1
- package/esm/hooks/usePanel.js.flow +6 -4
- package/esm/hooks/usePanel.js.map +1 -1
- package/esm/hooks/useProgressIndicator.js +21 -6
- package/esm/hooks/useProgressIndicator.js.flow +27 -10
- package/esm/hooks/useProgressIndicator.js.map +1 -1
- package/esm/models/attributes/AttributeSetModel.js +1 -1
- package/esm/models/attributes/AttributeSetModel.js.flow +1 -1
- package/esm/models/attributes/AttributeSetModel.js.map +1 -1
- package/esm/models/attributes/ChoiceAttributeModel.js +19 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.flow +23 -2
- package/esm/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/esm/models/filters/AssignmentFilterModel.js +1 -12
- package/esm/models/filters/AssignmentFilterModel.js.flow +6 -14
- package/esm/models/filters/AssignmentFilterModel.js.map +1 -1
- package/esm/models/filters/BaseFilterModel.js +12 -0
- package/esm/models/filters/BaseFilterModel.js.flow +12 -0
- package/esm/models/filters/BaseFilterModel.js.map +1 -1
- package/esm/models/filters/ConceptIndexFilterModel.js.flow +5 -2
- package/esm/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/esm/models/filters/FilterCollection.js +26 -8
- package/esm/models/filters/FilterCollection.js.flow +23 -6
- package/esm/models/filters/FilterCollection.js.map +1 -1
- package/esm/models/filters/FilterModel.js.flow +2 -2
- package/esm/models/filters/FilterModel.js.map +1 -1
- package/esm/models/filters/RangeFilterModel.js.flow +2 -2
- package/esm/models/filters/RangeFilterModel.js.map +1 -1
- package/esm/models/filters/StringFilterModel.js.flow +2 -2
- package/esm/models/filters/StringFilterModel.js.map +1 -1
- package/esm/models/links/LinkModel.js +17 -1
- package/esm/models/links/LinkModel.js.flow +18 -1
- package/esm/models/links/LinkModel.js.map +1 -1
- package/esm/models/list/ListModel.js.flow +2 -2
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/search/CaseSearchModel.js.flow +2 -2
- package/esm/models/search/CaseSearchModel.js.map +1 -1
- package/esm/models/types.js +1 -1
- package/esm/models/types.js.flow +28 -10
- package/esm/models/types.js.map +1 -1
- package/esm/react-server/serverUtil.js +2 -2
- package/esm/react-server/serverUtil.js.flow +2 -2
- package/esm/react-server/serverUtil.js.map +1 -1
- package/lib/hooks/index.js +11 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useForm.js +5 -5
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useList.js +47 -3
- package/lib/hooks/useList.js.map +1 -1
- package/lib/hooks/useLookup.js +70 -0
- package/lib/hooks/useLookup.js.map +1 -0
- package/lib/hooks/usePanel.js +6 -1
- package/lib/hooks/usePanel.js.map +1 -1
- package/lib/hooks/useProgressIndicator.js +23 -7
- package/lib/hooks/useProgressIndicator.js.map +1 -1
- package/lib/models/attributes/AttributeSetModel.js +1 -1
- package/lib/models/attributes/AttributeSetModel.js.map +1 -1
- package/lib/models/attributes/ChoiceAttributeModel.js +18 -1
- package/lib/models/attributes/ChoiceAttributeModel.js.map +1 -1
- package/lib/models/filters/AssignmentFilterModel.js +0 -12
- package/lib/models/filters/AssignmentFilterModel.js.map +1 -1
- package/lib/models/filters/BaseFilterModel.js +12 -0
- package/lib/models/filters/BaseFilterModel.js.map +1 -1
- package/lib/models/filters/ConceptIndexFilterModel.js.map +1 -1
- package/lib/models/filters/FilterCollection.js +26 -8
- package/lib/models/filters/FilterCollection.js.map +1 -1
- package/lib/models/filters/FilterModel.js.map +1 -1
- package/lib/models/filters/RangeFilterModel.js.map +1 -1
- package/lib/models/filters/StringFilterModel.js.map +1 -1
- package/lib/models/links/LinkModel.js +17 -0
- package/lib/models/links/LinkModel.js.map +1 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/search/CaseSearchModel.js.map +1 -1
- package/lib/models/types.js +2 -0
- package/lib/models/types.js.map +1 -1
- package/lib/react-server/serverUtil.js +5 -5
- package/lib/react-server/serverUtil.js.map +1 -1
- package/package.json +3 -3
- package/src/hooks/__tests__/UseModularUIModel.spec.js +1 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/useForm.js +7 -4
- package/src/hooks/useList.js +74 -2
- package/src/hooks/useLookup.js +82 -0
- package/src/hooks/usePanel.js +6 -4
- package/src/hooks/useProgressIndicator.js +27 -10
- package/src/models/attributes/AttributeSetModel.js +1 -1
- package/src/models/attributes/ChoiceAttributeModel.js +23 -2
- package/src/models/filters/AssignmentFilterModel.js +6 -14
- package/src/models/filters/BaseFilterModel.js +12 -0
- package/src/models/filters/ConceptIndexFilterModel.js +5 -2
- package/src/models/filters/FilterCollection.js +23 -6
- package/src/models/filters/FilterModel.js +2 -2
- package/src/models/filters/RangeFilterModel.js +2 -2
- package/src/models/filters/StringFilterModel.js +2 -2
- package/src/models/links/LinkModel.js +18 -1
- package/src/models/list/ListModel.js +2 -2
- package/src/models/search/CaseSearchModel.js +2 -2
- package/src/models/types.js +28 -10
- package/src/react-server/serverUtil.js +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverUtil.js","names":["_history","require","_objects","_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_exceptions","_redux","_i18n","_ModularUIRequest","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getEnabledLocales","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","undefined","filteredState","_stringify","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 setDateTimeSettings,\n} from \"../redux/actions/Preferences\";\n\nimport { getEnabledLocales } 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 getEnabledLocales().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 store.dispatch(setDateTimeSettings());\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 application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,QAAA,GAAAC,uBAAA,CAAAN,OAAA;AAGA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AASA,IAAAU,SAAA,GAAAV,OAAA;AAEA,IAAAW,WAAA,GAAAX,OAAA;AAEA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,KAAA,GAAAb,OAAA;AAEA,IAAAc,iBAAA,GAAAX,sBAAA,CAAAH,OAAA;AAA6D,SAAAM,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,QAAA,MAAAC,CAAA,OAAAD,QAAA,IAAAE,CAAA,OAAAF,QAAA,YAAAX,uBAAA,YA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B,GAAGR,KAAK;IACRI;EACF,CAAC;EAED,OAAO,IAAAK,UAAA,CAAA7F,OAAA,EAAe4F,aAAa,CAAC,CAACE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;AAC/D,CAAC;;AAED;AACA;AADA3E,OAAA,CAAAoE,SAAA,GAAAA,SAAA;AAEA,MAAMQ,UAAU,GAAGA,CACjBC,KAAU,EACVC,IAAY,EACZC,aAAsB,KACX;EACX,MAAMC,KAAK,GAAGH,KAAK,CAACI,YAAY,CAAC,CAAC;EAClC,MAAMC,IAAI,GAAGH,aAAa,GAAG,CAAC,GAAGA,aAAa,CAACI,MAAM,CAACD,IAAI,CAAC,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;AAAClF,OAAA,CAAA4E,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"serverUtil.js","names":["_history","require","_objects","_deepmerge","_interopRequireDefault","_configureStore","_Locales","_interopRequireWildcard","_requestInformation","_I18nActions","_Preferences","_Settings","_IllegalArgumentException","_ModularUIActions","_i18n","_ModularUIRequest","e","t","_WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","_Object$getOwnPropertyDescriptor","createReduxStore","requestHref","customReducers","initialState","history","createMemoryHistory","initialEntries","toString","store","configureStore","exports","setI18n","locales","request","Array","isArray","IllegalArgumentException","mergedLocales","_map","availableLocales","locale","code","customLocale","_find","custLocale","deepmerge","forEach","some","push","enabledLocales","_filter","_context","_includes","getEnabledLocales","localesInstance","Locales","preferredLocale","getPreferredLocale","dispatch","setLocales","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreference","setServerPreferences","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","preferencesProvider","isStudioContext","setPreference","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWith","dataFetcher","fetch","setThemePreference","Error","setApplication","getLocale","getState","application","ModularUIRequest","fetchSync","connectKey","initModels","key","model","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","undefined","filteredState","_stringify","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 setDateTimeSettings,\n} from \"../redux/actions/Preferences\";\n\nimport { getEnabledLocales } from \"../constants/Settings\";\n\nimport IllegalArgumentException from \"../exceptions/IllegalArgumentException\";\n\nimport { initModels } from \"../redux/_modularui/ModularUIActions\";\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 getEnabledLocales().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 store.dispatch(setDateTimeSettings());\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 application.connectKey = `application(/)(${locale})`;\n\n store.dispatch(\n initModels([\n {\n key: `application(/)(${locale})`,\n model: application,\n },\n ]),\n );\n } catch (e) {\n // swallow error, in this case we just don't pre-cache the webapplication,\n // which has not much difference for the end user\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,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;AAEA,IAAAI,eAAA,GAAAD,sBAAA,CAAAH,OAAA;AAEA,IAAAK,QAAA,GAAAC,uBAAA,CAAAN,OAAA;AAGA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AAEA,IAAAS,YAAA,GAAAT,OAAA;AASA,IAAAU,SAAA,GAAAV,OAAA;AAEA,IAAAW,yBAAA,GAAAR,sBAAA,CAAAH,OAAA;AAEA,IAAAY,iBAAA,GAAAZ,OAAA;AACA,IAAAa,KAAA,GAAAb,OAAA;AAEA,IAAAc,iBAAA,GAAAX,sBAAA,CAAAH,OAAA;AAA6D,SAAAM,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,QAAA,MAAAC,CAAA,OAAAD,QAAA,IAAAE,CAAA,OAAAF,QAAA,YAAAX,uBAAA,YAAAA,CAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAA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D,IAAI,CAAC,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;AAAClF,OAAA,CAAA4E,UAAA,GAAAA,UAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@beinformed/ui",
|
|
3
|
-
"version": "1.65.
|
|
3
|
+
"version": "1.65.8",
|
|
4
4
|
"description": "Toolbox for be informed javascript layouts",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"bugs": "https://support.beinformed.com",
|
|
@@ -114,8 +114,8 @@
|
|
|
114
114
|
"eslint-config-prettier": "^10.1.8",
|
|
115
115
|
"eslint-plugin-babel": "^5.3.1",
|
|
116
116
|
"eslint-plugin-ft-flow": "^3.0.11",
|
|
117
|
-
"eslint-plugin-jest": "^29.
|
|
118
|
-
"eslint-plugin-jsdoc": "^
|
|
117
|
+
"eslint-plugin-jest": "^29.12.1",
|
|
118
|
+
"eslint-plugin-jsdoc": "^61.5.0",
|
|
119
119
|
"eslint-plugin-react": "^7.37.5",
|
|
120
120
|
"eslint-plugin-react-hooks": "^5.2.0",
|
|
121
121
|
"eslint-plugin-you-dont-need-lodash-underscore": "^6.14.0",
|
package/src/hooks/index.js
CHANGED
package/src/hooks/useForm.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import { useDispatch } from "react-redux";
|
|
3
3
|
|
|
4
|
-
import Href from "../models/href/Href";
|
|
5
|
-
|
|
6
4
|
import { getSetting, HTTP_METHODS } from "../constants";
|
|
7
5
|
|
|
8
6
|
import type {
|
|
9
7
|
RemoveModelByKeyAction,
|
|
10
8
|
UpdateFormAction,
|
|
11
9
|
} from "../redux/_modularui";
|
|
12
|
-
import {
|
|
13
|
-
|
|
10
|
+
import {
|
|
11
|
+
loadModularUI,
|
|
12
|
+
removeModelByKey,
|
|
13
|
+
} from "../redux/_modularui/ModularUIActions";
|
|
14
14
|
|
|
15
15
|
import {
|
|
16
16
|
addRepeatableAttributeSet,
|
|
@@ -22,8 +22,11 @@ import {
|
|
|
22
22
|
updateFormAttribute,
|
|
23
23
|
} from "../redux/actions";
|
|
24
24
|
|
|
25
|
+
import Href from "../models/href/Href";
|
|
25
26
|
import FormModel from "../models/form/FormModel";
|
|
26
27
|
|
|
28
|
+
import { useModularUI } from "./useModularUI";
|
|
29
|
+
|
|
27
30
|
import type { AttributeType, FormObjectModel, ModularUIModel } from "../models";
|
|
28
31
|
import type { UpdateFormOptions } from "../redux/types";
|
|
29
32
|
|
package/src/hooks/useList.js
CHANGED
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
// @flow
|
|
2
|
-
import {
|
|
2
|
+
import { useHistory } from "react-router";
|
|
3
3
|
import { useDispatch } from "react-redux";
|
|
4
|
+
|
|
5
|
+
import { useModularUIBasic } from "./useModularUIBasic";
|
|
4
6
|
import { HTTP_METHODS } from "../constants/Constants";
|
|
7
|
+
|
|
5
8
|
import { loadModularUI } from "../redux";
|
|
9
|
+
|
|
6
10
|
import DetailModel from "../models/detail/DetailModel";
|
|
7
11
|
import ListModel from "../models/list/ListModel";
|
|
8
12
|
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
9
13
|
import ListDetailModel from "../models/list/ListDetailModel";
|
|
10
14
|
import Href from "../models/href/Href";
|
|
15
|
+
import FilterCollection from "../models/filters/FilterCollection";
|
|
16
|
+
import AssignmentFilterModel from "../models/filters/AssignmentFilterModel";
|
|
17
|
+
import FilterModel from "../models/filters/FilterModel";
|
|
11
18
|
|
|
12
19
|
import type { HookOptions } from "./useModularUIBasic";
|
|
13
|
-
import {
|
|
20
|
+
import type { AttributeType, IFilter } from "../models/types";
|
|
14
21
|
|
|
15
22
|
type ListNavigationHook = {
|
|
16
23
|
update: (list: ListModel, resetPage?: boolean) => void,
|
|
24
|
+
updateFilters: (list: ListModel, filters: FilterCollection) => void,
|
|
25
|
+
updateFilter: (
|
|
26
|
+
list: ListModel,
|
|
27
|
+
filter: IFilter,
|
|
28
|
+
value: string,
|
|
29
|
+
attribute?: AttributeType,
|
|
30
|
+
) => void,
|
|
31
|
+
updateSort: (list: ListModel, sortOption: string) => void,
|
|
32
|
+
updatePage: (list: ListModel, page: number) => void,
|
|
33
|
+
updatePageSize: (list: ListModel, pagesize: number) => void,
|
|
34
|
+
resetFilters: (list: ListModel) => void,
|
|
35
|
+
removeFilter: (list: ListModel, filter: IFilter) => void,
|
|
17
36
|
};
|
|
18
37
|
|
|
19
38
|
/**
|
|
@@ -85,7 +104,60 @@ export const useListNavigation = (): ListNavigationHook => {
|
|
|
85
104
|
}
|
|
86
105
|
};
|
|
87
106
|
|
|
107
|
+
const updateFilters = (list: ListModel, filters: FilterCollection) => {
|
|
108
|
+
list.filterCollection = filters;
|
|
109
|
+
update(list, true);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const updateFilter = (
|
|
113
|
+
list: ListModel,
|
|
114
|
+
filter: IFilter,
|
|
115
|
+
value: string,
|
|
116
|
+
attribute?: AttributeType,
|
|
117
|
+
) => {
|
|
118
|
+
if (attribute) {
|
|
119
|
+
filter.update(attribute, value);
|
|
120
|
+
} else if (filter instanceof AssignmentFilterModel) {
|
|
121
|
+
throw new Error("Need the attribute to update for AssigmentFilterModel");
|
|
122
|
+
} else if (filter instanceof FilterModel) {
|
|
123
|
+
filter.update(filter.attribute, value);
|
|
124
|
+
}
|
|
125
|
+
update(list, true);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const resetFilters = (list: ListModel) => {
|
|
129
|
+
list.filterCollection.reset();
|
|
130
|
+
update(list, true);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const removeFilter = (list: ListModel, filter: IFilter) => {
|
|
134
|
+
list.filterCollection.getFilterByName(filter.name)?.reset();
|
|
135
|
+
update(list, true);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const updateSort = (list: ListModel, sortOption: string) => {
|
|
139
|
+
list.sorting.value = sortOption;
|
|
140
|
+
update(list, true);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const updatePage = (list: ListModel, page: number) => {
|
|
144
|
+
list.paging.page = page;
|
|
145
|
+
update(list);
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const updatePageSize = (list: ListModel, pagesize: number) => {
|
|
149
|
+
list.paging.pagesize.value = pagesize;
|
|
150
|
+
update(list);
|
|
151
|
+
};
|
|
152
|
+
|
|
88
153
|
return {
|
|
89
154
|
update,
|
|
155
|
+
updateFilters,
|
|
156
|
+
updateFilter,
|
|
157
|
+
updateSort,
|
|
158
|
+
updatePage,
|
|
159
|
+
updatePageSize,
|
|
160
|
+
resetFilters,
|
|
161
|
+
removeFilter,
|
|
90
162
|
};
|
|
91
163
|
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// @flow
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import { HTTP_METHODS } from "../constants";
|
|
5
|
+
|
|
6
|
+
import Href from "../models/href/Href";
|
|
7
|
+
import LinkModel from "../models/links/LinkModel";
|
|
8
|
+
import LookupOptionsModel from "../models/lookup/LookupOptionsModel";
|
|
9
|
+
|
|
10
|
+
import { useModularUIRequest } from "./useModularUIRequest";
|
|
11
|
+
import { useProgressIndicator } from "./useProgressIndicator";
|
|
12
|
+
|
|
13
|
+
type UseLookupHook = {
|
|
14
|
+
lookupOptions: LookupOptionsModel | null,
|
|
15
|
+
lookupLoading: boolean,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Lookup options call
|
|
20
|
+
*/
|
|
21
|
+
export const useLookup = (
|
|
22
|
+
lookupLink: LinkModel,
|
|
23
|
+
filterInput: string = "",
|
|
24
|
+
minLength: number = 2,
|
|
25
|
+
debounceMs: number = 300,
|
|
26
|
+
): UseLookupHook => {
|
|
27
|
+
const { start, finish } = useProgressIndicator();
|
|
28
|
+
const modularuiRequest = useModularUIRequest();
|
|
29
|
+
|
|
30
|
+
const [lookupOptions, setLookupOptions] = useState(null);
|
|
31
|
+
const [lookupLoading, setLookupLoading] = useState(false);
|
|
32
|
+
|
|
33
|
+
const { href, filterName, method } = lookupLink;
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (filterInput.length < minLength) {
|
|
37
|
+
setLookupOptions(null);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const timeoutId = setTimeout(async () => {
|
|
42
|
+
setLookupLoading(true);
|
|
43
|
+
start();
|
|
44
|
+
|
|
45
|
+
const lookupHref = new Href(href);
|
|
46
|
+
const requestOptions = { method, data: undefined };
|
|
47
|
+
if (method === HTTP_METHODS.POST) {
|
|
48
|
+
requestOptions.data = { [filterName]: filterInput };
|
|
49
|
+
} else {
|
|
50
|
+
lookupHref.addParameter(filterName, filterInput);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
modularuiRequest(lookupHref, requestOptions)
|
|
54
|
+
.fetch()
|
|
55
|
+
.then((lookupResponse) => {
|
|
56
|
+
if (lookupResponse instanceof LookupOptionsModel) {
|
|
57
|
+
setLookupOptions(lookupResponse);
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
.finally(() => {
|
|
61
|
+
finish();
|
|
62
|
+
setLookupLoading(false);
|
|
63
|
+
});
|
|
64
|
+
}, debounceMs);
|
|
65
|
+
|
|
66
|
+
return () => {
|
|
67
|
+
clearTimeout(timeoutId);
|
|
68
|
+
};
|
|
69
|
+
}, [
|
|
70
|
+
debounceMs,
|
|
71
|
+
filterInput,
|
|
72
|
+
filterName,
|
|
73
|
+
finish,
|
|
74
|
+
href,
|
|
75
|
+
method,
|
|
76
|
+
minLength,
|
|
77
|
+
modularuiRequest,
|
|
78
|
+
start,
|
|
79
|
+
]);
|
|
80
|
+
|
|
81
|
+
return { lookupOptions, lookupLoading };
|
|
82
|
+
};
|
package/src/hooks/usePanel.js
CHANGED
|
@@ -5,9 +5,10 @@ import Href from "../models/href/Href";
|
|
|
5
5
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
6
6
|
|
|
7
7
|
import type { HookOptions } from "./useModularUIBasic";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
8
|
+
import GroupingPanelModel from "../models/panels/GroupingPanelModel";
|
|
9
|
+
import ListModel from "../models/list/ListModel";
|
|
10
|
+
import DetailModel from "../models/detail/DetailModel";
|
|
11
|
+
import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
11
12
|
|
|
12
13
|
const useUrl = (href?: string | Href, fromRoute: boolean = false) => {
|
|
13
14
|
const [previousUrl, setPreviousUrl] = useState(null);
|
|
@@ -69,7 +70,8 @@ export const usePanel = (
|
|
|
69
70
|
|
|
70
71
|
const url = useUrl(href, fromRoute || false);
|
|
71
72
|
const basicOptions = {
|
|
72
|
-
expectedModels: ["List", "GroupingPanel", "Detail"],
|
|
73
|
+
expectedModels: ["List", "GroupingPanel", "Detail", "CaseSearch"],
|
|
74
|
+
targetModel: [ListModel, GroupingPanelModel, DetailModel, CaseSearchModel],
|
|
73
75
|
...(hookOptions: HookOptions),
|
|
74
76
|
};
|
|
75
77
|
|
|
@@ -7,27 +7,44 @@ import {
|
|
|
7
7
|
updateProgress,
|
|
8
8
|
} from "../redux/actions/ProgressIndicator";
|
|
9
9
|
import type { ProgressIndicatorState } from "../redux/types";
|
|
10
|
+
import { useCallback } from "react";
|
|
10
11
|
|
|
11
12
|
type ProgressIndicatorHook = {
|
|
12
|
-
...ProgressIndicatorState,
|
|
13
13
|
start: () => void,
|
|
14
14
|
finish: () => void,
|
|
15
15
|
reset: () => void,
|
|
16
16
|
update: (percentComplete: number) => void,
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
type ProgressIndicatorStateHook = {
|
|
20
|
+
...ProgressIndicatorState,
|
|
21
|
+
};
|
|
22
|
+
|
|
19
23
|
/**
|
|
20
24
|
*/
|
|
21
25
|
export const useProgressIndicator = (): ProgressIndicatorHook => {
|
|
22
26
|
const dispatch = useDispatch();
|
|
23
|
-
const progress = useSelector((state) => state.progressindicator);
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
const start = useCallback(() => {
|
|
29
|
+
dispatch(startProgress());
|
|
30
|
+
}, [dispatch]);
|
|
31
|
+
const finish = useCallback(() => {
|
|
32
|
+
dispatch(finishProgress());
|
|
33
|
+
}, [dispatch]);
|
|
34
|
+
const reset = useCallback(() => {
|
|
35
|
+
dispatch(resetProgress());
|
|
36
|
+
}, [dispatch]);
|
|
37
|
+
const update = useCallback(
|
|
38
|
+
(percentComplete: number) => {
|
|
39
|
+
dispatch(updateProgress(percentComplete));
|
|
40
|
+
},
|
|
41
|
+
[dispatch],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return { start, finish, reset, update };
|
|
33
45
|
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*/
|
|
49
|
+
export const useProgressIndicatorState = (): ProgressIndicatorStateHook =>
|
|
50
|
+
useSelector((state) => state.progressindicator);
|
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
RENDER_SECTION_LABEL,
|
|
14
14
|
SORT_OPTIONS,
|
|
15
15
|
} from "../../constants/LayoutHints";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
ATTRIBUTE_WIDTH,
|
|
18
|
+
PARAMETER_TYPES,
|
|
19
|
+
HTTP_METHODS,
|
|
20
|
+
} from "../../constants";
|
|
17
21
|
|
|
18
22
|
import type {
|
|
19
23
|
ModularUIModel,
|
|
@@ -133,7 +137,24 @@ export default class ChoiceAttributeModel extends AttributeModel {
|
|
|
133
137
|
* Retrieve lookup service link
|
|
134
138
|
*/
|
|
135
139
|
get lookupLink(): LinkModel | null {
|
|
136
|
-
|
|
140
|
+
const link = this.links.getLinkByKey("lookupOptions");
|
|
141
|
+
if (link && this.lookupParameterType === PARAMETER_TYPES.BODY) {
|
|
142
|
+
link.method = HTTP_METHODS.POST;
|
|
143
|
+
}
|
|
144
|
+
return link;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Indicate if the lookup must be done with POST or GET
|
|
149
|
+
*/
|
|
150
|
+
get lookupParameterType(): $Values<typeof PARAMETER_TYPES> {
|
|
151
|
+
const parameterType = this.getContribution("parameterType");
|
|
152
|
+
switch (parameterType) {
|
|
153
|
+
case "bodyParameter":
|
|
154
|
+
return PARAMETER_TYPES.BODY;
|
|
155
|
+
default:
|
|
156
|
+
return PARAMETER_TYPES.QUERY;
|
|
157
|
+
}
|
|
137
158
|
}
|
|
138
159
|
|
|
139
160
|
/**
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
// @flow
|
|
2
2
|
import BaseFilterModel from "../filters/BaseFilterModel";
|
|
3
3
|
|
|
4
|
-
import type { AttributeType, ModelOptions } from "../types";
|
|
4
|
+
import type { IFilter, AttributeType, ModelOptions } from "../types";
|
|
5
5
|
import { IllegalStateException } from "../../exceptions";
|
|
6
6
|
import createAttribute from "../attributes/_createAttribute";
|
|
7
|
+
|
|
7
8
|
/**
|
|
8
9
|
* Assignment filter consists of two filters: assignment type and user filter
|
|
9
10
|
*/
|
|
10
|
-
export default class AssignmentFilterModel
|
|
11
|
+
export default class AssignmentFilterModel
|
|
12
|
+
extends BaseFilterModel
|
|
13
|
+
implements IFilter
|
|
14
|
+
{
|
|
11
15
|
_listKey: string;
|
|
12
16
|
_assignmenttype: AttributeType;
|
|
13
17
|
_user: AttributeType;
|
|
@@ -26,18 +30,6 @@ export default class AssignmentFilterModel extends BaseFilterModel {
|
|
|
26
30
|
this._user = this.createUserModel();
|
|
27
31
|
}
|
|
28
32
|
|
|
29
|
-
/**
|
|
30
|
-
*/
|
|
31
|
-
get key(): ?string {
|
|
32
|
-
return this.data.name;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
*/
|
|
37
|
-
get contextid(): string {
|
|
38
|
-
return this.getContribution("contextid", "");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
33
|
/**
|
|
42
34
|
* Creates an assignmenttype model when assignmenttype json is present
|
|
43
35
|
*/
|
|
@@ -29,6 +29,12 @@ export default class BaseFilterModel extends BaseModel {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
*/
|
|
34
|
+
get key(): string {
|
|
35
|
+
return this.data.name;
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
/**
|
|
33
39
|
* Get the type of a filter.
|
|
34
40
|
*/
|
|
@@ -72,6 +78,12 @@ export default class BaseFilterModel extends BaseModel {
|
|
|
72
78
|
this._context = context;
|
|
73
79
|
}
|
|
74
80
|
|
|
81
|
+
/**
|
|
82
|
+
*/
|
|
83
|
+
get contextid(): string {
|
|
84
|
+
return this.getContribution("contextid", "");
|
|
85
|
+
}
|
|
86
|
+
|
|
75
87
|
/**
|
|
76
88
|
* Getting the context label
|
|
77
89
|
*/
|
|
@@ -2,12 +2,15 @@
|
|
|
2
2
|
import FilterModel from "../filters/FilterModel";
|
|
3
3
|
import ChoiceAttributeModel from "../attributes/ChoiceAttributeModel";
|
|
4
4
|
|
|
5
|
-
import type { ModelOptions } from "../types";
|
|
5
|
+
import type { IFilter, ModelOptions } from "../types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* The concept index model is a special filter used to index all first concept label letters in de modelcatalog.
|
|
9
9
|
*/
|
|
10
|
-
export default class ConceptIndexFilterModel
|
|
10
|
+
export default class ConceptIndexFilterModel
|
|
11
|
+
extends FilterModel
|
|
12
|
+
implements IFilter
|
|
13
|
+
{
|
|
11
14
|
/**
|
|
12
15
|
* Construct a filter
|
|
13
16
|
*/
|
|
@@ -8,13 +8,13 @@ import ConceptIndexFilterModel from "../filters/ConceptIndexFilterModel";
|
|
|
8
8
|
import CompositeAttributeModel from "../attributes/CompositeAttributeModel";
|
|
9
9
|
import FilterModel from "../filters/FilterModel";
|
|
10
10
|
|
|
11
|
-
import type { AttributeType,
|
|
11
|
+
import type { AttributeType, IFilter, ModelOptions } from "../types";
|
|
12
12
|
import { PARAMETER_TYPES } from "../../constants";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Contains a collection of filters
|
|
16
16
|
*/
|
|
17
|
-
export default class FilterCollection extends BaseCollection<
|
|
17
|
+
export default class FilterCollection extends BaseCollection<IFilter> {
|
|
18
18
|
/**
|
|
19
19
|
* Construct a collection of filters
|
|
20
20
|
*/
|
|
@@ -68,7 +68,7 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
68
68
|
data: Object,
|
|
69
69
|
contributions: Object,
|
|
70
70
|
modelOptions?: ModelOptions,
|
|
71
|
-
):
|
|
71
|
+
): IFilter {
|
|
72
72
|
const type = contributions.type || "stringfilter";
|
|
73
73
|
if (type === "choicefilter" && filterKey === "index") {
|
|
74
74
|
return new ConceptIndexFilterModel(data, contributions, modelOptions);
|
|
@@ -92,7 +92,7 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
92
92
|
/**
|
|
93
93
|
* Call the reset function on all filters
|
|
94
94
|
*
|
|
95
|
-
* @see {
|
|
95
|
+
* @see {IFilter#reset()}
|
|
96
96
|
*/
|
|
97
97
|
reset(): FilterCollection {
|
|
98
98
|
this.collection = this.collection.map((filter) => filter.reset());
|
|
@@ -134,10 +134,16 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
134
134
|
);
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
*/
|
|
139
|
+
getFilterByName(name: string): IFilter | null {
|
|
140
|
+
return this.find((filter) => filter.name === name) || null;
|
|
141
|
+
}
|
|
142
|
+
|
|
137
143
|
/**
|
|
138
144
|
* Getting the filter by name
|
|
139
145
|
*/
|
|
140
|
-
getFilterByAttributeKey(key: string):
|
|
146
|
+
getFilterByAttributeKey(key: string): IFilter | null {
|
|
141
147
|
return (
|
|
142
148
|
this.find((filter) => {
|
|
143
149
|
if (filter instanceof RangeFilterModel) {
|
|
@@ -148,7 +154,11 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
148
154
|
return this.checkAssignmentFilterByAttributeKey(filter, key);
|
|
149
155
|
}
|
|
150
156
|
|
|
151
|
-
|
|
157
|
+
if (filter instanceof FilterModel) {
|
|
158
|
+
return filter.attribute.key === key;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return false;
|
|
152
162
|
}) || null
|
|
153
163
|
);
|
|
154
164
|
}
|
|
@@ -191,6 +201,13 @@ export default class FilterCollection extends BaseCollection<FilterType> {
|
|
|
191
201
|
return this.collection.some((filter) => filter.isActive());
|
|
192
202
|
}
|
|
193
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Retrieve all filters with a value
|
|
206
|
+
*/
|
|
207
|
+
getActiveFilters(): Array<IFilter> {
|
|
208
|
+
return this.collection.filter((filter) => filter.isActive());
|
|
209
|
+
}
|
|
210
|
+
|
|
194
211
|
/**
|
|
195
212
|
*/
|
|
196
213
|
get formdata(): { [string]: any } | null {
|
|
@@ -3,11 +3,11 @@ import BaseFilterModel from "../filters/BaseFilterModel";
|
|
|
3
3
|
import createAttribute from "../attributes/_createAttribute";
|
|
4
4
|
import { IllegalStateException } from "../../exceptions";
|
|
5
5
|
|
|
6
|
-
import type { AttributeType, ModelOptions } from "../types";
|
|
6
|
+
import type { AttributeType, IFilter, ModelOptions } from "../types";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
*/
|
|
10
|
-
export default class FilterModel extends BaseFilterModel {
|
|
10
|
+
export default class FilterModel extends BaseFilterModel implements IFilter {
|
|
11
11
|
_attribute: AttributeType | null = null;
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
import FilterModel from "../filters/FilterModel";
|
|
3
3
|
|
|
4
4
|
import CompositeAttributeModel from "../attributes/CompositeAttributeModel";
|
|
5
|
-
import type { AttributeType } from "../types";
|
|
5
|
+
import type { AttributeType, IFilter } from "../types";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Range filter, for instance a date range filter or a number range filter
|
|
9
9
|
*/
|
|
10
|
-
export default class RangeFilterModel extends FilterModel {
|
|
10
|
+
export default class RangeFilterModel extends FilterModel implements IFilter {
|
|
11
11
|
/**
|
|
12
12
|
*/
|
|
13
13
|
update(attribute: AttributeType, value: string) {
|