@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
|
@@ -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
|
);
|
|
@@ -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) =>
|
|
@@ -25,6 +25,7 @@ type RequestOptions = {
|
|
|
25
25
|
locale: string,
|
|
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;
|
package/src/utils/fetch/types.js
CHANGED
|
@@ -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
|
};
|