@beinformed/ui 1.56.0 → 1.57.0-contextpath.1
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 +29 -0
- package/esm/constants/Settings.js +4 -1
- package/esm/constants/Settings.js.map +1 -1
- package/esm/hooks/useForm.js +3 -1
- package/esm/hooks/useForm.js.map +1 -1
- package/esm/hooks/useModularUI.js +5 -0
- package/esm/hooks/useModularUI.js.map +1 -1
- package/esm/hooks/useModularUIBasic.js +11 -1
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/hooks/useModularUIModel.js +36 -25
- package/esm/hooks/useModularUIModel.js.map +1 -1
- package/esm/models/actions/ActionCollection.js +2 -2
- package/esm/models/actions/ActionCollection.js.map +1 -1
- package/esm/models/actions/ActionModel.js +27 -8
- package/esm/models/actions/ActionModel.js.map +1 -1
- package/esm/models/application/ApplicationModel.js +1 -1
- package/esm/models/application/ApplicationModel.js.map +1 -1
- package/esm/models/base/ResourceModel.js +25 -3
- package/esm/models/base/ResourceModel.js.map +1 -1
- package/esm/models/caseview/CaseViewModel.js +2 -2
- package/esm/models/caseview/CaseViewModel.js.map +1 -1
- package/esm/models/concepts/ConceptLinkModel.js +1 -0
- package/esm/models/concepts/ConceptLinkModel.js.map +1 -1
- package/esm/models/concepts/SourceReferenceModel.js +2 -1
- package/esm/models/concepts/SourceReferenceModel.js.map +1 -1
- package/esm/models/content/ContentIndexModel.js +2 -2
- package/esm/models/content/ContentIndexModel.js.map +1 -1
- package/esm/models/content/ContentLinkModel.js +2 -0
- package/esm/models/content/ContentLinkModel.js.map +1 -1
- package/esm/models/content/SectionModel.js +1 -0
- package/esm/models/content/SectionModel.js.map +1 -1
- package/esm/models/detail/DetailModel.js +1 -1
- package/esm/models/detail/DetailModel.js.map +1 -1
- package/esm/models/error/ErrorResponse.js +2 -0
- package/esm/models/error/ErrorResponse.js.map +1 -1
- package/esm/models/form/FormModel.js +1 -1
- package/esm/models/form/FormModel.js.map +1 -1
- package/esm/models/href/Href.js +71 -7
- package/esm/models/href/Href.js.map +1 -1
- package/esm/models/href/ListHref.js +1 -1
- package/esm/models/href/ListHref.js.map +1 -1
- package/esm/models/links/LinkCollection.js +3 -1
- package/esm/models/links/LinkCollection.js.map +1 -1
- package/esm/models/links/LinkModel.js +10 -9
- package/esm/models/links/LinkModel.js.map +1 -1
- package/esm/models/list/ListItemCollection.js +1 -1
- package/esm/models/list/ListItemCollection.js.map +1 -1
- package/esm/models/list/ListItemModel.js +3 -1
- package/esm/models/list/ListItemModel.js.map +1 -1
- package/esm/models/list/ListModel.js +1 -1
- package/esm/models/list/ListModel.js.map +1 -1
- package/esm/models/panels/GroupingPanelModel.js +1 -1
- package/esm/models/panels/GroupingPanelModel.js.map +1 -1
- package/esm/models/tab/TabModel.js +2 -2
- package/esm/models/tab/TabModel.js.map +1 -1
- package/esm/models/taskgroup/TaskGroupModel.js +4 -2
- package/esm/models/taskgroup/TaskGroupModel.js.map +1 -1
- package/esm/modularui/Authenticate.js +2 -1
- package/esm/modularui/Authenticate.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +43 -7
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/modularui/ModularUIResponse.js +31 -0
- package/esm/modularui/ModularUIResponse.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +3 -1
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +6 -0
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/redux/actions/Application.js +11 -4
- package/esm/redux/actions/Application.js.map +1 -1
- package/esm/redux/connectors/PanelRenderer.js +2 -0
- package/esm/redux/connectors/PanelRenderer.js.map +1 -1
- package/esm/utils/fetch/types.js.map +1 -1
- package/lib/constants/Settings.js +4 -1
- package/lib/constants/Settings.js.flow +2 -2
- package/lib/constants/Settings.js.map +1 -1
- package/lib/hooks/useForm.js +3 -1
- package/lib/hooks/useForm.js.flow +2 -0
- package/lib/hooks/useForm.js.map +1 -1
- package/lib/hooks/useModularUI.js +5 -0
- package/lib/hooks/useModularUI.js.flow +6 -1
- package/lib/hooks/useModularUI.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +11 -1
- package/lib/hooks/useModularUIBasic.js.flow +14 -0
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/hooks/useModularUIModel.js +36 -24
- package/lib/hooks/useModularUIModel.js.flow +58 -11
- package/lib/hooks/useModularUIModel.js.map +1 -1
- package/lib/models/actions/ActionCollection.js +2 -2
- package/lib/models/actions/ActionCollection.js.flow +14 -2
- package/lib/models/actions/ActionCollection.js.map +1 -1
- package/lib/models/actions/ActionModel.js +31 -12
- package/lib/models/actions/ActionModel.js.flow +38 -16
- package/lib/models/actions/ActionModel.js.map +1 -1
- package/lib/models/application/ApplicationModel.js +1 -1
- package/lib/models/application/ApplicationModel.js.flow +7 -1
- package/lib/models/application/ApplicationModel.js.map +1 -1
- package/lib/models/base/ResourceModel.js +24 -3
- package/lib/models/base/ResourceModel.js.flow +35 -10
- package/lib/models/base/ResourceModel.js.map +1 -1
- package/lib/models/caseview/CaseViewModel.js +2 -2
- package/lib/models/caseview/CaseViewModel.js.flow +3 -1
- package/lib/models/caseview/CaseViewModel.js.map +1 -1
- package/lib/models/concepts/ConceptLinkModel.js +1 -0
- package/lib/models/concepts/ConceptLinkModel.js.flow +1 -0
- package/lib/models/concepts/ConceptLinkModel.js.map +1 -1
- package/lib/models/concepts/SourceReferenceModel.js +2 -1
- package/lib/models/concepts/SourceReferenceModel.js.flow +2 -1
- package/lib/models/concepts/SourceReferenceModel.js.map +1 -1
- package/lib/models/content/ContentIndexModel.js +2 -2
- package/lib/models/content/ContentIndexModel.js.flow +2 -2
- package/lib/models/content/ContentIndexModel.js.map +1 -1
- package/lib/models/content/ContentLinkModel.js +2 -0
- package/lib/models/content/ContentLinkModel.js.flow +2 -0
- package/lib/models/content/ContentLinkModel.js.map +1 -1
- package/lib/models/content/SectionModel.js +1 -0
- package/lib/models/content/SectionModel.js.flow +1 -0
- package/lib/models/content/SectionModel.js.map +1 -1
- package/lib/models/detail/DetailModel.js +1 -1
- package/lib/models/detail/DetailModel.js.flow +2 -0
- package/lib/models/detail/DetailModel.js.map +1 -1
- package/lib/models/error/ErrorResponse.js +2 -0
- package/lib/models/error/ErrorResponse.js.flow +2 -0
- package/lib/models/error/ErrorResponse.js.map +1 -1
- package/lib/models/form/FormModel.js +1 -1
- package/lib/models/form/FormModel.js.flow +1 -1
- package/lib/models/form/FormModel.js.map +1 -1
- package/lib/models/href/Href.js +71 -7
- package/lib/models/href/Href.js.flow +79 -7
- package/lib/models/href/Href.js.map +1 -1
- package/lib/models/href/ListHref.js +1 -1
- package/lib/models/href/ListHref.js.flow +1 -1
- package/lib/models/href/ListHref.js.map +1 -1
- package/lib/models/href/__tests__/Href.spec.js.flow +9 -3
- package/lib/models/links/LinkCollection.js +3 -1
- package/lib/models/links/LinkCollection.js.flow +8 -2
- package/lib/models/links/LinkCollection.js.map +1 -1
- package/lib/models/links/LinkModel.js +10 -9
- package/lib/models/links/LinkModel.js.flow +24 -16
- package/lib/models/links/LinkModel.js.map +1 -1
- package/lib/models/list/ListItemCollection.js +1 -1
- package/lib/models/list/ListItemCollection.js.flow +2 -0
- package/lib/models/list/ListItemCollection.js.map +1 -1
- package/lib/models/list/ListItemModel.js +3 -1
- package/lib/models/list/ListItemModel.js.flow +4 -0
- package/lib/models/list/ListItemModel.js.map +1 -1
- package/lib/models/list/ListModel.js +1 -1
- package/lib/models/list/ListModel.js.flow +6 -1
- package/lib/models/list/ListModel.js.map +1 -1
- package/lib/models/panels/GroupingPanelModel.js +1 -1
- package/lib/models/panels/GroupingPanelModel.js.flow +2 -0
- package/lib/models/panels/GroupingPanelModel.js.map +1 -1
- package/lib/models/tab/TabModel.js +2 -2
- package/lib/models/tab/TabModel.js.flow +4 -0
- package/lib/models/tab/TabModel.js.map +1 -1
- package/lib/models/taskgroup/TaskGroupModel.js +4 -2
- package/lib/models/taskgroup/TaskGroupModel.js.flow +6 -0
- package/lib/models/taskgroup/TaskGroupModel.js.map +1 -1
- package/lib/modularui/Authenticate.js +2 -1
- package/lib/modularui/Authenticate.js.flow +2 -1
- package/lib/modularui/Authenticate.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +43 -7
- package/lib/modularui/ModularUIRequest.js.flow +49 -8
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/modularui/ModularUIResponse.js +31 -0
- package/lib/modularui/ModularUIResponse.js.flow +35 -0
- package/lib/modularui/ModularUIResponse.js.map +1 -1
- package/lib/modularui/__tests__/CustomContextPath.spec.js.flow +61 -0
- package/lib/redux/_modularui/ModularUIActions.js +3 -1
- package/lib/redux/_modularui/ModularUIActions.js.flow +6 -1
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +6 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.flow +10 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/types.js.flow +2 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/redux/actions/Application.js +10 -3
- package/lib/redux/actions/Application.js.flow +16 -4
- package/lib/redux/actions/Application.js.map +1 -1
- package/lib/redux/connectors/PanelRenderer.js +2 -0
- package/lib/redux/connectors/PanelRenderer.js.flow +1 -0
- package/lib/redux/connectors/PanelRenderer.js.map +1 -1
- package/lib/utils/fetch/types.js.flow +2 -0
- package/lib/utils/fetch/types.js.map +1 -1
- package/package.json +1 -1
- package/src/constants/Settings.js +2 -2
- package/src/hooks/useForm.js +2 -0
- package/src/hooks/useModularUI.js +6 -1
- package/src/hooks/useModularUIBasic.js +14 -0
- package/src/hooks/useModularUIModel.js +58 -11
- package/src/models/actions/ActionCollection.js +14 -2
- package/src/models/actions/ActionModel.js +38 -16
- package/src/models/application/ApplicationModel.js +7 -1
- package/src/models/base/ResourceModel.js +35 -10
- package/src/models/caseview/CaseViewModel.js +3 -1
- package/src/models/concepts/ConceptLinkModel.js +1 -0
- package/src/models/concepts/SourceReferenceModel.js +2 -1
- package/src/models/content/ContentIndexModel.js +2 -2
- package/src/models/content/ContentLinkModel.js +2 -0
- package/src/models/content/SectionModel.js +1 -0
- package/src/models/detail/DetailModel.js +2 -0
- package/src/models/error/ErrorResponse.js +2 -0
- package/src/models/form/FormModel.js +1 -1
- package/src/models/href/Href.js +79 -7
- package/src/models/href/ListHref.js +1 -1
- package/src/models/href/__tests__/Href.spec.js +9 -3
- package/src/models/links/LinkCollection.js +8 -2
- package/src/models/links/LinkModel.js +24 -16
- package/src/models/list/ListItemCollection.js +2 -0
- package/src/models/list/ListItemModel.js +4 -0
- package/src/models/list/ListModel.js +6 -1
- package/src/models/panels/GroupingPanelModel.js +2 -0
- package/src/models/tab/TabModel.js +4 -0
- package/src/models/taskgroup/TaskGroupModel.js +6 -0
- package/src/modularui/Authenticate.js +2 -1
- package/src/modularui/ModularUIRequest.js +49 -8
- package/src/modularui/ModularUIResponse.js +35 -0
- package/src/modularui/__tests__/CustomContextPath.spec.js +61 -0
- package/src/modularui/__tests__/contributions.json +312 -0
- package/src/modularui/__tests__/data.json +263 -0
- package/src/redux/_modularui/ModularUIActions.js +6 -1
- package/src/redux/_modularui/ModularUIMiddleware.js +10 -0
- package/src/redux/_modularui/types.js +2 -0
- package/src/redux/actions/Application.js +16 -4
- package/src/redux/connectors/PanelRenderer.js +1 -0
- package/src/utils/fetch/types.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [1.57.0-contextpath.1](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.57.0-contextpath.0...v1.57.0-contextpath.1) (2024-10-09)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **href:** add contextpath to the state of a location object (react-router) ([7571460](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/75714607d7206ab3ec04809b18e91f6038ae7b07))
|
|
11
|
+
* **listitem:** add contextpath to list items ([2681000](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/2681000c5496818b62a6a017032ae972bd2c4e9b))
|
|
12
|
+
* **modularui:** copy contextpath and origin for hrefs ([358d8d6](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/358d8d6f63c3559728f78ff885e658891dddd9e7))
|
|
13
|
+
* **reload:** add contextpath and origin to reload application action ([836898f](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/836898fe0b75b79c4cbdd59c945808e657327dae))
|
|
14
|
+
|
|
15
|
+
## [1.57.0-contextpath.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.56.0...v1.57.0-contextpath.0) (2024-10-09)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **context-path:** keep track of the context path in a resource model ([a801f0d](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/a801f0dab9ce2964227896d223965d5068252d9e))
|
|
21
|
+
* **context-path:** make it possible to set contextPath as option to the request ([64fe458](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/64fe458979625887d422797522911314bbc241af))
|
|
22
|
+
* **context-path:** resolves the path based on whether the context path and base path differ ([0854493](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/0854493036ed776593992686568d3263466b881a))
|
|
23
|
+
* **context:** add origin and context path to actions and modularuiresponse ([040525a](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/040525ae6a1a632feebb812c0849a26bc079cf9a))
|
|
24
|
+
* **context:** add origin and context path to href and links ([e3bdc58](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/e3bdc58e8bf3e6842d0520b0814abec7abcf3c68))
|
|
25
|
+
* **href:** make origin settable for requests and fix href ([25d4e68](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/25d4e68621f456d2b30eb4e98c2185f6960768be))
|
|
26
|
+
* **useforme:** added origin and context path ([34cfdb3](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/34cfdb3de9286c791280fdc361112efb32cd8ce2))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
|
|
31
|
+
* **authentication:** set correct pac4j client for basic authentication ([5e1d403](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/5e1d403466e08e78926896e004ae61324e7aa691))
|
|
32
|
+
* **href:** context path ([a37f375](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/commit/a37f3757c8ed95d116bf73449ca9088c7ff12e04))
|
|
33
|
+
|
|
5
34
|
## [1.56.0](https://git.beinformed.com/public/nl.beinformed.bi.layout.lib.ui/compare/v1.55.2...v1.56.0) (2024-10-09)
|
|
6
35
|
|
|
7
36
|
|
|
@@ -131,7 +131,10 @@ export const loginType = () => getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);
|
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
133
|
*/
|
|
134
|
-
export const loginPath = ()
|
|
134
|
+
export const loginPath = function () {
|
|
135
|
+
let clientName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "FormClient";
|
|
136
|
+
return getSetting(LOGIN_PATH_SETTING, `/callback?client_name=${clientName}`);
|
|
137
|
+
};
|
|
135
138
|
/**
|
|
136
139
|
*/
|
|
137
140
|
export const loginUsernameField = () => getSetting(LOGIN_USERNAME_SETTING, "j_username");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Settings.js","names":["isPlainObject","has","getRepositoryResourceUrl","ALL_CONTENT_IN_DATA_SETTING","INTERNAL_LOGIN_TYPE","LOGIN_TYPE","LOGIN_PATH_SETTING","LOGIN_USERNAME_SETTING","LOGIN_PASSWORD_SETTING","LOGOUT_PATH_SETTING","UPLOAD_PATH","CAPTCHA_PATH","serverBase","__CONTEXT_PATH__","defaultSettings","CONTEXT_PATH","window","contextPath","CACHE_CONTRIBUTIONS","DEBUG_I18N_MESSAGE_NOT_FOUND","HIDE_NOTIFICATION_TIMEOUT","ALWAYS_COMMIT_FORM","RENDER_QUESTION_LABELS","RENDER_MANDATORY_ATTRIBUTE_INDICATION","RENDER_OPTIONAL_ATTRIBUTE_INDICATION","AVAILABLE_LIST_VIEWS","USE_CLIENTSIDE_VALIDATION","USE_INSTANT_SERVER_VALIDATION","ENABLED_LOCALES","RENDER_GLOBAL_LOGIN_PAGE","RENDER_GLOBAL_LOGOUT_PAGE","RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE","LOGIN_PATH","ADMINISTRATOR_LOGIN_PATH","LOGOUT_PATH","RENDER_FORMS_IN_MODAL","SHOW_SUBMIT_WAIT_TIMEOUT","SWIM_LANE_DIAGRAM_CONFIGURATION","BUSINESS_SCENARIO_CONCEPT_TYPE","BUSINESS_SCENARIO_STEP_CONCEPT_TYPE","BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE","BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE","CALENDAR_WEEK_STARTS_ON","CALENDAR_FIRST_WEEK_CONTAINS_DATE","UI_PARAMETERS","ALLOW_HIDE_WHEN_EMPTY_ON_TABS","PAGE_RELOAD_ON_UNAUTHORIZED_ERROR","XHR_TIMEOUT_MS","HIDE_WHEN_EMPTY_IGNORE_TASKS","SHOW_AVATARS","settings","setSettings","config","_Object$assign","getSetting","key","defaultValue","undefined","Error","setSetting","value","allSettings","cacheContributions","getBasePath","getUploadPath","getCaptchaPath","hasAllContentInData","loginType","JAAS","loginPath","loginUsernameField","loginPasswordField","logoutPath","getSwimLaneDiagramConfiguration","configLocation","_startsWithInstanceProperty","call","setContextPath","BASE"],"sources":["../../src/constants/Settings.js"],"sourcesContent":["// @flow\nimport { isPlainObject, has } from \"../utils/helpers/objects\";\nimport { getRepositoryResourceUrl } from \"../utils/helpers/repositoryResource\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n INTERNAL_LOGIN_TYPE,\n LOGIN_TYPE,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGOUT_PATH_SETTING,\n UPLOAD_PATH,\n CAPTCHA_PATH,\n} from \"./Constants\";\n\ntype Setting = boolean | string | number | Array<string>;\n\nconst serverBase =\n typeof __CONTEXT_PATH__ === \"undefined\" ? null : __CONTEXT_PATH__;\n\nconst defaultSettings: { [name: string]: Setting } = {\n // This uses contextPath set from property from server\n CONTEXT_PATH:\n serverBase ??\n (typeof window !== \"undefined\" && window.contextPath\n ? window.contextPath\n : \"/BeInformed\"),\n\n // Indicates if contributions should be cached\n CACHE_CONTRIBUTIONS: true,\n\n // Debug missing i18n messages in layout\n DEBUG_I18N_MESSAGE_NOT_FOUND: true,\n\n // Time to show the notification bar\n HIDE_NOTIFICATION_TIMEOUT: 5000,\n\n // Always commit form, does not show result pages for instruments\n ALWAYS_COMMIT_FORM: false,\n\n // Render instrument and event question labels on forms (might result in duplicate labels)\n RENDER_QUESTION_LABELS: true,\n\n // Render mandatory indications on attributes\n RENDER_MANDATORY_ATTRIBUTE_INDICATION: true,\n\n // Render optional indications on attributes\n RENDER_OPTIONAL_ATTRIBUTE_INDICATION: false,\n\n // Renders a toggle with supported list views, options are ListView and TableView\n AVAILABLE_LIST_VIEWS: [\"ListView\", \"TableView\"],\n\n // Toggle client side validation\n USE_CLIENTSIDE_VALIDATION: true,\n\n // Indicates if server validation should be used when a form field is changed\n USE_INSTANT_SERVER_VALIDATION: true,\n\n // Indicates which locales are enabled\n ENABLED_LOCALES: [\"en\", \"nl\"],\n\n // Renders the global log in page\n RENDER_GLOBAL_LOGIN_PAGE: false,\n\n // Renders the global log out page\n RENDER_GLOBAL_LOGOUT_PAGE: false,\n\n // Renders the login variants as option on the global logout page\n RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE: false,\n\n // Path to login page / component\n LOGIN_PATH: \"/signin\",\n\n // Path to administrator login page / component\n ADMINISTRATOR_LOGIN_PATH: \"\",\n\n // Path to logout page / component\n LOGOUT_PATH: \"/signout\",\n\n // Render forms in a modal\n RENDER_FORMS_IN_MODAL: true,\n\n // Wait timeout before rendering submit wait icon\n SHOW_SUBMIT_WAIT_TIMEOUT: 300,\n\n // Swim lane diagram configuration file\n SWIM_LANE_DIAGRAM_CONFIGURATION: \"/Library/Diagrams/Overviews.json\",\n\n // Business scenario concept types\n BUSINESS_SCENARIO_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/BusinessScenario\",\n ],\n BUSINESS_SCENARIO_STEP_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/ScenarioStep\",\n ],\n BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/Persona\",\n ],\n BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/System\",\n ],\n\n // indicates on what day the week starts (0 = Sunday)\n CALENDAR_WEEK_STARTS_ON: 1,\n\n // indicates which date indicates the first week of the year\n CALENDAR_FIRST_WEEK_CONTAINS_DATE: 1,\n\n // parameters that are added for the ui state, but should not be send to the modular ui\n UI_PARAMETERS: [],\n\n // disable hide-when-empty hint for layouts running on Be Informed versions older than 21.1\n ALLOW_HIDE_WHEN_EMPTY_ON_TABS: true,\n\n // reload the complete page on signout, usefull when third party authentication is in place\n PAGE_RELOAD_ON_UNAUTHORIZED_ERROR: false,\n\n XHR_TIMEOUT_MS: 300000,\n\n HIDE_WHEN_EMPTY_IGNORE_TASKS: false,\n\n SHOW_AVATARS: true,\n};\n\nlet settings = defaultSettings;\n\n/**\n */\nexport const setSettings = (config: Object) => {\n if (isPlainObject(config)) {\n settings = Object.assign(defaultSettings, config);\n }\n};\n\n/**\n */\nexport const getSetting = (key: string, defaultValue?: any): any => {\n if (!has(settings, key) && defaultValue === undefined) {\n throw new Error(\n `Setting with name ${key} not found and no defaultValue given`,\n );\n }\n\n return settings[key] ?? defaultValue;\n};\n\n/**\n */\nexport const setSetting = (key: string, value: any) => {\n settings[key] = value;\n};\n\n/**\n */\nexport const allSettings = (): { [name: string]: Setting } => settings;\n\n/**\n * Indicates if contributions must be cached\n */\nexport const cacheContributions = (): boolean =>\n getSetting(\"CACHE_CONTRIBUTIONS\", true);\n\n/**\n * Base path\n * This uses contextPath set from property from server\n * When requesting a remote server with CORS enabled, add the origin, for example:\n * export const BEINFORMED_PATH = 'http://192.168.128.61:8080/BeInformed';\n */\nexport const getBasePath = (): string =>\n getSetting(\"CONTEXT_PATH\", \"/BeInformed\");\n\n/**\n * Path to upload service\n */\nexport const getUploadPath = (): string => `${getBasePath()}${UPLOAD_PATH}`;\n\n/**\n * Path to captcha service\n */\nexport const getCaptchaPath = (): string => `${getBasePath()}${CAPTCHA_PATH}`;\n\n/**\n */\nexport const hasAllContentInData = (): boolean =>\n getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n\n/**\n * Login type, only available when pac4j is configured\n *\n * Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS\n */\nexport const loginType = (): string =>\n getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);\n\n/**\n */\nexport const loginPath = (): string =>\n getSetting(LOGIN_PATH_SETTING, \"/callback?client_name=FormClient\");\n/**\n */\nexport const loginUsernameField = (): string =>\n getSetting(LOGIN_USERNAME_SETTING, \"j_username\");\n/**\n */\nexport const loginPasswordField = (): string =>\n getSetting(LOGIN_PASSWORD_SETTING, \"j_password\");\n/**\n */\nexport const logoutPath = (): string =>\n getSetting(LOGOUT_PATH_SETTING, \"/logout\");\n\nexport const LOGIN_PATH: string = loginPath();\nexport const LOGOUT_PATH: string = logoutPath();\n\n/**\n * Model overview swim lane configuration\n */\nexport const getSwimLaneDiagramConfiguration: Object = () => {\n let configLocation = getSetting(\n \"SWIM_LANE_DIAGRAM_CONFIGURATION\",\n \"/Library/Diagrams/Overviews.json\",\n );\n if (!configLocation.startsWith(\"/\")) {\n configLocation = `/${configLocation}`;\n }\n return getRepositoryResourceUrl(configLocation);\n};\n\n/**\n * Set the context path for requests to be informed\n */\nexport const setContextPath = (contextPath: string) => {\n setSetting(\"CONTEXT_PATH\", contextPath);\n};\n\n/**\n * Backwards compatible export of BASE constant\n */\nexport const BASE: string = getBasePath();\n"],"mappings":";;AACA,SAASA,aAAa,EAAEC,GAAG,QAAQ,0BAA0B;AAC7D,SAASC,wBAAwB,QAAQ,qCAAqC;AAC9E,SACEC,2BAA2B,EAC3BC,mBAAmB,EACnBC,UAAU,EACVC,kBAAkB,EAClBC,sBAAsB,EACtBC,sBAAsB,EACtBC,mBAAmB,EACnBC,WAAW,EACXC,YAAY,QACP,aAAa;AAIpB,MAAMC,UAAU,GACd,OAAOC,gBAAgB,KAAK,WAAW,GAAG,IAAI,GAAGA,gBAAgB;AAEnE,MAAMC,eAA4C,GAAG;EACnD;EACAC,YAAY,EACVH,UAAU,KACT,OAAOI,MAAM,KAAK,WAAW,IAAIA,MAAM,CAACC,WAAW,GAChDD,MAAM,CAACC,WAAW,GAClB,aAAa,CAAC;EAEpB;EACAC,mBAAmB,EAAE,IAAI;EAEzB;EACAC,4BAA4B,EAAE,IAAI;EAElC;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,kBAAkB,EAAE,KAAK;EAEzB;EACAC,sBAAsB,EAAE,IAAI;EAE5B;EACAC,qCAAqC,EAAE,IAAI;EAE3C;EACAC,oCAAoC,EAAE,KAAK;EAE3C;EACAC,oBAAoB,EAAE,CAAC,UAAU,EAAE,WAAW,CAAC;EAE/C;EACAC,yBAAyB,EAAE,IAAI;EAE/B;EACAC,6BAA6B,EAA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;AACA,OAAO,MAAMgE,UAAU,GAAGA,CAAA,KACxBlB,UAAU,CAAC7C,mBAAmB,EAAE,SAAS,CAAC;AAE5C,OAAO,MAAMuB,UAAkB,GAAGqC,SAAS,CAAC,CAAC;AAC7C,OAAO,MAAMnC,WAAmB,GAAGsC,UAAU,CAAC,CAAC;;AAE/C;AACA;AACA;AACA,OAAO,MAAMC,+BAAuC,GAAGA,CAAA,KAAM;EAC3D,IAAIC,cAAc,GAAGpB,UAAU,CAC7B,iCAAiC,EACjC,kCACF,CAAC;EACD,IAAI,CAACqB,2BAAA,CAAAD,cAAc,EAAAE,IAAA,CAAdF,cAAc,EAAY,GAAG,CAAC,EAAE;IACnCA,cAAc,GAAG,IAAIA,cAAc,EAAE;EACvC;EACA,OAAOxE,wBAAwB,CAACwE,cAAc,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMG,cAAc,GAAI5D,WAAmB,IAAK;EACrD0C,UAAU,CAAC,cAAc,EAAE1C,WAAW,CAAC;AACzC,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAM6D,IAAY,GAAGf,WAAW,CAAC,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"Settings.js","names":["isPlainObject","has","getRepositoryResourceUrl","ALL_CONTENT_IN_DATA_SETTING","INTERNAL_LOGIN_TYPE","LOGIN_TYPE","LOGIN_PATH_SETTING","LOGIN_USERNAME_SETTING","LOGIN_PASSWORD_SETTING","LOGOUT_PATH_SETTING","UPLOAD_PATH","CAPTCHA_PATH","serverBase","__CONTEXT_PATH__","defaultSettings","CONTEXT_PATH","window","contextPath","CACHE_CONTRIBUTIONS","DEBUG_I18N_MESSAGE_NOT_FOUND","HIDE_NOTIFICATION_TIMEOUT","ALWAYS_COMMIT_FORM","RENDER_QUESTION_LABELS","RENDER_MANDATORY_ATTRIBUTE_INDICATION","RENDER_OPTIONAL_ATTRIBUTE_INDICATION","AVAILABLE_LIST_VIEWS","USE_CLIENTSIDE_VALIDATION","USE_INSTANT_SERVER_VALIDATION","ENABLED_LOCALES","RENDER_GLOBAL_LOGIN_PAGE","RENDER_GLOBAL_LOGOUT_PAGE","RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE","LOGIN_PATH","ADMINISTRATOR_LOGIN_PATH","LOGOUT_PATH","RENDER_FORMS_IN_MODAL","SHOW_SUBMIT_WAIT_TIMEOUT","SWIM_LANE_DIAGRAM_CONFIGURATION","BUSINESS_SCENARIO_CONCEPT_TYPE","BUSINESS_SCENARIO_STEP_CONCEPT_TYPE","BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE","BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE","CALENDAR_WEEK_STARTS_ON","CALENDAR_FIRST_WEEK_CONTAINS_DATE","UI_PARAMETERS","ALLOW_HIDE_WHEN_EMPTY_ON_TABS","PAGE_RELOAD_ON_UNAUTHORIZED_ERROR","XHR_TIMEOUT_MS","HIDE_WHEN_EMPTY_IGNORE_TASKS","SHOW_AVATARS","settings","setSettings","config","_Object$assign","getSetting","key","defaultValue","undefined","Error","setSetting","value","allSettings","cacheContributions","getBasePath","getUploadPath","getCaptchaPath","hasAllContentInData","loginType","JAAS","loginPath","clientName","arguments","length","loginUsernameField","loginPasswordField","logoutPath","getSwimLaneDiagramConfiguration","configLocation","_startsWithInstanceProperty","call","setContextPath","BASE"],"sources":["../../src/constants/Settings.js"],"sourcesContent":["// @flow\nimport { isPlainObject, has } from \"../utils/helpers/objects\";\nimport { getRepositoryResourceUrl } from \"../utils/helpers/repositoryResource\";\nimport {\n ALL_CONTENT_IN_DATA_SETTING,\n INTERNAL_LOGIN_TYPE,\n LOGIN_TYPE,\n LOGIN_PATH_SETTING,\n LOGIN_USERNAME_SETTING,\n LOGIN_PASSWORD_SETTING,\n LOGOUT_PATH_SETTING,\n UPLOAD_PATH,\n CAPTCHA_PATH,\n} from \"./Constants\";\n\ntype Setting = boolean | string | number | Array<string>;\n\nconst serverBase =\n typeof __CONTEXT_PATH__ === \"undefined\" ? null : __CONTEXT_PATH__;\n\nconst defaultSettings: { [name: string]: Setting } = {\n // This uses contextPath set from property from server\n CONTEXT_PATH:\n serverBase ??\n (typeof window !== \"undefined\" && window.contextPath\n ? window.contextPath\n : \"/BeInformed\"),\n\n // Indicates if contributions should be cached\n CACHE_CONTRIBUTIONS: true,\n\n // Debug missing i18n messages in layout\n DEBUG_I18N_MESSAGE_NOT_FOUND: true,\n\n // Time to show the notification bar\n HIDE_NOTIFICATION_TIMEOUT: 5000,\n\n // Always commit form, does not show result pages for instruments\n ALWAYS_COMMIT_FORM: false,\n\n // Render instrument and event question labels on forms (might result in duplicate labels)\n RENDER_QUESTION_LABELS: true,\n\n // Render mandatory indications on attributes\n RENDER_MANDATORY_ATTRIBUTE_INDICATION: true,\n\n // Render optional indications on attributes\n RENDER_OPTIONAL_ATTRIBUTE_INDICATION: false,\n\n // Renders a toggle with supported list views, options are ListView and TableView\n AVAILABLE_LIST_VIEWS: [\"ListView\", \"TableView\"],\n\n // Toggle client side validation\n USE_CLIENTSIDE_VALIDATION: true,\n\n // Indicates if server validation should be used when a form field is changed\n USE_INSTANT_SERVER_VALIDATION: true,\n\n // Indicates which locales are enabled\n ENABLED_LOCALES: [\"en\", \"nl\"],\n\n // Renders the global log in page\n RENDER_GLOBAL_LOGIN_PAGE: false,\n\n // Renders the global log out page\n RENDER_GLOBAL_LOGOUT_PAGE: false,\n\n // Renders the login variants as option on the global logout page\n RENDER_MULTI_LOGIN_ON_GLOBAL_LOGOUT_PAGE: false,\n\n // Path to login page / component\n LOGIN_PATH: \"/signin\",\n\n // Path to administrator login page / component\n ADMINISTRATOR_LOGIN_PATH: \"\",\n\n // Path to logout page / component\n LOGOUT_PATH: \"/signout\",\n\n // Render forms in a modal\n RENDER_FORMS_IN_MODAL: true,\n\n // Wait timeout before rendering submit wait icon\n SHOW_SUBMIT_WAIT_TIMEOUT: 300,\n\n // Swim lane diagram configuration file\n SWIM_LANE_DIAGRAM_CONFIGURATION: \"/Library/Diagrams/Overviews.json\",\n\n // Business scenario concept types\n BUSINESS_SCENARIO_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/BusinessScenario\",\n ],\n BUSINESS_SCENARIO_STEP_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/ScenarioStep\",\n ],\n BUSINESS_SCENARIO_PERSONA_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/Persona\",\n ],\n BUSINESS_SCENARIO_SYSTEM_CONCEPT_TYPE: [\n \"/Library/KMTs/Business scenarios.bixml/System\",\n ],\n\n // indicates on what day the week starts (0 = Sunday)\n CALENDAR_WEEK_STARTS_ON: 1,\n\n // indicates which date indicates the first week of the year\n CALENDAR_FIRST_WEEK_CONTAINS_DATE: 1,\n\n // parameters that are added for the ui state, but should not be send to the modular ui\n UI_PARAMETERS: [],\n\n // disable hide-when-empty hint for layouts running on Be Informed versions older than 21.1\n ALLOW_HIDE_WHEN_EMPTY_ON_TABS: true,\n\n // reload the complete page on signout, usefull when third party authentication is in place\n PAGE_RELOAD_ON_UNAUTHORIZED_ERROR: false,\n\n XHR_TIMEOUT_MS: 300000,\n\n HIDE_WHEN_EMPTY_IGNORE_TASKS: false,\n\n SHOW_AVATARS: true,\n};\n\nlet settings = defaultSettings;\n\n/**\n */\nexport const setSettings = (config: Object) => {\n if (isPlainObject(config)) {\n settings = Object.assign(defaultSettings, config);\n }\n};\n\n/**\n */\nexport const getSetting = (key: string, defaultValue?: any): any => {\n if (!has(settings, key) && defaultValue === undefined) {\n throw new Error(\n `Setting with name ${key} not found and no defaultValue given`,\n );\n }\n\n return settings[key] ?? defaultValue;\n};\n\n/**\n */\nexport const setSetting = (key: string, value: any) => {\n settings[key] = value;\n};\n\n/**\n */\nexport const allSettings = (): { [name: string]: Setting } => settings;\n\n/**\n * Indicates if contributions must be cached\n */\nexport const cacheContributions = (): boolean =>\n getSetting(\"CACHE_CONTRIBUTIONS\", true);\n\n/**\n * Base path\n * This uses contextPath set from property from server\n * When requesting a remote server with CORS enabled, add the origin, for example:\n * export const BEINFORMED_PATH = 'http://192.168.128.61:8080/BeInformed';\n */\nexport const getBasePath = (): string =>\n getSetting(\"CONTEXT_PATH\", \"/BeInformed\");\n\n/**\n * Path to upload service\n */\nexport const getUploadPath = (): string => `${getBasePath()}${UPLOAD_PATH}`;\n\n/**\n * Path to captcha service\n */\nexport const getCaptchaPath = (): string => `${getBasePath()}${CAPTCHA_PATH}`;\n\n/**\n */\nexport const hasAllContentInData = (): boolean =>\n getSetting(ALL_CONTENT_IN_DATA_SETTING, true);\n\n/**\n * Login type, only available when pac4j is configured\n *\n * Preview does not support pac4j, thus is probably not configured when started, which results in login type JAAS\n */\nexport const loginType = (): string =>\n getSetting(LOGIN_TYPE, INTERNAL_LOGIN_TYPE.JAAS);\n\n/**\n */\nexport const loginPath = (clientName: string = \"FormClient\"): string =>\n getSetting(LOGIN_PATH_SETTING, `/callback?client_name=${clientName}`);\n/**\n */\nexport const loginUsernameField = (): string =>\n getSetting(LOGIN_USERNAME_SETTING, \"j_username\");\n/**\n */\nexport const loginPasswordField = (): string =>\n getSetting(LOGIN_PASSWORD_SETTING, \"j_password\");\n/**\n */\nexport const logoutPath = (): string =>\n getSetting(LOGOUT_PATH_SETTING, \"/logout\");\n\nexport const LOGIN_PATH: string = loginPath();\nexport const LOGOUT_PATH: string = logoutPath();\n\n/**\n * Model overview swim lane configuration\n */\nexport const getSwimLaneDiagramConfiguration: Object = () => {\n let configLocation = getSetting(\n \"SWIM_LANE_DIAGRAM_CONFIGURATION\",\n \"/Library/Diagrams/Overviews.json\",\n );\n if (!configLocation.startsWith(\"/\")) {\n configLocation = `/${configLocation}`;\n }\n return getRepositoryResourceUrl(configLocation);\n};\n\n/**\n * Set the context path for requests to be informed\n */\nexport const setContextPath = (contextPath: string) => {\n setSetting(\"CONTEXT_PATH\", contextPath);\n};\n\n/**\n * Backwards compatible export of BASE constant\n */\nexport const BASE: string = getBasePath();\n"],"mappings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,cAAc,GAAGvB,UAAU,CAC7B,iCAAiC,EACjC,kCACF,CAAC;EACD,IAAI,CAACwB,2BAAA,CAAAD,cAAc,EAAAE,IAAA,CAAdF,cAAc,EAAY,GAAG,CAAC,EAAE;IACnCA,cAAc,GAAG,IAAIA,cAAc,EAAE;EACvC;EACA,OAAO3E,wBAAwB,CAAC2E,cAAc,CAAC;AACjD,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMG,cAAc,GAAI/D,WAAmB,IAAK;EACrD0C,UAAU,CAAC,cAAc,EAAE1C,WAAW,CAAC;AACzC,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMgE,IAAY,GAAGlB,WAAW,CAAC,CAAC","ignoreList":[]}
|
package/esm/hooks/useForm.js
CHANGED
|
@@ -17,7 +17,9 @@ export const useForm = (href, data) => {
|
|
|
17
17
|
method: HTTP_METHODS.POST,
|
|
18
18
|
targetModel: FormModel,
|
|
19
19
|
removeOnUnmount: true,
|
|
20
|
-
data
|
|
20
|
+
data,
|
|
21
|
+
origin: formHref.origin,
|
|
22
|
+
contextPath: formHref.contextPath
|
|
21
23
|
});
|
|
22
24
|
if (form?.model) {
|
|
23
25
|
return form.model;
|
package/esm/hooks/useForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useForm.js","names":["useDispatch","Href","getSetting","HTTP_METHODS","loadModularUI","removeModelByKey","useModularUI","addRepeatableAttributeSet","cancelForm","cancelRepeatableAttributeSet","previousObject","removeRepeatableAttributeSet","showFormNotification","updateFormAttribute","FormModel","useForm","href","data","formHref","addParameter","form","method","POST","targetModel","removeOnUnmount","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","formdata","updateHandler","newModel","clonedModel","clone","update","remove","showFormNotificationAction","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport type {\n RemoveModelByKeyAction,\n UpdateFormAction,\n} from \"../redux/_modularui\";\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { AttributeType, FormObjectModel, ModularUIModel } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateFormAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateFormAction,\n cancel: (object: FormObjectModel) => UpdateFormAction,\n remove: (object: FormObjectModel) => UpdateFormAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href, data?: Object): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n data,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n const clonedModel: FormModel = form.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n targetModel: FormModel,\n }),\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Hook that returns a function to update attributes of a form object.\n * <br >\n * The returned function accepts the following options:\n *\n * - autosubmit: Automatically submit the form after a change\n * - autosav: Automatically save the form (in the background) after a change\n * - autoupdate: Automatically update the current form object after a change\n * - forceUpdate: Force the update even if conditions are not met.\n * - validate: Activate/deactivate the form object validation by an update.\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel,\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,OAAOC,IAAI,MAAM,qBAAqB;AAEtC,SAASC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AAMvD,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,qBAAqB;AACrE,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,SACEC,yBAAyB,EACzBC,UAAU,EACVC,4BAA4B,EAC5BC,cAAc,EACdC,4BAA4B,EAC5BC,oBAAoB,EACpBC,mBAAmB,QACd,kBAAkB;AAEzB,OAAOC,SAAS,MAAM,0BAA0B;AAyBhD;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CAACC,IAAmB,EAAEC,IAAa,KAAiB;EACzE,MAAMC,QAAQ,GAAG,IAAIjB,IAAI,CAACe,IAAI,CAAC;EAE/B,IAAI,CAACd,UAAU,CAAC,oBAAoB,CAAC,EAAE;IACrCgB,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC1C;EAEA,MAAMC,IAAI,GAAGd,YAAY,CAAC,MAAM,EAAEY,QAAQ,EAAE;IAC1CG,MAAM,EAAElB,YAAY,CAACmB,IAAI;IACzBC,WAAW,EAAET,SAAS;IACtBU,eAAe,EAAE,IAAI;IACrBP;
|
|
1
|
+
{"version":3,"file":"useForm.js","names":["useDispatch","Href","getSetting","HTTP_METHODS","loadModularUI","removeModelByKey","useModularUI","addRepeatableAttributeSet","cancelForm","cancelRepeatableAttributeSet","previousObject","removeRepeatableAttributeSet","showFormNotification","updateFormAttribute","FormModel","useForm","href","data","formHref","addParameter","form","method","POST","targetModel","removeOnUnmount","origin","contextPath","model","useFormNavigation","dispatch","previous","cancel","submit","connectKey","selfhref","formdata","updateHandler","newModel","clonedModel","clone","update","remove","showFormNotificationAction","useAttributeUpdate","object","attribute","value","options","useAttributeSet","save"],"sources":["../../src/hooks/useForm.js"],"sourcesContent":["// @flow\nimport { useDispatch } from \"react-redux\";\n\nimport Href from \"../models/href/Href\";\n\nimport { getSetting, HTTP_METHODS } from \"../constants\";\n\nimport type {\n RemoveModelByKeyAction,\n UpdateFormAction,\n} from \"../redux/_modularui\";\nimport { loadModularUI, removeModelByKey } from \"../redux/_modularui\";\nimport { useModularUI } from \"./useModularUI\";\n\nimport {\n addRepeatableAttributeSet,\n cancelForm,\n cancelRepeatableAttributeSet,\n previousObject,\n removeRepeatableAttributeSet,\n showFormNotification,\n updateFormAttribute,\n} from \"../redux/actions\";\n\nimport FormModel from \"../models/form/FormModel\";\n\nimport type { AttributeType, FormObjectModel, ModularUIModel } from \"../models\";\nimport type { UpdateFormOptions } from \"../redux/types\";\n\ntype FormNavigationHook = {\n previous: (form: FormModel) => UpdateFormAction,\n cancel: (form: FormModel) => void,\n submit: (form: FormModel) => void,\n showFormNotification: (form: FormModel) => void,\n remove: (form: FormModel) => RemoveModelByKeyAction,\n};\n\ntype AttributeSetHook = {\n save: () => UpdateFormAction,\n cancel: (object: FormObjectModel) => UpdateFormAction,\n remove: (object: FormObjectModel) => UpdateFormAction,\n};\n\ntype AttributeUpdateHook = (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n) => void;\n\n/**\n * Load a form by href\n */\nexport const useForm = (href: string | Href, data?: Object): ?FormModel => {\n const formHref = new Href(href);\n\n if (!getSetting(\"ALWAYS_COMMIT_FORM\")) {\n formHref.addParameter(\"commit\", \"false\");\n }\n\n const form = useModularUI(\"form\", formHref, {\n method: HTTP_METHODS.POST,\n targetModel: FormModel,\n removeOnUnmount: true,\n data,\n origin: formHref.origin,\n contextPath: formHref.contextPath,\n });\n\n if (form?.model) {\n return form.model;\n }\n};\n\n/**\n * Form navigation methods\n */\nexport const useFormNavigation = (): FormNavigationHook => {\n const dispatch = useDispatch();\n\n const previous = (form: FormModel) => dispatch(previousObject(form));\n\n const cancel = (form: FormModel) => dispatch(cancelForm(form));\n\n const submit = (form: FormModel) =>\n dispatch(\n loadModularUI(form.connectKey, form.selfhref, {\n method: HTTP_METHODS.POST,\n data: form.formdata,\n updateHandler: (newModel: ModularUIModel): ModularUIModel => {\n if (newModel instanceof FormModel) {\n const clonedModel: FormModel = form.clone();\n clonedModel.update(newModel);\n return clonedModel;\n }\n return newModel;\n },\n targetModel: FormModel,\n }),\n );\n\n const remove = (form: FormModel) =>\n dispatch(removeModelByKey(form.connectKey));\n\n const showFormNotificationAction = (form: FormModel) =>\n dispatch(showFormNotification(form));\n\n return {\n previous,\n cancel,\n submit,\n remove,\n showFormNotification: showFormNotificationAction,\n };\n};\n\n/**\n * Hook that returns a function to update attributes of a form object.\n * <br >\n * The returned function accepts the following options:\n *\n * - autosubmit: Automatically submit the form after a change\n * - autosav: Automatically save the form (in the background) after a change\n * - autoupdate: Automatically update the current form object after a change\n * - forceUpdate: Force the update even if conditions are not met.\n * - validate: Activate/deactivate the form object validation by an update.\n */\nexport const useAttributeUpdate = (\n form: FormModel,\n object: FormObjectModel,\n): AttributeUpdateHook => {\n const dispatch = useDispatch();\n\n return (\n attribute: AttributeType,\n value: string,\n options: UpdateFormOptions,\n ) => dispatch(updateFormAttribute(form, object, attribute, value, options));\n};\n\n/**\n * Attributeset actions\n */\nexport const useAttributeSet = (form: FormModel): AttributeSetHook => {\n const dispatch = useDispatch();\n\n return {\n save: () => dispatch(addRepeatableAttributeSet(form)),\n cancel: (object: FormObjectModel) =>\n dispatch(cancelRepeatableAttributeSet(form, object)),\n remove: (object: FormObjectModel) =>\n dispatch(removeRepeatableAttributeSet(form, object)),\n };\n};\n"],"mappings":"AACA,SAASA,WAAW,QAAQ,aAAa;AAEzC,OAAOC,IAAI,MAAM,qBAAqB;AAEtC,SAASC,UAAU,EAAEC,YAAY,QAAQ,cAAc;AAMvD,SAASC,aAAa,EAAEC,gBAAgB,QAAQ,qBAAqB;AACrE,SAASC,YAAY,QAAQ,gBAAgB;AAE7C,SACEC,yBAAyB,EACzBC,UAAU,EACVC,4BAA4B,EAC5BC,cAAc,EACdC,4BAA4B,EAC5BC,oBAAoB,EACpBC,mBAAmB,QACd,kBAAkB;AAEzB,OAAOC,SAAS,MAAM,0BAA0B;AAyBhD;AACA;AACA;AACA,OAAO,MAAMC,OAAO,GAAGA,CAACC,IAAmB,EAAEC,IAAa,KAAiB;EACzE,MAAMC,QAAQ,GAAG,IAAIjB,IAAI,CAACe,IAAI,CAAC;EAE/B,IAAI,CAACd,UAAU,CAAC,oBAAoB,CAAC,EAAE;IACrCgB,QAAQ,CAACC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC;EAC1C;EAEA,MAAMC,IAAI,GAAGd,YAAY,CAAC,MAAM,EAAEY,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AACQ,IAAI,CAAC,CAAC;EAEtC,OAAO;IACLU,QAAQ;IACRC,MAAM;IACNC,MAAM;IACNS,MAAM;IACN7B,oBAAoB,EAAE8B;EACxB,CAAC;AACH,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,kBAAkB,GAAGA,CAChCvB,IAAe,EACfwB,MAAuB,KACC;EACxB,MAAMf,QAAQ,GAAG7B,WAAW,CAAC,CAAC;EAE9B,OAAO,CACL6C,SAAwB,EACxBC,KAAa,EACbC,OAA0B,KACvBlB,QAAQ,CAAChB,mBAAmB,CAACO,IAAI,EAAEwB,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,OAAO,CAAC,CAAC;AAC7E,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMC,eAAe,GAAI5B,IAAe,IAAuB;EACpE,MAAMS,QAAQ,GAAG7B,WAAW,CAAC,CAAC;EAE9B,OAAO;IACLiD,IAAI,EAAEA,CAAA,KAAMpB,QAAQ,CAACtB,yBAAyB,CAACa,IAAI,CAAC,CAAC;IACrDW,MAAM,EAAGa,MAAuB,IAC9Bf,QAAQ,CAACpB,4BAA4B,CAACW,IAAI,EAAEwB,MAAM,CAAC,CAAC;IACtDH,MAAM,EAAGG,MAAuB,IAC9Bf,QAAQ,CAAClB,4BAA4B,CAACS,IAAI,EAAEwB,MAAM,CAAC;EACvD,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ import { HTTP_METHODS } from "../constants";
|
|
|
4
4
|
import { loadModularUI, removeModelByKey } from "../redux/_modularui/ModularUIActions";
|
|
5
5
|
import useDeepCompareEffect from "./useDeepCompareEffect";
|
|
6
6
|
import { useLocale } from "./useI18n";
|
|
7
|
+
import Href from "../models/href/Href";
|
|
7
8
|
/**
|
|
8
9
|
*/
|
|
9
10
|
const useKeyForHook = (modelKey, url) => {
|
|
@@ -22,6 +23,10 @@ export const useModularUI = function (modelKey, url) {
|
|
|
22
23
|
const dispatch = useDispatch();
|
|
23
24
|
const href = url?.toString() || "";
|
|
24
25
|
const key = useKeyForHook(modelKey, href);
|
|
26
|
+
if (url instanceof Href) {
|
|
27
|
+
options.origin = options.origin ?? url.origin;
|
|
28
|
+
options.contextPath = options.contextPath ?? url.contextPath;
|
|
29
|
+
}
|
|
25
30
|
const prevOptions = useRef(options);
|
|
26
31
|
const prevHref = useRef(href);
|
|
27
32
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useDispatch","useSelector","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","useKeyForHook","modelKey","url","locale","split","useModularUI","options","arguments","length","undefined","method","GET","removeOnUnmount","dispatch","href","toString","key","prevOptions","prevHref","isOldReload","current","isReload","state","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\
|
|
1
|
+
{"version":3,"file":"useModularUI.js","names":["useEffect","useRef","useDispatch","useSelector","HTTP_METHODS","loadModularUI","removeModelByKey","useDeepCompareEffect","useLocale","Href","useKeyForHook","modelKey","url","locale","split","useModularUI","options","arguments","length","undefined","method","GET","removeOnUnmount","dispatch","href","toString","key","origin","contextPath","prevOptions","prevHref","isOldReload","current","isReload","state","modularui"],"sources":["../../src/hooks/useModularUI.js"],"sourcesContent":["// @flow\nimport { useEffect, useRef } from \"react\";\nimport { useDispatch, useSelector } from \"react-redux\";\n\nimport { HTTP_METHODS } from \"../constants\";\nimport {\n loadModularUI,\n removeModelByKey,\n} from \"../redux/_modularui/ModularUIActions\";\n\nimport useDeepCompareEffect from \"./useDeepCompareEffect\";\n\nimport { useLocale } from \"./useI18n\";\nimport Href from \"../models/href/Href\";\n\nimport type { RequestModularUIOptions } from \"../utils\";\n\n/**\n */\nconst useKeyForHook = (modelKey: string, url: string) => {\n const locale = useLocale();\n return `${modelKey}(${url.split(\"?\")[0]})(${locale})`;\n};\n\n/**\n * Use redux action and selector to retrieve the correct modular ui service model\n */\nexport const useModularUI = (\n modelKey: string,\n url: string | Href,\n options: RequestModularUIOptions = {\n method: HTTP_METHODS.GET,\n removeOnUnmount: false,\n },\n): any => {\n const dispatch = useDispatch();\n const href = url?.toString() || \"\";\n const key = useKeyForHook(modelKey, href);\n\n if (url instanceof Href) {\n options.origin = options.origin ?? url.origin;\n options.contextPath = options.contextPath ?? url.contextPath;\n }\n\n const prevOptions = useRef(options);\n const prevHref = useRef(href);\n\n // dispatch loadModularUI\n useDeepCompareEffect(() => {\n // prevent reloads when previous option had the isReload, but the new options not\n const isOldReload =\n prevHref.current === href &&\n prevOptions.current.isReload &&\n !options.isReload;\n\n if (href !== \"\" && !isOldReload) {\n dispatch(loadModularUI(key, href, options));\n }\n\n prevOptions.current = options;\n prevHref.current = href;\n }, [key, href, options]);\n\n const { removeOnUnmount = false } = options;\n useEffect(() => {\n return () => {\n if (removeOnUnmount) {\n dispatch(removeModelByKey(key));\n }\n };\n }, [dispatch, key, removeOnUnmount]);\n\n // retrieve current model from modularui reducer\n return useSelector((state) => {\n return state.modularui[key];\n });\n};\n"],"mappings":"AACA,SAASA,SAAS,EAAEC,MAAM,QAAQ,OAAO;AACzC,SAASC,WAAW,EAAEC,WAAW,QAAQ,aAAa;AAEtD,SAASC,YAAY,QAAQ,cAAc;AAC3C,SACEC,aAAa,EACbC,gBAAgB,QACX,sCAAsC;AAE7C,OAAOC,oBAAoB,MAAM,wBAAwB;AAEzD,SAASC,SAAS,QAAQ,WAAW;AACrC,OAAOC,IAAI,MAAM,qBAAqB;AAItC;AACA;AACA,MAAMC,aAAa,GAAGA,CAACC,QAAgB,EAAEC,GAAW,KA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7C;IAEAa,WAAW,CAACG,OAAO,GAAGhB,OAAO;IAC7Bc,QAAQ,CAACE,OAAO,GAAGR,IAAI;EACzB,CAAC,EAAE,CAACE,GAAG,EAAEF,IAAI,EAAER,OAAO,CAAC,CAAC;EAExB,MAAM;IAAEM,eAAe,GAAG;EAAM,CAAC,GAAGN,OAAO;EAC3ChB,SAAS,CAAC,MAAM;IACd,OAAO,MAAM;MACX,IAAIsB,eAAe,EAAE;QACnBC,QAAQ,CAACjB,gBAAgB,CAACoB,GAAG,CAAC,CAAC;MACjC;IACF,CAAC;EACH,CAAC,EAAE,CAACH,QAAQ,EAAEG,GAAG,EAAEJ,eAAe,CAAC,CAAC;;EAEpC;EACA,OAAOnB,WAAW,CAAE+B,KAAK,IAAK;IAC5B,OAAOA,KAAK,CAACC,SAAS,CAACT,GAAG,CAAC;EAC7B,CAAC,CAAC;AACJ,CAAC","ignoreList":[]}
|
|
@@ -9,13 +9,17 @@ export const useModularUIBasic = function (key, href) {
|
|
|
9
9
|
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
10
10
|
expectedModels: [],
|
|
11
11
|
targetModel: undefined,
|
|
12
|
-
forceTargetModel: false
|
|
12
|
+
forceTargetModel: false,
|
|
13
|
+
origin: undefined,
|
|
14
|
+
contextPath: undefined
|
|
13
15
|
};
|
|
14
16
|
const location = useLocation();
|
|
15
17
|
const useModularUIOptions = {
|
|
16
18
|
targetModel: undefined,
|
|
17
19
|
forceTargetModel: undefined,
|
|
18
20
|
isReload: false,
|
|
21
|
+
origin: undefined,
|
|
22
|
+
contextPath: undefined,
|
|
19
23
|
cache: false
|
|
20
24
|
};
|
|
21
25
|
if (options.targetModel) {
|
|
@@ -30,6 +34,12 @@ export const useModularUIBasic = function (key, href) {
|
|
|
30
34
|
if (location.state?.reload && _startsWithInstanceProperty(_context = location.pathname).call(_context, href.toString())) {
|
|
31
35
|
useModularUIOptions.isReload = true;
|
|
32
36
|
}
|
|
37
|
+
if (options.origin) {
|
|
38
|
+
useModularUIOptions.origin = options.origin;
|
|
39
|
+
}
|
|
40
|
+
if (options.contextPath) {
|
|
41
|
+
useModularUIOptions.contextPath = options.contextPath;
|
|
42
|
+
}
|
|
33
43
|
|
|
34
44
|
// $FlowFixMe[incompatible-call]
|
|
35
45
|
const modularUI = useModularUI(key, href, useModularUIOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIBasic.js","names":["useModularUI","useLocation","IllegalStateException","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","location","useModularUIOptions","isReload","cache","state","reload","_startsWithInstanceProperty","pathname","call","toString","modularUI","model","isCorrectModel","some","expectedModel","type","console","error"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels?: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n cache?: boolean,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n },\n): T | null => {\n const location = useLocation();\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n cache: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\n }\n\n if (options.cache) {\n useModularUIOptions.cache = options.cache;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n\n const expectedModels = options.expectedModels ?? [];\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";AACA,SAASA,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,qBAAqB,QAAQ,eAAe;
|
|
1
|
+
{"version":3,"file":"useModularUIBasic.js","names":["useModularUI","useLocation","IllegalStateException","useModularUIBasic","key","href","_context","options","arguments","length","undefined","expectedModels","targetModel","forceTargetModel","origin","contextPath","location","useModularUIOptions","isReload","cache","state","reload","_startsWithInstanceProperty","pathname","call","toString","modularUI","model","isCorrectModel","some","expectedModel","type","console","error"],"sources":["../../src/hooks/useModularUIBasic.js"],"sourcesContent":["// @flow\nimport { useModularUI } from \"./useModularUI\";\n\nimport { useLocation } from \"./useRouter\";\n\nimport { IllegalStateException } from \"../exceptions\";\n\nimport type { ModularUIModel, Href } from \"../models\";\n\nexport type UseModularUIBasicOptions<T: ModularUIModel> = {\n expectedModels?: Array<string>,\n targetModel?: Class<T> | Array<Class<T>>,\n forceTargetModel?: boolean,\n origin?: string,\n contextPath?: string,\n cache?: boolean,\n};\n\n/**\n */\nexport const useModularUIBasic = <T: ModularUIModel>(\n key: string,\n href: string | Href,\n options: UseModularUIBasicOptions<T> = {\n expectedModels: [],\n targetModel: undefined,\n forceTargetModel: false,\n origin: undefined,\n contextPath: undefined,\n },\n): T | null => {\n const location = useLocation();\n\n const useModularUIOptions = {\n targetModel: undefined,\n forceTargetModel: undefined,\n isReload: false,\n origin: undefined,\n contextPath: undefined,\n cache: false,\n };\n if (options.targetModel) {\n useModularUIOptions.targetModel = options.targetModel;\n useModularUIOptions.forceTargetModel = options.forceTargetModel;\n }\n\n if (options.cache) {\n useModularUIOptions.cache = options.cache;\n }\n\n // reload when the modular service starts with the current location\n if (location.state?.reload && location.pathname.startsWith(href.toString())) {\n useModularUIOptions.isReload = true;\n }\n\n if (options.origin) {\n useModularUIOptions.origin = options.origin;\n }\n\n if (options.contextPath) {\n useModularUIOptions.contextPath = options.contextPath;\n }\n\n // $FlowFixMe[incompatible-call]\n const modularUI = useModularUI(key, href, useModularUIOptions);\n\n if (modularUI?.model) {\n const { model } = modularUI;\n\n const expectedModels = options.expectedModels ?? [];\n if (expectedModels.length > 0) {\n const isCorrectModel = expectedModels.some((expectedModel) => {\n return model.type === expectedModel;\n });\n\n if (!isCorrectModel) {\n console.error(modularUI, \"is not of instance\", expectedModels);\n throw new IllegalStateException(\"Resolved model has incorrect type\");\n }\n }\n\n return model;\n }\n\n return null;\n};\n"],"mappings":";AACA,SAASA,YAAY,QAAQ,gBAAgB;AAE7C,SAASC,WAAW,QAAQ,aAAa;AAEzC,SAASC,qBAAqB,QAAQ,eAAe;AAarD;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAG,SAAAA,CAC/BC,GAAW,EACXC,IAAmB,EAQN;EAAA,IAAAC,QAAA;EAAA,IAPbC,OAAoC,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG;IACrCG,cAAc,EAAE,EAAE;IAClBC,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAE,KAAK;IACvBC,MAAM,EAAEJ,SAAS;IACjBK,WAAW,EAAEL;EACf,CAAC;EAED,MAAMM,QAAQ,GAAGf,WAAW,CAAC,CAAC;EAE9B,MAAMgB,mBAAmB,GAAG;IAC1BL,WAAW,EAAEF,SAAS;IACtBG,gBAAgB,EAAEH,SAAS;IAC3BQ,QAAQ,EAAE,KAAK;IACfJ,MAAM,EAAEJ,SAAS;IACjBK,WAAW,EAAEL,SAAS;IACtBS,KAAK,EAAE;EACT,CAAC;EACD,IAAIZ,OAAO,CAACK,WAAW,EAAE;IACvBK,mBAAmB,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AEA,OAAO,IAAI;AACb,CAAC","ignoreList":[]}
|
|
@@ -8,91 +8,102 @@ import CaseSearchModel from "../models/search/CaseSearchModel";
|
|
|
8
8
|
import ListDetailModel from "../models/list/ListDetailModel";
|
|
9
9
|
import UserProfileModel from "../models/user/UserProfileModel";
|
|
10
10
|
import { useModularUIBasic } from "./useModularUIBasic";
|
|
11
|
-
|
|
12
11
|
/**
|
|
13
12
|
* Load application
|
|
14
13
|
*/
|
|
15
|
-
export const useApplication =
|
|
14
|
+
export const useApplication = options => useModularUIBasic("application", "/", {
|
|
16
15
|
expectedModels: ["Application"],
|
|
17
|
-
targetModel: ApplicationModel
|
|
16
|
+
targetModel: ApplicationModel,
|
|
17
|
+
...options
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Load a tab by href
|
|
22
22
|
*/
|
|
23
|
-
export const useTab = href => useModularUIBasic("tab", href, {
|
|
23
|
+
export const useTab = (href, options) => useModularUIBasic("tab", href, {
|
|
24
24
|
expectedModels: ["Tab"],
|
|
25
|
-
targetModel: TabModel
|
|
25
|
+
targetModel: TabModel,
|
|
26
|
+
...options
|
|
26
27
|
});
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Load caseview by href
|
|
30
31
|
*/
|
|
31
|
-
export const useCaseView = href => useModularUIBasic("caseview", href, {
|
|
32
|
+
export const useCaseView = (href, options) => useModularUIBasic("caseview", href, {
|
|
32
33
|
expectedModels: ["CaseView"],
|
|
33
|
-
targetModel: CaseViewModel
|
|
34
|
+
targetModel: CaseViewModel,
|
|
35
|
+
...options
|
|
34
36
|
});
|
|
35
37
|
|
|
36
38
|
/**
|
|
37
39
|
*/
|
|
38
|
-
export const usePanel = href => useModularUIBasic("panel", href, {
|
|
39
|
-
expectedModels: ["List", "GroupingPanel", "Detail"]
|
|
40
|
+
export const usePanel = (href, options) => useModularUIBasic("panel", href, {
|
|
41
|
+
expectedModels: ["List", "GroupingPanel", "Detail"],
|
|
42
|
+
...options
|
|
40
43
|
});
|
|
41
44
|
|
|
42
45
|
/**
|
|
43
46
|
*/
|
|
44
|
-
export const useList = href => useModularUIBasic("list", href, {
|
|
47
|
+
export const useList = (href, options) => useModularUIBasic("list", href, {
|
|
45
48
|
expectedModels: ["List"],
|
|
46
|
-
targetModel: ListModel
|
|
49
|
+
targetModel: ListModel,
|
|
50
|
+
...options
|
|
47
51
|
});
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
54
|
*/
|
|
51
|
-
export const useListOrDetail = href => useModularUIBasic("list", href, {
|
|
55
|
+
export const useListOrDetail = (href, options) => useModularUIBasic("list", href, {
|
|
52
56
|
expectedModels: ["List", "Detail"],
|
|
53
|
-
targetModel: [ListModel, DetailModel]
|
|
57
|
+
targetModel: [ListModel, DetailModel],
|
|
58
|
+
...options
|
|
54
59
|
});
|
|
55
60
|
|
|
56
61
|
/**
|
|
57
62
|
*/
|
|
58
|
-
export const useListDetail = href => useModularUIBasic("listdetail", href, {
|
|
63
|
+
export const useListDetail = (href, options) => useModularUIBasic("listdetail", href, {
|
|
59
64
|
expectedModels: ["ListDetail"],
|
|
60
65
|
targetModel: ListDetailModel,
|
|
61
|
-
forceTargetModel: true
|
|
66
|
+
forceTargetModel: true,
|
|
67
|
+
...options
|
|
62
68
|
});
|
|
63
69
|
|
|
64
70
|
/**
|
|
65
71
|
*/
|
|
66
|
-
export const useGroupingPanel = href => useModularUIBasic("groupingpanel", href, {
|
|
72
|
+
export const useGroupingPanel = (href, options) => useModularUIBasic("groupingpanel", href, {
|
|
67
73
|
expectedModels: ["GroupingPanel"],
|
|
68
|
-
targetModel: GroupingPanelModel
|
|
74
|
+
targetModel: GroupingPanelModel,
|
|
75
|
+
...options
|
|
69
76
|
});
|
|
70
77
|
|
|
71
78
|
/**
|
|
72
79
|
*/
|
|
73
|
-
export const useDetailPanel = href => useModularUIBasic("detailpanel", href, {
|
|
80
|
+
export const useDetailPanel = (href, options) => useModularUIBasic("detailpanel", href, {
|
|
74
81
|
expectedModels: ["Detail"],
|
|
75
|
-
targetModel: DetailModel
|
|
82
|
+
targetModel: DetailModel,
|
|
83
|
+
...options
|
|
76
84
|
});
|
|
77
85
|
|
|
78
86
|
/**
|
|
79
87
|
*/
|
|
80
|
-
export const useQuicksearch = href => useModularUIBasic("quicksearch", href, {
|
|
88
|
+
export const useQuicksearch = (href, options) => useModularUIBasic("quicksearch", href, {
|
|
81
89
|
expectedModels: ["CaseSearch"],
|
|
82
|
-
targetModel: CaseSearchModel
|
|
90
|
+
targetModel: CaseSearchModel,
|
|
91
|
+
...options
|
|
83
92
|
});
|
|
84
93
|
|
|
85
94
|
/**
|
|
86
95
|
*/
|
|
87
|
-
export const useSearch = href => useModularUIBasic("search", href, {
|
|
96
|
+
export const useSearch = (href, options) => useModularUIBasic("search", href, {
|
|
88
97
|
expectedModels: ["CaseSearch"],
|
|
89
|
-
targetModel: CaseSearchModel
|
|
98
|
+
targetModel: CaseSearchModel,
|
|
99
|
+
...options
|
|
90
100
|
});
|
|
91
101
|
|
|
92
102
|
/**
|
|
93
103
|
*/
|
|
94
|
-
export const useUserProfile = href => useModularUIBasic("userprofile", href, {
|
|
104
|
+
export const useUserProfile = (href, options) => useModularUIBasic("userprofile", href, {
|
|
95
105
|
expectedModels: ["UserProfile"],
|
|
96
|
-
targetModel: UserProfileModel
|
|
106
|
+
targetModel: UserProfileModel,
|
|
107
|
+
...options
|
|
97
108
|
});
|
|
98
109
|
//# sourceMappingURL=useModularUIModel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIModel.js","names":["ApplicationModel","CaseViewModel","TabModel","ListModel","GroupingPanelModel","DetailModel","CaseSearchModel","ListDetailModel","UserProfileModel","useModularUIBasic","useApplication","expectedModels","targetModel","useTab","href","useCaseView","usePanel","useList","useListOrDetail","useListDetail","forceTargetModel","useGroupingPanel","useDetailPanel","useQuicksearch","useSearch","useUserProfile"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (): ApplicationModel | null =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string): TabModel | null =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (href: string): CaseViewModel | null =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n });\n\n/**\n */\nexport const usePanel = (\n href: string,\n): ListModel | GroupingPanelModel | DetailModel | null =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n });\n\n/**\n */\nexport const useList = (href: string): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n });\n\n/**\n */\nexport const useListOrDetail = (href: string): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"Detail\"],\n targetModel: [ListModel, DetailModel],\n });\n\n/**\n */\nexport const useListDetail = (href: string): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n forceTargetModel: true,\n });\n\n/**\n */\nexport const useGroupingPanel = (href: string): GroupingPanelModel | null =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n });\n\n/**\n */\nexport const useDetailPanel = (href: string): DetailModel | null =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n });\n\n/**\n */\nexport const useQuicksearch = (href: string): CaseSearchModel | null =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useSearch = (href: string): CaseSearchModel | null =>\n useModularUIBasic(\"search\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useUserProfile = (href: string): UserProfileModel | null =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n });\n"],"mappings":"AACA,OAAOA,gBAAgB,MAAM,wCAAwC;AACrE,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,OAAOC,QAAQ,MAAM,wBAAwB;AAC7C,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,kBAAkB,MAAM,qCAAqC;AACpE,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,gBAAgB,MAAM,iCAAiC;AAE9D,SAASC,iBAAiB,QAAQ,qBAAqB
|
|
1
|
+
{"version":3,"file":"useModularUIModel.js","names":["ApplicationModel","CaseViewModel","TabModel","ListModel","GroupingPanelModel","DetailModel","CaseSearchModel","ListDetailModel","UserProfileModel","useModularUIBasic","useApplication","options","expectedModels","targetModel","useTab","href","useCaseView","usePanel","useList","useListOrDetail","useListDetail","forceTargetModel","useGroupingPanel","useDetailPanel","useQuicksearch","useSearch","useUserProfile"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\ntype HookOptions = {\n origin?: string,\n contextPath?: string,\n};\n\n/**\n * Load application\n */\nexport const useApplication = (\n options?: HookOptions,\n): ApplicationModel | null =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n ...options,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string, options?: HookOptions): TabModel | null =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n ...options,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (\n href: string,\n options?: HookOptions,\n): CaseViewModel | null =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n ...options,\n });\n\n/**\n */\nexport const usePanel = (\n href: string,\n options?: HookOptions,\n): ListModel | GroupingPanelModel | DetailModel | null =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n ...options,\n });\n\n/**\n */\nexport const useList = (\n href: string,\n options?: HookOptions,\n): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n ...options,\n });\n\n/**\n */\nexport const useListOrDetail = (\n href: string,\n options?: HookOptions,\n): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"Detail\"],\n targetModel: [ListModel, DetailModel],\n ...options,\n });\n\n/**\n */\nexport const useListDetail = (\n href: string,\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 useGroupingPanel = (\n href: string,\n options?: HookOptions,\n): GroupingPanelModel | null =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n ...options,\n });\n\n/**\n */\nexport const useDetailPanel = (\n href: string,\n options?: HookOptions,\n): DetailModel | null =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n ...options,\n });\n\n/**\n */\nexport const useQuicksearch = (\n href: string,\n options?: HookOptions,\n): CaseSearchModel | null =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n ...options,\n });\n\n/**\n */\nexport const useSearch = (\n href: string,\n options?: HookOptions,\n): CaseSearchModel | null =>\n useModularUIBasic(\"search\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n ...options,\n });\n\n/**\n */\nexport const useUserProfile = (\n href: string,\n options?: HookOptions,\n): UserProfileModel | null =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n ...options,\n });\n"],"mappings":"AACA,OAAOA,gBAAgB,MAAM,wCAAwC;AACrE,OAAOC,aAAa,MAAM,kCAAkC;AAC5D,OAAOC,QAAQ,MAAM,wBAAwB;AAC7C,OAAOC,SAAS,MAAM,0BAA0B;AAChD,OAAOC,kBAAkB,MAAM,qCAAqC;AACpE,OAAOC,WAAW,MAAM,8BAA8B;AACtD,OAAOC,eAAe,MAAM,kCAAkC;AAC9D,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,gBAAgB,MAAM,iCAAiC;AAE9D,SAASC,iBAAiB,QAAQ,qBAAqB;AAOvD;AACA;AACA;AACA,OAAO,MAAMC,cAAc,GACzBC,OAAqB,IAErBF,iBAAiB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aAAa,EAAEM,IAAI,EAAE;EACrCH,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEL,gBAAgB;EAC7B,GAAGG;AACL,CAAC,CAAC","ignoreList":[]}
|
|
@@ -9,7 +9,7 @@ import ActionModel from "./ActionModel";
|
|
|
9
9
|
* Collection of actions
|
|
10
10
|
*/
|
|
11
11
|
export default class ActionCollection extends BaseCollection {
|
|
12
|
-
constructor(actions, actionsContributions) {
|
|
12
|
+
constructor(actions, actionsContributions, origin, contextPath) {
|
|
13
13
|
super();
|
|
14
14
|
|
|
15
15
|
// no actions gives an empty collection
|
|
@@ -20,7 +20,7 @@ export default class ActionCollection extends BaseCollection {
|
|
|
20
20
|
for (const actionData of actions) {
|
|
21
21
|
const actionContribution = _findInstanceProperty(actionsContributions).call(actionsContributions, actionContribution => actionContribution.name === actionData.name && actionContribution.type !== "service-operation");
|
|
22
22
|
if (actionContribution) {
|
|
23
|
-
actionModels.push(new ActionModel(actionData, actionContribution));
|
|
23
|
+
actionModels.push(new ActionModel(actionData, actionContribution, origin, contextPath));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
this.collection = actionModels;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionCollection.js","names":["BaseCollection","ActionModel","ActionCollection","constructor","actions","actionsContributions","Array","isArray","collection","actionModels","actionData","actionContribution","_findInstanceProperty","call","name","type","push","getActionByKey","key","_context","newCollection","_filterInstanceProperty","action","first","getActionsByType","_context2","_includesInstanceProperty","getActionsByLayoutHint","_context3","_len","arguments","length","hints","_key","layouthint","has","hasActionsByLayoutHint","routePath","_context4","enabledRoutes","isDisabled","path","_mapInstanceProperty","selfhref","join"],"sources":["../../../src/models/actions/ActionCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport ActionModel from \"./ActionModel\";\n\n/**\n * Collection of actions\n */\nexport default class ActionCollection extends BaseCollection<ActionModel> {\n constructor(actions?: Object
|
|
1
|
+
{"version":3,"file":"ActionCollection.js","names":["BaseCollection","ActionModel","ActionCollection","constructor","actions","actionsContributions","origin","contextPath","Array","isArray","collection","actionModels","actionData","actionContribution","_findInstanceProperty","call","name","type","push","getActionByKey","key","_context","newCollection","_filterInstanceProperty","action","first","getActionsByType","_context2","_includesInstanceProperty","getActionsByLayoutHint","_context3","_len","arguments","length","hints","_key","layouthint","has","hasActionsByLayoutHint","routePath","_context4","enabledRoutes","isDisabled","path","_mapInstanceProperty","selfhref","join"],"sources":["../../../src/models/actions/ActionCollection.js"],"sourcesContent":["// @flow\nimport BaseCollection from \"../base/BaseCollection\";\nimport ActionModel from \"./ActionModel\";\n\n/**\n * Collection of actions\n */\nexport default class ActionCollection extends BaseCollection<ActionModel> {\n constructor(\n actions?: Object,\n actionsContributions?: Object,\n origin?: string,\n contextPath?: string,\n ) {\n super();\n\n // no actions gives an empty collection\n if (!Array.isArray(actions)) {\n this.collection = [];\n } else if (Array.isArray(actionsContributions)) {\n const actionModels = [];\n for (const actionData of actions) {\n const actionContribution = actionsContributions.find(\n (actionContribution) =>\n actionContribution.name === actionData.name &&\n actionContribution.type !== \"service-operation\",\n );\n\n if (actionContribution) {\n actionModels.push(\n new ActionModel(\n actionData,\n actionContribution,\n origin,\n contextPath,\n ),\n );\n }\n }\n\n this.collection = actionModels;\n }\n }\n\n /**\n * Retrieve action by key\n */\n getActionByKey(key: string): ActionModel | null {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) => action.key === key);\n\n return newCollection.first;\n }\n\n /**\n * Retrieve actions by type\n */\n getActionsByType(type: string | Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n Array.isArray(type) ? type.includes(action.type) : action.type === type,\n );\n\n return newCollection;\n }\n\n /**\n * Retrieve actions including a layout hint\n */\n getActionsByLayoutHint(...hints: Array<string>): ActionCollection {\n const newCollection = new ActionCollection();\n\n newCollection.collection = this.filter((action) =>\n action.layouthint.has(...hints),\n );\n\n return newCollection;\n }\n\n /**\n * Indicates if an action with layout hint exists\n */\n hasActionsByLayoutHint(...hints: Array<string>): boolean {\n return this.getActionsByLayoutHint(...hints).length > 0;\n }\n\n /**\n * Use as path regex for react router routes\n */\n get routePath(): string {\n const enabledRoutes = this.collection.filter(\n (action) => !action.isDisabled,\n );\n\n if (enabledRoutes.length === 0) {\n return \"__NON_EXISTING_ROUTE__\";\n }\n\n const path = enabledRoutes.map((action) => action.selfhref.path).join(\"|\");\n\n return this.length > 1 ? `(${path})` : path;\n }\n}\n"],"mappings":";;;;AACA,OAAOA,cAAc,MAAM,wBAAwB;AACnD,OAAOC,WAAW,MAAM,eAAe;;AAEvC;AACA;AACA;AACA,eAAe,MAAMC,gBAAgB,SAASF,cAAc,CAAc;EACxEG,WAAWA,CACTC,OAAgB,EAChBC,oBAA6B,EAC7BC,MAAe,EACfC,WAAoB,EACpB;IACA,KAAK,CAAC,CAAC;;IAEP;IACA,IAAI,CAACC,KAAK,CAACC,OAAO,CAACL,OAAO,CAAC,EAAE;MAC3B,IAAI,CAACM,UAAU,GAAG,EAAE;IACtB,CAAC,MAAM,IAAIF,KAAK,CAACC,OAAO,CAACJ,oBAAoB,CAAC,EAAE;MAC9C,MAAMM,YAAY,GAAG,EAAE;MACvB,KAAK,MAAMC,UAAU,IAAIR,OAAO,EAAE;QAChC,MAAMS,kBAAkB,GAAGC,qBAAA,CAAAT,oBAAoB,EAAAU,IAAA,CAApBV,oBAAoB,EAC5CQ,kBAAkB,IACjBA,kBAAkB,CAACG,IAAI,KAAKJ,UAAU,CAACI,IAAI,IAC3CH,kBAAkB,CAACI,IAAI,KAAK,mBAChC,CAAC;QAED,IAAIJ,kBAAkB,EAAE;UACtBF,YAAY,CAACO,IAAI,CACf,IAAIjB,WAAW,CACbW,UAAU,EACVC,kBAAkB,EAClBP,MAAM,EACNC,WACF,CACF,CAAC;QACH;MACF;MAEA,IAAI,CAACG,UAAU,GAAGC,YAAY;IAChC;EACF;;EAEA;AACF;A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,aAAa;EACtB;;EAEA;AACF;AACA;EACEgB,sBAAsBA,CAAA,EAAmC;IACvD,OAAO,IAAI,CAACT,sBAAsB,CAAC,GAAAG,SAAQ,CAAC,CAACC,MAAM,GAAG,CAAC;EACzD;;EAEA;AACF;AACA;EACE,IAAIM,SAASA,CAAA,EAAW;IAAA,IAAAC,SAAA;IACtB,MAAMC,aAAa,GAAGlB,uBAAA,CAAAiB,SAAA,OAAI,CAAC9B,UAAU,EAAAK,IAAA,CAAAyB,SAAA,EAClChB,MAAM,IAAK,CAACA,MAAM,CAACkB,UACtB,CAAC;IAED,IAAID,aAAa,CAACR,MAAM,KAAK,CAAC,EAAE;MAC9B,OAAO,wBAAwB;IACjC;IAEA,MAAMU,IAAI,GAAGC,oBAAA,CAAAH,aAAa,EAAA1B,IAAA,CAAb0B,aAAa,EAAMjB,MAAM,IAAKA,MAAM,CAACqB,QAAQ,CAACF,IAAI,CAAC,CAACG,IAAI,CAAC,GAAG,CAAC;IAE1E,OAAO,IAAI,CAACb,MAAM,GAAG,CAAC,GAAG,IAAIU,IAAI,GAAG,GAAGA,IAAI;EAC7C;AACF","ignoreList":[]}
|
|
@@ -6,32 +6,39 @@ import ProcessStatusSettingsModel from "../process/ProcessStatusSettingsModel";
|
|
|
6
6
|
import AttributeCollection from "../attributes/AttributeCollection";
|
|
7
7
|
import BaseModel from "../base/BaseModel";
|
|
8
8
|
import Href from "../href/Href";
|
|
9
|
-
import { HTTP_METHODS } from "../../constants
|
|
10
|
-
import { CREATE_ACTION, UPDATE_ACTION, DELETE_ACTION } from "../../constants/LayoutHints";
|
|
9
|
+
import { getBasePath, HTTP_METHODS, CREATE_ACTION, UPDATE_ACTION, DELETE_ACTION } from "../../constants";
|
|
11
10
|
/**
|
|
12
11
|
* Defines an Action. For instance an action on the tab 'books', which leads to a form
|
|
13
12
|
*/
|
|
14
13
|
export default class ActionModel extends BaseModel {
|
|
15
|
-
constructor(data, contributions) {
|
|
14
|
+
constructor(data, contributions, origin, contextPath) {
|
|
16
15
|
super(data, contributions);
|
|
17
16
|
_defineProperty(this, "_fieldCollection", void 0);
|
|
18
17
|
_defineProperty(this, "_href", void 0);
|
|
19
18
|
_defineProperty(this, "_icon", void 0);
|
|
19
|
+
_defineProperty(this, "_origin", void 0);
|
|
20
|
+
_defineProperty(this, "_contextPath", void 0);
|
|
20
21
|
this._fieldCollection = new AttributeCollection(this.data.fields, this.contributions.fields);
|
|
22
|
+
this._origin = origin;
|
|
23
|
+
this._contextPath = contextPath;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
*/
|
|
25
28
|
static createFromHref(name, href, label) {
|
|
26
29
|
let type = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "form";
|
|
27
|
-
|
|
30
|
+
let origin = arguments.length > 4 ? arguments[4] : undefined;
|
|
31
|
+
let contextPath = arguments.length > 5 ? arguments[5] : undefined;
|
|
32
|
+
const data = {
|
|
28
33
|
name,
|
|
29
34
|
href
|
|
30
|
-
}
|
|
35
|
+
};
|
|
36
|
+
const contributions = {
|
|
31
37
|
name,
|
|
32
|
-
label: label
|
|
38
|
+
label: label ?? name,
|
|
33
39
|
type
|
|
34
|
-
}
|
|
40
|
+
};
|
|
41
|
+
return new ActionModel(data, contributions, origin, contextPath);
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
/**
|
|
@@ -40,11 +47,23 @@ export default class ActionModel extends BaseModel {
|
|
|
40
47
|
return this.data.href == null;
|
|
41
48
|
}
|
|
42
49
|
|
|
50
|
+
/**
|
|
51
|
+
*/
|
|
52
|
+
get origin() {
|
|
53
|
+
return this._origin ?? "";
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
*/
|
|
58
|
+
get contextPath() {
|
|
59
|
+
return this._contextPath ?? getBasePath();
|
|
60
|
+
}
|
|
61
|
+
|
|
43
62
|
/**
|
|
44
63
|
* retrieve href of action
|
|
45
64
|
*/
|
|
46
65
|
get selfhref() {
|
|
47
|
-
return this._href
|
|
66
|
+
return this._href ?? new Href(`${this.data.href}?${this.querystring}`, "Form", this.origin, this.contextPath);
|
|
48
67
|
}
|
|
49
68
|
|
|
50
69
|
/**
|