@gisce/react-ooui 1.2.0-rc.72 → 1.2.0-rc.73
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/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 +1697 -1667
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +17 -15
- 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/FormActionBar.tsx +0 -9
- 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 +3 -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,"file":"Form.d.ts","sourceRoot":"","sources":["Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAkCf,OAAO,EAAE,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F,wBAAgC"}
|
package/package.json
CHANGED
|
@@ -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) {
|
|
@@ -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
|
+
};
|
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
} from "@/context/ContentRootContext";
|
|
57
57
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
58
58
|
import { convertToPlain2ManyValues } from "@/helpers/one2manyHelper";
|
|
59
|
+
import { ErrorAlert } from "@/ui/ErrorAlert";
|
|
59
60
|
|
|
60
61
|
export type FormProps = {
|
|
61
62
|
model: string;
|
|
@@ -632,6 +633,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
632
633
|
|
|
633
634
|
await fetchValues();
|
|
634
635
|
submitSucceed = true;
|
|
636
|
+
message.success(t("savedRegisters"));
|
|
635
637
|
} catch (err) {
|
|
636
638
|
formSubmitting.current = false;
|
|
637
639
|
setIsSubmitting(false);
|
|
@@ -1060,14 +1062,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
1060
1062
|
>
|
|
1061
1063
|
{({ measureRef }) => (
|
|
1062
1064
|
<div className="pb-2" ref={measureRef}>
|
|
1063
|
-
{error &&
|
|
1064
|
-
<Alert
|
|
1065
|
-
className="mt-10 mb-20"
|
|
1066
|
-
message={JSON.stringify(error)}
|
|
1067
|
-
type="error"
|
|
1068
|
-
banner
|
|
1069
|
-
/>
|
|
1070
|
-
)}
|
|
1065
|
+
{error && <ErrorAlert className="mt-10 mb-20" error={error} />}
|
|
1071
1066
|
{content()}
|
|
1072
1067
|
{showFooter && footer()}
|
|
1073
1068
|
</div>
|