@gisce/react-ooui 1.1.63 → 1.1.64-rc.0
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/AttachmentsButtonWrapper.d.ts.map +1 -1
- package/dist/actionbar/FormActionBar.d.ts.map +1 -1
- package/dist/helpers/errorHelper.d.ts +6 -0
- package/dist/helpers/errorHelper.d.ts.map +1 -0
- package/dist/react-ooui.es.js +2306 -2273
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +18 -16
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/ui/ActionErrorDialog.d.ts.map +1 -1
- package/dist/ui/ErrorAlert.d.ts +6 -0
- package/dist/ui/ErrorAlert.d.ts.map +1 -0
- package/dist/widgets/views/Form.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actionbar/AttachmentsButtonWrapper.tsx +15 -12
- package/src/actionbar/FormActionBar.tsx +0 -9
- package/src/context/ContentRootContext.tsx +1 -1
- package/src/helpers/errorHelper.ts +27 -0
- package/src/ui/ActionErrorDialog.tsx +4 -21
- package/src/ui/ErrorAlert.tsx +37 -0
- package/src/widgets/views/Form.tsx +7 -8
|
@@ -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":"AAOA,QAAA,MAAM,UAAU,QAAS,MAAM,SAc9B,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorAlert.d.ts","sourceRoot":"","sources":["ErrorAlert.tsx"],"names":[],"mappings":";AAKA,eAAO,MAAM,UAAU;WAId,GAAG;eACC,MAAM;iBA0BlB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,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AE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB,CAAC;;AAk+BF,wBAAgC"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,11 @@ import {
|
|
|
8
8
|
TableOutlined,
|
|
9
9
|
} from "@ant-design/icons";
|
|
10
10
|
import { Popover, Button, Row, Col, Tooltip, Spin } from "antd";
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
LocaleContext,
|
|
13
|
+
LocaleContextType,
|
|
14
|
+
tForLang,
|
|
15
|
+
} from "@/context/LocaleContext";
|
|
12
16
|
|
|
13
17
|
export type Attachment = {
|
|
14
18
|
id: number;
|
|
@@ -32,7 +36,7 @@ export const AttachmentsButtonWrapper = (
|
|
|
32
36
|
props: AttachmentsButtonWrapperProps
|
|
33
37
|
) => {
|
|
34
38
|
const { numberOfAttachments, disabled } = props;
|
|
35
|
-
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
39
|
+
const { t, lang } = useContext(LocaleContext) as LocaleContextType;
|
|
36
40
|
const [popoverVisible, setPopoverVisible] = useState<boolean>(false);
|
|
37
41
|
|
|
38
42
|
const button = (
|
|
@@ -52,7 +56,7 @@ export const AttachmentsButtonWrapper = (
|
|
|
52
56
|
onVisibleChange={(visible: boolean) => setPopoverVisible(visible)}
|
|
53
57
|
visible={popoverVisible}
|
|
54
58
|
placement="bottom"
|
|
55
|
-
content={Content(props, setPopoverVisible)}
|
|
59
|
+
content={Content(props, setPopoverVisible, lang)}
|
|
56
60
|
title={t("attachments")}
|
|
57
61
|
arrowContent={null}
|
|
58
62
|
>
|
|
@@ -63,7 +67,8 @@ export const AttachmentsButtonWrapper = (
|
|
|
63
67
|
|
|
64
68
|
const Content = (
|
|
65
69
|
props: AttachmentsButtonWrapperProps,
|
|
66
|
-
setPopoverVisible: (visible: boolean) => void
|
|
70
|
+
setPopoverVisible: (visible: boolean) => void,
|
|
71
|
+
locale: string
|
|
67
72
|
) => {
|
|
68
73
|
const {
|
|
69
74
|
attachments = [],
|
|
@@ -73,8 +78,6 @@ const Content = (
|
|
|
73
78
|
onOpenAttachmentDetail,
|
|
74
79
|
onListAllAttachments,
|
|
75
80
|
} = props;
|
|
76
|
-
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
77
|
-
|
|
78
81
|
if (loading) {
|
|
79
82
|
return <Spin style={{ padding: 20 }} />;
|
|
80
83
|
}
|
|
@@ -89,7 +92,7 @@ const Content = (
|
|
|
89
92
|
onListAllAttachments();
|
|
90
93
|
}}
|
|
91
94
|
>
|
|
92
|
-
<TableOutlined /> {
|
|
95
|
+
<TableOutlined /> {tForLang("listAllAttachments", locale)}
|
|
93
96
|
</a>
|
|
94
97
|
<a
|
|
95
98
|
style={{ display: "block" }}
|
|
@@ -99,11 +102,11 @@ const Content = (
|
|
|
99
102
|
onAddNewAttachment();
|
|
100
103
|
}}
|
|
101
104
|
>
|
|
102
|
-
<FileAddOutlined /> {
|
|
105
|
+
<FileAddOutlined /> {tForLang("addNewAttachment", locale)}
|
|
103
106
|
</a>
|
|
104
107
|
{attachments.length > 0 && (
|
|
105
108
|
<>
|
|
106
|
-
<li className="
|
|
109
|
+
<li className="ant-dropdown-menu-item-divider"></li>
|
|
107
110
|
{attachments.map((attachment: any) => {
|
|
108
111
|
const Icon = attachment.link ? LinkOutlined : DownloadOutlined;
|
|
109
112
|
return (
|
|
@@ -119,8 +122,8 @@ const Content = (
|
|
|
119
122
|
<Tooltip
|
|
120
123
|
title={
|
|
121
124
|
attachment.link
|
|
122
|
-
?
|
|
123
|
-
:
|
|
125
|
+
? tForLang("openAttachmentLink", locale)
|
|
126
|
+
: tForLang("download", locale)
|
|
124
127
|
}
|
|
125
128
|
>
|
|
126
129
|
<Icon
|
|
@@ -134,7 +137,7 @@ const Content = (
|
|
|
134
137
|
)}
|
|
135
138
|
</Col>
|
|
136
139
|
<Col flex="25px" style={{ textAlign: "center" }}>
|
|
137
|
-
<Tooltip title={
|
|
140
|
+
<Tooltip title={tForLang("openAttachment", locale)}>
|
|
138
141
|
<FormOutlined
|
|
139
142
|
style={{ cursor: "pointer" }}
|
|
140
143
|
onClick={() => {
|
|
@@ -78,15 +78,6 @@ 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]);
|
|
90
81
|
|
|
91
82
|
function tryRefresh(callback: any) {
|
|
92
83
|
if (formHasChanges) {
|
|
@@ -439,7 +439,7 @@ async function getViewsAndInitialView({
|
|
|
439
439
|
};
|
|
440
440
|
} else if (!view_id) {
|
|
441
441
|
const type = view_mode.split(",")[0];
|
|
442
|
-
const [retrievedViewId] =
|
|
442
|
+
const [retrievedViewId] = retriedViewData.find(([_, viewType]) => viewType === type)!;
|
|
443
443
|
initialView = { id: retrievedViewId, type };
|
|
444
444
|
} else {
|
|
445
445
|
initialView = {
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
};
|
|
@@ -1,38 +1,21 @@
|
|
|
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";
|
|
4
5
|
|
|
5
6
|
const { error, warning } = Modal;
|
|
6
7
|
|
|
7
8
|
const showDialog = (err: string) => {
|
|
8
|
-
|
|
9
|
-
let type;
|
|
10
|
-
let title;
|
|
9
|
+
const { message, type, title } = parseError(err);
|
|
11
10
|
|
|
12
|
-
|
|
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 =
|
|
11
|
+
const iconComponent =
|
|
29
12
|
type === "error" ? <ExclamationCircleOutlined /> : <WarningOutlined />;
|
|
30
13
|
|
|
31
14
|
const modalType = type === "error" ? error : warning;
|
|
32
15
|
|
|
33
16
|
modalType({
|
|
34
17
|
title,
|
|
35
|
-
icon,
|
|
18
|
+
icon: iconComponent,
|
|
36
19
|
centered: true,
|
|
37
20
|
content: message,
|
|
38
21
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
};
|
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
ContentRootContextType,
|
|
56
56
|
} from "@/context/ContentRootContext";
|
|
57
57
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
58
|
+
import { ErrorAlert } from "@/ui/ErrorAlert";
|
|
58
59
|
|
|
59
60
|
export type FormProps = {
|
|
60
61
|
model: string;
|
|
@@ -635,6 +636,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
635
636
|
|
|
636
637
|
await fetchValues();
|
|
637
638
|
submitSucceed = true;
|
|
639
|
+
message.success(t("savedRegisters"));
|
|
638
640
|
} catch (err) {
|
|
639
641
|
formSubmitting.current = false;
|
|
640
642
|
setIsSubmitting(false);
|
|
@@ -869,6 +871,10 @@ function Form(props: FormProps, ref: any) {
|
|
|
869
871
|
model,
|
|
870
872
|
action,
|
|
871
873
|
payload: getCurrentId()!,
|
|
874
|
+
context: {
|
|
875
|
+
...parentContext,
|
|
876
|
+
...formOoui?.context,
|
|
877
|
+
},
|
|
872
878
|
});
|
|
873
879
|
|
|
874
880
|
if (response.type && response.type === "ir.actions.act_window_close") {
|
|
@@ -1058,14 +1064,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
1058
1064
|
>
|
|
1059
1065
|
{({ measureRef }) => (
|
|
1060
1066
|
<div className="pb-2" ref={measureRef}>
|
|
1061
|
-
{error &&
|
|
1062
|
-
<Alert
|
|
1063
|
-
className="mt-10 mb-20"
|
|
1064
|
-
message={JSON.stringify(error)}
|
|
1065
|
-
type="error"
|
|
1066
|
-
banner
|
|
1067
|
-
/>
|
|
1068
|
-
)}
|
|
1067
|
+
{error && <ErrorAlert className="mt-10 mb-20" error={error} />}
|
|
1069
1068
|
{content()}
|
|
1070
1069
|
{showFooter && footer()}
|
|
1071
1070
|
</div>
|