@gisce/react-ooui 1.1.61-rc.0 → 1.1.61
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/dist/actionbar/ChangeViewButton.d.ts.map +1 -1
- package/dist/actionbar/FormActionBar.d.ts.map +1 -1
- package/dist/context/ContentRootContext.d.ts.map +1 -1
- package/dist/react-ooui.es.js +2264 -2339
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +16 -18
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/ui/ActionErrorDialog.d.ts.map +1 -1
- package/dist/widgets/views/Form.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actionbar/ChangeViewButton.tsx +3 -1
- package/src/actionbar/FormActionBar.tsx +9 -0
- package/src/context/ContentRootContext.tsx +28 -64
- package/src/ui/ActionErrorDialog.tsx +21 -4
- package/src/widgets/views/Form.tsx +8 -7
- package/dist/helpers/errorHelper.d.ts +0 -6
- package/dist/helpers/errorHelper.d.ts.map +0 -1
- package/dist/ui/ErrorAlert.d.ts +0 -6
- package/dist/ui/ErrorAlert.d.ts.map +0 -1
- package/src/helpers/errorHelper.ts +0 -27
- package/src/ui/ErrorAlert.tsx +0 -37
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionErrorDialog.d.ts","sourceRoot":"","sources":["ActionErrorDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ActionErrorDialog.d.ts","sourceRoot":"","sources":["ActionErrorDialog.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,UAAU,QAAS,MAAM,SAgC9B,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAkCf,OAAO,EAAE,QAAQ,EAAgB,MAAM,SAAS,CAAC;
|
|
1
|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+57,9 @@ function ChangeViewButton(props: Props) {
|
|
|
57
57
|
{getIconForView(view)}
|
|
58
58
|
</Col>
|
|
59
59
|
<Col flex="auto" style={{ paddingRight: 20 }}>
|
|
60
|
-
{view.type
|
|
60
|
+
{view.type === "graph"
|
|
61
|
+
? (view as GraphView).name
|
|
62
|
+
: view.type.charAt(0).toUpperCase() + view.type.slice(1)}
|
|
61
63
|
</Col>
|
|
62
64
|
<Col flex="none">
|
|
63
65
|
<CheckOutlined
|
|
@@ -78,6 +78,15 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
|
|
|
78
78
|
TabManagerContext
|
|
79
79
|
) as TabManagerContextType;
|
|
80
80
|
const { openRelate, openDefaultActionForModel } = tabManagerContext || {};
|
|
81
|
+
const prevFormIsSavingRef = useRef<boolean>(false);
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!formIsSaving && prevFormIsSavingRef.current) {
|
|
85
|
+
message.success(t("savedRegisters"));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
prevFormIsSavingRef.current = formIsSaving || false;
|
|
89
|
+
}, [formIsSaving]);
|
|
81
90
|
|
|
82
91
|
function tryRefresh(callback: any) {
|
|
83
92
|
if (formHasChanges) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormView, GenerateReportOptions
|
|
1
|
+
import { FormView, GenerateReportOptions } from "@/types";
|
|
2
2
|
import React, {
|
|
3
3
|
useContext,
|
|
4
4
|
useRef,
|
|
@@ -261,12 +261,33 @@ const ContentRootProvider = (
|
|
|
261
261
|
|
|
262
262
|
return {};
|
|
263
263
|
} else {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
264
|
+
let initialView;
|
|
265
|
+
const viewTypes = actionData.view_mode.split(",");
|
|
266
|
+
const views = [];
|
|
267
|
+
|
|
268
|
+
for (const viewType of viewTypes) {
|
|
269
|
+
const viewData = await ConnectionProvider.getHandler().getView({
|
|
270
|
+
model: actionData.res_model,
|
|
271
|
+
type: viewType,
|
|
272
|
+
context: mergedContext,
|
|
273
|
+
});
|
|
274
|
+
views.push([viewData.view_id, viewType]);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (!actionData.view_id) {
|
|
278
|
+
const type = actionData.view_mode.split(",")[0];
|
|
279
|
+
|
|
280
|
+
const [retrievedViewId] = views.find(
|
|
281
|
+
([_, viewType]) => viewType === type
|
|
282
|
+
)!;
|
|
283
|
+
|
|
284
|
+
initialView = { id: retrievedViewId, type };
|
|
285
|
+
} else {
|
|
286
|
+
initialView = {
|
|
287
|
+
id: actionData.view_id,
|
|
288
|
+
type: actionData.view_mode.split(",")[0],
|
|
289
|
+
};
|
|
290
|
+
}
|
|
270
291
|
|
|
271
292
|
openAction?.({
|
|
272
293
|
target: "current",
|
|
@@ -394,61 +415,4 @@ const ContentRootProvider = (
|
|
|
394
415
|
);
|
|
395
416
|
};
|
|
396
417
|
|
|
397
|
-
async function getViewsAndInitialView({
|
|
398
|
-
views,
|
|
399
|
-
view_mode,
|
|
400
|
-
model,
|
|
401
|
-
context,
|
|
402
|
-
view_id,
|
|
403
|
-
}: {
|
|
404
|
-
views: any[];
|
|
405
|
-
view_mode: string;
|
|
406
|
-
model: string;
|
|
407
|
-
context: any;
|
|
408
|
-
view_id?: number;
|
|
409
|
-
}) {
|
|
410
|
-
const retriedViewData = [];
|
|
411
|
-
let initialView;
|
|
412
|
-
|
|
413
|
-
if (views) {
|
|
414
|
-
for (const view of views) {
|
|
415
|
-
const viewData = await ConnectionProvider.getHandler().getView({
|
|
416
|
-
model,
|
|
417
|
-
type: view[1],
|
|
418
|
-
id: view[0],
|
|
419
|
-
context,
|
|
420
|
-
});
|
|
421
|
-
retriedViewData.push([viewData.view_id, view[1]]);
|
|
422
|
-
}
|
|
423
|
-
} else {
|
|
424
|
-
const viewTypes = view_mode.split(",");
|
|
425
|
-
for (const viewType of viewTypes) {
|
|
426
|
-
const viewData = await ConnectionProvider.getHandler().getView({
|
|
427
|
-
model,
|
|
428
|
-
type: viewType as ViewType,
|
|
429
|
-
context,
|
|
430
|
-
});
|
|
431
|
-
retriedViewData.push([viewData.view_id, viewType]);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
if (views && views.length > 0) {
|
|
435
|
-
const [id, type] = views[0];
|
|
436
|
-
initialView = {
|
|
437
|
-
id,
|
|
438
|
-
type,
|
|
439
|
-
};
|
|
440
|
-
} else if (!view_id) {
|
|
441
|
-
const type = view_mode.split(",")[0];
|
|
442
|
-
const [retrievedViewId] = views.find(([_, viewType]) => viewType === type)!;
|
|
443
|
-
initialView = { id: retrievedViewId, type };
|
|
444
|
-
} else {
|
|
445
|
-
initialView = {
|
|
446
|
-
id: view_id,
|
|
447
|
-
type: view_mode.split(",")[0],
|
|
448
|
-
};
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
return { views: retriedViewData, initialView };
|
|
452
|
-
}
|
|
453
|
-
|
|
454
418
|
export default forwardRef(ContentRootProvider);
|
|
@@ -1,21 +1,38 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Modal } from "antd";
|
|
3
3
|
import { ExclamationCircleOutlined, WarningOutlined } from "@ant-design/icons";
|
|
4
|
-
import { parseError } from "@/helpers/errorHelper";
|
|
5
4
|
|
|
6
5
|
const { error, warning } = Modal;
|
|
7
6
|
|
|
8
7
|
const showDialog = (err: string) => {
|
|
9
|
-
|
|
8
|
+
let message;
|
|
9
|
+
let type;
|
|
10
|
+
let title;
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
if (
|
|
13
|
+
typeof err === "string" &&
|
|
14
|
+
err.indexOf(" -- ") !== -1 &&
|
|
15
|
+
err.indexOf("\n\n") !== -1
|
|
16
|
+
) {
|
|
17
|
+
const splitted = err.split("\n\n");
|
|
18
|
+
message = splitted[1];
|
|
19
|
+
const args = splitted[0].split(" -- ");
|
|
20
|
+
type = args[0];
|
|
21
|
+
title = args[1];
|
|
22
|
+
} else {
|
|
23
|
+
message = err;
|
|
24
|
+
type = "error";
|
|
25
|
+
title = "Error";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const icon =
|
|
12
29
|
type === "error" ? <ExclamationCircleOutlined /> : <WarningOutlined />;
|
|
13
30
|
|
|
14
31
|
const modalType = type === "error" ? error : warning;
|
|
15
32
|
|
|
16
33
|
modalType({
|
|
17
34
|
title,
|
|
18
|
-
icon
|
|
35
|
+
icon,
|
|
19
36
|
centered: true,
|
|
20
37
|
content: message,
|
|
21
38
|
});
|
|
@@ -55,7 +55,6 @@ import {
|
|
|
55
55
|
ContentRootContextType,
|
|
56
56
|
} from "@/context/ContentRootContext";
|
|
57
57
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
58
|
-
import { ErrorAlert } from "@/ui/ErrorAlert";
|
|
59
58
|
|
|
60
59
|
export type FormProps = {
|
|
61
60
|
model: string;
|
|
@@ -636,7 +635,6 @@ function Form(props: FormProps, ref: any) {
|
|
|
636
635
|
|
|
637
636
|
await fetchValues();
|
|
638
637
|
submitSucceed = true;
|
|
639
|
-
message.success(t("savedRegisters"));
|
|
640
638
|
} catch (err) {
|
|
641
639
|
formSubmitting.current = false;
|
|
642
640
|
setIsSubmitting(false);
|
|
@@ -871,10 +869,6 @@ function Form(props: FormProps, ref: any) {
|
|
|
871
869
|
model,
|
|
872
870
|
action,
|
|
873
871
|
payload: getCurrentId()!,
|
|
874
|
-
context: {
|
|
875
|
-
...parentContext,
|
|
876
|
-
...formOoui?.context,
|
|
877
|
-
},
|
|
878
872
|
});
|
|
879
873
|
|
|
880
874
|
if (response.type && response.type === "ir.actions.act_window_close") {
|
|
@@ -1064,7 +1058,14 @@ function Form(props: FormProps, ref: any) {
|
|
|
1064
1058
|
>
|
|
1065
1059
|
{({ measureRef }) => (
|
|
1066
1060
|
<div className="pb-2" ref={measureRef}>
|
|
1067
|
-
{error &&
|
|
1061
|
+
{error && (
|
|
1062
|
+
<Alert
|
|
1063
|
+
className="mt-10 mb-20"
|
|
1064
|
+
message={JSON.stringify(error)}
|
|
1065
|
+
type="error"
|
|
1066
|
+
banner
|
|
1067
|
+
/>
|
|
1068
|
+
)}
|
|
1068
1069
|
{content()}
|
|
1069
1070
|
{showFooter && footer()}
|
|
1070
1071
|
</div>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorHelper.d.ts","sourceRoot":"","sources":["errorHelper.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,kBAAmB,MAAM;;;;CA0B/C,CAAC"}
|
package/dist/ui/ErrorAlert.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorAlert.d.ts","sourceRoot":"","sources":["ErrorAlert.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAM,UAAU;WAId,GAAG;eACC,MAAM;iBA0BlB,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export const parseError = (errorResponse: string) => {
|
|
2
|
-
let message;
|
|
3
|
-
let type;
|
|
4
|
-
let title;
|
|
5
|
-
|
|
6
|
-
if (
|
|
7
|
-
typeof errorResponse === "string" &&
|
|
8
|
-
errorResponse.indexOf(" -- ") !== -1 &&
|
|
9
|
-
errorResponse.indexOf("\n\n") !== -1
|
|
10
|
-
) {
|
|
11
|
-
const splitted = errorResponse.split("\n\n");
|
|
12
|
-
message = splitted[1].replace(/\n/g, "<br />");
|
|
13
|
-
const args = splitted[0].split(" -- ");
|
|
14
|
-
type = args[0];
|
|
15
|
-
title = args[1];
|
|
16
|
-
} else {
|
|
17
|
-
message = errorResponse;
|
|
18
|
-
type = "error";
|
|
19
|
-
title = "Error";
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
type,
|
|
24
|
-
message,
|
|
25
|
-
title,
|
|
26
|
-
};
|
|
27
|
-
};
|
package/src/ui/ErrorAlert.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { parseError } from "@/helpers/errorHelper";
|
|
2
|
-
import { Alert } from "antd";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { Interweave } from "interweave";
|
|
5
|
-
|
|
6
|
-
export const ErrorAlert = ({
|
|
7
|
-
error,
|
|
8
|
-
className,
|
|
9
|
-
}: {
|
|
10
|
-
error: any;
|
|
11
|
-
className: string;
|
|
12
|
-
}) => {
|
|
13
|
-
let messageContent;
|
|
14
|
-
let messageType = "error";
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
typeof error === "string" &&
|
|
18
|
-
error.indexOf(" -- ") !== -1 &&
|
|
19
|
-
error.indexOf("\n\n") !== -1
|
|
20
|
-
) {
|
|
21
|
-
const { message, type, title } = parseError(error);
|
|
22
|
-
messageContent = <Interweave content={`${title}<br />${message}`} />;
|
|
23
|
-
messageType = type;
|
|
24
|
-
} else {
|
|
25
|
-
messageContent = error.message
|
|
26
|
-
? JSON.stringify(error.message)
|
|
27
|
-
: JSON.stringify(error);
|
|
28
|
-
}
|
|
29
|
-
return (
|
|
30
|
-
<Alert
|
|
31
|
-
className={className}
|
|
32
|
-
message={messageContent}
|
|
33
|
-
type={messageType as any}
|
|
34
|
-
banner
|
|
35
|
-
/>
|
|
36
|
-
);
|
|
37
|
-
};
|