@gisce/react-ooui 1.1.60 → 1.1.61-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":"Markdown.d.ts","sourceRoot":"","sources":["Markdown.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEpC,eAAQ,MAAM,QAAQ,UAAW,WAAW,gBAM3C,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,GAAG,gBAKvC,CAAA"}
1
+ {"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["Markdown.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAC,WAAW,EAAC,MAAM,SAAS,CAAC;AAEpC,eAAQ,MAAM,QAAQ,UAAW,WAAW,gBAM3C,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,GAAG,gBAQvC,CAAA"}
@@ -1 +1 @@
1
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-ooui",
3
- "version": "1.1.60",
3
+ "version": "1.1.61-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.3",
39
+ "@gisce/ooui": "^0.19.4",
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",
@@ -57,9 +57,7 @@ function ChangeViewButton(props: Props) {
57
57
  {getIconForView(view)}
58
58
  </Col>
59
59
  <Col flex="auto" style={{ paddingRight: 20 }}>
60
- {view.type === "graph"
61
- ? (view as GraphView).name
62
- : view.type.charAt(0).toUpperCase() + view.type.slice(1)}
60
+ {view.type.charAt(0).toUpperCase() + view.type.slice(1)}
63
61
  </Col>
64
62
  <Col flex="none">
65
63
  <CheckOutlined
@@ -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) {
@@ -1,4 +1,4 @@
1
- import { FormView, GenerateReportOptions } from "@/types";
1
+ import { FormView, GenerateReportOptions, ViewType } from "@/types";
2
2
  import React, {
3
3
  useContext,
4
4
  useRef,
@@ -261,33 +261,12 @@ const ContentRootProvider = (
261
261
 
262
262
  return {};
263
263
  } else {
264
- let initialView;
265
- const viewTypes = actionData.view_mode.split(",");
266
- const views = [];
267
-
268
- for (const viewType of viewTypes) {
269
- const viewData = await ConnectionProvider.getHandler().getView({
270
- model: actionData.res_model,
271
- type: viewType,
272
- context: mergedContext,
273
- });
274
- views.push([viewData.view_id, viewType]);
275
- }
276
-
277
- if (!actionData.view_id) {
278
- const type = actionData.view_mode.split(",")[0];
279
-
280
- const [retrievedViewId] = views.find(
281
- ([_, viewType]) => viewType === type
282
- )!;
283
-
284
- initialView = { id: retrievedViewId, type };
285
- } else {
286
- initialView = {
287
- id: actionData.view_id,
288
- type: actionData.view_mode.split(",")[0],
289
- };
290
- }
264
+ const { initialView, views } = await getViewsAndInitialView({
265
+ model: actionData.res_model,
266
+ context: mergedContext,
267
+ view_mode: actionData.view_mode,
268
+ views: actionData.views,
269
+ });
291
270
 
292
271
  openAction?.({
293
272
  target: "current",
@@ -415,4 +394,61 @@ const ContentRootProvider = (
415
394
  );
416
395
  };
417
396
 
397
+ async function getViewsAndInitialView({
398
+ views,
399
+ view_mode,
400
+ model,
401
+ context,
402
+ view_id,
403
+ }: {
404
+ views: any[];
405
+ view_mode: string;
406
+ model: string;
407
+ context: any;
408
+ view_id?: number;
409
+ }) {
410
+ const retriedViewData = [];
411
+ let initialView;
412
+
413
+ if (views) {
414
+ for (const view of views) {
415
+ const viewData = await ConnectionProvider.getHandler().getView({
416
+ model,
417
+ type: view[1],
418
+ id: view[0],
419
+ context,
420
+ });
421
+ retriedViewData.push([viewData.view_id, view[1]]);
422
+ }
423
+ } else {
424
+ const viewTypes = view_mode.split(",");
425
+ for (const viewType of viewTypes) {
426
+ const viewData = await ConnectionProvider.getHandler().getView({
427
+ model,
428
+ type: viewType as ViewType,
429
+ context,
430
+ });
431
+ retriedViewData.push([viewData.view_id, viewType]);
432
+ }
433
+ }
434
+ if (views && views.length > 0) {
435
+ const [id, type] = views[0];
436
+ initialView = {
437
+ id,
438
+ type,
439
+ };
440
+ } else if (!view_id) {
441
+ const type = view_mode.split(",")[0];
442
+ const [retrievedViewId] = views.find(([_, viewType]) => viewType === type)!;
443
+ initialView = { id: retrievedViewId, type };
444
+ } else {
445
+ initialView = {
446
+ id: view_id,
447
+ type: view_mode.split(",")[0],
448
+ };
449
+ }
450
+
451
+ return { views: retriedViewData, initialView };
452
+ }
453
+
418
454
  export default forwardRef(ContentRootProvider);
@@ -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
+ };
@@ -77,7 +77,7 @@ export const LabelH1 = (): React.ReactElement => {
77
77
  const ooui = new LabelOoui({
78
78
  name: "field",
79
79
  string: "Lorem ipsum",
80
- widget_props: "{'label_size': 'h1'}",
80
+ widget_props: "{'label_size': 1}",
81
81
  });
82
82
  return (
83
83
  <LocaleProvider lang="en_US">
@@ -90,7 +90,7 @@ export const LabelH2Warning = (): React.ReactElement => {
90
90
  const ooui = new LabelOoui({
91
91
  name: "field",
92
92
  string: "Lorem ipsum",
93
- widget_props: "{'label_size': 'h1', 'label_type': 'warning'}",
93
+ widget_props: "{'label_size': 2, 'label_type': 'warning'}",
94
94
  });
95
95
  return (
96
96
  <LocaleProvider lang="en_US">
@@ -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
+ };
@@ -26,7 +26,7 @@ const Label = (props: Props) => {
26
26
  const responsiveAlign = responsiveBehaviour ? "left" : "right";
27
27
  const labelAlgin = align ? align : fieldForLabel ? responsiveAlign : "left";
28
28
 
29
- const TextType = labelSize === "text" ? Text : Title;
29
+ const TextType = labelSize === undefined ? Text : Title;
30
30
 
31
31
  return (
32
32
  <div
@@ -39,7 +39,7 @@ const Label = (props: Props) => {
39
39
  )}
40
40
  <span className="pr-2">
41
41
  <TextType
42
- level={labelSize !== "text" ? (labelSize as string as any) : null}
42
+ level={labelSize}
43
43
  type={labelType as any}
44
44
  >
45
45
  <Interweave content={labelText} />
@@ -12,8 +12,11 @@ export const Markdown = (props: WidgetProps) => {
12
12
  };
13
13
 
14
14
  export const MarkdownInput = (props: any) => {
15
- const {value} = props;
15
+ const {value, ooui} = props;
16
16
  return (
17
- <ReactMarkdown children={value}/>
17
+ <div style={{height: ooui.height ? ooui.height + 'px' : '100%'}}>
18
+ <ReactMarkdown children={value} className="ant-typography"/>
19
+ </div>
20
+
18
21
  )
19
- }
22
+ }
@@ -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>