@gisce/react-ooui 1.1.64 → 1.1.65-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.
@@ -1 +1 @@
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
+ {"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,6 @@
1
+ /// <reference types="react" />
2
+ export declare const ErrorAlert: ({ error, className, }: {
3
+ error: any;
4
+ className: string;
5
+ }) => JSX.Element;
6
+ //# sourceMappingURL=ErrorAlert.d.ts.map
@@ -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,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,CAA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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;;AAk+BF,wBAAgC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SearchField.d.ts","sourceRoot":"","sources":["SearchField.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,KAAK,EAA8B,MAAM,aAAa,CAAC;AAGhE,aAAK,KAAK,GAAG;IACX,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAgBF,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,eAyCvC"}
1
+ {"version":3,"file":"SearchField.d.ts","sourceRoot":"","sources":["SearchField.tsx"],"names":[],"mappings":";AAUA,OAAO,EAAE,KAAK,EAAgD,MAAM,aAAa,CAAC;AAGlF,aAAK,KAAK,GAAG;IACX,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,eAyCvC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.1.64",
3
+ "version": "1.1.65-rc.0",
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.4",
39
+ "@gisce/ooui": "^0.19.5-rc.1",
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,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
- let message;
9
- let type;
10
- let title;
9
+ const { message, type, title } = parseError(err);
11
10
 
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 =
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>
@@ -8,27 +8,13 @@ import { PairFields } from "./PairFields";
8
8
 
9
9
  import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
10
10
 
11
- import { Field, Selection as SelectionOoui } from "@gisce/ooui";
11
+ import { Field, SearchFieldTypes, Selection as SelectionOoui } from "@gisce/ooui";
12
12
  import { MultiSelection } from "@/widgets/base/MultiSelection";
13
13
 
14
14
  type Props = {
15
15
  field: Field;
16
16
  };
17
17
 
18
- const types = {
19
- text: "text",
20
- many2one: "many2one",
21
- char: "char",
22
- boolean: "boolean",
23
- selection: "selection",
24
- float: "float",
25
- float_time: "float_time",
26
- progressbar: "progressbar",
27
- integer: "integer",
28
- date: "date",
29
- datetime: "datetime",
30
- };
31
-
32
18
  export function SearchField(props: Props) {
33
19
  const { field } = props;
34
20
  field.readOnly = false;
@@ -39,7 +25,7 @@ export function SearchField(props: Props) {
39
25
  const widgetType = field.type;
40
26
 
41
27
  switch (widgetType) {
42
- case types.boolean: {
28
+ case SearchFieldTypes.boolean: {
43
29
  const ooui = new SelectionOoui({
44
30
  name: field._id,
45
31
  string: field.label,
@@ -51,19 +37,19 @@ export function SearchField(props: Props) {
51
37
 
52
38
  return <Selection layout="vertical" ooui={ooui} showLabel />;
53
39
  }
54
- case types.float:
55
- case types.progressbar:
56
- case types.float_time:
57
- case types.integer: {
40
+ case SearchFieldTypes.float:
41
+ case SearchFieldTypes.progressbar:
42
+ case SearchFieldTypes.float_time:
43
+ case SearchFieldTypes.integer: {
58
44
  return <PairFields ooui={field} showLabel />;
59
45
  }
60
- case types.date: {
46
+ case SearchFieldTypes.date: {
61
47
  return <DateRangePicker ooui={field} layout="vertical" showLabel />;
62
48
  }
63
- case types.datetime: {
49
+ case SearchFieldTypes.datetime: {
64
50
  return <DateTimeRangePicker ooui={field} layout="vertical" showLabel />;
65
51
  }
66
- case types.selection: {
52
+ case SearchFieldTypes.selection: {
67
53
  return <MultiSelection layout="vertical" ooui={field} showLabel />;
68
54
  }
69
55
  default: {