@beinformed/ui 1.25.4 → 1.25.5
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 +6 -0
- package/esm/hooks/useModularUIBasic.js +4 -1
- package/esm/hooks/useModularUIBasic.js.map +1 -1
- package/esm/hooks/useModularUIModel.js +2 -1
- package/esm/hooks/useModularUIModel.js.map +1 -1
- package/esm/modularui/ModularUIRequest.js +19 -2
- package/esm/modularui/ModularUIRequest.js.map +1 -1
- package/esm/redux/_modularui/ModularUIActions.js +2 -0
- package/esm/redux/_modularui/ModularUIActions.js.map +1 -1
- package/esm/redux/_modularui/ModularUIMiddleware.js +1 -0
- package/esm/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/esm/redux/_modularui/types.js.map +1 -1
- package/esm/utils/fetch/types.js.map +1 -1
- package/lib/hooks/useModularUIBasic.js +4 -1
- package/lib/hooks/useModularUIBasic.js.flow +8 -1
- package/lib/hooks/useModularUIBasic.js.map +1 -1
- package/lib/hooks/useModularUIModel.js +2 -1
- package/lib/hooks/useModularUIModel.js.flow +1 -0
- package/lib/hooks/useModularUIModel.js.map +1 -1
- package/lib/modularui/ModularUIRequest.js +19 -2
- package/lib/modularui/ModularUIRequest.js.flow +21 -3
- package/lib/modularui/ModularUIRequest.js.map +1 -1
- package/lib/redux/_modularui/ModularUIActions.js +2 -0
- package/lib/redux/_modularui/ModularUIActions.js.flow +2 -0
- package/lib/redux/_modularui/ModularUIActions.js.map +1 -1
- package/lib/redux/_modularui/ModularUIMiddleware.js +1 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.flow +2 -0
- package/lib/redux/_modularui/ModularUIMiddleware.js.map +1 -1
- package/lib/redux/_modularui/types.js.flow +1 -0
- package/lib/redux/_modularui/types.js.map +1 -1
- package/lib/utils/fetch/types.js.flow +1 -1
- package/lib/utils/fetch/types.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useModularUIBasic.js +8 -1
- package/src/hooks/useModularUIModel.js +1 -0
- package/src/modularui/ModularUIRequest.js +21 -3
- package/src/redux/_modularui/ModularUIActions.js +2 -0
- package/src/redux/_modularui/ModularUIMiddleware.js +2 -0
- package/src/redux/_modularui/types.js +1 -0
- package/src/utils/fetch/types.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useModularUIModel.js","names":["useApplication","useModularUIBasic","expectedModels","targetModel","ApplicationModel","useTab","href","TabModel","useCaseView","CaseViewModel","usePanel","useList","ListModel","useListOrDetail","DetailModel","useListDetail","ListDetailModel","useGroupingPanel","GroupingPanelModel","useDetailPanel","useQuicksearch","CaseSearchModel","useUserProfile","UserProfileModel"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (): ApplicationModel | null =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string): TabModel | null =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (href: string): CaseViewModel | null =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n });\n\n/**\n */\nexport const usePanel = (\n href: string\n): ListModel | GroupingPanelModel | DetailModel | null =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n });\n\n/**\n */\nexport const useList = (href: string): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n });\n\n/**\n */\nexport const useListOrDetail = (href: string): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"Detail\"],\n targetModel: [ListModel, DetailModel],\n });\n\n/**\n */\nexport const useListDetail = (href: string): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n });\n\n/**\n */\nexport const useGroupingPanel = (href: string): GroupingPanelModel | null =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n });\n\n/**\n */\nexport const useDetailPanel = (href: string): DetailModel | null =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n });\n\n/**\n */\nexport const useQuicksearch = (href: string): CaseSearchModel | null =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useUserProfile = (href: string): UserProfileModel | null =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n });\n"],"mappings":";;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACO,MAAMA,cAAc,GAAG,MAC5B,IAAAC,oCAAiB,EAAC,aAAa,EAAE,GAAG,EAAE;EACpCC,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEC;AACf,CAAC,CAAC;;AAEJ;AACA;AACA;AAFA;AAGO,MAAMC,MAAM,GAAIC,IAAY,IACjC,IAAAL,oCAAiB,EAAC,KAAK,EAAEK,IAAI,EAAE;EAC7BJ,cAAc,EAAE,CAAC,KAAK,CAAC;EACvBC,WAAW,EAAEI;AACf,CAAC,CAAC;;AAEJ;AACA;AACA;AAFA;AAGO,MAAMC,WAAW,GAAIF,IAAY,IACtC,IAAAL,oCAAiB,EAAC,UAAU,EAAEK,IAAI,EAAE;EAClCJ,cAAc,EAAE,CAAC,UAAU,CAAC;EAC5BC,WAAW,EAAEM;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,QAAQ,GACnBJ,IAAY,IAEZ,IAAAL,oCAAiB,EAAC,OAAO,EAAEK,IAAI,EAAE;EAC/BJ,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ;AACpD,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMS,OAAO,GAAIL,IAAY,IAClC,IAAAL,oCAAiB,EAAC,MAAM,EAAEK,IAAI,EAAE;EAC9BJ,cAAc,EAAE,CAAC,MAAM,CAAC;EACxBC,WAAW,EAAES;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,eAAe,GAAIP,IAAY,IAC1C,IAAAL,oCAAiB,EAAC,MAAM,EAAEK,IAAI,EAAE;EAC9BJ,cAAc,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;EAClCC,WAAW,EAAE,CAACS,kBAAS,EAAEE,oBAAW;AACtC,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,aAAa,GAAIT,IAAY,IACxC,IAAAL,oCAAiB,EAAC,YAAY,EAAEK,IAAI,EAAE;EACpCJ,cAAc,EAAE,CAAC,YAAY,CAAC;EAC9BC,WAAW,EAAEa;
|
|
1
|
+
{"version":3,"file":"useModularUIModel.js","names":["useApplication","useModularUIBasic","expectedModels","targetModel","ApplicationModel","useTab","href","TabModel","useCaseView","CaseViewModel","usePanel","useList","ListModel","useListOrDetail","DetailModel","useListDetail","ListDetailModel","forceTargetModel","useGroupingPanel","GroupingPanelModel","useDetailPanel","useQuicksearch","CaseSearchModel","useUserProfile","UserProfileModel"],"sources":["../../src/hooks/useModularUIModel.js"],"sourcesContent":["// @flow\nimport ApplicationModel from \"../models/application/ApplicationModel\";\nimport CaseViewModel from \"../models/caseview/CaseViewModel\";\nimport TabModel from \"../models/tab/TabModel\";\nimport ListModel from \"../models/list/ListModel\";\nimport GroupingPanelModel from \"../models/panels/GroupingPanelModel\";\nimport DetailModel from \"../models/detail/DetailModel\";\nimport CaseSearchModel from \"../models/search/CaseSearchModel\";\nimport ListDetailModel from \"../models/list/ListDetailModel\";\nimport UserProfileModel from \"../models/user/UserProfileModel\";\n\nimport { useModularUIBasic } from \"./useModularUIBasic\";\n\n/**\n * Load application\n */\nexport const useApplication = (): ApplicationModel | null =>\n useModularUIBasic(\"application\", \"/\", {\n expectedModels: [\"Application\"],\n targetModel: ApplicationModel,\n });\n\n/**\n * Load a tab by href\n */\nexport const useTab = (href: string): TabModel | null =>\n useModularUIBasic(\"tab\", href, {\n expectedModels: [\"Tab\"],\n targetModel: TabModel,\n });\n\n/**\n * Load caseview by href\n */\nexport const useCaseView = (href: string): CaseViewModel | null =>\n useModularUIBasic(\"caseview\", href, {\n expectedModels: [\"CaseView\"],\n targetModel: CaseViewModel,\n });\n\n/**\n */\nexport const usePanel = (\n href: string\n): ListModel | GroupingPanelModel | DetailModel | null =>\n useModularUIBasic(\"panel\", href, {\n expectedModels: [\"List\", \"GroupingPanel\", \"Detail\"],\n });\n\n/**\n */\nexport const useList = (href: string): ListModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\"],\n targetModel: ListModel,\n });\n\n/**\n */\nexport const useListOrDetail = (href: string): ListModel | DetailModel | null =>\n useModularUIBasic(\"list\", href, {\n expectedModels: [\"List\", \"Detail\"],\n targetModel: [ListModel, DetailModel],\n });\n\n/**\n */\nexport const useListDetail = (href: string): ListDetailModel | null =>\n useModularUIBasic(\"listdetail\", href, {\n expectedModels: [\"ListDetail\"],\n targetModel: ListDetailModel,\n forceTargetModel: true,\n });\n\n/**\n */\nexport const useGroupingPanel = (href: string): GroupingPanelModel | null =>\n useModularUIBasic(\"groupingpanel\", href, {\n expectedModels: [\"GroupingPanel\"],\n targetModel: GroupingPanelModel,\n });\n\n/**\n */\nexport const useDetailPanel = (href: string): DetailModel | null =>\n useModularUIBasic(\"detailpanel\", href, {\n expectedModels: [\"Detail\"],\n targetModel: DetailModel,\n });\n\n/**\n */\nexport const useQuicksearch = (href: string): CaseSearchModel | null =>\n useModularUIBasic(\"quicksearch\", href, {\n expectedModels: [\"CaseSearch\"],\n targetModel: CaseSearchModel,\n });\n\n/**\n */\nexport const useUserProfile = (href: string): UserProfileModel | null =>\n useModularUIBasic(\"userprofile\", href, {\n expectedModels: [\"UserProfile\"],\n targetModel: UserProfileModel,\n });\n"],"mappings":";;;;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACO,MAAMA,cAAc,GAAG,MAC5B,IAAAC,oCAAiB,EAAC,aAAa,EAAE,GAAG,EAAE;EACpCC,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEC;AACf,CAAC,CAAC;;AAEJ;AACA;AACA;AAFA;AAGO,MAAMC,MAAM,GAAIC,IAAY,IACjC,IAAAL,oCAAiB,EAAC,KAAK,EAAEK,IAAI,EAAE;EAC7BJ,cAAc,EAAE,CAAC,KAAK,CAAC;EACvBC,WAAW,EAAEI;AACf,CAAC,CAAC;;AAEJ;AACA;AACA;AAFA;AAGO,MAAMC,WAAW,GAAIF,IAAY,IACtC,IAAAL,oCAAiB,EAAC,UAAU,EAAEK,IAAI,EAAE;EAClCJ,cAAc,EAAE,CAAC,UAAU,CAAC;EAC5BC,WAAW,EAAEM;AACf,CAAC,CAAC;;AAEJ;AACA;AADA;AAEO,MAAMC,QAAQ,GACnBJ,IAAY,IAEZ,IAAAL,oCAAiB,EAAC,OAAO,EAAEK,IAAI,EAAE;EAC/BJ,cAAc,EAAE,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ;AACpD,C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AAL,oCAAiB,EAAC,aAAa,EAAEK,IAAI,EAAE;EACrCJ,cAAc,EAAE,CAAC,aAAa,CAAC;EAC/BC,WAAW,EAAEqB;AACf,CAAC,CAAC;AAAC"}
|
|
@@ -39,6 +39,7 @@ class ModularUIRequest {
|
|
|
39
39
|
(0, _defineProperty2.default)(this, "_href", void 0);
|
|
40
40
|
(0, _defineProperty2.default)(this, "_options", void 0);
|
|
41
41
|
(0, _defineProperty2.default)(this, "_targetModel", void 0);
|
|
42
|
+
(0, _defineProperty2.default)(this, "_forceTargetModel", false);
|
|
42
43
|
(0, _defineProperty2.default)(this, "_contributionsHref", void 0);
|
|
43
44
|
(0, _defineProperty2.default)(this, "_locale", void 0);
|
|
44
45
|
(0, _defineProperty2.default)(this, "_method", _Constants.HTTP_METHODS.GET);
|
|
@@ -135,6 +136,7 @@ class ModularUIRequest {
|
|
|
135
136
|
/* eslint-disable no-unused-vars */
|
|
136
137
|
const {
|
|
137
138
|
targetModel,
|
|
139
|
+
forceTargetModel,
|
|
138
140
|
updateModel,
|
|
139
141
|
childmodels,
|
|
140
142
|
isValidationRequest,
|
|
@@ -169,21 +171,36 @@ class ModularUIRequest {
|
|
|
169
171
|
return this._targetModel;
|
|
170
172
|
}
|
|
171
173
|
|
|
174
|
+
/**
|
|
175
|
+
*/
|
|
176
|
+
set forceTargetModel(forceTargetModel) {
|
|
177
|
+
this._forceTargetModel = forceTargetModel ?? false;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
*/
|
|
182
|
+
get forceTargetModel() {
|
|
183
|
+
return this._forceTargetModel;
|
|
184
|
+
}
|
|
185
|
+
|
|
172
186
|
/**
|
|
173
187
|
*/
|
|
174
188
|
resolveModel() {
|
|
175
189
|
let availableModels;
|
|
176
190
|
if (this.targetModel) {
|
|
177
191
|
availableModels = Array.isArray(this.targetModel) ? [...this.targetModel] : [this.targetModel];
|
|
192
|
+
if (this.forceTargetModel) {
|
|
193
|
+
return availableModels[0];
|
|
194
|
+
}
|
|
178
195
|
}
|
|
179
196
|
const Model = (0, _resolveModel.default)(this.response, availableModels);
|
|
180
197
|
if (Model && Model.isApplicableModel) {
|
|
181
198
|
return Model;
|
|
182
199
|
}
|
|
183
200
|
if (availableModels) {
|
|
184
|
-
throw new _exceptions.IllegalStateException(`data is not applicable for model(s): ${(0, _map.default)(availableModels).call(availableModels, m => m.modelName).join(", ")}`);
|
|
201
|
+
throw new _exceptions.IllegalStateException(`data for ${this.href.toString()} is not applicable for model(s): ${(0, _map.default)(availableModels).call(availableModels, m => m.modelName).join(", ")}, received response: ${(0, _stringify.default)(this.response)}`);
|
|
185
202
|
}
|
|
186
|
-
throw new _exceptions.IllegalStateException(`no javascript model is applicable for received response: ${(0, _stringify.default)(this.response)}`);
|
|
203
|
+
throw new _exceptions.IllegalStateException(`no javascript model is applicable for received request of ${this.href.toString()}, with response: ${(0, _stringify.default)(this.response)}`);
|
|
187
204
|
}
|
|
188
205
|
|
|
189
206
|
/**
|
|
@@ -42,6 +42,7 @@ class ModularUIRequest {
|
|
|
42
42
|
_href: Href;
|
|
43
43
|
_options: RequestModularUIOptions;
|
|
44
44
|
_targetModel: ?TargetModel;
|
|
45
|
+
_forceTargetModel: boolean = false;
|
|
45
46
|
_contributionsHref: string;
|
|
46
47
|
_locale: string;
|
|
47
48
|
_method: $Keys<typeof HTTP_METHODS> = HTTP_METHODS.GET;
|
|
@@ -153,6 +154,7 @@ class ModularUIRequest {
|
|
|
153
154
|
/* eslint-disable no-unused-vars */
|
|
154
155
|
const {
|
|
155
156
|
targetModel,
|
|
157
|
+
forceTargetModel,
|
|
156
158
|
updateModel,
|
|
157
159
|
childmodels,
|
|
158
160
|
isValidationRequest,
|
|
@@ -189,6 +191,18 @@ class ModularUIRequest {
|
|
|
189
191
|
return this._targetModel;
|
|
190
192
|
}
|
|
191
193
|
|
|
194
|
+
/**
|
|
195
|
+
*/
|
|
196
|
+
set forceTargetModel(forceTargetModel: boolean) {
|
|
197
|
+
this._forceTargetModel = forceTargetModel ?? false;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
*/
|
|
202
|
+
get forceTargetModel(): boolean {
|
|
203
|
+
return this._forceTargetModel;
|
|
204
|
+
}
|
|
205
|
+
|
|
192
206
|
/**
|
|
193
207
|
*/
|
|
194
208
|
resolveModel(): Class<ModularUIModel> {
|
|
@@ -197,6 +211,10 @@ class ModularUIRequest {
|
|
|
197
211
|
availableModels = Array.isArray(this.targetModel)
|
|
198
212
|
? [...this.targetModel]
|
|
199
213
|
: [this.targetModel];
|
|
214
|
+
|
|
215
|
+
if (this.forceTargetModel) {
|
|
216
|
+
return availableModels[0];
|
|
217
|
+
}
|
|
200
218
|
}
|
|
201
219
|
|
|
202
220
|
const Model: Class<ModularUIModel> | null = resolveModel(
|
|
@@ -210,14 +228,14 @@ class ModularUIRequest {
|
|
|
210
228
|
|
|
211
229
|
if (availableModels) {
|
|
212
230
|
throw new IllegalStateException(
|
|
213
|
-
`data is not applicable for model(s): ${availableModels
|
|
231
|
+
`data for ${this.href.toString()} is not applicable for model(s): ${availableModels
|
|
214
232
|
.map((m) => m.modelName)
|
|
215
|
-
.join(", ")}`
|
|
233
|
+
.join(", ")}, received response: ${JSON.stringify(this.response)}`
|
|
216
234
|
);
|
|
217
235
|
}
|
|
218
236
|
|
|
219
237
|
throw new IllegalStateException(
|
|
220
|
-
`no javascript model is applicable for received response: ${JSON.stringify(
|
|
238
|
+
`no javascript model is applicable for received request of ${this.href.toString()}, with response: ${JSON.stringify(
|
|
221
239
|
this.response
|
|
222
240
|
)}`
|
|
223
241
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIRequest.js","names":["ModularUIRequest","constructor","href","options","HTTP_METHODS","GET","IllegalArgumentException","_response","ModularUIResponse","Href","locale","parameters","targetModel","method","contributionsHref","_contributionsHref","_locale","response","_href","_method","_options","requestOptions","updateModel","childmodels","isValidationRequest","removeOnUnmount","withChildModels","_targetModel","resolveModel","availableModels","Array","isArray","Model","isApplicableModel","IllegalStateException","m","modelName","join","createModel","processContributionsService","contributionsData","isPlainObject","contributionsKey","error","handleContributionsError","key","contributions","errorMessage","properties","message","ModularUIError","handleDataError","path","toString","handleData","data","links","_links","processDataService","fetchContributionsService","universalFetch","url","BASE","cache","fetchDataService","params","getQuerystringForModularUI","onProgress","processAsyncLayoutHints","getSetting","processApplicationLinks","processTabLinks","processPanelLinks","resolve","contributionLinks","dataLinks","contributionTabLink","tab","dataTabLinks","dataLink","name","processLinks","components","then","newLinks","replaceApplicationLinks","tabName","tabLink","component","panel","dataLinksPerName","linksPerName","hideWhenEmptyLinks","contributionLink","layouthint","includes","HIDE_WHEN_EMPTY","isHiddenListChecks","push","isHiddenList","all","hiddenLinks","newDataLinks","dataLinkKey","HIDE_WHEN_EMPTY_IGNORE_TASKS","_embedded","actions","noListItems","noActions","isHidden","catch","progressEvent","_progressEvent","getDynamicValidationData","model","prevData","JSON","parse","FormModel","newData","validationData","deepmerge","loadDynamicValidations","currentFormObject","hasDynamicValidations","validationHref","setParameter","updateValidations","fetch","Error","fetchChildModels","fetchFromCache","childModelLinks","getInitialChildModelLinks","childModelRequests","childModelLink","request","isCacheable","allSettled","childModels","resolvedChildModels","forEach","childModel","status","reason","console","value","addChildModels","fetchContent","withChildSections","ContentModel","childSectionLinks","length","fetchContentChildSections","contentModel","newContentModel","clone","childSectionLink","contentHrefWithEntryDate","selfhref","addParameter","TIMEVERSION_FILTER_NAME","entryDate","sectionModels","childSections","post","POST","postForm","form","formdata","update"],"sources":["../../src/modularui/ModularUIRequest.js"],"sourcesContent":["// @flow\nimport deepmerge from \"deepmerge\";\n\nimport {\n BASE,\n HTTP_METHODS,\n TIMEVERSION_FILTER_NAME,\n} from \"../constants/Constants\";\n\nimport { HIDE_WHEN_EMPTY } from \"../constants/LayoutHints\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport Href from \"../models/href/Href\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport resolveModel from \"../models/resolveModel\";\nimport FormModel from \"../models/form/FormModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport ModularUIResponse from \"./ModularUIResponse\";\n\nimport ModularUIError from \"./ModularUIError\";\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport { isPlainObject } from \"../utils/helpers/objects\";\n\nimport type { TargetModel } from \"./types\";\nimport type {\n RequestBaseOptions,\n RequestModularUIOptions,\n} from \"../utils/fetch/types\";\nimport type { ModularUIModel } from \"../models/types\";\n\n/**\n * Helper for fetching data and contributions from the Be Informed modular ui\n * and merge it into a target or resolvable model.\n */\nclass ModularUIRequest {\n _response: ModularUIResponse;\n\n _href: Href;\n _options: RequestModularUIOptions;\n _targetModel: ?TargetModel;\n _contributionsHref: string;\n _locale: string;\n _method: $Keys<typeof HTTP_METHODS> = HTTP_METHODS.GET;\n\n _progressEvent: ProgressEventHandler;\n\n /**\n */\n constructor(\n href: Href | string,\n options: $Shape<RequestModularUIOptions> = {}\n ) {\n if (!href) {\n throw new IllegalArgumentException(\n \"You must pass a href to the resource that is requested\"\n );\n }\n\n this.options = options;\n\n this._response = new ModularUIResponse();\n\n this.href = typeof href === \"string\" ? new Href(href) : href;\n this.locale = options.locale ?? \"en\";\n\n // copy request parameters to response, to be able to use them in the models\n // self links are missing the request parameters\n this._response.parameters = this.href.parameters;\n\n if (options.targetModel) {\n this.targetModel = options.targetModel;\n }\n\n if (options.method) {\n this.method = options.method;\n } else {\n this.method = this.href.method;\n }\n }\n\n /**\n */\n get contributionsHref(): string {\n return this._contributionsHref;\n }\n\n /**\n */\n set contributionsHref(contributionsHref: string) {\n this._contributionsHref = contributionsHref;\n }\n\n /**\n */\n set locale(locale: string) {\n this._locale = locale;\n this._response.locale = locale;\n }\n\n /**\n */\n get locale(): string {\n return this._locale;\n }\n\n /**\n */\n get response(): ModularUIResponse {\n return this._response;\n }\n\n /**\n */\n set href(href: Href) {\n this._href = href;\n }\n\n /**\n */\n get href(): Href {\n return this._href;\n }\n\n /**\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method;\n }\n\n /**\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n */\n get options(): RequestModularUIOptions {\n return {\n ...this._options,\n locale: this.locale,\n method: this.method,\n };\n }\n\n /**\n */\n get requestOptions(): RequestBaseOptions {\n /* eslint-disable no-unused-vars */\n const {\n targetModel,\n updateModel,\n childmodels,\n isValidationRequest,\n removeOnUnmount,\n ...requestOptions\n } = this.options;\n /* eslint-enable no-unused-vars */\n return requestOptions;\n }\n\n /**\n */\n set options(options: RequestModularUIOptions) {\n this._options = options;\n }\n\n /**\n */\n get withChildModels(): boolean {\n return (\n !(\"childmodels\" in this.options) || this.options.childmodels === true\n );\n }\n\n /**\n */\n set targetModel(targetModel: TargetModel) {\n this._targetModel = targetModel;\n }\n\n /**\n */\n get targetModel(): ?TargetModel {\n return this._targetModel;\n }\n\n /**\n */\n resolveModel(): Class<ModularUIModel> {\n let availableModels;\n if (this.targetModel) {\n availableModels = Array.isArray(this.targetModel)\n ? [...this.targetModel]\n : [this.targetModel];\n }\n\n const Model: Class<ModularUIModel> | null = resolveModel(\n this.response,\n availableModels\n );\n\n if (Model && Model.isApplicableModel) {\n return Model;\n }\n\n if (availableModels) {\n throw new IllegalStateException(\n `data is not applicable for model(s): ${availableModels\n .map((m) => m.modelName)\n .join(\", \")}`\n );\n }\n\n throw new IllegalStateException(\n `no javascript model is applicable for received response: ${JSON.stringify(\n this.response\n )}`\n );\n }\n\n /**\n */\n createModel(): ModularUIModel {\n const Model = this.resolveModel();\n return new Model(this.response);\n }\n\n /**\n */\n processContributionsService(contributionsData: Object): void {\n if (!isPlainObject(contributionsData)) {\n throw new IllegalArgumentException(\n \"Missing contributions data or contributions is not JSON\"\n );\n }\n\n const [contributionsKey] = Object.keys(contributionsData);\n\n if (contributionsData.error && contributionsKey === \"error\") {\n this.handleContributionsError(contributionsData.error);\n }\n\n // The key of the data service is different from the contributions service for forms\n if (!(this.response.key in contributionsData)) {\n this.response.key = contributionsKey;\n }\n\n this.response.contributions = contributionsData[this.response.key];\n }\n\n /**\n */\n handleContributionsError(error: Object): void {\n const errorMessage = error.properties?.message ?? \"Error in contribution\";\n throw new ModularUIError(errorMessage, error, this.contributionsHref);\n }\n\n /**\n */\n handleDataError(error: Object): void {\n if (error.properties) {\n const errorMessage = error.properties?.message ?? \"Error in data\";\n throw new ModularUIError(errorMessage, error, this.href.path.toString());\n }\n\n throw new IllegalArgumentException(error);\n }\n\n /**\n */\n handleData(key: string, data: Object): void {\n this.response.key = key;\n this.response.data = data;\n\n const links = data._links;\n\n if (links && links.contributions) {\n this.contributionsHref = links.contributions.href;\n } else if (Array.isArray(links) && links[0].contributions) {\n this.contributionsHref = links[0].contributions.href;\n } else {\n throw new IllegalArgumentException(\n `Contributions link not found for data with key ${key}`\n );\n }\n }\n\n /**\n */\n processDataService(data: Object): void {\n if (!isPlainObject(data)) {\n throw new IllegalArgumentException(\"Missing data or data is not JSON\");\n }\n\n if (data.error) {\n this.handleDataError(data.error);\n } else {\n const [key] = Object.keys(data);\n this.handleData(key, data[key]);\n }\n }\n\n /**\n */\n fetchContributionsService(): Promise<any> {\n if (!this.contributionsHref) {\n throw new IllegalStateException(\"Missing a contributions href\");\n }\n\n return universalFetch({\n url: `${BASE}${this.contributionsHref}`,\n cache: true,\n locale: this.options.locale,\n });\n }\n\n /**\n */\n fetchDataService(): Promise<any> {\n return universalFetch({\n ...this.requestOptions,\n url: `${BASE}${this.href.path}`,\n params: this.href.getQuerystringForModularUI(),\n locale: this.options.locale,\n onProgress: this.onProgress,\n });\n }\n\n /**\n * Check if links contain a 'hide-when-empty' layout hint and remove the link from\n * the component when it exists and no results are available\n */\n async processAsyncLayoutHints(): Promise<void> {\n if (getSetting(\"ALLOW_HIDE_WHEN_EMPTY_ON_TABS\")) {\n await this.processApplicationLinks();\n await this.processTabLinks();\n }\n await this.processPanelLinks();\n\n return Promise.resolve();\n }\n\n /**\n * hide application links<br>\n * _links on application data contains an extra level of tab links\n */\n processApplicationLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n const dataLinks = this.response.data._links;\n if (!contributionLinks || !dataLinks) {\n return Promise.resolve();\n }\n\n if (\"tab\" in contributionLinks && \"tab\" in dataLinks) {\n for (const contributionTabLink of contributionLinks.tab) {\n if (\"components\" in contributionTabLink) {\n const dataTabLinks = dataLinks.tab.find(\n (dataLink) => dataLink.name === contributionTabLink.name\n );\n\n if (dataTabLinks && \"components\" in dataTabLinks) {\n return this.processLinks(\n dataTabLinks.components,\n contributionTabLink.components\n ).then((newLinks) =>\n this.replaceApplicationLinks(contributionTabLink.name, newLinks)\n );\n }\n }\n }\n }\n\n return Promise.resolve();\n }\n\n /**\n * Replace hidden link in application link tree\n */\n replaceApplicationLinks(tabName: string, newLinks: Array<Object>): void {\n this.response.data._links.tab = this.response.data._links.tab.map(\n (tabLink) => {\n const key = tabLink.name;\n if (tabName === key) {\n tabLink.components = newLinks;\n }\n return tabLink;\n }\n );\n }\n\n /**\n */\n processTabLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"component\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links.component,\n contributionLinks.component\n ).then((newLinks) => {\n this.response.data._links.component = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n */\n processPanelLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"panel\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links,\n contributionLinks.panel\n ).then((newLinks) => {\n this.response.data._links = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n * Retrieve an object of key: link\n */\n dataLinksPerName(dataLinks: any): { [linkName: string]: any } {\n if (Array.isArray(dataLinks)) {\n const links = {};\n for (const dataLink of dataLinks) {\n links[dataLink.name] = dataLink;\n }\n return links;\n }\n return dataLinks;\n }\n\n /**\n * Check if links are empty and hide them when hide-when-empty hint exists\n */\n processLinks(\n dataLinks: any,\n contributionLinks: any\n ): Promise<Object | Array<Object>> {\n const linksPerName = this.dataLinksPerName(dataLinks);\n const hideWhenEmptyLinks = contributionLinks.filter((contributionLink) =>\n contributionLink.layouthint?.includes(HIDE_WHEN_EMPTY)\n );\n\n const isHiddenListChecks = [];\n\n for (const contributionLink of hideWhenEmptyLinks) {\n const dataLink = linksPerName[contributionLink.name];\n if (dataLink?.href) {\n isHiddenListChecks.push(\n this.isHiddenList(contributionLink.name, dataLink.href)\n );\n }\n }\n\n return Promise.all(isHiddenListChecks).then(\n (hiddenLinks: Array<string>) => {\n if (Array.isArray(dataLinks)) {\n return dataLinks.filter(\n (dataLink) => !hiddenLinks.includes(dataLink.name)\n );\n }\n\n const newDataLinks: { [string]: any } = {};\n for (const dataLinkKey in dataLinks) {\n if (!hiddenLinks.includes(dataLinkKey)) {\n newDataLinks[dataLinkKey] = dataLinks[dataLinkKey];\n }\n }\n return newDataLinks;\n }\n );\n }\n\n /**\n */\n isHiddenList(name: string, href: string): Promise<string> {\n const HIDE_WHEN_EMPTY_IGNORE_TASKS = getSetting(\n \"HIDE_WHEN_EMPTY_IGNORE_TASKS\",\n false\n );\n\n return universalFetch({\n ...this.requestOptions,\n url: `${BASE}${href}`,\n })\n .then((response: Object) => {\n if (isPlainObject(response)) {\n const [key] = Object.keys(response);\n const { _embedded, actions } = response[key];\n\n const noListItems = _embedded === null;\n const noActions = actions == null || HIDE_WHEN_EMPTY_IGNORE_TASKS;\n\n const isHidden = noListItems && noActions;\n if (isHidden) {\n return name;\n }\n }\n return \"\";\n })\n .catch(() => {\n return \"\";\n });\n }\n\n /**\n */\n set onProgress(progressEvent: ProgressEventHandler) {\n this._progressEvent = progressEvent;\n }\n\n /**\n */\n get onProgress(): ProgressEventHandler {\n return this._progressEvent || null;\n }\n\n /**\n * Combine previous send request data with new validation data to create a complete request object\n * The received model is new FormModel containing ONLY the current question, not the previously entered questions\n * to create a complete request we append the originally send form objects\n */\n getDynamicValidationData(model: ModularUIModel): string {\n const prevData =\n typeof this.options.data === \"string\"\n ? JSON.parse(this.options.data)\n : this.options.data;\n\n if (model instanceof FormModel) {\n const newData = JSON.parse(model.validationData);\n // $FlowFixMe incompatible-call\n return JSON.stringify(deepmerge(prevData || {}, newData));\n }\n\n return JSON.stringify(prevData) ?? \"{}\";\n }\n\n /**\n * First load of dynamic values when a form is loaded\n */\n loadDynamicValidations(model: ModularUIModel): Promise<ModularUIModel> {\n if (\n !this.options.isValidationRequest &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\") &&\n model instanceof FormModel &&\n model.currentFormObject &&\n model.currentFormObject.hasDynamicValidations\n ) {\n const validationHref = this.href.setParameter(\"commit\", \"false\");\n return universalFetch({\n ...this.requestOptions,\n url: `${BASE}${this.href.path}`,\n params: validationHref.getQuerystringForModularUI(),\n data: this.getDynamicValidationData(model),\n }).then((data) => {\n if (data == null || typeof data !== \"object\") {\n return model;\n }\n\n const [key] = Object.keys(data);\n return model.updateValidations(data[key]);\n });\n }\n\n return Promise.resolve(model);\n }\n\n /**\n */\n fetch(): Promise<ModularUIModel> {\n return this.fetchDataService()\n .then((data) => {\n if (data == null) {\n throw new Error(`No data received for ${this.href.toString()}`);\n }\n\n this.processDataService(data);\n return this.fetchContributionsService();\n })\n .then((contributionsData) => {\n if (contributionsData == null) {\n throw new Error(\n `No contributions data received for ${this.contributionsHref}`\n );\n }\n\n this.processContributionsService(contributionsData);\n return this.processAsyncLayoutHints();\n })\n .then(() => Promise.resolve(this.createModel()))\n .then((model) => this.loadDynamicValidations(model))\n .then((model) => {\n if (this.withChildModels) {\n return this.fetchChildModels(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n */\n fetchFromCache(): Promise<ModularUIModel> {\n this.options = {\n ...this.options,\n cache: true,\n };\n\n return this.fetch();\n }\n\n /**\n */\n fetchChildModels(model: ModularUIModel): Promise<ModularUIModel> {\n const childModelLinks = model.getInitialChildModelLinks();\n\n const childModelRequests = childModelLinks.map((childModelLink) => {\n const request = new ModularUIRequest(childModelLink.href, {\n locale: this.locale,\n });\n\n if (childModelLink.targetModel) {\n request.targetModel = childModelLink.targetModel;\n }\n\n if (childModelLink.isCacheable) {\n return request.fetchFromCache();\n }\n\n return request.fetch();\n });\n\n return Promise.allSettled(childModelRequests).then((childModels) => {\n const resolvedChildModels = [];\n\n childModels.forEach((childModel) => {\n if (childModel.status === \"rejected\") {\n const { reason } = childModel;\n if (reason.name !== \"Error.ChangePasswordRequired\") {\n console.error(\n \"Unexpected error when retrieving child model:\",\n reason\n );\n }\n } else {\n resolvedChildModels.push(childModel.value);\n }\n });\n\n model.addChildModels(resolvedChildModels);\n\n return model;\n });\n }\n\n /**\n */\n fetchContent(withChildSections: boolean): Promise<mixed> {\n return this.fetchFromCache().then((model) => {\n if (\n withChildSections &&\n model instanceof ContentModel &&\n model.childSectionLinks.length > 0\n ) {\n return this.fetchContentChildSections(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n * Recursively return child sections defined on the content model\n */\n fetchContentChildSections(contentModel: ContentModel): Promise<mixed> {\n const newContentModel = contentModel.clone();\n\n return Promise.all(\n contentModel.childSectionLinks.map((childSectionLink) => {\n const contentHrefWithEntryDate = childSectionLink.selfhref.addParameter(\n TIMEVERSION_FILTER_NAME,\n contentModel.entryDate\n );\n\n const request = new ModularUIRequest(contentHrefWithEntryDate, {\n locale: this.locale,\n });\n\n return request.fetchContent(true);\n })\n ).then((sectionModels) => {\n newContentModel.childSections = sectionModels;\n\n return newContentModel;\n });\n }\n\n /**\n * Make a post request with optionally data to send\n * @param data\n */\n post(data?: string | { [key: string]: string }): Promise<ModularUIModel> {\n this.method = HTTP_METHODS.POST;\n this.options = {\n ...this.options,\n data,\n };\n\n return this.fetch();\n }\n\n /**\n * Make a POST request using the form, an updated form is returned (merge of old and new form)\n * @param form\n * @returns {Promise<FormModel>}\n */\n postForm(form: FormModel): Promise<FormModel> {\n this.method = HTTP_METHODS.POST;\n this.options = {\n ...this.options,\n data: form.formdata,\n };\n\n return this.fetch().then((response) => {\n return form.update(response);\n });\n }\n}\n\nexport default ModularUIRequest;\n"],"mappings":";;;;;;;;;;;;;;;AACA;AAEA;AAMA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AASA;AACA;AACA;AACA;AACA,MAAMA,gBAAgB,CAAC;EAYrB;AACF;EACEC,WAAW,CACTC,IAAmB,EAEnB;IAAA,IADAC,OAAwC,uEAAG,CAAC,CAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA,+CARTC,uBAAY,CAACC,GAAG;IAAA;IAUpD,IAAI,CAACH,IAAI,EAAE;MACT,MAAM,IAAII,oCAAwB,CAChC,wDAAwD,CACzD;IACH;IAEA,IAAI,CAACH,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACI,SAAS,GAAG,IAAIC,0BAAiB,EAAE;IAExC,IAAI,CAACN,IAAI,GAAG,OAAOA,IAAI,KAAK,QAAQ,GAAG,IAAIO,aAAI,CAACP,IAAI,CAAC,GAAGA,IAAI;IAC5D,IAAI,CAACQ,MAAM,GAAGP,OAAO,CAACO,MAAM,IAAI,IAAI;;IAEpC;IACA;IACA,IAAI,CAACH,SAAS,CAACI,UAAU,GAAG,IAAI,CAACT,IAAI,CAACS,UAAU;IAEhD,IAAIR,OAAO,CAACS,WAAW,EAAE;MACvB,IAAI,CAACA,WAAW,GAAGT,OAAO,CAACS,WAAW;IACxC;IAEA,IAAIT,OAAO,CAACU,MAAM,EAAE;MAClB,IAAI,CAACA,MAAM,GAAGV,OAAO,CAACU,MAAM;IAC9B,CAAC,MAAM;MACL,IAAI,CAACA,MAAM,GAAG,IAAI,CAACX,IAAI,CAACW,MAAM;IAChC;EACF;;EAEA;AACF;EACE,IAAIC,iBAAiB,GAAW;IAC9B,OAAO,IAAI,CAACC,kBAAkB;EAChC;;EAEA;AACF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AC;MAEF,OAAO8H,OAAO,CAACY,YAAY,CAAC,IAAI,CAAC;IACnC,CAAC,CAAC,CACH,CAACjE,IAAI,CAAEgF,aAAa,IAAK;MACxBR,eAAe,CAACS,aAAa,GAAGD,aAAa;MAE7C,OAAOR,eAAe;IACxB,CAAC,CAAC;EACJ;;EAEA;AACF;AACA;AACA;EACEU,IAAI,CAAC9G,IAAyC,EAA2B;IACvE,IAAI,CAAC1C,MAAM,GAAGT,uBAAY,CAACkK,IAAI;IAC/B,IAAI,CAACnK,OAAO,GAAG;MACb,GAAG,IAAI,CAACA,OAAO;MACfoD;IACF,CAAC;IAED,OAAO,IAAI,CAACyE,KAAK,EAAE;EACrB;;EAEA;AACF;AACA;AACA;AACA;EACEuC,QAAQ,CAACC,IAAe,EAAsB;IAC5C,IAAI,CAAC3J,MAAM,GAAGT,uBAAY,CAACkK,IAAI;IAC/B,IAAI,CAACnK,OAAO,GAAG;MACb,GAAG,IAAI,CAACA,OAAO;MACfoD,IAAI,EAAEiH,IAAI,CAACC;IACb,CAAC;IAED,OAAO,IAAI,CAACzC,KAAK,EAAE,CAAC7C,IAAI,CAAElE,QAAQ,IAAK;MACrC,OAAOuJ,IAAI,CAACE,MAAM,CAACzJ,QAAQ,CAAC;IAC9B,CAAC,CAAC;EACJ;AACF;AAAC,eAEcjB,gBAAgB;AAAA"}
|
|
1
|
+
{"version":3,"file":"ModularUIRequest.js","names":["ModularUIRequest","constructor","href","options","HTTP_METHODS","GET","IllegalArgumentException","_response","ModularUIResponse","Href","locale","parameters","targetModel","method","contributionsHref","_contributionsHref","_locale","response","_href","_method","_options","requestOptions","forceTargetModel","updateModel","childmodels","isValidationRequest","removeOnUnmount","withChildModels","_targetModel","_forceTargetModel","resolveModel","availableModels","Array","isArray","Model","isApplicableModel","IllegalStateException","toString","m","modelName","join","createModel","processContributionsService","contributionsData","isPlainObject","contributionsKey","error","handleContributionsError","key","contributions","errorMessage","properties","message","ModularUIError","handleDataError","path","handleData","data","links","_links","processDataService","fetchContributionsService","universalFetch","url","BASE","cache","fetchDataService","params","getQuerystringForModularUI","onProgress","processAsyncLayoutHints","getSetting","processApplicationLinks","processTabLinks","processPanelLinks","resolve","contributionLinks","dataLinks","contributionTabLink","tab","dataTabLinks","dataLink","name","processLinks","components","then","newLinks","replaceApplicationLinks","tabName","tabLink","component","panel","dataLinksPerName","linksPerName","hideWhenEmptyLinks","contributionLink","layouthint","includes","HIDE_WHEN_EMPTY","isHiddenListChecks","push","isHiddenList","all","hiddenLinks","newDataLinks","dataLinkKey","HIDE_WHEN_EMPTY_IGNORE_TASKS","_embedded","actions","noListItems","noActions","isHidden","catch","progressEvent","_progressEvent","getDynamicValidationData","model","prevData","JSON","parse","FormModel","newData","validationData","deepmerge","loadDynamicValidations","currentFormObject","hasDynamicValidations","validationHref","setParameter","updateValidations","fetch","Error","fetchChildModels","fetchFromCache","childModelLinks","getInitialChildModelLinks","childModelRequests","childModelLink","request","isCacheable","allSettled","childModels","resolvedChildModels","forEach","childModel","status","reason","console","value","addChildModels","fetchContent","withChildSections","ContentModel","childSectionLinks","length","fetchContentChildSections","contentModel","newContentModel","clone","childSectionLink","contentHrefWithEntryDate","selfhref","addParameter","TIMEVERSION_FILTER_NAME","entryDate","sectionModels","childSections","post","POST","postForm","form","formdata","update"],"sources":["../../src/modularui/ModularUIRequest.js"],"sourcesContent":["// @flow\nimport deepmerge from \"deepmerge\";\n\nimport {\n BASE,\n HTTP_METHODS,\n TIMEVERSION_FILTER_NAME,\n} from \"../constants/Constants\";\n\nimport { HIDE_WHEN_EMPTY } from \"../constants/LayoutHints\";\n\nimport { getSetting } from \"../constants/Settings\";\n\nimport Href from \"../models/href/Href\";\n\nimport universalFetch from \"../utils/fetch/universalFetch\";\nimport resolveModel from \"../models/resolveModel\";\nimport FormModel from \"../models/form/FormModel\";\nimport ContentModel from \"../models/content/ContentModel\";\n\nimport ModularUIResponse from \"./ModularUIResponse\";\n\nimport ModularUIError from \"./ModularUIError\";\nimport { IllegalArgumentException, IllegalStateException } from \"../exceptions\";\n\nimport { isPlainObject } from \"../utils/helpers/objects\";\n\nimport type { TargetModel } from \"./types\";\nimport type {\n RequestBaseOptions,\n RequestModularUIOptions,\n} from \"../utils/fetch/types\";\nimport type { ModularUIModel } from \"../models/types\";\n\n/**\n * Helper for fetching data and contributions from the Be Informed modular ui\n * and merge it into a target or resolvable model.\n */\nclass ModularUIRequest {\n _response: ModularUIResponse;\n\n _href: Href;\n _options: RequestModularUIOptions;\n _targetModel: ?TargetModel;\n _forceTargetModel: boolean = false;\n _contributionsHref: string;\n _locale: string;\n _method: $Keys<typeof HTTP_METHODS> = HTTP_METHODS.GET;\n\n _progressEvent: ProgressEventHandler;\n\n /**\n */\n constructor(\n href: Href | string,\n options: $Shape<RequestModularUIOptions> = {}\n ) {\n if (!href) {\n throw new IllegalArgumentException(\n \"You must pass a href to the resource that is requested\"\n );\n }\n\n this.options = options;\n\n this._response = new ModularUIResponse();\n\n this.href = typeof href === \"string\" ? new Href(href) : href;\n this.locale = options.locale ?? \"en\";\n\n // copy request parameters to response, to be able to use them in the models\n // self links are missing the request parameters\n this._response.parameters = this.href.parameters;\n\n if (options.targetModel) {\n this.targetModel = options.targetModel;\n }\n\n if (options.method) {\n this.method = options.method;\n } else {\n this.method = this.href.method;\n }\n }\n\n /**\n */\n get contributionsHref(): string {\n return this._contributionsHref;\n }\n\n /**\n */\n set contributionsHref(contributionsHref: string) {\n this._contributionsHref = contributionsHref;\n }\n\n /**\n */\n set locale(locale: string) {\n this._locale = locale;\n this._response.locale = locale;\n }\n\n /**\n */\n get locale(): string {\n return this._locale;\n }\n\n /**\n */\n get response(): ModularUIResponse {\n return this._response;\n }\n\n /**\n */\n set href(href: Href) {\n this._href = href;\n }\n\n /**\n */\n get href(): Href {\n return this._href;\n }\n\n /**\n */\n set method(method: $Keys<typeof HTTP_METHODS>) {\n this._method = method;\n }\n\n /**\n */\n get method(): $Keys<typeof HTTP_METHODS> {\n return this._method;\n }\n\n /**\n */\n get options(): RequestModularUIOptions {\n return {\n ...this._options,\n locale: this.locale,\n method: this.method,\n };\n }\n\n /**\n */\n get requestOptions(): RequestBaseOptions {\n /* eslint-disable no-unused-vars */\n const {\n targetModel,\n forceTargetModel,\n updateModel,\n childmodels,\n isValidationRequest,\n removeOnUnmount,\n ...requestOptions\n } = this.options;\n /* eslint-enable no-unused-vars */\n return requestOptions;\n }\n\n /**\n */\n set options(options: RequestModularUIOptions) {\n this._options = options;\n }\n\n /**\n */\n get withChildModels(): boolean {\n return (\n !(\"childmodels\" in this.options) || this.options.childmodels === true\n );\n }\n\n /**\n */\n set targetModel(targetModel: TargetModel) {\n this._targetModel = targetModel;\n }\n\n /**\n */\n get targetModel(): ?TargetModel {\n return this._targetModel;\n }\n\n /**\n */\n set forceTargetModel(forceTargetModel: boolean) {\n this._forceTargetModel = forceTargetModel ?? false;\n }\n\n /**\n */\n get forceTargetModel(): boolean {\n return this._forceTargetModel;\n }\n\n /**\n */\n resolveModel(): Class<ModularUIModel> {\n let availableModels;\n if (this.targetModel) {\n availableModels = Array.isArray(this.targetModel)\n ? [...this.targetModel]\n : [this.targetModel];\n\n if (this.forceTargetModel) {\n return availableModels[0];\n }\n }\n\n const Model: Class<ModularUIModel> | null = resolveModel(\n this.response,\n availableModels\n );\n\n if (Model && Model.isApplicableModel) {\n return Model;\n }\n\n if (availableModels) {\n throw new IllegalStateException(\n `data for ${this.href.toString()} is not applicable for model(s): ${availableModels\n .map((m) => m.modelName)\n .join(\", \")}, received response: ${JSON.stringify(this.response)}`\n );\n }\n\n throw new IllegalStateException(\n `no javascript model is applicable for received request of ${this.href.toString()}, with response: ${JSON.stringify(\n this.response\n )}`\n );\n }\n\n /**\n */\n createModel(): ModularUIModel {\n const Model = this.resolveModel();\n return new Model(this.response);\n }\n\n /**\n */\n processContributionsService(contributionsData: Object): void {\n if (!isPlainObject(contributionsData)) {\n throw new IllegalArgumentException(\n \"Missing contributions data or contributions is not JSON\"\n );\n }\n\n const [contributionsKey] = Object.keys(contributionsData);\n\n if (contributionsData.error && contributionsKey === \"error\") {\n this.handleContributionsError(contributionsData.error);\n }\n\n // The key of the data service is different from the contributions service for forms\n if (!(this.response.key in contributionsData)) {\n this.response.key = contributionsKey;\n }\n\n this.response.contributions = contributionsData[this.response.key];\n }\n\n /**\n */\n handleContributionsError(error: Object): void {\n const errorMessage = error.properties?.message ?? \"Error in contribution\";\n throw new ModularUIError(errorMessage, error, this.contributionsHref);\n }\n\n /**\n */\n handleDataError(error: Object): void {\n if (error.properties) {\n const errorMessage = error.properties?.message ?? \"Error in data\";\n throw new ModularUIError(errorMessage, error, this.href.path.toString());\n }\n\n throw new IllegalArgumentException(error);\n }\n\n /**\n */\n handleData(key: string, data: Object): void {\n this.response.key = key;\n this.response.data = data;\n\n const links = data._links;\n\n if (links && links.contributions) {\n this.contributionsHref = links.contributions.href;\n } else if (Array.isArray(links) && links[0].contributions) {\n this.contributionsHref = links[0].contributions.href;\n } else {\n throw new IllegalArgumentException(\n `Contributions link not found for data with key ${key}`\n );\n }\n }\n\n /**\n */\n processDataService(data: Object): void {\n if (!isPlainObject(data)) {\n throw new IllegalArgumentException(\"Missing data or data is not JSON\");\n }\n\n if (data.error) {\n this.handleDataError(data.error);\n } else {\n const [key] = Object.keys(data);\n this.handleData(key, data[key]);\n }\n }\n\n /**\n */\n fetchContributionsService(): Promise<any> {\n if (!this.contributionsHref) {\n throw new IllegalStateException(\"Missing a contributions href\");\n }\n\n return universalFetch({\n url: `${BASE}${this.contributionsHref}`,\n cache: true,\n locale: this.options.locale,\n });\n }\n\n /**\n */\n fetchDataService(): Promise<any> {\n return universalFetch({\n ...this.requestOptions,\n url: `${BASE}${this.href.path}`,\n params: this.href.getQuerystringForModularUI(),\n locale: this.options.locale,\n onProgress: this.onProgress,\n });\n }\n\n /**\n * Check if links contain a 'hide-when-empty' layout hint and remove the link from\n * the component when it exists and no results are available\n */\n async processAsyncLayoutHints(): Promise<void> {\n if (getSetting(\"ALLOW_HIDE_WHEN_EMPTY_ON_TABS\")) {\n await this.processApplicationLinks();\n await this.processTabLinks();\n }\n await this.processPanelLinks();\n\n return Promise.resolve();\n }\n\n /**\n * hide application links<br>\n * _links on application data contains an extra level of tab links\n */\n processApplicationLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n const dataLinks = this.response.data._links;\n if (!contributionLinks || !dataLinks) {\n return Promise.resolve();\n }\n\n if (\"tab\" in contributionLinks && \"tab\" in dataLinks) {\n for (const contributionTabLink of contributionLinks.tab) {\n if (\"components\" in contributionTabLink) {\n const dataTabLinks = dataLinks.tab.find(\n (dataLink) => dataLink.name === contributionTabLink.name\n );\n\n if (dataTabLinks && \"components\" in dataTabLinks) {\n return this.processLinks(\n dataTabLinks.components,\n contributionTabLink.components\n ).then((newLinks) =>\n this.replaceApplicationLinks(contributionTabLink.name, newLinks)\n );\n }\n }\n }\n }\n\n return Promise.resolve();\n }\n\n /**\n * Replace hidden link in application link tree\n */\n replaceApplicationLinks(tabName: string, newLinks: Array<Object>): void {\n this.response.data._links.tab = this.response.data._links.tab.map(\n (tabLink) => {\n const key = tabLink.name;\n if (tabName === key) {\n tabLink.components = newLinks;\n }\n return tabLink;\n }\n );\n }\n\n /**\n */\n processTabLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"component\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links.component,\n contributionLinks.component\n ).then((newLinks) => {\n this.response.data._links.component = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n */\n processPanelLinks(): Promise<void> {\n const contributionLinks = this.response.contributions._links;\n\n if (!contributionLinks) {\n return Promise.resolve();\n }\n\n if (\"panel\" in contributionLinks) {\n return this.processLinks(\n this.response.data._links,\n contributionLinks.panel\n ).then((newLinks) => {\n this.response.data._links = newLinks;\n });\n }\n\n return Promise.resolve();\n }\n\n /**\n * Retrieve an object of key: link\n */\n dataLinksPerName(dataLinks: any): { [linkName: string]: any } {\n if (Array.isArray(dataLinks)) {\n const links = {};\n for (const dataLink of dataLinks) {\n links[dataLink.name] = dataLink;\n }\n return links;\n }\n return dataLinks;\n }\n\n /**\n * Check if links are empty and hide them when hide-when-empty hint exists\n */\n processLinks(\n dataLinks: any,\n contributionLinks: any\n ): Promise<Object | Array<Object>> {\n const linksPerName = this.dataLinksPerName(dataLinks);\n const hideWhenEmptyLinks = contributionLinks.filter((contributionLink) =>\n contributionLink.layouthint?.includes(HIDE_WHEN_EMPTY)\n );\n\n const isHiddenListChecks = [];\n\n for (const contributionLink of hideWhenEmptyLinks) {\n const dataLink = linksPerName[contributionLink.name];\n if (dataLink?.href) {\n isHiddenListChecks.push(\n this.isHiddenList(contributionLink.name, dataLink.href)\n );\n }\n }\n\n return Promise.all(isHiddenListChecks).then(\n (hiddenLinks: Array<string>) => {\n if (Array.isArray(dataLinks)) {\n return dataLinks.filter(\n (dataLink) => !hiddenLinks.includes(dataLink.name)\n );\n }\n\n const newDataLinks: { [string]: any } = {};\n for (const dataLinkKey in dataLinks) {\n if (!hiddenLinks.includes(dataLinkKey)) {\n newDataLinks[dataLinkKey] = dataLinks[dataLinkKey];\n }\n }\n return newDataLinks;\n }\n );\n }\n\n /**\n */\n isHiddenList(name: string, href: string): Promise<string> {\n const HIDE_WHEN_EMPTY_IGNORE_TASKS = getSetting(\n \"HIDE_WHEN_EMPTY_IGNORE_TASKS\",\n false\n );\n\n return universalFetch({\n ...this.requestOptions,\n url: `${BASE}${href}`,\n })\n .then((response: Object) => {\n if (isPlainObject(response)) {\n const [key] = Object.keys(response);\n const { _embedded, actions } = response[key];\n\n const noListItems = _embedded === null;\n const noActions = actions == null || HIDE_WHEN_EMPTY_IGNORE_TASKS;\n\n const isHidden = noListItems && noActions;\n if (isHidden) {\n return name;\n }\n }\n return \"\";\n })\n .catch(() => {\n return \"\";\n });\n }\n\n /**\n */\n set onProgress(progressEvent: ProgressEventHandler) {\n this._progressEvent = progressEvent;\n }\n\n /**\n */\n get onProgress(): ProgressEventHandler {\n return this._progressEvent || null;\n }\n\n /**\n * Combine previous send request data with new validation data to create a complete request object\n * The received model is new FormModel containing ONLY the current question, not the previously entered questions\n * to create a complete request we append the originally send form objects\n */\n getDynamicValidationData(model: ModularUIModel): string {\n const prevData =\n typeof this.options.data === \"string\"\n ? JSON.parse(this.options.data)\n : this.options.data;\n\n if (model instanceof FormModel) {\n const newData = JSON.parse(model.validationData);\n // $FlowFixMe incompatible-call\n return JSON.stringify(deepmerge(prevData || {}, newData));\n }\n\n return JSON.stringify(prevData) ?? \"{}\";\n }\n\n /**\n * First load of dynamic values when a form is loaded\n */\n loadDynamicValidations(model: ModularUIModel): Promise<ModularUIModel> {\n if (\n !this.options.isValidationRequest &&\n getSetting(\"USE_INSTANT_SERVER_VALIDATION\") &&\n model instanceof FormModel &&\n model.currentFormObject &&\n model.currentFormObject.hasDynamicValidations\n ) {\n const validationHref = this.href.setParameter(\"commit\", \"false\");\n return universalFetch({\n ...this.requestOptions,\n url: `${BASE}${this.href.path}`,\n params: validationHref.getQuerystringForModularUI(),\n data: this.getDynamicValidationData(model),\n }).then((data) => {\n if (data == null || typeof data !== \"object\") {\n return model;\n }\n\n const [key] = Object.keys(data);\n return model.updateValidations(data[key]);\n });\n }\n\n return Promise.resolve(model);\n }\n\n /**\n */\n fetch(): Promise<ModularUIModel> {\n return this.fetchDataService()\n .then((data) => {\n if (data == null) {\n throw new Error(`No data received for ${this.href.toString()}`);\n }\n\n this.processDataService(data);\n return this.fetchContributionsService();\n })\n .then((contributionsData) => {\n if (contributionsData == null) {\n throw new Error(\n `No contributions data received for ${this.contributionsHref}`\n );\n }\n\n this.processContributionsService(contributionsData);\n return this.processAsyncLayoutHints();\n })\n .then(() => Promise.resolve(this.createModel()))\n .then((model) => this.loadDynamicValidations(model))\n .then((model) => {\n if (this.withChildModels) {\n return this.fetchChildModels(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n */\n fetchFromCache(): Promise<ModularUIModel> {\n this.options = {\n ...this.options,\n cache: true,\n };\n\n return this.fetch();\n }\n\n /**\n */\n fetchChildModels(model: ModularUIModel): Promise<ModularUIModel> {\n const childModelLinks = model.getInitialChildModelLinks();\n\n const childModelRequests = childModelLinks.map((childModelLink) => {\n const request = new ModularUIRequest(childModelLink.href, {\n locale: this.locale,\n });\n\n if (childModelLink.targetModel) {\n request.targetModel = childModelLink.targetModel;\n }\n\n if (childModelLink.isCacheable) {\n return request.fetchFromCache();\n }\n\n return request.fetch();\n });\n\n return Promise.allSettled(childModelRequests).then((childModels) => {\n const resolvedChildModels = [];\n\n childModels.forEach((childModel) => {\n if (childModel.status === \"rejected\") {\n const { reason } = childModel;\n if (reason.name !== \"Error.ChangePasswordRequired\") {\n console.error(\n \"Unexpected error when retrieving child model:\",\n reason\n );\n }\n } else {\n resolvedChildModels.push(childModel.value);\n }\n });\n\n model.addChildModels(resolvedChildModels);\n\n return model;\n });\n }\n\n /**\n */\n fetchContent(withChildSections: boolean): Promise<mixed> {\n return this.fetchFromCache().then((model) => {\n if (\n withChildSections &&\n model instanceof ContentModel &&\n model.childSectionLinks.length > 0\n ) {\n return this.fetchContentChildSections(model);\n }\n\n return Promise.resolve(model);\n });\n }\n\n /**\n * Recursively return child sections defined on the content model\n */\n fetchContentChildSections(contentModel: ContentModel): Promise<mixed> {\n const newContentModel = contentModel.clone();\n\n return Promise.all(\n contentModel.childSectionLinks.map((childSectionLink) => {\n const contentHrefWithEntryDate = childSectionLink.selfhref.addParameter(\n TIMEVERSION_FILTER_NAME,\n contentModel.entryDate\n );\n\n const request = new ModularUIRequest(contentHrefWithEntryDate, {\n locale: this.locale,\n });\n\n return request.fetchContent(true);\n })\n ).then((sectionModels) => {\n newContentModel.childSections = sectionModels;\n\n return newContentModel;\n });\n }\n\n /**\n * Make a post request with optionally data to send\n * @param data\n */\n post(data?: string | { [key: string]: string }): Promise<ModularUIModel> {\n this.method = HTTP_METHODS.POST;\n this.options = {\n ...this.options,\n data,\n };\n\n return this.fetch();\n }\n\n /**\n * Make a POST request using the form, an updated form is returned (merge of old and new form)\n * @param form\n * @returns {Promise<FormModel>}\n */\n postForm(form: FormModel): Promise<FormModel> {\n this.method = HTTP_METHODS.POST;\n this.options = {\n ...this.options,\n data: form.formdata,\n };\n\n return this.fetch().then((response) => {\n return form.update(response);\n });\n }\n}\n\nexport default ModularUIRequest;\n"],"mappings":";;;;;;;;;;;;;;;AACA;AAEA;AAMA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAEA;AASA;AACA;AACA;AACA;AACA,MAAMA,gBAAgB,CAAC;EAarB;AACF;EACEC,WAAW,CACTC,IAAmB,EAEnB;IAAA,IADAC,OAAwC,uEAAG,CAAC,CAAC;IAAA;IAAA;IAAA;IAAA;IAAA,yDAXlB,KAAK;IAAA;IAAA;IAAA,+CAGIC,uBAAY,CAACC,GAAG;IAAA;IAUpD,IAAI,CAACH,IAAI,EAAE;MACT,MAAM,IAAII,oCAAwB,CAChC,wDAAwD,CACzD;IACH;IAEA,IAAI,CAACH,OAAO,GAAGA,OAAO;IAEtB,IAAI,CAACI,SAAS,GAAG,IAAIC,0BAAiB,EAAE;IAExC,IAAI,CAACN,IAAI,GAAG,OAAOA,IAAI,KAAK,QAAQ,GAAG,IAAIO,aAAI,CAACP,IAAI,CAAC,GAAGA,IAAI;IAC5D,IAAI,CAACQ,MAAM,GAAGP,OAAO,CAACO,MAAM,IAAI,IAAI;;IAEpC;IACA;IACA,IAAI,CAACH,SAAS,CAACI,UAAU,GAAG,IAAI,CAACT,IAAI,CAACS,UAAU;IAEhD,IAAIR,OAAO,CAACS,WAAW,EAAE;MACvB,IAAI,CAACA,WAAW,GAAGT,OAAO,CAACS,WAAW;IACxC;IAEA,IAAIT,OAAO,CAACU,MAAM,EAAE;MAClB,IAAI,CAACA,MAAM,GAAGV,OAAO,CAACU,MAAM;IAC9B,CAAC,MAAM;MACL,IAAI,CAACA,MAAM,GAAG,IAAI,CAACX,IAAI,CAACW,MAAM;IAChC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IAAK;MACrC,OAAOyJ,IAAI,CAACE,MAAM,CAAC3J,QAAQ,CAAC;IAC9B,CAAC,CAAC;EACJ;AACF;AAAC,eAEcjB,gBAAgB;AAAA"}
|
|
@@ -77,6 +77,7 @@ const loadModelSuccessAction = (key, model, modelToUpdate) => {
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
/**
|
|
80
|
+
* This action is handled by the modularui middleware
|
|
80
81
|
*/
|
|
81
82
|
const loadModel = (key, href, options) => ({
|
|
82
83
|
type: "MODULARUI/FETCH",
|
|
@@ -87,6 +88,7 @@ const loadModel = (key, href, options) => ({
|
|
|
87
88
|
locale: options?.locale ?? "en",
|
|
88
89
|
childmodels: options?.childmodels,
|
|
89
90
|
targetModel: options?.targetModel,
|
|
91
|
+
forceTargetModel: options?.forceTargetModel,
|
|
90
92
|
/**
|
|
91
93
|
*/
|
|
92
94
|
successAction: model => loadModelSuccessAction(key, model, options?.updateModel),
|
|
@@ -90,6 +90,7 @@ const loadModelSuccessAction = (
|
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
|
+
* This action is handled by the modularui middleware
|
|
93
94
|
*/
|
|
94
95
|
export const loadModel = (
|
|
95
96
|
key: string,
|
|
@@ -104,6 +105,7 @@ export const loadModel = (
|
|
|
104
105
|
locale: options?.locale ?? "en",
|
|
105
106
|
childmodels: options?.childmodels,
|
|
106
107
|
targetModel: options?.targetModel,
|
|
108
|
+
forceTargetModel: options?.forceTargetModel,
|
|
107
109
|
/**
|
|
108
110
|
*/
|
|
109
111
|
successAction: (model) =>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIActions.js","names":["setModel","key","model","connectKey","type","payload","updateModel","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","LOADING","startProgress","loadModelPromise","resolve","then","response","FINISHED","finishProgress","catch","handleError","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n modelToUpdate: ?ModularUIModel\n): UpdateModelAction | SetModelAction => {\n if (modelToUpdate) {\n // $FlowFixMe[prop-missing]\n if (typeof modelToUpdate[\"update\"] === \"function\") {\n const clonedModel = modelToUpdate.clone();\n clonedModel.update(model);\n\n return updateModel(clonedModel);\n }\n\n throw new Error(\n `loadModel action: updateModel is set as option for ${key}, but the model is missing an update methode`\n );\n }\n\n return setModel(key, model);\n};\n\n/**\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateModel),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACO,MAAMA,QAAQ,GAAG,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF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,aAAI,GAAGF,IAAI,GAAG,IAAIE,aAAI,CAACF,IAAI,CAAC;IAClDG,MAAM,EAAEF,OAAO,EAAEE,MAAM,IAAIC,uBAAY,CAACC,GAAG;IAC3CC,IAAI,EAAEL,OAAO,EAAEK,IAAI;IACnBC,MAAM,EAAEN,OAAO,EAAEM,MAAM,IAAI,IAAI;IAC/BC,WAAW,EAAEP,OAAO,EAAEO,WAAW;IACjCC,WAAW,EAAER,OAAO,EAAEQ,WAAW;
|
|
1
|
+
{"version":3,"file":"ModularUIActions.js","names":["setModel","key","model","connectKey","type","payload","updateModel","removeModelByKey","resetModularUI","updateStatus","status","loadModelSuccessAction","modelToUpdate","clonedModel","clone","update","Error","loadModel","href","options","Href","method","HTTP_METHODS","GET","data","locale","childmodels","targetModel","forceTargetModel","successAction","errorAction","error","errorResponse","ErrorResponse","isChangePassword","isResourceNotFoundAfterReload","MODULARUI_STATUS","ERROR","loadModularUI","dispatch","LOADING","startProgress","loadModelPromise","resolve","then","response","FINISHED","finishProgress","catch","handleError","reloadModel","selfhref","isReload"],"sources":["../../../src/redux/_modularui/ModularUIActions.js"],"sourcesContent":["// @flow\nimport { HTTP_METHODS, MODULARUI_STATUS } from \"../../constants/Constants\";\nimport Href from \"../../models/href/Href\";\nimport ErrorResponse from \"../../models/error/ErrorResponse\";\nimport { finishProgress, startProgress } from \"../actions/ProgressIndicator\";\nimport { handleError } from \"../actions/Error\";\n\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { Dispatch, ThunkAction } from \"../types\";\nimport type {\n ModularUIAction,\n SetModelAction,\n UpdateModelAction,\n RemoveModelByKeyAction,\n ResetModularUIAction,\n UpdateStatusAction,\n} from \"./types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\n/**\n */\nexport const setModel = (\n key: string,\n model: ModularUIModel\n): SetModelAction => {\n // set key on model for later reference\n model.connectKey = key;\n return {\n type: \"MODULARUI/SET\",\n payload: {\n key,\n model,\n },\n };\n};\n\n/**\n */\nexport const updateModel = (model: ModularUIModel): UpdateModelAction => ({\n type: \"MODULARUI/UPDATE\",\n payload: model,\n});\n\n/**\n */\nexport const removeModelByKey = (key: string): RemoveModelByKeyAction => ({\n type: \"MODULARUI/REMOVE_KEY\",\n payload: key,\n});\n\n/**\n * Removes all models except the application model from the modular ui reducer\n */\nexport const resetModularUI = (): ResetModularUIAction => ({\n type: \"MODULARUI/RESET\",\n});\n\n/**\n */\nexport const updateStatus = (\n key: string,\n status: $Keys<typeof MODULARUI_STATUS>\n): UpdateStatusAction => ({\n type: \"MODULARUI/STATUS\",\n payload: { key, status },\n});\n\n/**\n */\nconst loadModelSuccessAction = (\n key: string,\n model: ModularUIModel,\n modelToUpdate: ?ModularUIModel\n): UpdateModelAction | SetModelAction => {\n if (modelToUpdate) {\n // $FlowFixMe[prop-missing]\n if (typeof modelToUpdate[\"update\"] === \"function\") {\n const clonedModel = modelToUpdate.clone();\n clonedModel.update(model);\n\n return updateModel(clonedModel);\n }\n\n throw new Error(\n `loadModel action: updateModel is set as option for ${key}, but the model is missing an update methode`\n );\n }\n\n return setModel(key, model);\n};\n\n/**\n * This action is handled by the modularui middleware\n */\nexport const loadModel = (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n): ModularUIAction => ({\n type: \"MODULARUI/FETCH\",\n payload: {\n href: href instanceof Href ? href : new Href(href),\n method: options?.method ?? HTTP_METHODS.GET,\n data: options?.data,\n locale: options?.locale ?? \"en\",\n childmodels: options?.childmodels,\n targetModel: options?.targetModel,\n forceTargetModel: options?.forceTargetModel,\n /**\n */\n successAction: (model) =>\n loadModelSuccessAction(key, model, options?.updateModel),\n /**\n */\n errorAction: (error) => {\n const errorResponse = new ErrorResponse(error, key);\n if (errorResponse.isChangePassword) {\n return {\n type: \"NO_ACTION\",\n };\n } else if (errorResponse.isResourceNotFoundAfterReload) {\n return removeModelByKey(key);\n }\n\n return updateStatus(key, MODULARUI_STATUS.ERROR);\n },\n },\n});\n\n/**\n */\nexport const loadModularUI =\n (\n key: string,\n href: Href | string,\n options?: RequestModularUIOptions\n ): ThunkAction =>\n (dispatch: Dispatch) => {\n dispatch(updateStatus(key, MODULARUI_STATUS.LOADING));\n dispatch(startProgress());\n\n const loadModelPromise = dispatch(loadModel(key, href, options));\n\n return Promise.resolve(loadModelPromise)\n .then((response) => {\n if (response?.type === \"FINISH_PROGRESS\") {\n dispatch(updateStatus(key, MODULARUI_STATUS.FINISHED));\n }\n\n return dispatch(finishProgress());\n })\n .catch((error) => dispatch(handleError(error)));\n };\n\n/**\n */\nexport const reloadModel = (\n model: ModularUIModel,\n options?: RequestModularUIOptions\n): ThunkAction =>\n loadModularUI(model.connectKey, model.selfhref, {\n ...options,\n isReload: true,\n });\n"],"mappings":";;;;;;;;AACA;AACA;AACA;AACA;AACA;AAcA;AACA;AACO,MAAMA,QAAQ,GAAG,CACtBC,GAAW,EACXC,KAAqB,KACF;EACnB;EACAA,KAAK,CAACC,UAAU,GAAGF,GAAG;EACtB,OAAO;IACLG,IAAI,EAAE,eAAe;IACrBC,OAAO,EAAE;MACPJ,GAAG;MACHC;IACF;EACF,CAAC;AACH,CAAC;;AAED;AACA;AADA;AAEO,MAAMI,WAAW,GAAIJ,KAAqB,KAAyB;EACxEE,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAEH;AACX,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMK,gBAAgB,GAAIN,GAAW,KAA8B;EACxEG,IAAI,EAAE,sBAAsB;EAC5BC,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEF;AACA;AACA;AAFA;AAGO,MAAMO,cAAc,GAAG,OAA6B;EACzDJ,IAAI,EAAE;AACR,CAAC,CAAC;;AAEF;AACA;AADA;AAEO,MAAMK,YAAY,GAAG,CAC1BR,GAAW,EACXS,MAAsC,MACd;EACxBN,IAAI,EAAE,kBAAkB;EACxBC,OAAO,EAAE;IAAEJ,GAAG;IAAES;EAAO;AACzB,CAAC,CAAC;;AAEF;AACA;AADA;AAEA,MAA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
26
26
|
childmodels?: boolean,
|
|
27
27
|
targetModel?: TargetModel,
|
|
28
|
+
forceTargetModel?: boolean,
|
|
28
29
|
isReload?: boolean,
|
|
29
30
|
};
|
|
30
31
|
|
|
@@ -42,6 +43,7 @@ const createRequest = (modularui: RequestOptions): ModularUIRequest => {
|
|
|
42
43
|
|
|
43
44
|
if (modularui.targetModel) {
|
|
44
45
|
request.targetModel = modularui.targetModel;
|
|
46
|
+
request.forceTargetModel = modularui.forceTargetModel ?? false;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
return request;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModularUIMiddleware.js","names":["createRequest","modularui","request","ModularUIRequest","href","method","HTTP_METHODS","GET","data","locale","childmodels","isReload","targetModel","responseHandler","next","dispatch","successAction","model","successResult","then","result","catch","error","handleError","Error","finishProgress","errorHandler","errorAction","err","errorResult","handleFetch","action","startProgress","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: string | { [key: string]: string },\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n isReload?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n });\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch\n) => {\n dispatch(startProgress());\n\n const { successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next\n );\n }\n\n return next(action);\n };\n"],"mappings":";;;;;;;;AACA;AACA;AAEA;AAEA;
|
|
1
|
+
{"version":3,"file":"ModularUIMiddleware.js","names":["createRequest","modularui","request","ModularUIRequest","href","method","HTTP_METHODS","GET","data","locale","childmodels","isReload","targetModel","forceTargetModel","responseHandler","next","dispatch","successAction","model","successResult","then","result","catch","error","handleError","Error","finishProgress","errorHandler","errorAction","err","errorResult","handleFetch","action","startProgress","requestOptions","payload","modularuiRequest","fetch","modularUIMiddleware","api","type","getState","i18n"],"sources":["../../../src/redux/_modularui/ModularUIMiddleware.js"],"sourcesContent":["// @flow\nimport ModularUIRequest from \"../../modularui/ModularUIRequest\";\nimport { HTTP_METHODS } from \"../../constants/Constants\";\n\nimport { startProgress, finishProgress } from \"../actions/ProgressIndicator\";\n\nimport { handleError } from \"../actions/Error\";\n\nimport type { Middleware, MiddlewareAPI } from \"redux\";\nimport type {\n ReduxAction,\n ReduxState,\n Dispatch,\n PossibleAction,\n} from \"../types\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { ModularUIAction, SuccessAction, ErrorAction } from \"./types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\ntype RequestOptions = {\n href: Href,\n method?: $Keys<typeof HTTP_METHODS>,\n data?: string | { [key: string]: string },\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n isReload?: boolean,\n};\n\n/**\n * Symbol key that carries API call info interpreted by this Redux middleware.\n */\nconst createRequest = (modularui: RequestOptions): ModularUIRequest => {\n const request = new ModularUIRequest(modularui.href, {\n method: modularui.method || HTTP_METHODS.GET,\n data: modularui.data || {},\n locale: modularui.locale,\n childmodels: modularui.childmodels ?? true,\n isReload: modularui.isReload,\n });\n\n if (modularui.targetModel) {\n request.targetModel = modularui.targetModel;\n request.forceTargetModel = modularui.forceTargetModel ?? false;\n }\n\n return request;\n};\n\n/**\n */\nconst responseHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n successAction: SuccessAction,\n model: ModularUIModel\n) => {\n if (successAction) {\n const successResult = successAction(model);\n\n if (successResult instanceof Promise) {\n successResult\n .then((result) => {\n dispatch(result);\n })\n .catch((error) => {\n next(handleError(error));\n });\n } else {\n try {\n dispatch(successResult);\n } catch (error) {\n throw new Error(\n `Result of successResult is not a valid redux action: ${error}`\n );\n }\n }\n }\n\n return next(finishProgress());\n};\n\n/**\n */\nconst errorHandler = (\n next: Dispatch,\n dispatch: Dispatch,\n errorAction: ?ErrorAction,\n err: any\n) => {\n dispatch(finishProgress());\n\n if (errorAction) {\n const errorResult = errorAction(err);\n\n if (errorResult instanceof Promise) {\n errorResult.then((result) => dispatch(result));\n } else {\n dispatch(errorResult);\n }\n }\n\n return next(handleError(err));\n};\n\n/**\n */\nconst handleFetch = (\n action: ModularUIAction,\n locale: string,\n dispatch: Dispatch,\n next: Dispatch\n) => {\n dispatch(startProgress());\n\n const { successAction, errorAction, ...requestOptions } = action.payload;\n requestOptions.locale = locale;\n\n const modularuiRequest = createRequest(requestOptions);\n\n return modularuiRequest\n .fetch()\n .then((model) => responseHandler(next, dispatch, successAction, model))\n .catch((error) => errorHandler(next, dispatch, errorAction, error));\n};\n\n/**\n */\nexport const modularUIMiddleware: Middleware<\n ReduxState,\n ReduxAction,\n Dispatch\n> =\n (api: MiddlewareAPI<ReduxState, ReduxAction, Dispatch>) =>\n (next: Dispatch) =>\n (action: PossibleAction) => {\n if (action.type === \"MODULARUI/FETCH\") {\n return handleFetch(\n // $FlowExpectedError[incompatible-exact]\n action,\n api.getState().i18n.locale,\n api.dispatch,\n next\n );\n }\n\n return next(action);\n };\n"],"mappings":";;;;;;;;AACA;AACA;AAEA;AAEA;AAyBA;AACA;AACA;AACA,MAAMA,aAAa,GAAIC,SAAyB,IAAuB;EACrE,MAAMC,OAAO,GAAG,IAAIC,yBAAgB,CAACF,SAAS,CAACG,IAAI,EAAE;IACnDC,MAAM,EAAEJ,SAAS,CAACI,MAA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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: string | { [key: string]: string },\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/redux/_modularui/types.js"],"sourcesContent":["// @flow\nimport type { ModularUIModel } from \"../../models/types\";\nimport type Href from \"../../models/href/Href\";\nimport type { FetchException } from \"../../exceptions\";\nimport type { NoAction } from \"../types\";\nimport typeof {\n HTTP_METHODS,\n MODULARUI_STATUS,\n} from \"../../constants/Constants\";\nimport type { ComponentType } from \"react\";\nimport type { TargetModel } from \"../../modularui/types\";\nimport type { RequestModularUIOptions } from \"../../utils/fetch/types\";\n\nexport type ModularUIOptions = {\n propName?: string,\n removeOnUnmount?: boolean,\n ...RequestModularUIOptions,\n};\n\nexport type ModelEntry = {\n +status: string,\n +model: ModularUIModel,\n +lastModification: number,\n};\n\nexport type ModularUIState = {\n [string]: ModelEntry,\n ...\n};\n\nexport type SetModelAction = {\n type: \"MODULARUI/SET\",\n payload: {\n key: string,\n model: ?ModularUIModel,\n },\n};\n\nexport type UpdateModelAction = {\n type: \"MODULARUI/UPDATE\",\n payload: ModularUIModel,\n};\n\nexport type SuccessAction = (\n model: ModularUIModel\n) => UpdateModelAction | SetModelAction;\n\nexport type ErrorAction = (\n error: FetchException\n) => UpdateStatusAction | RemoveModelByKeyAction | NoAction;\n\nexport type ModularUIAction = {\n type: \"MODULARUI/FETCH\",\n payload: {\n href: Href,\n method?: $Keys<HTTP_METHODS>,\n data?: string | { [key: string]: string },\n locale: string,\n childmodels?: boolean,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n successAction: (\n model: ModularUIModel\n ) => UpdateModelAction | SetModelAction,\n errorAction?: ErrorAction,\n },\n};\n\nexport type RemoveModelByKeyAction = {\n type: \"MODULARUI/REMOVE_KEY\",\n payload: string,\n};\n\nexport type ResetModularUIAction = {\n type: \"MODULARUI/RESET\",\n};\n\nexport type UpdateStatusAction = {\n type: \"MODULARUI/STATUS\",\n payload: {\n key: string,\n status: $Keys<MODULARUI_STATUS>,\n },\n};\n\nexport type ModularUIConnector = (\n Component: ComponentType<any>\n) => ComponentType<any>;\n"],"mappings":""}
|
|
@@ -34,9 +34,9 @@ export type RequestOptions = { ...RequestURLOptions, ...RequestBaseOptions };
|
|
|
34
34
|
export type RequestModularUIOptions = {
|
|
35
35
|
...RequestBaseOptions,
|
|
36
36
|
targetModel?: TargetModel,
|
|
37
|
+
forceTargetModel?: boolean,
|
|
37
38
|
updateModel?: ModularUIModel,
|
|
38
39
|
childmodels?: boolean,
|
|
39
40
|
isValidationRequest?: boolean,
|
|
40
|
-
|
|
41
41
|
removeOnUnmount?: boolean,
|
|
42
42
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/fetch/types.js"],"sourcesContent":["// @flow\nimport typeof { HTTP_METHODS } from \"../../constants/Constants\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\nexport type RequestURLOptions = {\n url: string,\n};\n\nexport type RequestBaseOptions = {\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: string | { [key: string]: string },\n timeout?: number,\n responseType?: string,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n includeContext?: boolean,\n locale?: string,\n cache?: boolean,\n isReload?: boolean,\n};\n\nexport type RequestOptions = { ...RequestURLOptions, ...RequestBaseOptions };\n\nexport type RequestModularUIOptions = {\n ...RequestBaseOptions,\n targetModel?: TargetModel,\n updateModel?: ModularUIModel,\n childmodels?: boolean,\n isValidationRequest?: boolean,\n
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../../src/utils/fetch/types.js"],"sourcesContent":["// @flow\nimport typeof { HTTP_METHODS } from \"../../constants/Constants\";\nimport type { ModularUIModel } from \"../../models/types\";\nimport type { TargetModel } from \"../../modularui/types\";\n\nexport type RequestURLOptions = {\n url: string,\n};\n\nexport type RequestBaseOptions = {\n method?: $Keys<HTTP_METHODS>,\n params?: string,\n data?: string | { [key: string]: string },\n timeout?: number,\n responseType?: string,\n headers?: {\n [headerName: string]: string,\n Accept?: string,\n \"Accept-Language\"?: string,\n \"Content-Type\"?: string,\n \"x-filename\"?: string,\n \"x-filesize\"?: string,\n },\n events?: { [eventName: string]: () => void },\n onProgress?: ProgressEventHandler,\n includeContext?: boolean,\n locale?: string,\n cache?: boolean,\n isReload?: boolean,\n};\n\nexport type RequestOptions = { ...RequestURLOptions, ...RequestBaseOptions };\n\nexport type RequestModularUIOptions = {\n ...RequestBaseOptions,\n targetModel?: TargetModel,\n forceTargetModel?: boolean,\n updateModel?: ModularUIModel,\n childmodels?: boolean,\n isValidationRequest?: boolean,\n removeOnUnmount?: boolean,\n};\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import type { ModularUIModel, Href } from "../models";
|
|
|
10
10
|
type UseModularUIBasicOptions<T: ModularUIModel> = {
|
|
11
11
|
expectedModels: Array<string>,
|
|
12
12
|
targetModel?: Class<T> | Array<Class<T>>,
|
|
13
|
+
forceTargetModel?: boolean,
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
/**
|
|
@@ -20,6 +21,7 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
20
21
|
options: UseModularUIBasicOptions<T> = {
|
|
21
22
|
expectedModels: [],
|
|
22
23
|
targetModel: undefined,
|
|
24
|
+
forceTargetModel: false,
|
|
23
25
|
}
|
|
24
26
|
): T | null => {
|
|
25
27
|
const location = useLocation();
|
|
@@ -27,9 +29,14 @@ export const useModularUIBasic = <T: ModularUIModel>(
|
|
|
27
29
|
throw new IllegalArgumentException("Missing href");
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
const useModularUIOptions = {
|
|
32
|
+
const useModularUIOptions = {
|
|
33
|
+
targetModel: undefined,
|
|
34
|
+
forceTargetModel: undefined,
|
|
35
|
+
isReload: false,
|
|
36
|
+
};
|
|
31
37
|
if (options.targetModel) {
|
|
32
38
|
useModularUIOptions.targetModel = options.targetModel;
|
|
39
|
+
useModularUIOptions.forceTargetModel = options.forceTargetModel;
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
// reload when the modular service starts with the current location
|