@gisce/react-ooui 1.1.65-rc.0 → 1.1.66
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 +2304 -2328
- 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/custom/ButtonGroup.d.ts +1 -1
- package/dist/widgets/custom/ButtonGroup.d.ts.map +1 -1
- package/dist/widgets/views/Form.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/actionbar/FormActionBar.tsx +9 -0
- package/src/ui/ActionErrorDialog.tsx +21 -4
- package/src/widgets/custom/ButtonGroup.tsx +31 -21
- 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"}
|
|
@@ -3,6 +3,6 @@ import { ButtonGroup as ButtonGroupOoui } from "@gisce/ooui";
|
|
|
3
3
|
declare type ButtonGroupProps = {
|
|
4
4
|
ooui: ButtonGroupOoui;
|
|
5
5
|
};
|
|
6
|
-
export declare const ButtonGroup: (props: ButtonGroupProps) => JSX.Element;
|
|
6
|
+
export declare const ButtonGroup: (props: ButtonGroupProps) => JSX.Element | null | undefined;
|
|
7
7
|
export {};
|
|
8
8
|
//# sourceMappingURL=ButtonGroup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ButtonGroup.d.ts","sourceRoot":"","sources":["ButtonGroup.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"ButtonGroup.d.ts","sourceRoot":"","sources":["ButtonGroup.tsx"],"names":[],"mappings":";AAKA,OAAO,EACL,WAAW,IAAI,eAAe,EAG/B,MAAM,aAAa,CAAC;AAQrB,aAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AAQF,eAAO,MAAM,WAAW,UAAW,gBAAgB,mCA2ElD,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
|
+
{"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;AAiBjD,oBAAY,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC9B,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACxE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,OAAO,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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gisce/react-ooui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.66",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"src",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ant-design/plots": "^1.0.9",
|
|
39
|
-
"@gisce/ooui": "^0.19.
|
|
39
|
+
"@gisce/ooui": "^0.19.6",
|
|
40
40
|
"@gisce/react-formiga-table": "^0.5.0",
|
|
41
41
|
"@monaco-editor/react": "^4.4.5",
|
|
42
42
|
"@tabler/icons-react": "^2.11.0",
|
|
@@ -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
|
});
|
|
@@ -2,6 +2,7 @@ import React, { useContext, useState } from "react";
|
|
|
2
2
|
import Field from "@/common/Field";
|
|
3
3
|
import { DownOutlined } from "@ant-design/icons";
|
|
4
4
|
import { Dropdown, Menu } from "antd";
|
|
5
|
+
import { Button } from "@/widgets/base/Button";
|
|
5
6
|
import {
|
|
6
7
|
ButtonGroup as ButtonGroupOoui,
|
|
7
8
|
Button as ButtonOoui,
|
|
@@ -20,6 +21,8 @@ type ButtonGroupProps = {
|
|
|
20
21
|
|
|
21
22
|
type ItemsProps = {
|
|
22
23
|
ooui: ButtonOoui[];
|
|
24
|
+
executeButtonAction: any,
|
|
25
|
+
lang: string
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
export const ButtonGroup = (props: ButtonGroupProps) => {
|
|
@@ -73,27 +76,37 @@ export const ButtonGroup = (props: ButtonGroupProps) => {
|
|
|
73
76
|
|
|
74
77
|
onClick_confirm();
|
|
75
78
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
79
|
+
if (ooui.buttons.length === 0) {
|
|
80
|
+
return null;
|
|
81
|
+
} else if (ooui.buttons.length > 1) {
|
|
82
|
+
return (
|
|
83
|
+
<Field ooui={new FieldOoui({ ...{ ooui } })}>
|
|
84
|
+
<Dropdown.Button
|
|
85
|
+
disabled={!activated || readOnly}
|
|
86
|
+
onClick={onClick}
|
|
87
|
+
icon={<DownOutlined />}
|
|
88
|
+
type={primary ? "primary" : undefined}
|
|
89
|
+
//danger={danger ? true : undefined} This works but typescript
|
|
90
|
+
// doesn't accept
|
|
91
|
+
overlay={<Items ooui={secondaryButtons} executeButtonAction={executeButtonAction} lang={lang} /> }
|
|
92
|
+
>
|
|
93
|
+
{getButtonIcon()}
|
|
94
|
+
{caption}
|
|
95
|
+
</Dropdown.Button>
|
|
96
|
+
</Field>
|
|
97
|
+
);
|
|
98
|
+
} else if (defaultButton) {
|
|
99
|
+
return (
|
|
100
|
+
<Button ooui={defaultButton} />
|
|
101
|
+
)
|
|
102
|
+
}
|
|
93
103
|
};
|
|
94
104
|
|
|
95
105
|
const Items = (props: ItemsProps) => {
|
|
96
|
-
const { ooui } = props;
|
|
106
|
+
const { ooui, executeButtonAction, lang } = props;
|
|
107
|
+
if (!ooui) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
97
110
|
const items = ooui.map((button) => {
|
|
98
111
|
const {
|
|
99
112
|
id,
|
|
@@ -106,10 +119,7 @@ const Items = (props: ItemsProps) => {
|
|
|
106
119
|
readOnly,
|
|
107
120
|
danger,
|
|
108
121
|
} = button;
|
|
109
|
-
const formContext = useContext(FormContext) as FormContextType;
|
|
110
|
-
const { executeButtonAction } = formContext || {};
|
|
111
122
|
const [isRunning, setIsRunning] = useState<boolean>(false);
|
|
112
|
-
const { lang } = useContext(LocaleContext) as LocaleContextType;
|
|
113
123
|
|
|
114
124
|
async function onClick_confirm() {
|
|
115
125
|
setIsRunning(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
|
-
};
|