@beinformed/ui 1.65.6 → 1.65.7
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 +9 -0
- package/esm/hooks/__tests__/UseModularUIModel.spec.js.flow +1 -0
- 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/usePanel.js +6 -1
- package/esm/hooks/usePanel.js.flow +6 -4
- package/esm/hooks/usePanel.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/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/useList.js +47 -3
- package/lib/hooks/useList.js.map +1 -1
- package/lib/hooks/usePanel.js +6 -1
- package/lib/hooks/usePanel.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/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 +1 -1
- package/src/hooks/__tests__/UseModularUIModel.spec.js +1 -0
- package/src/hooks/useList.js +74 -2
- package/src/hooks/usePanel.js +6 -4
- 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/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":["createMemoryHistory","has","deepmerge","configureStore","availableLocales","Locales","getPreferredLocale","setLocales","setServerPreference","setThemePreference","setPreference","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","getEnabledLocales","IllegalArgumentException","initModels","getLocale","ModularUIRequest","createReduxStore","requestHref","customReducers","initialState","history","initialEntries","toString","store","setI18n","locales","request","Array","isArray","mergedLocales","_mapInstanceProperty","call","locale","code","customLocale","_findInstanceProperty","custLocale","forEach","some","push","enabledLocales","_filterInstanceProperty","_context","_includesInstanceProperty","localesInstance","preferredLocale","dispatch","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreferences","preferencesProvider","isStudioContext","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWithInstanceProperty","dataFetcher","fetch","Error","setApplication","getState","application","fetchSync","connectKey","key","model","e","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","undefined","filteredState","_JSON$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,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,EACnBC,mBAAmB,QACd,8BAA8B;AAErC,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD,SAASC,wBAAwB,QAAQ,eAAe;AAExD,SAASC,UAAU,QAAQ,UAAU;AACrC,SAASC,SAAS,QAAQ,yBAAyB;AAEnD,OAAOC,gBAAgB,MAAM,+BAA+B;AAa5D;AACA;AACA,MAAMC,gBAAgB,GAAGA,CACvBC,WAAiB,EACjBC,cAAsB,EACtBC,YAAiC,KAClB;EACf;EACA,MAAMC,OAAsB,GAAGvB,mBAAmB,CAAC;IACjDwB,cAAc,EAAE,CAACJ,WAAW,CAACK,QAAQ,CAAC,CAAC;EACzC,CAAC,CAAC;EAEF,MAAM;IAAEC;EAAM,CAAC,GAAGvB,cAAc,C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AAC,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;AAED,SACE3E,gBAAgB,EAChBQ,OAAO,EACPyC,cAAc,EACdZ,oBAAoB,EACpBG,qBAAqB,EACrB6B,UAAU,EACVZ,YAAY,EACZI,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"serverUtil.js","names":["createMemoryHistory","has","deepmerge","configureStore","availableLocales","Locales","getPreferredLocale","setLocales","setServerPreference","setThemePreference","setPreference","setAllContentInDataSetting","setLoginPreferences","setDateTimeSettings","getEnabledLocales","IllegalArgumentException","initModels","getLocale","ModularUIRequest","createReduxStore","requestHref","customReducers","initialState","history","initialEntries","toString","store","setI18n","locales","request","Array","isArray","mergedLocales","_mapInstanceProperty","call","locale","code","customLocale","_findInstanceProperty","custLocale","forEach","some","push","enabledLocales","_filterInstanceProperty","_context","_includesInstanceProperty","localesInstance","preferredLocale","dispatch","setServerPreferencesFromArray","serverPreferences","serverPreference","name","defaultValue","type","setServerPreferences","preferencesProvider","isStudioContext","setConfigurationTheme","configTheme","configFileLocation","getLayoutConfigFileLocation","configFilePath","_startsWithInstanceProperty","dataFetcher","fetch","Error","setApplication","getState","application","fetchSync","connectKey","key","model","e","handleErrors","state","error","shouldThrowOnServer","dehydrate","modularui","status","lastModification","undefined","filteredState","_JSON$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,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,U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E;MACTO,SAAS,CAACR,GAAG,CAAC,GAAG;QACfS,MAAM;QACNC,gBAAgB;QAChBT,KAAK,EAAEA,KAAK,CAACM,SAAS,CAAC;MACzB,CAAC;IACH,CAAC,MAAM;MACLC,SAAS,CAACR,GAAG,CAAC,GAAG;QACfS,MAAM;QACNC,gBAAgB;QAChBT,KAAK,EAAEU;MACT,CAAC;IACH;EACF;EAEA,MAAMC,aAAa,GAAG;IACpB,GAAGR,KAAK;IACRI;EACF,CAAC;EAED,OAAOK,eAAA,CAAeD,aAAa,CAAC,CAACE,OAAO,CAAC,IAAI,EAAE,SAAS,CAAC;AAC/D,CAAC;;AAED;AACA;AACA,MAAMC,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;AAED,SACE3E,gBAAgB,EAChBQ,OAAO,EACPyC,cAAc,EACdZ,oBAAoB,EACpBG,qBAAqB,EACrB6B,UAAU,EACVZ,YAAY,EACZI,SAAS","ignoreList":[]}
|
package/lib/hooks/useList.js
CHANGED
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.useListOrDetail = exports.useListNavigation = exports.useListDetail = exports.useList = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _reactRouter = require("react-router");
|
|
9
9
|
var _reactRedux = require("react-redux");
|
|
10
|
+
var _useModularUIBasic = require("./useModularUIBasic");
|
|
10
11
|
var _Constants = require("../constants/Constants");
|
|
11
12
|
var _redux = require("../redux");
|
|
12
13
|
var _DetailModel = _interopRequireDefault(require("../models/detail/DetailModel"));
|
|
@@ -14,7 +15,9 @@ var _ListModel = _interopRequireDefault(require("../models/list/ListModel"));
|
|
|
14
15
|
var _CaseSearchModel = _interopRequireDefault(require("../models/search/CaseSearchModel"));
|
|
15
16
|
var _ListDetailModel = _interopRequireDefault(require("../models/list/ListDetailModel"));
|
|
16
17
|
var _Href = _interopRequireDefault(require("../models/href/Href"));
|
|
17
|
-
var
|
|
18
|
+
var _FilterCollection = _interopRequireDefault(require("../models/filters/FilterCollection"));
|
|
19
|
+
var _AssignmentFilterModel = _interopRequireDefault(require("../models/filters/AssignmentFilterModel"));
|
|
20
|
+
var _FilterModel = _interopRequireDefault(require("../models/filters/FilterModel"));
|
|
18
21
|
/**
|
|
19
22
|
*/
|
|
20
23
|
const useList = (href, options) => (0, _useModularUIBasic.useModularUIBasic)("list", href, {
|
|
@@ -73,8 +76,49 @@ const useListNavigation = () => {
|
|
|
73
76
|
}));
|
|
74
77
|
}
|
|
75
78
|
};
|
|
79
|
+
const updateFilters = (list, filters) => {
|
|
80
|
+
list.filterCollection = filters;
|
|
81
|
+
update(list, true);
|
|
82
|
+
};
|
|
83
|
+
const updateFilter = (list, filter, value, attribute) => {
|
|
84
|
+
if (attribute) {
|
|
85
|
+
filter.update(attribute, value);
|
|
86
|
+
} else if (filter instanceof _AssignmentFilterModel.default) {
|
|
87
|
+
throw new Error("Need the attribute to update for AssigmentFilterModel");
|
|
88
|
+
} else if (filter instanceof _FilterModel.default) {
|
|
89
|
+
filter.update(filter.attribute, value);
|
|
90
|
+
}
|
|
91
|
+
update(list, true);
|
|
92
|
+
};
|
|
93
|
+
const resetFilters = list => {
|
|
94
|
+
list.filterCollection.reset();
|
|
95
|
+
update(list, true);
|
|
96
|
+
};
|
|
97
|
+
const removeFilter = (list, filter) => {
|
|
98
|
+
list.filterCollection.getFilterByName(filter.name)?.reset();
|
|
99
|
+
update(list, true);
|
|
100
|
+
};
|
|
101
|
+
const updateSort = (list, sortOption) => {
|
|
102
|
+
list.sorting.value = sortOption;
|
|
103
|
+
update(list, true);
|
|
104
|
+
};
|
|
105
|
+
const updatePage = (list, page) => {
|
|
106
|
+
list.paging.page = page;
|
|
107
|
+
update(list);
|
|
108
|
+
};
|
|
109
|
+
const updatePageSize = (list, pagesize) => {
|
|
110
|
+
list.paging.pagesize.value = pagesize;
|
|
111
|
+
update(list);
|
|
112
|
+
};
|
|
76
113
|
return {
|
|
77
|
-
update
|
|
114
|
+
update,
|
|
115
|
+
updateFilters,
|
|
116
|
+
updateFilter,
|
|
117
|
+
updateSort,
|
|
118
|
+
updatePage,
|
|
119
|
+
updatePageSize,
|
|
120
|
+
resetFilters,
|
|
121
|
+
removeFilter
|
|
78
122
|
};
|
|
79
123
|
};
|
|
80
124
|
exports.useListNavigation = useListNavigation;
|
package/lib/hooks/useList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.js","names":["
|
|
1
|
+
{"version":3,"file":"useList.js","names":["_reactRouter","require","_reactRedux","_useModularUIBasic","_Constants","_redux","_DetailModel","_interopRequireDefault","_ListModel","_CaseSearchModel","_ListDetailModel","_Href","_FilterCollection","_AssignmentFilterModel","_FilterModel","useList","href","options","useModularUIBasic","expectedModels","targetModel","ListModel","CaseSearchModel","exports","useListOrDetail","DetailModel","useListDetail","ListDetailModel","forceTargetModel","useListNavigation","history","useHistory","dispatch","useDispatch","update","list","resetPage","listHref","selfhref","page","requestMethod","HTTP_METHODS","POST","push","search","querystring","state","formdata","loadModularUI","connectKey","method","data","GET","updateFilters","filters","filterCollection","updateFilter","filter","value","attribute","AssignmentFilterModel","Error","FilterModel","resetFilters","reset","removeFilter","getFilterByName","name","updateSort","sortOption","sorting","updatePage","paging","updatePageSize","pagesize"],"sources":["../../src/hooks/useList.js"],"sourcesContent":["// @flow\nimport { useHistory } from \"react-router\";\nimport { useDispatch } from \"react-redux\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\nimport { HTTP_METHODS } from \"../constants/Constants\";\n\nimport { loadModularUI } from \"../redux\";\n\nimport DetailModel from \"../models/detail/DetailModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport Href from \"../models/href/Href\";\nimport FilterCollection from \"../models/filters/FilterCollection\";\nimport AssignmentFilterModel from \"../models/filters/AssignmentFilterModel\";\nimport FilterModel from \"../models/filters/FilterModel\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport type { AttributeType, IFilter } from \"../models/types\";\n\ntype ListNavigationHook = {\n update: (list: ListModel, resetPage?: boolean) => void,\n updateFilters: (list: ListModel, filters: FilterCollection) => void,\n updateFilter: (\n list: ListModel,\n filter: IFilter,\n value: string,\n attribute?: AttributeType,\n ) => void,\n updateSort: (list: ListModel, sortOption: string) => void,\n updatePage: (list: ListModel, page: number) => void,\n updatePageSize: (list: ListModel, pagesize: number) => void,\n resetFilters: (list: ListModel) => void,\n removeFilter: (list: ListModel, filter: IFilter) => void,\n};\n\n/**\n */\nexport const useList = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"CaseSearch\"],\n targetModel: [ListModel, CaseSearchModel],\n ...options,\n });\n\n/**\n */\nexport const useListOrDetail = (\n href: string | Href,\n options?: HookOptions,\n): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"CaseSearch\", \"Detail\"],\n targetModel: [ListModel, CaseSearchModel, DetailModel],\n ...options,\n });\n\n/**\n */\nexport const useListDetail = (\n href: string | Href,\n options?: HookOptions,\n): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n forceTargetModel: true,\n ...options,\n });\n\n/**\n */\nexport const useListNavigation = (): ListNavigationHook => {\n const history = useHistory();\n const dispatch = useDispatch();\n\n const update = (list: ListModel, resetPage: boolean = false) => {\n const listHref = list.selfhref;\n if (resetPage) {\n listHref.page = null;\n }\n\n if (list.requestMethod === HTTP_METHODS.POST) {\n history.push({ search: listHref.querystring, state: list.formdata });\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.POST,\n data: list.formdata,\n targetModel: [ListModel, CaseSearchModel],\n }),\n );\n } else {\n history.push({ search: listHref.querystring });\n dispatch(\n loadModularUI(list.connectKey, listHref, {\n method: HTTP_METHODS.GET,\n targetModel: [ListModel, CaseSearchModel],\n }),\n );\n }\n };\n\n const updateFilters = (list: ListModel, filters: FilterCollection) => {\n list.filterCollection = filters;\n update(list, true);\n };\n\n const updateFilter = (\n list: ListModel,\n filter: IFilter,\n value: string,\n attribute?: AttributeType,\n ) => {\n if (attribute) {\n filter.update(attribute, value);\n } else if (filter instanceof AssignmentFilterModel) {\n throw new Error(\"Need the attribute to update for AssigmentFilterModel\");\n } else if (filter instanceof FilterModel) {\n filter.update(filter.attribute, value);\n }\n update(list, true);\n };\n\n const resetFilters = (list: ListModel) => {\n list.filterCollection.reset();\n update(list, true);\n };\n\n const removeFilter = (list: ListModel, filter: IFilter) => {\n list.filterCollection.getFilterByName(filter.name)?.reset();\n update(list, true);\n };\n\n const updateSort = (list: ListModel, sortOption: string) => {\n list.sorting.value = sortOption;\n update(list, true);\n };\n\n const updatePage = (list: ListModel, page: number) => {\n list.paging.page = page;\n update(list);\n };\n\n const updatePageSize = (list: ListModel, pagesize: number) => {\n list.paging.pagesize.value = pagesize;\n update(list);\n };\n\n return {\n update,\n updateFilters,\n updateFilter,\n updateSort,\n updatePage,\n updatePageSize,\n resetFilters,\n removeFilter,\n };\n};\n"],"mappings":";;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAE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AED,MAAMsC,cAAc,GAAGA,CAACtC,IAAe,EAAEuC,QAAgB,KAAK;IAC5DvC,IAAI,CAACqC,MAAM,CAACE,QAAQ,CAAChB,KAAK,GAAGgB,QAAQ;IACrCxC,MAAM,CAACC,IAAI,CAAC;EACd,CAAC;EAED,OAAO;IACLD,MAAM;IACNmB,aAAa;IACbG,YAAY;IACZY,UAAU;IACVG,UAAU;IACVE,cAAc;IACdV,YAAY;IACZE;EACF,CAAC;AACH,CAAC;AAAC1C,OAAA,CAAAM,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
package/lib/hooks/usePanel.js
CHANGED
|
@@ -10,6 +10,10 @@ var _react = require("react");
|
|
|
10
10
|
var _reactRouter = require("react-router");
|
|
11
11
|
var _Href = _interopRequireDefault(require("../models/href/Href"));
|
|
12
12
|
var _useModularUIBasic = require("./useModularUIBasic");
|
|
13
|
+
var _GroupingPanelModel = _interopRequireDefault(require("../models/panels/GroupingPanelModel"));
|
|
14
|
+
var _ListModel = _interopRequireDefault(require("../models/list/ListModel"));
|
|
15
|
+
var _DetailModel = _interopRequireDefault(require("../models/detail/DetailModel"));
|
|
16
|
+
var _CaseSearchModel = _interopRequireDefault(require("../models/search/CaseSearchModel"));
|
|
13
17
|
const useUrl = (href, fromRoute = false) => {
|
|
14
18
|
const [previousUrl, setPreviousUrl] = (0, _react.useState)(null);
|
|
15
19
|
const [previousExact, setPreviousExact] = (0, _react.useState)(false);
|
|
@@ -53,7 +57,8 @@ const usePanel = (href, options) => {
|
|
|
53
57
|
};
|
|
54
58
|
const url = useUrl(href, fromRoute || false);
|
|
55
59
|
const basicOptions = {
|
|
56
|
-
expectedModels: ["List", "GroupingPanel", "Detail"],
|
|
60
|
+
expectedModels: ["List", "GroupingPanel", "Detail", "CaseSearch"],
|
|
61
|
+
targetModel: [_ListModel.default, _GroupingPanelModel.default, _DetailModel.default, _CaseSearchModel.default],
|
|
57
62
|
...hookOptions
|
|
58
63
|
};
|
|
59
64
|
return (0, _useModularUIBasic.useModularUIBasic)("panel", url, basicOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePanel.js","names":["_react","require","_reactRouter","_Href","_interopRequireDefault","_useModularUIBasic","useUrl","href","fromRoute","previousUrl","setPreviousUrl","useState","previousExact","setPreviousExact","match","useRouteMatch","location","useLocation","useMemo","_context","Href","url","isExact","addParametersFromString","search","equalsWithParameters","shouldUpdate","Function","call","bind","_startsWith","default","usePanel","options","hookOptions","basicOptions","expectedModels","useModularUIBasic","exports"],"sources":["../../src/hooks/usePanel.js"],"sourcesContent":["// @flow\nimport { useState, useMemo } from \"react\";\nimport { useLocation, useRouteMatch } from \"react-router\";\nimport Href from \"../models/href/Href\";\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport
|
|
1
|
+
{"version":3,"file":"usePanel.js","names":["_react","require","_reactRouter","_Href","_interopRequireDefault","_useModularUIBasic","_GroupingPanelModel","_ListModel","_DetailModel","_CaseSearchModel","useUrl","href","fromRoute","previousUrl","setPreviousUrl","useState","previousExact","setPreviousExact","match","useRouteMatch","location","useLocation","useMemo","_context","Href","url","isExact","addParametersFromString","search","equalsWithParameters","shouldUpdate","Function","call","bind","_startsWith","default","usePanel","options","hookOptions","basicOptions","expectedModels","targetModel","ListModel","GroupingPanelModel","DetailModel","CaseSearchModel","useModularUIBasic","exports"],"sources":["../../src/hooks/usePanel.js"],"sourcesContent":["// @flow\nimport { useState, useMemo } from \"react\";\nimport { useLocation, useRouteMatch } from \"react-router\";\nimport Href from \"../models/href/Href\";\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\nimport type { HookOptions } from \"./useModularUIBasic\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\n\nconst useUrl = (href?: string | Href, fromRoute: boolean = false) => {\n const [previousUrl, setPreviousUrl] = useState(null);\n const [previousExact, setPreviousExact] = useState(false);\n\n const match = useRouteMatch();\n const location = useLocation();\n\n return useMemo(() => {\n if (href == null && previousUrl == null) {\n return new Href(\"\");\n }\n\n const url = href instanceof Href ? href : new Href(href);\n\n if (!fromRoute) {\n return url;\n }\n\n if (match.isExact) {\n url.addParametersFromString(location.search);\n }\n\n // Check equality to prevent unnecessary state updates\n if (url.equalsWithParameters(previousUrl)) {\n return previousUrl || url;\n }\n\n const shouldUpdate =\n match.isExact === true ||\n previousExact === match.isExact ||\n !previousUrl?.startsWith(match.url);\n\n if (shouldUpdate) {\n setPreviousUrl(url);\n setPreviousExact(match.isExact);\n return url;\n }\n\n return previousUrl || new Href(\"\");\n }, [\n href,\n previousUrl,\n fromRoute,\n match.isExact,\n match.url,\n previousExact,\n location.search,\n ]);\n};\n\n/**\n */\nexport const usePanel = (\n href?: string | Href,\n options?: HookOptions & { fromRoute?: boolean },\n): ListModel | GroupingPanelModel | DetailModel | null => {\n const { fromRoute, ...hookOptions } = options || { fromRoute: false };\n\n const url = useUrl(href, fromRoute || false);\n const basicOptions = {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\", \"CaseSearch\"],\n targetModel: [ListModel, GroupingPanelModel, DetailModel, CaseSearchModel],\n ...(hookOptions: HookOptions),\n };\n\n return useModularUIBasic(\"panel\", url, basicOptions);\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AAGA,IAAAK,mBAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,UAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,YAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,gBAAA,GAAAL,sBAAA,CAAAH,OAAA;AAEA,MAAMS,MAAM,GAAGA,CA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,GAAG;IACZ;IAEA,OAAOZ,WAAW,IAAI,IAAIW,aAAI,CAAC,EAAE,CAAC;EACpC,CAAC,EAAE,CACDb,IAAI,EACJE,WAAW,EACXD,SAAS,EACTM,KAAK,CAACQ,OAAO,EACbR,KAAK,CAACO,GAAG,EACTT,aAAa,EACbI,QAAQ,CAACQ,MAAM,CAChB,CAAC;AACJ,CAAC;;AAED;AACA;AACO,MAAMQ,QAAQ,GAAGA,CACtBzB,IAAoB,EACpB0B,OAA+C,KACS;EACxD,MAAM;IAAEzB,SAAS;IAAE,GAAG0B;EAAY,CAAC,GAAGD,OAAO,IAAI;IAAEzB,SAAS,EAAE;EAAM,CAAC;EAErE,MAAMa,GAAG,GAAGf,MAAM,CAACC,IAAI,EAAEC,SAAS,IAAI,KAAK,CAAC;EAC5C,MAAM2B,YAAY,GAAG;IACnBC,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,CAAC;IACjEC,WAAW,EAAE,CAACC,kBAAS,EAAEC,2BAAkB,EAAEC,oBAAW,EAAEC,wBAAe,CAAC;IAC1E,GAAIP;EACN,CAAC;EAED,OAAO,IAAAQ,oCAAiB,EAAC,OAAO,EAAErB,GAAG,EAAEc,YAAY,CAAC;AACtD,CAAC;AAACQ,OAAA,CAAAX,QAAA,GAAAA,QAAA","ignoreList":[]}
|
|
@@ -25,18 +25,6 @@ class AssignmentFilterModel extends _BaseFilterModel.default {
|
|
|
25
25
|
this._user = this.createUserModel();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
/**
|
|
29
|
-
*/
|
|
30
|
-
get key() {
|
|
31
|
-
return this.data.name;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
*/
|
|
36
|
-
get contextid() {
|
|
37
|
-
return this.getContribution("contextid", "");
|
|
38
|
-
}
|
|
39
|
-
|
|
40
28
|
/**
|
|
41
29
|
* Creates an assignmenttype model when assignmenttype json is present
|
|
42
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssignmentFilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","_exceptions","_createAttribute","AssignmentFilterModel","BaseFilterModel","constructor","data","contributions","modelOptions","_defineProperty2","default","_assignmenttype","createAssignmentTypeModel","_user","createUserModel","key","name","contextid","getContribution","assignmentTypeData","IllegalStateException","dynamicschema","assignmentTypeContributions","type","enumerated","optionMode","_links","createAttribute","param","userData","userContributions","assignmenttype","user","params","value","inputvalue","hasValue","reset","update","attribute","isActive","initvalue","isValid","readonlyvalue","formdata","exports"],"sources":["../../../src/models/filters/AssignmentFilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"../filters/BaseFilterModel\";\n\nimport type { AttributeType, ModelOptions } from \"../types\";\nimport { IllegalStateException } from \"../../exceptions\";\nimport createAttribute from \"../attributes/_createAttribute\";\n/**\n * Assignment filter consists of two filters: assignment type and user filter\n */\nexport default class AssignmentFilterModel extends BaseFilterModel {\n _listKey: string;\n _assignmenttype: AttributeType;\n _user: AttributeType;\n\n /**\n * Construct an assignment filter\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n this._assignmenttype = this.createAssignmentTypeModel();\n this._user = this.createUserModel();\n }\n\n /**\n */\n get key(): ?string {\n return this.data.name;\n }\n\n /**\n */\n get contextid(): string {\n return this.getContribution(\"contextid\", \"\");\n }\n\n /**\n * Creates an assignmenttype model when assignmenttype json is present\n */\n createAssignmentTypeModel(): AttributeType {\n const key = `${this.contextid}ASSIGNMENTTYPE`;\n const assignmentTypeData = this.data[key];\n\n if (typeof assignmentTypeData === \"undefined\") {\n throw new IllegalStateException(\n `Missing assignment type data for ${key}`,\n );\n }\n\n if (this.data.dynamicschema && this.data.dynamicschema[key]) {\n assignmentTypeData.dynamicschema = {\n [key]: this.data.dynamicschema[key],\n };\n }\n\n const assignmentTypeContributions = {\n ...this.contributions[key],\n type: \"choice\",\n enumerated: true,\n optionMode: assignmentTypeData._links ? \"lookup\" : \"static\",\n };\n\n return createAttribute(\n assignmentTypeData.name || assignmentTypeData.param,\n assignmentTypeData,\n assignmentTypeContributions,\n this.modelOptions,\n );\n }\n\n /**\n * Creates an assignmenttype model when userkey json is present\n */\n createUserModel(): AttributeType {\n const key = `${this.contextid}USERKEY`;\n const userData = this.data[key];\n\n if (this.data.dynamicschema && this.data.dynamicschema[key]) {\n userData.dynamicschema = {\n [key]: this.data.dynamicschema[key],\n };\n }\n\n const userContributions = {\n ...this.contributions[key],\n type: \"choice\",\n enumerated: true,\n optionMode: userData._links ? \"lookup\" : \"static\",\n };\n\n return createAttribute(\n userData.name || userData.param,\n userData,\n userContributions,\n this.modelOptions,\n );\n }\n\n /**\n * The assignment filter consists of two part. This method return the assignment type attribute\n */\n get assignmenttype(): AttributeType {\n return this._assignmenttype;\n }\n\n /**\n * The assignment filter consists of two part. This method return the user identifier attribute\n */\n get user(): AttributeType {\n return this._user;\n }\n\n /**\n * Getting the parameters of this filter\n */\n get params(): Array<{ name: string, value: ?string }> {\n return [\n {\n name: this.assignmenttype.name,\n value: this.assignmenttype.value,\n },\n {\n name: this.user.name,\n value: this.user.value,\n },\n ];\n }\n\n /**\n */\n get value(): { [string]: any } {\n return {\n [this.assignmenttype.name]: this.assignmenttype.value,\n [this.user.name]: this.user.value,\n };\n }\n\n /**\n */\n get inputvalue(): { [string]: any } {\n return {\n [this.assignmenttype.name]: this.assignmenttype.inputvalue,\n [this.user.name]: this.user.inputvalue,\n };\n }\n\n /**\n * Indicates if the filter has a value.\n */\n hasValue(): boolean {\n return (\n (this.assignmenttype.value !== null &&\n this.assignmenttype.value !== \"\") ||\n (this.user.value !== null && this.user.value !== \"\")\n );\n }\n\n /**\n * Reset the values within the filter\n */\n reset(): AssignmentFilterModel {\n if (this.assignmenttype) {\n this.assignmenttype.reset();\n }\n if (this.user) {\n this.user.reset();\n }\n\n return this;\n }\n\n /**\n * Update this filter\n */\n update(attribute: AttributeType, value: string) {\n if (this.user != null && this.user.key === attribute.key) {\n this.user.update(value);\n } else if (\n this.assignmenttype != null &&\n this.assignmenttype.key === attribute.key\n ) {\n this.assignmenttype.update(value);\n }\n }\n\n /**\n * Inidiates if filter is active\n */\n isActive(): boolean {\n return (\n (this.assignmenttype != null && this.assignmenttype.initvalue !== null) ||\n (this.user != null && this.user.initvalue !== null)\n );\n }\n\n /**\n * Inidiates if filter is valid\n */\n get isValid(): boolean {\n return (\n this.assignmenttype != null &&\n this.assignmenttype.isValid &&\n this.user != null &&\n this.user.isValid\n );\n }\n\n /**\n */\n get readonlyvalue(): { [string]: string } {\n return {\n [this.assignmenttype.name]: this.assignmenttype.readonlyvalue,\n [this.user.name]: this.user.readonlyvalue,\n };\n }\n\n /**\n */\n get formdata(): { [string]: any } | null {\n return this.value;\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA;AACA;AACA;AACe,MAAMG,qBAAqB,SAASC,wBAAe,CAAC;EAKjE;AACF;AACA;EACEC,WAAWA,CACTC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EAC3B;IACA,KAAK,CAACF,IAAI,EAAEC,aAAa,EAAEC,YAAY,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzC,IAAI,CAACC,eAAe,GAAG,IAAI,CAACC,yBAAyB,CAAC,CAAC;IACvD,IAAI,CAACC,KAAK,GAAG,IAAI,CAACC,eAAe,CAAC,CAAC;EACrC;;EAEA;AACF;EACE,IAAIC,GAAGA,CAAA,EAAY;IACjB,OAAO,IAAI,CAACT,IAAI,CAACU,IAAI;EACvB;;EAEA;AACF;EACE,IAAIC,SAASA,CAAA,EAAW;IACtB,OAAO,IAAI,CA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vD;;EAEA;AACF;AACA;EACE,IAAIC,OAAOA,CAAA,EAAY;IACrB,OACE,IAAI,CAACX,cAAc,IAAI,IAAI,IAC3B,IAAI,CAACA,cAAc,CAACW,OAAO,IAC3B,IAAI,CAACV,IAAI,IAAI,IAAI,IACjB,IAAI,CAACA,IAAI,CAACU,OAAO;EAErB;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAyB;IACxC,OAAO;MACL,CAAC,IAAI,CAACZ,cAAc,CAACf,IAAI,GAAG,IAAI,CAACe,cAAc,CAACY,aAAa;MAC7D,CAAC,IAAI,CAACX,IAAI,CAAChB,IAAI,GAAG,IAAI,CAACgB,IAAI,CAACW;IAC9B,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAACV,KAAK;EACnB;AACF;AAACW,OAAA,CAAAnC,OAAA,GAAAP,qBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"AssignmentFilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","_exceptions","_createAttribute","AssignmentFilterModel","BaseFilterModel","constructor","data","contributions","modelOptions","_defineProperty2","default","_assignmenttype","createAssignmentTypeModel","_user","createUserModel","key","contextid","assignmentTypeData","IllegalStateException","dynamicschema","assignmentTypeContributions","type","enumerated","optionMode","_links","createAttribute","name","param","userData","userContributions","assignmenttype","user","params","value","inputvalue","hasValue","reset","update","attribute","isActive","initvalue","isValid","readonlyvalue","formdata","exports"],"sources":["../../../src/models/filters/AssignmentFilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"../filters/BaseFilterModel\";\n\nimport type { IFilter, AttributeType, ModelOptions } from \"../types\";\nimport { IllegalStateException } from \"../../exceptions\";\nimport createAttribute from \"../attributes/_createAttribute\";\n\n/**\n * Assignment filter consists of two filters: assignment type and user filter\n */\nexport default class AssignmentFilterModel\n extends BaseFilterModel\n implements IFilter\n{\n _listKey: string;\n _assignmenttype: AttributeType;\n _user: AttributeType;\n\n /**\n * Construct an assignment filter\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n this._assignmenttype = this.createAssignmentTypeModel();\n this._user = this.createUserModel();\n }\n\n /**\n * Creates an assignmenttype model when assignmenttype json is present\n */\n createAssignmentTypeModel(): AttributeType {\n const key = `${this.contextid}ASSIGNMENTTYPE`;\n const assignmentTypeData = this.data[key];\n\n if (typeof assignmentTypeData === \"undefined\") {\n throw new IllegalStateException(\n `Missing assignment type data for ${key}`,\n );\n }\n\n if (this.data.dynamicschema && this.data.dynamicschema[key]) {\n assignmentTypeData.dynamicschema = {\n [key]: this.data.dynamicschema[key],\n };\n }\n\n const assignmentTypeContributions = {\n ...this.contributions[key],\n type: \"choice\",\n enumerated: true,\n optionMode: assignmentTypeData._links ? \"lookup\" : \"static\",\n };\n\n return createAttribute(\n assignmentTypeData.name || assignmentTypeData.param,\n assignmentTypeData,\n assignmentTypeContributions,\n this.modelOptions,\n );\n }\n\n /**\n * Creates an assignmenttype model when userkey json is present\n */\n createUserModel(): AttributeType {\n const key = `${this.contextid}USERKEY`;\n const userData = this.data[key];\n\n if (this.data.dynamicschema && this.data.dynamicschema[key]) {\n userData.dynamicschema = {\n [key]: this.data.dynamicschema[key],\n };\n }\n\n const userContributions = {\n ...this.contributions[key],\n type: \"choice\",\n enumerated: true,\n optionMode: userData._links ? \"lookup\" : \"static\",\n };\n\n return createAttribute(\n userData.name || userData.param,\n userData,\n userContributions,\n this.modelOptions,\n );\n }\n\n /**\n * The assignment filter consists of two part. This method return the assignment type attribute\n */\n get assignmenttype(): AttributeType {\n return this._assignmenttype;\n }\n\n /**\n * The assignment filter consists of two part. This method return the user identifier attribute\n */\n get user(): AttributeType {\n return this._user;\n }\n\n /**\n * Getting the parameters of this filter\n */\n get params(): Array<{ name: string, value: ?string }> {\n return [\n {\n name: this.assignmenttype.name,\n value: this.assignmenttype.value,\n },\n {\n name: this.user.name,\n value: this.user.value,\n },\n ];\n }\n\n /**\n */\n get value(): { [string]: any } {\n return {\n [this.assignmenttype.name]: this.assignmenttype.value,\n [this.user.name]: this.user.value,\n };\n }\n\n /**\n */\n get inputvalue(): { [string]: any } {\n return {\n [this.assignmenttype.name]: this.assignmenttype.inputvalue,\n [this.user.name]: this.user.inputvalue,\n };\n }\n\n /**\n * Indicates if the filter has a value.\n */\n hasValue(): boolean {\n return (\n (this.assignmenttype.value !== null &&\n this.assignmenttype.value !== \"\") ||\n (this.user.value !== null && this.user.value !== \"\")\n );\n }\n\n /**\n * Reset the values within the filter\n */\n reset(): AssignmentFilterModel {\n if (this.assignmenttype) {\n this.assignmenttype.reset();\n }\n if (this.user) {\n this.user.reset();\n }\n\n return this;\n }\n\n /**\n * Update this filter\n */\n update(attribute: AttributeType, value: string) {\n if (this.user != null && this.user.key === attribute.key) {\n this.user.update(value);\n } else if (\n this.assignmenttype != null &&\n this.assignmenttype.key === attribute.key\n ) {\n this.assignmenttype.update(value);\n }\n }\n\n /**\n * Inidiates if filter is active\n */\n isActive(): boolean {\n return (\n (this.assignmenttype != null && this.assignmenttype.initvalue !== null) ||\n (this.user != null && this.user.initvalue !== null)\n );\n }\n\n /**\n * Inidiates if filter is valid\n */\n get isValid(): boolean {\n return (\n this.assignmenttype != null &&\n this.assignmenttype.isValid &&\n this.user != null &&\n this.user.isValid\n );\n }\n\n /**\n */\n get readonlyvalue(): { [string]: string } {\n return {\n [this.assignmenttype.name]: this.assignmenttype.readonlyvalue,\n [this.user.name]: this.user.readonlyvalue,\n };\n }\n\n /**\n */\n get formdata(): { [string]: any } | null {\n return this.value;\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAH,sBAAA,CAAAC,OAAA;AAEA;AACA;AACA;AACe,MAAMG,qBAAqB,SAChCC,wBAAe,CAEzB;EAKE;AACF;AACA;EACEC,WAAW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;MACA,IAAI,CAACe,cAAc,CAACO,MAAM,CAACJ,KAAK,CAAC;IACnC;EACF;;EAEA;AACF;AACA;EACEM,QAAQA,CAAA,EAAY;IAClB,OACG,IAAI,CAACT,cAAc,IAAI,IAAI,IAAI,IAAI,CAACA,cAAc,CAACU,SAAS,KAAK,IAAI,IACrE,IAAI,CAACT,IAAI,IAAI,IAAI,IAAI,IAAI,CAACA,IAAI,CAACS,SAAS,KAAK,IAAK;EAEvD;;EAEA;AACF;AACA;EACE,IAAIC,OAAOA,CAAA,EAAY;IACrB,OACE,IAAI,CAACX,cAAc,IAAI,IAAI,IAC3B,IAAI,CAACA,cAAc,CAACW,OAAO,IAC3B,IAAI,CAACV,IAAI,IAAI,IAAI,IACjB,IAAI,CAACA,IAAI,CAACU,OAAO;EAErB;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAyB;IACxC,OAAO;MACL,CAAC,IAAI,CAACZ,cAAc,CAACJ,IAAI,GAAG,IAAI,CAACI,cAAc,CAACY,aAAa;MAC7D,CAAC,IAAI,CAACX,IAAI,CAACL,IAAI,GAAG,IAAI,CAACK,IAAI,CAACW;IAC9B,CAAC;EACH;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAACV,KAAK;EACnB;AACF;AAACW,OAAA,CAAAlC,OAAA,GAAAP,qBAAA","ignoreList":[]}
|
|
@@ -23,6 +23,12 @@ class BaseFilterModel extends _BaseModel.default {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
*/
|
|
28
|
+
get key() {
|
|
29
|
+
return this.data.name;
|
|
30
|
+
}
|
|
31
|
+
|
|
26
32
|
/**
|
|
27
33
|
* Get the type of a filter.
|
|
28
34
|
*/
|
|
@@ -64,6 +70,12 @@ class BaseFilterModel extends _BaseModel.default {
|
|
|
64
70
|
this._context = context;
|
|
65
71
|
}
|
|
66
72
|
|
|
73
|
+
/**
|
|
74
|
+
*/
|
|
75
|
+
get contextid() {
|
|
76
|
+
return this.getContribution("contextid", "");
|
|
77
|
+
}
|
|
78
|
+
|
|
67
79
|
/**
|
|
68
80
|
* Getting the context label
|
|
69
81
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseFilterModel.js","names":["_BaseModel","_interopRequireDefault","require","_Constants","BaseFilterModel","BaseModel","constructor","data","contributions","modelOptions","_defineProperty2","default","listKey","listkey","type","replace","parameterType","getContribution","PARAMETER_TYPES","BODY","QUERY","isMultiple","context","_context","contextLabel","label","_listKey","
|
|
1
|
+
{"version":3,"file":"BaseFilterModel.js","names":["_BaseModel","_interopRequireDefault","require","_Constants","BaseFilterModel","BaseModel","constructor","data","contributions","modelOptions","_defineProperty2","default","listKey","listkey","key","name","type","replace","parameterType","getContribution","PARAMETER_TYPES","BODY","QUERY","isMultiple","context","_context","contextid","contextLabel","label","_listKey","PARAMETER_SEPARATOR","param","isQuickSearch","quicksearch","assistantMessage","exports"],"sources":["../../../src/models/filters/BaseFilterModel.js"],"sourcesContent":["// @flow\nimport BaseModel from \"../base/BaseModel\";\n\nimport {\n PARAMETER_SEPARATOR,\n PARAMETER_TYPES,\n} from \"../../constants/Constants\";\n\nimport type { ModelOptions } from \"../types\";\n\n/**\n * Base class for filters\n */\nexport default class BaseFilterModel extends BaseModel {\n _context: Object;\n _listKey: string;\n\n /**\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n if (this.contributions.listKey) {\n this.listkey = this.contributions.listKey;\n }\n }\n\n /**\n */\n get key(): string {\n return this.data.name;\n }\n\n /**\n * Get the type of a filter.\n */\n get type(): string {\n return this.contributions.type\n ? this.contributions.type.replace(\"filter\", \"\")\n : \"string\";\n }\n\n /**\n * Returns the parameter type, when the filter can only be used in a POST request the type is 'bodyParameter', else 'queryParameter'.\n */\n get parameterType(): $Values<typeof PARAMETER_TYPES> {\n const parameterType = this.getContribution(\"parameterType\");\n switch (parameterType) {\n case \"bodyParameter\":\n return PARAMETER_TYPES.BODY;\n default:\n return PARAMETER_TYPES.QUERY;\n }\n }\n\n /**\n * Inidiates if filter is multiplechoice\n */\n get isMultiple(): boolean {\n return this.getContribution(\"multiplechoice\", false);\n }\n\n /**\n * Getting context data\n */\n get context(): Object {\n return this._context;\n }\n\n /**\n * Set context of filter\n */\n set context(context: Object) {\n this._context = context;\n }\n\n /**\n */\n get contextid(): string {\n return this.getContribution(\"contextid\", \"\");\n }\n\n /**\n * Getting the context label\n */\n get contextLabel(): string {\n return this.context?.label ?? \"\";\n }\n\n /**\n * Getting key of the list these filters apply to\n */\n get listkey(): string {\n return this._listKey;\n }\n\n /**\n * Set key of list this filter belongs to\n */\n set listkey(key: string) {\n this._listKey = key;\n }\n\n /**\n * Getting the label of the filter\n */\n get label(): string {\n return this.getContribution(\"label\", \"\");\n }\n\n /**\n * Getting the name of the filter\n */\n get name(): string {\n if (this.listkey) {\n return this.listkey + PARAMETER_SEPARATOR + this.param;\n }\n\n return this.param;\n }\n\n /**\n * Getting the param name of the filter\n */\n get param(): string {\n return this.data.param ?? this.data.name;\n }\n\n /**\n * Inidicates if filter is a quick search filter\n */\n isQuickSearch(): boolean {\n return this.contributions.quicksearch === true;\n }\n\n /**\n * Get assistant message\n */\n get assistantMessage(): string | null {\n return this.getContribution(\"assistant\");\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AAOA;AACA;AACA;AACe,MAAME,eAAe,SAASC,kBAAS,CAAC;EAIrD;AACF;EACEC,WAAWA,CACTC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EAC3B;IACA,KAAK,CAACF,IAAI,EAAEC,aAAa,EAAEC,YAAY,CAAC;IAAC,IAAAC,gBAAA,CAAAC,OAAA;IAAA,IAAAD,gBAAA,CAAAC,OAAA;IAEzC,IAAI,IAAI,CAACH,aAAa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A;EACE,IAAIhB,OAAOA,CAACC,GAAW,EAAE;IACvB,IAAI,CAACe,QAAQ,GAAGf,GAAG;EACrB;;EAEA;AACF;AACA;EACE,IAAIc,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACT,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;EAC1C;;EAEA;AACF;AACA;EACE,IAAIJ,IAAIA,CAAA,EAAW;IACjB,IAAI,IAAI,CAACF,OAAO,EAAE;MAChB,OAAO,IAAI,CAACA,OAAO,GAAGiB,8BAAmB,GAAG,IAAI,CAACC,KAAK;IACxD;IAEA,OAAO,IAAI,CAACA,KAAK;EACnB;;EAEA;AACF;AACA;EACE,IAAIA,KAAKA,CAAA,EAAW;IAClB,OAAO,IAAI,CAACxB,IAAI,CAACwB,KAAK,IAAI,IAAI,CAACxB,IAAI,CAACQ,IAAI;EAC1C;;EAEA;AACF;AACA;EACEiB,aAAaA,CAAA,EAAY;IACvB,OAAO,IAAI,CAACxB,aAAa,CAACyB,WAAW,KAAK,IAAI;EAChD;;EAEA;AACF;AACA;EACE,IAAIC,gBAAgBA,CAAA,EAAkB;IACpC,OAAO,IAAI,CAACf,eAAe,CAAC,WAAW,CAAC;EAC1C;AACF;AAACgB,OAAA,CAAAxB,OAAA,GAAAP,eAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConceptIndexFilterModel.js","names":["_FilterModel","_interopRequireDefault","require","_ChoiceAttributeModel","ConceptIndexFilterModel","FilterModel","constructor","data","contributions","modelOptions","attribute","ChoiceAttributeModel","options","_context","_context2","_context3","selectedValues","_map","default","_filter","call","option","selected","key","hasOptionByCode","forEach","addOption","code","label","exports"],"sources":["../../../src/models/filters/ConceptIndexFilterModel.js"],"sourcesContent":["// @flow\nimport FilterModel from \"../filters/FilterModel\";\nimport ChoiceAttributeModel from \"../attributes/ChoiceAttributeModel\";\n\nimport type { ModelOptions } from \"../types\";\n\n/**\n * The concept index model is a special filter used to index all first concept label letters in de modelcatalog.\n */\nexport default class ConceptIndexFilterModel
|
|
1
|
+
{"version":3,"file":"ConceptIndexFilterModel.js","names":["_FilterModel","_interopRequireDefault","require","_ChoiceAttributeModel","ConceptIndexFilterModel","FilterModel","constructor","data","contributions","modelOptions","attribute","ChoiceAttributeModel","options","_context","_context2","_context3","selectedValues","_map","default","_filter","call","option","selected","key","hasOptionByCode","forEach","addOption","code","label","exports"],"sources":["../../../src/models/filters/ConceptIndexFilterModel.js"],"sourcesContent":["// @flow\nimport FilterModel from \"../filters/FilterModel\";\nimport ChoiceAttributeModel from \"../attributes/ChoiceAttributeModel\";\n\nimport type { IFilter, ModelOptions } from \"../types\";\n\n/**\n * The concept index model is a special filter used to index all first concept label letters in de modelcatalog.\n */\nexport default class ConceptIndexFilterModel\n extends FilterModel\n implements IFilter\n{\n /**\n * Construct a filter\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n if (this.attribute instanceof ChoiceAttributeModel) {\n const attribute: ChoiceAttributeModel = this.attribute;\n\n if (attribute && data.options) {\n const selectedValues = data.options\n .filter((option) => option.selected)\n .map((option) => option.key);\n\n data.options\n .filter((option) => !attribute.options.hasOptionByCode(option.key))\n .forEach((option) => {\n attribute.options.addOption(selectedValues, {\n code: option.key,\n label: option.key,\n });\n });\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAIA;AACA;AACA;AACe,MAAME,uBAAuB,SAClCC,oBAAW,CAErB;EACE;AACF;AACA;EACEC,WAAWA,CACTC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EAC3B;IACA,KAAK,CAACF,IAAI,EAAEC,aAAa,EAAEC,YAAY,CAAC;IAExC,IAAI,IAAI,CAACC,SAAS,YAAYC,6BAAoB,EAAE;MAClD,MAAMD,SAA+B,GAAG,IAAI,CAACA,SAAS;MAEtD,IAAIA,SAAS,IAAIH,IAAI,CAACK,OAAO,EAAE;QAAA,IAAAC,QAAA,EAAAC,SAAA,EAAAC,SAAA;QAC7B,MAAMC,cAAc,GAAG,IAAAC,IAAA,CAAAC,OAAA,EAAAL,QAAA,OAAAM,OAAA,CAAAD,OAAA,EAAAJ,SAAA,GAAAP,IAAI,CAACK,OAAO,EAAAQ,IAAA,CAAAN,SAAA,EACxBO,MAAM,IAAKA,MAAM,CAACC,QAAQ,CAAC,EAAAF,IAAA,CAAAP,QAAA,EAC9BQ,MAAM,IAAKA,MAAM,CAACE,GAAG,CAAC;QAE9B,IAAAJ,OAAA,CAAAD,OAAA,EAAAH,SAAA,GAAAR,IAAI,CAACK,OAAO,EAAAQ,IAAA,CAAAL,SAAA,EACDM,MAAM,IAAK,CAACX,SAAS,CAACE,OAAO,CAACY,eAAe,CAACH,MAAM,CAACE,GAAG,CAAC,CAAC,CAClEE,OAAO,CAAEJ,MAAM,IAAK;UACnBX,SAAS,CAACE,OAAO,CAACc,SAAS,CAACV,cAAc,EAAE;YAC1CW,IAAI,EAAEN,MAAM,CAACE,GAAG;YAChBK,KAAK,EAAEP,MAAM,CAACE;UAChB,CAAC,CAAC;QACJ,CAAC,CAAC;MACN;IACF;EACF;AACF;AAACM,OAAA,CAAAX,OAAA,GAAAd,uBAAA","ignoreList":[]}
|
|
@@ -75,7 +75,7 @@ class FilterCollection extends _BaseCollection.default {
|
|
|
75
75
|
/**
|
|
76
76
|
* Call the reset function on all filters
|
|
77
77
|
*
|
|
78
|
-
* @see {
|
|
78
|
+
* @see {IFilter#reset()}
|
|
79
79
|
*/
|
|
80
80
|
reset() {
|
|
81
81
|
var _context4;
|
|
@@ -101,19 +101,29 @@ class FilterCollection extends _BaseCollection.default {
|
|
|
101
101
|
return filter.key === key || filter.user?.key === key || filter.assignmenttype?.key === key;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
*/
|
|
106
|
+
getFilterByName(name) {
|
|
107
|
+
var _context5;
|
|
108
|
+
return (0, _find.default)(_context5 = this).call(_context5, filter => filter.name === name) || null;
|
|
109
|
+
}
|
|
110
|
+
|
|
104
111
|
/**
|
|
105
112
|
* Getting the filter by name
|
|
106
113
|
*/
|
|
107
114
|
getFilterByAttributeKey(key) {
|
|
108
|
-
var
|
|
109
|
-
return (0, _find.default)(
|
|
115
|
+
var _context6;
|
|
116
|
+
return (0, _find.default)(_context6 = this).call(_context6, filter => {
|
|
110
117
|
if (filter instanceof _RangeFilterModel.default) {
|
|
111
118
|
return this.checkRangeFilterByAttributeKey(filter, key);
|
|
112
119
|
}
|
|
113
120
|
if (filter instanceof _AssignmentFilterModel.default) {
|
|
114
121
|
return this.checkAssignmentFilterByAttributeKey(filter, key);
|
|
115
122
|
}
|
|
116
|
-
|
|
123
|
+
if (filter instanceof _FilterModel.default) {
|
|
124
|
+
return filter.attribute.key === key;
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
117
127
|
}) || null;
|
|
118
128
|
}
|
|
119
129
|
|
|
@@ -121,14 +131,14 @@ class FilterCollection extends _BaseCollection.default {
|
|
|
121
131
|
* Update Filter by input name and value
|
|
122
132
|
*/
|
|
123
133
|
update(attribute, value) {
|
|
124
|
-
var
|
|
134
|
+
var _context7;
|
|
125
135
|
const filterToUpdate = attribute.parentKey ? this.getFilterByAttributeKey(attribute.parentKey) : this.getFilterByAttributeKey(attribute.key);
|
|
126
136
|
if (!filterToUpdate) {
|
|
127
137
|
throw new Error(`Can not find filter by attribute key: ${attribute.key}`);
|
|
128
138
|
}
|
|
129
139
|
const newFilter = filterToUpdate.clone();
|
|
130
140
|
newFilter.update(attribute, value);
|
|
131
|
-
this.collection = (0, _map.default)(
|
|
141
|
+
this.collection = (0, _map.default)(_context7 = this.collection).call(_context7, filter => {
|
|
132
142
|
if (filter.name === newFilter.name) {
|
|
133
143
|
return newFilter;
|
|
134
144
|
}
|
|
@@ -150,11 +160,19 @@ class FilterCollection extends _BaseCollection.default {
|
|
|
150
160
|
return this.collection.some(filter => filter.isActive());
|
|
151
161
|
}
|
|
152
162
|
|
|
163
|
+
/**
|
|
164
|
+
* Retrieve all filters with a value
|
|
165
|
+
*/
|
|
166
|
+
getActiveFilters() {
|
|
167
|
+
var _context8;
|
|
168
|
+
return (0, _filter.default)(_context8 = this.collection).call(_context8, filter => filter.isActive());
|
|
169
|
+
}
|
|
170
|
+
|
|
153
171
|
/**
|
|
154
172
|
*/
|
|
155
173
|
get formdata() {
|
|
156
|
-
var
|
|
157
|
-
const bodyFields = (0, _filter.default)(
|
|
174
|
+
var _context9;
|
|
175
|
+
const bodyFields = (0, _filter.default)(_context9 = this).call(_context9, f => f.parameterType === _constants.PARAMETER_TYPES.BODY && f.hasValue() && f.formdata);
|
|
158
176
|
if (bodyFields.length === 0) {
|
|
159
177
|
return null;
|
|
160
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterCollection.js","names":["_BaseCollection","_interopRequireDefault","require","_StringFilterModel","_RangeFilterModel","_AssignmentFilterModel","_ConceptIndexFilterModel","_CompositeAttributeModel","_FilterModel","_constants","FilterCollection","BaseCollection","constructor","data","contributions","modelOptions","Array","isArray","_filter","default","_context","_context2","collection","_map","call","filterContribution","_keys","filterKey","filterData","filterContributionByKey","filter","createFilter","dynamicschema","listkey","contexts","contextid","_context3","filterContext","_find","context","id","type","ConceptIndexFilterModel","_includes","RangeFilterModel","AssignmentFilterModel","StringFilterModel","FilterModel","reset","_context4","checkRangeFilterByAttributeKey","key","rangeAttribute","attribute","CompositeAttributeModel","start","end","checkAssignmentFilterByAttributeKey","user","assignmenttype","getFilterByAttributeKey","_context5","update","value","_context6","filterToUpdate","parentKey","Error","newFilter","clone","name","isValid","every","hasActiveFilters","some","isActive","formdata","_context7","bodyFields","f","parameterType","PARAMETER_TYPES","BODY","hasValue","length","reduce","_assign","exports"],"sources":["../../../src/models/filters/FilterCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\n\nimport StringFilterModel from \"../filters/StringFilterModel\";\nimport RangeFilterModel from \"../filters/RangeFilterModel\";\nimport AssignmentFilterModel from \"../filters/AssignmentFilterModel\";\nimport ConceptIndexFilterModel from \"../filters/ConceptIndexFilterModel\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport FilterModel from \"../filters/FilterModel\";\n\nimport type { AttributeType, FilterType, ModelOptions } from \"../types\";\nimport { PARAMETER_TYPES } from \"../../constants\";\n\n/**\n * Contains a collection of filters\n */\nexport default class FilterCollection extends BaseCollection<FilterType> {\n /**\n * Construct a collection of filters\n */\n constructor(\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ModelOptions,\n ) {\n super();\n\n if (data && contributions && Array.isArray(contributions.filter)) {\n this.collection = contributions.filter\n .filter((filterContribution) => Object.keys(filterContribution)[0])\n .map((filterContribution) => {\n const [filterKey] = Object.keys(filterContribution);\n const filterData = data[filterKey];\n const filterContributionByKey = filterContribution[filterKey];\n\n const filter = this.createFilter(\n filterKey,\n {\n ...filterData,\n dynamicschema: contributions.dynamicschema,\n },\n filterContributionByKey,\n modelOptions,\n );\n\n if (contributions.listkey) {\n filter.listkey = contributions.listkey;\n }\n\n if (contributions.contexts && filterContributionByKey.contextid) {\n const filterContext = contributions.contexts.find(\n (context) => context.id === filterContributionByKey.contextid,\n );\n if (filterContext) {\n filter.context = filterContext;\n }\n }\n\n return filter;\n });\n }\n }\n\n /**\n */\n createFilter(\n filterKey: string,\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): FilterType {\n const type = contributions.type || \"stringfilter\";\n if (type === \"choicefilter\" && filterKey === \"index\") {\n return new ConceptIndexFilterModel(data, contributions, modelOptions);\n }\n\n if (type.includes(\"rangefilter\")) {\n return new RangeFilterModel(data, contributions, modelOptions);\n }\n\n if (type === \"assignmentfilter\") {\n return new AssignmentFilterModel(data, contributions, modelOptions);\n }\n\n if (type === \"stringfilter\") {\n return new StringFilterModel(data, contributions, modelOptions);\n }\n\n return new FilterModel(data, contributions, modelOptions);\n }\n\n /**\n * Call the reset function on all filters\n *\n * @see {FilterType#reset()}\n */\n reset(): FilterCollection {\n this.collection = this.collection.map((filter) => filter.reset());\n\n return this;\n }\n\n /**\n * Checks if range attribute key equals key\n */\n checkRangeFilterByAttributeKey(\n filter: RangeFilterModel,\n key: string,\n ): boolean {\n const rangeAttribute = filter.attribute;\n\n if (rangeAttribute instanceof CompositeAttributeModel) {\n return (\n rangeAttribute.key === key ||\n (rangeAttribute.start && rangeAttribute.start.key === key) ||\n (rangeAttribute.end && rangeAttribute.end.key === key)\n );\n }\n\n return false;\n }\n\n /**\n * Check if assignment filter attribute matches key\n */\n checkAssignmentFilterByAttributeKey(\n filter: AssignmentFilterModel,\n key: string,\n ): boolean {\n return (\n filter.key === key ||\n filter.user?.key === key ||\n filter.assignmenttype?.key === key\n );\n }\n\n /**\n * Getting the filter by name\n */\n getFilterByAttributeKey(key: string): FilterType | null {\n return (\n this.find((filter) => {\n if (filter instanceof RangeFilterModel) {\n return this.checkRangeFilterByAttributeKey(filter, key);\n }\n\n if (filter instanceof AssignmentFilterModel) {\n return this.checkAssignmentFilterByAttributeKey(filter, key);\n }\n\n return filter.attribute?.key === key;\n }) || null\n );\n }\n\n /**\n * Update Filter by input name and value\n */\n update(attribute: AttributeType, value: string): void {\n const filterToUpdate = attribute.parentKey\n ? this.getFilterByAttributeKey(attribute.parentKey)\n : this.getFilterByAttributeKey(attribute.key);\n\n if (!filterToUpdate) {\n throw new Error(`Can not find filter by attribute key: ${attribute.key}`);\n }\n\n const newFilter = filterToUpdate.clone();\n newFilter.update(attribute, value);\n\n this.collection = this.collection.map((filter) => {\n if (filter.name === newFilter.name) {\n return newFilter;\n }\n\n return filter;\n });\n }\n\n /**\n * Retrieve if all filters are valid\n */\n get isValid(): boolean {\n return this.collection.every((filter) => filter.isValid);\n }\n\n /**\n * Indicates if an active filter is present in the collection\n */\n hasActiveFilters(): boolean {\n return this.collection.some((filter) => filter.isActive());\n }\n\n /**\n */\n get formdata(): { [string]: any } | null {\n const bodyFields = this.filter(\n (f) =>\n f.parameterType === PARAMETER_TYPES.BODY && f.hasValue() && f.formdata,\n );\n\n if (bodyFields.length === 0) {\n return null;\n }\n\n return bodyFields.reduce((data, f) => {\n return Object.assign(data, f.formdata);\n }, {});\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,iBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,sBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,wBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,wBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,YAAA,GAAAP,sBAAA,CAAAC,OAAA;AAGA,IAAAO,UAAA,GAAAP,OAAA;AAEA;AACA;AACA;AACe,MAAMQ,gBAAgB,SAASC,uBAAc,CAAa;EACvE;AACF;AACA;EACEC,WAAWA,CACTC,IAAY,GAAG,CAAC,CAAC,EACjBC,aAAqB,GAAG,CAAC,CAAC,EAC1BC,YAA2B,EAC3B;IACA,KAAK,CAAC,CAAC;IAEP,IAAIF,IAAI,IAAIC,aAAa,IAAIE,KAAK,CAACC,OAAO,KAAAC,OAAA,CAAAC,OAAA,EAACL,aAAa,CAAO,CAAC,EAAE;MAAA,IAAAM,QAAA,EAAAC,SAAA;MAChE,IAAI,CAACC,UAAU,GAAG,IAAAC,IAAA,CAAAJ,OAAA,EAAAC,QAAA,OAAAF,OAAA,CAAAC,OAAA,EAAAE,SAAA,OAAAH,OAAA,CAAAC,OAAA,EAAAL,aAAa,GAAAU,IAAA,CAAAH,SAAA,EACpBI,kBAAkB,IAAK,IAAAC,KAAA,CAAAP,OAAA,EAAYM,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAAD,IAAA,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AIA,MAAM,CAACwC,IAAI,KAAKF,SAAS,CAACE,IAAI,EAAE;QAClC,OAAOF,SAAS;MAClB;MAEA,OAAOtC,MAAM;IACf,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;EACE,IAAIyC,OAAOA,CAAA,EAAY;IACrB,OAAO,IAAI,CAACjD,UAAU,CAACkD,KAAK,CAAE1C,MAAM,IAAKA,MAAM,CAACyC,OAAO,CAAC;EAC1D;;EAEA;AACF;AACA;EACEE,gBAAgBA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAACnD,UAAU,CAACoD,IAAI,CAAE5C,MAAM,IAAKA,MAAM,CAAC6C,QAAQ,CAAC,CAAC,CAAC;EAC5D;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAA6B;IAAA,IAAAC,SAAA;IACvC,MAAMC,UAAU,GAAG,IAAA5D,OAAA,CAAAC,OAAA,EAAA0D,SAAA,OAAI,EAAArD,IAAA,CAAAqD,SAAA,EACpBE,CAAC,IACAA,CAAC,CAACC,aAAa,KAAKC,0BAAe,CAACC,IAAI,IAAIH,CAAC,CAACI,QAAQ,CAAC,CAAC,IAAIJ,CAAC,CAACH,QAClE,CAAC;IAED,IAAIE,UAAU,CAACM,MAAM,KAAK,CAAC,EAAE;MAC3B,OAAO,IAAI;IACb;IAEA,OAAON,UAAU,CAACO,MAAM,CAAC,CAACxE,IAAI,EAAEkE,CAAC,KAAK;MACpC,OAAO,IAAAO,OAAA,CAAAnE,OAAA,EAAcN,IAAI,EAAEkE,CAAC,CAACH,QAAQ,CAAC;IACxC,CAAC,EAAE,CAAC,CAAC,CAAC;EACR;AACF;AAACW,OAAA,CAAApE,OAAA,GAAAT,gBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FilterCollection.js","names":["_BaseCollection","_interopRequireDefault","require","_StringFilterModel","_RangeFilterModel","_AssignmentFilterModel","_ConceptIndexFilterModel","_CompositeAttributeModel","_FilterModel","_constants","FilterCollection","BaseCollection","constructor","data","contributions","modelOptions","Array","isArray","_filter","default","_context","_context2","collection","_map","call","filterContribution","_keys","filterKey","filterData","filterContributionByKey","filter","createFilter","dynamicschema","listkey","contexts","contextid","_context3","filterContext","_find","context","id","type","ConceptIndexFilterModel","_includes","RangeFilterModel","AssignmentFilterModel","StringFilterModel","FilterModel","reset","_context4","checkRangeFilterByAttributeKey","key","rangeAttribute","attribute","CompositeAttributeModel","start","end","checkAssignmentFilterByAttributeKey","user","assignmenttype","getFilterByName","name","_context5","getFilterByAttributeKey","_context6","update","value","_context7","filterToUpdate","parentKey","Error","newFilter","clone","isValid","every","hasActiveFilters","some","isActive","getActiveFilters","_context8","formdata","_context9","bodyFields","f","parameterType","PARAMETER_TYPES","BODY","hasValue","length","reduce","_assign","exports"],"sources":["../../../src/models/filters/FilterCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\n\nimport StringFilterModel from \"../filters/StringFilterModel\";\nimport RangeFilterModel from \"../filters/RangeFilterModel\";\nimport AssignmentFilterModel from \"../filters/AssignmentFilterModel\";\nimport ConceptIndexFilterModel from \"../filters/ConceptIndexFilterModel\";\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport FilterModel from \"../filters/FilterModel\";\n\nimport type { AttributeType, IFilter, ModelOptions } from \"../types\";\nimport { PARAMETER_TYPES } from \"../../constants\";\n\n/**\n * Contains a collection of filters\n */\nexport default class FilterCollection extends BaseCollection<IFilter> {\n /**\n * Construct a collection of filters\n */\n constructor(\n data: Object = {},\n contributions: Object = {},\n modelOptions?: ModelOptions,\n ) {\n super();\n\n if (data && contributions && Array.isArray(contributions.filter)) {\n this.collection = contributions.filter\n .filter((filterContribution) => Object.keys(filterContribution)[0])\n .map((filterContribution) => {\n const [filterKey] = Object.keys(filterContribution);\n const filterData = data[filterKey];\n const filterContributionByKey = filterContribution[filterKey];\n\n const filter = this.createFilter(\n filterKey,\n {\n ...filterData,\n dynamicschema: contributions.dynamicschema,\n },\n filterContributionByKey,\n modelOptions,\n );\n\n if (contributions.listkey) {\n filter.listkey = contributions.listkey;\n }\n\n if (contributions.contexts && filterContributionByKey.contextid) {\n const filterContext = contributions.contexts.find(\n (context) => context.id === filterContributionByKey.contextid,\n );\n if (filterContext) {\n filter.context = filterContext;\n }\n }\n\n return filter;\n });\n }\n }\n\n /**\n */\n createFilter(\n filterKey: string,\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ): IFilter {\n const type = contributions.type || \"stringfilter\";\n if (type === \"choicefilter\" && filterKey === \"index\") {\n return new ConceptIndexFilterModel(data, contributions, modelOptions);\n }\n\n if (type.includes(\"rangefilter\")) {\n return new RangeFilterModel(data, contributions, modelOptions);\n }\n\n if (type === \"assignmentfilter\") {\n return new AssignmentFilterModel(data, contributions, modelOptions);\n }\n\n if (type === \"stringfilter\") {\n return new StringFilterModel(data, contributions, modelOptions);\n }\n\n return new FilterModel(data, contributions, modelOptions);\n }\n\n /**\n * Call the reset function on all filters\n *\n * @see {IFilter#reset()}\n */\n reset(): FilterCollection {\n this.collection = this.collection.map((filter) => filter.reset());\n\n return this;\n }\n\n /**\n * Checks if range attribute key equals key\n */\n checkRangeFilterByAttributeKey(\n filter: RangeFilterModel,\n key: string,\n ): boolean {\n const rangeAttribute = filter.attribute;\n\n if (rangeAttribute instanceof CompositeAttributeModel) {\n return (\n rangeAttribute.key === key ||\n (rangeAttribute.start && rangeAttribute.start.key === key) ||\n (rangeAttribute.end && rangeAttribute.end.key === key)\n );\n }\n\n return false;\n }\n\n /**\n * Check if assignment filter attribute matches key\n */\n checkAssignmentFilterByAttributeKey(\n filter: AssignmentFilterModel,\n key: string,\n ): boolean {\n return (\n filter.key === key ||\n filter.user?.key === key ||\n filter.assignmenttype?.key === key\n );\n }\n\n /**\n */\n getFilterByName(name: string): IFilter | null {\n return this.find((filter) => filter.name === name) || null;\n }\n\n /**\n * Getting the filter by name\n */\n getFilterByAttributeKey(key: string): IFilter | null {\n return (\n this.find((filter) => {\n if (filter instanceof RangeFilterModel) {\n return this.checkRangeFilterByAttributeKey(filter, key);\n }\n\n if (filter instanceof AssignmentFilterModel) {\n return this.checkAssignmentFilterByAttributeKey(filter, key);\n }\n\n if (filter instanceof FilterModel) {\n return filter.attribute.key === key;\n }\n\n return false;\n }) || null\n );\n }\n\n /**\n * Update Filter by input name and value\n */\n update(attribute: AttributeType, value: string): void {\n const filterToUpdate = attribute.parentKey\n ? this.getFilterByAttributeKey(attribute.parentKey)\n : this.getFilterByAttributeKey(attribute.key);\n\n if (!filterToUpdate) {\n throw new Error(`Can not find filter by attribute key: ${attribute.key}`);\n }\n\n const newFilter = filterToUpdate.clone();\n newFilter.update(attribute, value);\n\n this.collection = this.collection.map((filter) => {\n if (filter.name === newFilter.name) {\n return newFilter;\n }\n\n return filter;\n });\n }\n\n /**\n * Retrieve if all filters are valid\n */\n get isValid(): boolean {\n return this.collection.every((filter) => filter.isValid);\n }\n\n /**\n * Indicates if an active filter is present in the collection\n */\n hasActiveFilters(): boolean {\n return this.collection.some((filter) => filter.isActive());\n }\n\n /**\n * Retrieve all filters with a value\n */\n getActiveFilters(): Array<IFilter> {\n return this.collection.filter((filter) => filter.isActive());\n }\n\n /**\n */\n get formdata(): { [string]: any } | null {\n const bodyFields = this.filter(\n (f) =>\n f.parameterType === PARAMETER_TYPES.BODY && f.hasValue() && f.formdata,\n );\n\n if (bodyFields.length === 0) {\n return null;\n }\n\n return bodyFields.reduce((data, f) => {\n return Object.assign(data, f.formdata);\n }, {});\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,iBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,sBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,wBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,wBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,I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,MAAM,IAAKA,MAAM,CAAC2C,OAAO,CAAC;EAC1D;;EAEA;AACF;AACA;EACEE,gBAAgBA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAACrD,UAAU,CAACsD,IAAI,CAAE9C,MAAM,IAAKA,MAAM,CAAC+C,QAAQ,CAAC,CAAC,CAAC;EAC5D;;EAEA;AACF;AACA;EACEC,gBAAgBA,CAAA,EAAmB;IAAA,IAAAC,SAAA;IACjC,OAAO,IAAA7D,OAAA,CAAAC,OAAA,EAAA4D,SAAA,OAAI,CAACzD,UAAU,EAAAE,IAAA,CAAAuD,SAAA,EAASjD,MAAM,IAAKA,MAAM,CAAC+C,QAAQ,CAAC,CAAC,CAAC;EAC9D;;EAEA;AACF;EACE,IAAIG,QAAQA,CAAA,EAA6B;IAAA,IAAAC,SAAA;IACvC,MAAMC,UAAU,GAAG,IAAAhE,OAAA,CAAAC,OAAA,EAAA8D,SAAA,OAAI,EAAAzD,IAAA,CAAAyD,SAAA,EACpBE,CAAC,IACAA,CAAC,CAACC,aAAa,KAAKC,0BAAe,CAACC,IAAI,IAAIH,CAAC,CAACI,QAAQ,CAAC,CAAC,IAAIJ,CAAC,CAACH,QAClE,CAAC;IAED,IAAIE,UAAU,CAACM,MAAM,KAAK,CAAC,EAAE;MAC3B,OAAO,IAAI;IACb;IAEA,OAAON,UAAU,CAACO,MAAM,CAAC,CAAC5E,IAAI,EAAEsE,CAAC,KAAK;MACpC,OAAO,IAAAO,OAAA,CAAAvE,OAAA,EAAcN,IAAI,EAAEsE,CAAC,CAACH,QAAQ,CAAC;IACxC,CAAC,EAAE,CAAC,CAAC,CAAC;EACR;AACF;AAACW,OAAA,CAAAxE,OAAA,GAAAT,gBAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","_createAttribute","_exceptions","FilterModel","BaseFilterModel","constructor","data","contributions","modelOptions","_defineProperty2","default","_attribute","createAttribute","type","param","attribute","IllegalStateException","label","params","name","value","inputvalue","hasValue","reset","update","isActive","initvalue","isValid","readonlyvalue","formdata","exports"],"sources":["../../../src/models/filters/FilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"../filters/BaseFilterModel\";\nimport createAttribute from \"../attributes/_createAttribute\";\nimport { IllegalStateException } from \"../../exceptions\";\n\nimport type { AttributeType, ModelOptions } from \"../types\";\n\n/**\n */\nexport default class FilterModel extends BaseFilterModel {\n _attribute: AttributeType | null = null;\n\n /**\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n this._attribute = this.createAttribute(\n this.type,\n this.param,\n this.data,\n this.contributions,\n );\n }\n\n /**\n * Create attribute through the attribute factory. Create type based on filter key without the filter suffix\n */\n createAttribute(\n type: string,\n param: string,\n data: Object,\n contributions: Object,\n ): AttributeType | null {\n if (type === \"assignment\") {\n return null;\n }\n\n return createAttribute(\n param,\n data,\n {\n ...contributions,\n type: type,\n },\n this.modelOptions,\n );\n }\n\n /**\n * Get attribute of filter\n */\n get attribute(): AttributeType {\n if (!this._attribute) {\n throw new IllegalStateException(\n `Missing filter attribute on filter model: ${this.label}`,\n );\n }\n return this._attribute;\n }\n\n /**\n * Retrieve the parameters with it's value for this filter\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (!this.param) {\n return [];\n }\n\n return [\n {\n name: this.param,\n value: this.attribute?.value,\n },\n ];\n }\n\n /**\n * Getting the value of the filter\n */\n get value(): string | null {\n return this.attribute?.value;\n }\n\n /**\n * Getting the inputvalue of the filter\n */\n get inputvalue(): string {\n return this.attribute?.inputvalue;\n }\n\n /**\n * Indicates if the filter has a value.\n */\n hasValue(): boolean {\n return this.value !== null && this.value !== \"\";\n }\n\n /**\n * Reset the value of this filter to undefined\n */\n reset(): FilterModel {\n if (this.attribute) {\n this.attribute.reset();\n }\n\n return this;\n }\n\n /**\n * Update this filter with input name and value\n */\n update(attribute: AttributeType, value: string) {\n if (this.attribute) {\n this.attribute.update(value);\n }\n }\n\n /**\n * Inidiates if filter is active\n */\n isActive(): boolean {\n return this.attribute?.initvalue !== null;\n }\n\n /**\n * Inidiates if filter is valid\n */\n get isValid(): boolean {\n return this.attribute?.isValid || true;\n }\n\n /**\n */\n get readonlyvalue(): string {\n if (this.attribute) {\n return this.attribute.readonlyvalue;\n }\n return \"\";\n }\n\n /**\n */\n get formdata(): { [string]: any } | null {\n return this.attribute.formdata ?? null;\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAIA;AACA;AACe,MAAMG,WAAW,SAASC,wBAAe,
|
|
1
|
+
{"version":3,"file":"FilterModel.js","names":["_BaseFilterModel","_interopRequireDefault","require","_createAttribute","_exceptions","FilterModel","BaseFilterModel","constructor","data","contributions","modelOptions","_defineProperty2","default","_attribute","createAttribute","type","param","attribute","IllegalStateException","label","params","name","value","inputvalue","hasValue","reset","update","isActive","initvalue","isValid","readonlyvalue","formdata","exports"],"sources":["../../../src/models/filters/FilterModel.js"],"sourcesContent":["// @flow\nimport BaseFilterModel from \"../filters/BaseFilterModel\";\nimport createAttribute from \"../attributes/_createAttribute\";\nimport { IllegalStateException } from \"../../exceptions\";\n\nimport type { AttributeType, IFilter, ModelOptions } from \"../types\";\n\n/**\n */\nexport default class FilterModel extends BaseFilterModel implements IFilter {\n _attribute: AttributeType | null = null;\n\n /**\n */\n constructor(\n data: Object,\n contributions: Object,\n modelOptions?: ModelOptions,\n ) {\n super(data, contributions, modelOptions);\n\n this._attribute = this.createAttribute(\n this.type,\n this.param,\n this.data,\n this.contributions,\n );\n }\n\n /**\n * Create attribute through the attribute factory. Create type based on filter key without the filter suffix\n */\n createAttribute(\n type: string,\n param: string,\n data: Object,\n contributions: Object,\n ): AttributeType | null {\n if (type === \"assignment\") {\n return null;\n }\n\n return createAttribute(\n param,\n data,\n {\n ...contributions,\n type: type,\n },\n this.modelOptions,\n );\n }\n\n /**\n * Get attribute of filter\n */\n get attribute(): AttributeType {\n if (!this._attribute) {\n throw new IllegalStateException(\n `Missing filter attribute on filter model: ${this.label}`,\n );\n }\n return this._attribute;\n }\n\n /**\n * Retrieve the parameters with it's value for this filter\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (!this.param) {\n return [];\n }\n\n return [\n {\n name: this.param,\n value: this.attribute?.value,\n },\n ];\n }\n\n /**\n * Getting the value of the filter\n */\n get value(): string | null {\n return this.attribute?.value;\n }\n\n /**\n * Getting the inputvalue of the filter\n */\n get inputvalue(): string {\n return this.attribute?.inputvalue;\n }\n\n /**\n * Indicates if the filter has a value.\n */\n hasValue(): boolean {\n return this.value !== null && this.value !== \"\";\n }\n\n /**\n * Reset the value of this filter to undefined\n */\n reset(): FilterModel {\n if (this.attribute) {\n this.attribute.reset();\n }\n\n return this;\n }\n\n /**\n * Update this filter with input name and value\n */\n update(attribute: AttributeType, value: string) {\n if (this.attribute) {\n this.attribute.update(value);\n }\n }\n\n /**\n * Inidiates if filter is active\n */\n isActive(): boolean {\n return this.attribute?.initvalue !== null;\n }\n\n /**\n * Inidiates if filter is valid\n */\n get isValid(): boolean {\n return this.attribute?.isValid || true;\n }\n\n /**\n */\n get readonlyvalue(): string {\n if (this.attribute) {\n return this.attribute.readonlyvalue;\n }\n return \"\";\n }\n\n /**\n */\n get formdata(): { [string]: any } | null {\n return this.attribute.formdata ?? null;\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAIA;AACA;AACe,MAAMG,WAAW,SAASC,wBAAe,CAAoB;EAG1E;AACF;EACEC,WAAWA,CACTC,IAAY,EACZC,aAAqB,EACrBC,YAA2B,EAC3B;IACA,KAA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AAK,KAAK,IAAI,IAAI,IAAI,CAACA,KAAK,KAAK,EAAE;EACjD;;EAEA;AACF;AACA;EACEG,KAAKA,CAAA,EAAgB;IACnB,IAAI,IAAI,CAACR,SAAS,EAAE;MAClB,IAAI,CAACA,SAAS,CAACQ,KAAK,CAAC,CAAC;IACxB;IAEA,OAAO,IAAI;EACb;;EAEA;AACF;AACA;EACEC,MAAMA,CAACT,SAAwB,EAAEK,KAAa,EAAE;IAC9C,IAAI,IAAI,CAACL,SAAS,EAAE;MAClB,IAAI,CAACA,SAAS,CAACS,MAAM,CAACJ,KAAK,CAAC;IAC9B;EACF;;EAEA;AACF;AACA;EACEK,QAAQA,CAAA,EAAY;IAClB,OAAO,IAAI,CAACV,SAAS,EAAEW,SAAS,KAAK,IAAI;EAC3C;;EAEA;AACF;AACA;EACE,IAAIC,OAAOA,CAAA,EAAY;IACrB,OAAO,IAAI,CAACZ,SAAS,EAAEY,OAAO,IAAI,IAAI;EACxC;;EAEA;AACF;EACE,IAAIC,aAAaA,CAAA,EAAW;IAC1B,IAAI,IAAI,CAACb,SAAS,EAAE;MAClB,OAAO,IAAI,CAACA,SAAS,CAACa,aAAa;IACrC;IACA,OAAO,EAAE;EACX;;EAEA;AACF;EACE,IAAIC,QAAQA,CAAA,EAA6B;IACvC,OAAO,IAAI,CAACd,SAAS,CAACc,QAAQ,IAAI,IAAI;EACxC;AACF;AAACC,OAAA,CAAApB,OAAA,GAAAP,WAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RangeFilterModel.js","names":["_FilterModel","_interopRequireDefault","require","_CompositeAttributeModel","RangeFilterModel","FilterModel","update","attribute","value","CompositeAttributeModel","params","_context","_map","default","children","call","child","param","data","name","exports"],"sources":["../../../src/models/filters/RangeFilterModel.js"],"sourcesContent":["// @flow\nimport FilterModel from \"../filters/FilterModel\";\n\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport type { AttributeType } from \"../types\";\n\n/**\n * Range filter, for instance a date range filter or a number range filter\n */\nexport default class RangeFilterModel extends FilterModel {\n /**\n */\n update(attribute: AttributeType, value: string) {\n if (this.attribute instanceof CompositeAttributeModel) {\n this.attribute.update(value, attribute);\n } else if (this.attribute !== null) {\n this.attribute.update(value);\n }\n }\n\n /**\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (this.attribute instanceof CompositeAttributeModel) {\n return this.attribute.children.map((child) => {\n const { param } = this.data[child.name];\n return {\n name: param,\n value: child.value,\n };\n });\n }\n\n return [];\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,wBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA;AACA;AACA;AACe,MAAME,gBAAgB,SAASC,oBAAW,
|
|
1
|
+
{"version":3,"file":"RangeFilterModel.js","names":["_FilterModel","_interopRequireDefault","require","_CompositeAttributeModel","RangeFilterModel","FilterModel","update","attribute","value","CompositeAttributeModel","params","_context","_map","default","children","call","child","param","data","name","exports"],"sources":["../../../src/models/filters/RangeFilterModel.js"],"sourcesContent":["// @flow\nimport FilterModel from \"../filters/FilterModel\";\n\nimport CompositeAttributeModel from \"../attributes/CompositeAttributeModel\";\nimport type { AttributeType, IFilter } from \"../types\";\n\n/**\n * Range filter, for instance a date range filter or a number range filter\n */\nexport default class RangeFilterModel extends FilterModel implements IFilter {\n /**\n */\n update(attribute: AttributeType, value: string) {\n if (this.attribute instanceof CompositeAttributeModel) {\n this.attribute.update(value, attribute);\n } else if (this.attribute !== null) {\n this.attribute.update(value);\n }\n }\n\n /**\n */\n get params(): Array<{ name: string, value: ?string }> {\n if (this.attribute instanceof CompositeAttributeModel) {\n return this.attribute.children.map((child) => {\n const { param } = this.data[child.name];\n return {\n name: param,\n value: child.value,\n };\n });\n }\n\n return [];\n }\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,YAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,wBAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA;AACA;AACA;AACe,MAAME,gBAAgB,SAASC,oBAAW,CAAoB;EAC3E;AACF;EACEC,MAAMA,CAACC,SAAwB,EAAEC,KAAa,EAAE;IAC9C,IAAI,IAAI,CAACD,SAAS,YAAYE,gCAAuB,EAAE;MACrD,IAAI,CAACF,SAAS,CAACD,MAAM,CAACE,KAAK,EAAED,SAAS,CAAC;IACzC,CAAC,MAAM,IAAI,IAAI,CAACA,SAAS,KAAK,IAAI,EAAE;MAClC,IAAI,CAACA,SAAS,CAACD,MAAM,CAACE,KAAK,CAAC;IAC9B;EACF;;EAEA;AACF;EACE,IAAIE,MAAMA,CAAA,EAA4C;IACpD,IAAI,IAAI,CAACH,SAAS,YAAYE,gCAAuB,EAAE;MAAA,IAAAE,QAAA;MACrD,OAAO,IAAAC,IAAA,CAAAC,OAAA,EAAAF,QAAA,OAAI,CAACJ,SAAS,CAACO,QAAQ,EAAAC,IAAA,CAAAJ,QAAA,EAAMK,KAAK,IAAK;QAC5C,MAAM;UAAEC;QAAM,CAAC,GAAG,IAAI,CAACC,IAAI,CAACF,KAAK,CAACG,IAAI,CAAC;QACvC,OAAO;UACLA,IAAI,EAAEF,KAAK;UACXT,KAAK,EAAEQ,KAAK,CAACR;QACf,CAAC;MACH,CAAC,CAAC;IACJ;IAEA,OAAO,EAAE;EACX;AACF;AAACY,OAAA,CAAAP,OAAA,GAAAT,gBAAA","ignoreList":[]}
|