@gisce/react-ooui 1.1.63-rc.0 → 1.1.63
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/react-ooui.es.js +2644 -2677
- 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/views/ActionView.d.ts.map +1 -1
- package/dist/widgets/views/Form.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actionbar/FormActionBar.tsx +9 -0
- package/src/ui/ActionErrorDialog.tsx +21 -4
- package/src/views/ActionView.tsx +6 -2
- 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":"ActionView.d.ts","sourceRoot":"","sources":["ActionView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAIf,OAAO,EAIL,eAAe,EAGf,QAAQ,EACT,MAAM,eAAe,CAAC;AAkBvB,aAAK,KAAK,GAAG;IACX,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GA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O,CAAC;IAC5B,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB,CAAC;;AAo+BF,wBAAgC"}
|
package/package.json
CHANGED
|
@@ -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,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
|
});
|
package/src/views/ActionView.tsx
CHANGED
|
@@ -107,6 +107,7 @@ function ActionView(props: Props, ref: any) {
|
|
|
107
107
|
tabs,
|
|
108
108
|
activeKey,
|
|
109
109
|
openAction,
|
|
110
|
+
onRemoveTab,
|
|
110
111
|
} = tabManagerContext || {};
|
|
111
112
|
|
|
112
113
|
useHotkeys(
|
|
@@ -240,8 +241,9 @@ function ActionView(props: Props, ref: any) {
|
|
|
240
241
|
|
|
241
242
|
if (!currentViewToAssign) {
|
|
242
243
|
showErrorDialog(
|
|
243
|
-
|
|
244
|
+
`Error determining the first view to show for model ${model}.\nPlease, make sure the view ids on the fields_view_get responses are the same as the ones defined in the action`
|
|
244
245
|
);
|
|
246
|
+
onRemoveTab?.(tabKey);
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
setCurrentView(currentViewToAssign);
|
|
@@ -279,7 +281,9 @@ function ActionView(props: Props, ref: any) {
|
|
|
279
281
|
}, [tabs, activeKey]);
|
|
280
282
|
|
|
281
283
|
async function canWeClose() {
|
|
282
|
-
if (currentView
|
|
284
|
+
if (!currentView) {
|
|
285
|
+
return true;
|
|
286
|
+
} else if (currentView!.type === "form") {
|
|
283
287
|
return await (formRef.current as any).cancelUnsavedChanges();
|
|
284
288
|
} else {
|
|
285
289
|
return true;
|
|
@@ -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
|
-
};
|