@gisce/react-ooui 1.0.19 → 1.1.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.
Files changed (105) hide show
  1. package/dist/actionbar/ChangeViewButton.d.ts +3 -2
  2. package/dist/actionbar/ChangeViewButton.d.ts.map +1 -1
  3. package/dist/actionbar/FormActionBar.d.ts +3 -1
  4. package/dist/actionbar/FormActionBar.d.ts.map +1 -1
  5. package/dist/actionbar/GraphActionBar.d.ts +6 -0
  6. package/dist/actionbar/GraphActionBar.d.ts.map +1 -0
  7. package/dist/actionbar/TreeActionBar.d.ts +2 -1
  8. package/dist/actionbar/TreeActionBar.d.ts.map +1 -1
  9. package/dist/context/ActionViewContext.d.ts +7 -3
  10. package/dist/context/ActionViewContext.d.ts.map +1 -1
  11. package/dist/context/One2manyContext.d.ts +4 -4
  12. package/dist/context/One2manyContext.d.ts.map +1 -1
  13. package/dist/context/TabManagerContext.d.ts +2 -3
  14. package/dist/context/TabManagerContext.d.ts.map +1 -1
  15. package/dist/helpers/searchHelper.d.ts +6 -0
  16. package/dist/helpers/searchHelper.d.ts.map +1 -0
  17. package/dist/hooks/useSearch.d.ts +52 -0
  18. package/dist/hooks/useSearch.d.ts.map +1 -0
  19. package/dist/locales/ca_ES.d.ts +1 -0
  20. package/dist/locales/ca_ES.d.ts.map +1 -1
  21. package/dist/locales/en_US.d.ts +1 -0
  22. package/dist/locales/en_US.d.ts.map +1 -1
  23. package/dist/locales/es_ES.d.ts +1 -0
  24. package/dist/locales/es_ES.d.ts.map +1 -1
  25. package/dist/react-ooui.es.js +4867 -4416
  26. package/dist/react-ooui.es.js.map +1 -1
  27. package/dist/react-ooui.umd.js +14 -14
  28. package/dist/react-ooui.umd.js.map +1 -1
  29. package/dist/types/index.d.ts +29 -3
  30. package/dist/types/index.d.ts.map +1 -1
  31. package/dist/ui/TitleHeader.d.ts +1 -0
  32. package/dist/ui/TitleHeader.d.ts.map +1 -1
  33. package/dist/views/ActionView.d.ts +3 -7
  34. package/dist/views/ActionView.d.ts.map +1 -1
  35. package/dist/views/RootView.d.ts.map +1 -1
  36. package/dist/views/actionViews/DashboardActionView.d.ts +7 -0
  37. package/dist/views/actionViews/DashboardActionView.d.ts.map +1 -0
  38. package/dist/views/actionViews/FormActionView.d.ts +18 -0
  39. package/dist/views/actionViews/FormActionView.d.ts.map +1 -0
  40. package/dist/views/actionViews/GraphActionView.d.ts +13 -0
  41. package/dist/views/actionViews/GraphActionView.d.ts.map +1 -0
  42. package/dist/views/actionViews/TreeActionView.d.ts +19 -0
  43. package/dist/views/actionViews/TreeActionView.d.ts.map +1 -0
  44. package/dist/widgets/base/one2many/One2many.d.ts +0 -1
  45. package/dist/widgets/base/one2many/One2many.d.ts.map +1 -1
  46. package/dist/widgets/base/one2many/One2manyInput.d.ts.map +1 -1
  47. package/dist/widgets/base/one2many/One2manyTopBar.d.ts +2 -2
  48. package/dist/widgets/base/one2many/One2manyTopBar.d.ts.map +1 -1
  49. package/dist/widgets/custom/ButtonGroup.d.ts.map +1 -1
  50. package/dist/widgets/views/Dashboard/Dashboard.d.ts +1 -1
  51. package/dist/widgets/views/Dashboard/Dashboard.d.ts.map +1 -1
  52. package/dist/widgets/views/Dashboard/DashboardTree.d.ts.map +1 -1
  53. package/dist/widgets/views/Graph/Graph.d.ts +3 -3
  54. package/dist/widgets/views/Graph/Graph.d.ts.map +1 -1
  55. package/dist/widgets/views/Graph/GraphChart.d.ts +1 -1
  56. package/dist/widgets/views/Graph/GraphChart.d.ts.map +1 -1
  57. package/dist/widgets/views/Graph/useGraphData.d.ts +1 -1
  58. package/dist/widgets/views/Graph/useGraphData.d.ts.map +1 -1
  59. package/dist/widgets/views/SearchTree.d.ts.map +1 -1
  60. package/dist/widgets/views/searchFilter/SearchFilter.d.ts +4 -0
  61. package/dist/widgets/views/searchFilter/SearchFilter.d.ts.map +1 -1
  62. package/package.json +2 -2
  63. package/src/actionbar/ChangeViewButton.tsx +34 -39
  64. package/src/actionbar/FormActionBar.tsx +6 -6
  65. package/src/actionbar/GraphActionBar.tsx +67 -0
  66. package/src/actionbar/TreeActionBar.tsx +10 -11
  67. package/src/context/ActionViewContext.tsx +27 -8
  68. package/src/context/One2manyContext.tsx +5 -5
  69. package/src/context/TabManagerContext.tsx +2 -3
  70. package/src/helpers/{searchFilterHelper.ts → searchHelper.ts} +32 -7
  71. package/src/hooks/useFetchViews.ts +0 -0
  72. package/src/hooks/useSearch.ts +404 -0
  73. package/src/locales/ca_ES.tsx +1 -0
  74. package/src/locales/en_US.tsx +1 -0
  75. package/src/locales/es_ES.tsx +1 -0
  76. package/src/types/index.ts +37 -3
  77. package/src/ui/FavouriteButton.tsx +2 -2
  78. package/src/ui/TitleHeader.tsx +4 -3
  79. package/src/views/ActionView.tsx +185 -171
  80. package/src/views/RootView.tsx +5 -6
  81. package/src/views/actionViews/DashboardActionView.tsx +47 -0
  82. package/src/views/actionViews/FormActionView.tsx +70 -0
  83. package/src/views/actionViews/GraphActionView.tsx +136 -0
  84. package/src/views/actionViews/TreeActionView.tsx +77 -0
  85. package/src/widgets/base/Button.tsx +1 -1
  86. package/src/widgets/base/Image.tsx +1 -1
  87. package/src/widgets/base/many2one/Many2oneSuffix.tsx +1 -1
  88. package/src/widgets/base/one2many/One2many.tsx +5 -7
  89. package/src/widgets/base/one2many/One2manyInput.tsx +5 -7
  90. package/src/widgets/base/one2many/One2manyTopBar.tsx +5 -5
  91. package/src/widgets/containers/Notebook.tsx +1 -1
  92. package/src/widgets/custom/ButtonGroup.tsx +15 -14
  93. package/src/widgets/custom/Indicator.tsx +2 -2
  94. package/src/widgets/views/Dashboard/Dashboard.tsx +4 -5
  95. package/src/widgets/views/Dashboard/DashboardTree.tsx +15 -18
  96. package/src/widgets/views/Graph/Graph.tsx +40 -6
  97. package/src/widgets/views/Graph/GraphChart.tsx +1 -1
  98. package/src/widgets/views/Graph/useGraphData.tsx +2 -2
  99. package/src/widgets/views/SearchTree.tsx +81 -331
  100. package/src/widgets/views/searchFilter/SearchFilter.tsx +58 -23
  101. package/dist/helpers/searchFilterHelper.d.ts +0 -5
  102. package/dist/helpers/searchFilterHelper.d.ts.map +0 -1
  103. package/dist/widgets/views/Dashboard/Dashboard.types.d.ts +0 -8
  104. package/dist/widgets/views/Dashboard/Dashboard.types.d.ts.map +0 -1
  105. package/src/widgets/views/Dashboard/Dashboard.types.ts +0 -8
@@ -0,0 +1,136 @@
1
+ import GraphActionBar from "@/actionbar/GraphActionBar";
2
+ import TitleHeader from "@/ui/TitleHeader";
3
+ import { Graph } from "@/widgets/views/Graph/Graph";
4
+ import React, { useContext, useRef } from "react";
5
+ import {
6
+ ActionViewContext,
7
+ ActionViewContextType,
8
+ } from "@/context/ActionViewContext";
9
+ import { FormView, TreeView } from "@/types";
10
+ import { mergeSearchFields } from "@/helpers/formHelper";
11
+ import { useSearch } from "@/hooks/useSearch";
12
+ import SearchFilter from "@/widgets/views/searchFilter/SearchFilter";
13
+ import { Spin } from "antd";
14
+ import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
15
+
16
+ export type GraphActionViewProps = {
17
+ viewData: any;
18
+ visible: boolean;
19
+ model: string;
20
+ context: any;
21
+ domain: any;
22
+ formView: FormView;
23
+ treeView: TreeView;
24
+ };
25
+
26
+ export const GraphActionView = (props: GraphActionViewProps) => {
27
+ const { viewData, visible, model, context, domain, formView, treeView } =
28
+ props;
29
+ const graphRef = useRef();
30
+
31
+ const actionViewContext = useContext(
32
+ ActionViewContext
33
+ ) as ActionViewContextType;
34
+ const {
35
+ setResults: setResultsActionView = undefined,
36
+ setCurrentItemIndex = undefined,
37
+ currentId = undefined,
38
+ results: resultsActionView = undefined,
39
+ setSelectedRowItems = undefined,
40
+ setSearchParams = undefined,
41
+ searchVisible = true,
42
+ setSearchVisible = undefined,
43
+ sorter = undefined,
44
+ setSorter = undefined,
45
+ setTotalItems: setActionViewTotalItems = undefined,
46
+ setSearchTreeNameSearch = undefined,
47
+ setTreeIsLoading = undefined,
48
+ results = undefined,
49
+ } = actionViewContext || {};
50
+
51
+ const { searchParams, searchValues, setSearchValues } = useContext(
52
+ ActionViewContext
53
+ ) as ActionViewContextType;
54
+ const { t } = useContext(LocaleContext) as LocaleContextType;
55
+
56
+ const {
57
+ submit,
58
+ clear,
59
+ searchFilterLoading,
60
+ searchError,
61
+ offset,
62
+ limit,
63
+ tableRefreshing,
64
+ } = useSearch({
65
+ model,
66
+ setSearchTreeNameSearch,
67
+ setSelectedRowItems,
68
+ searchParams,
69
+ setSearchValues,
70
+ setSearchParams,
71
+ setSearchVisible,
72
+ setTreeIsLoading,
73
+ context,
74
+ formView: formView!,
75
+ treeView: treeView!,
76
+ sorter,
77
+ setSorter,
78
+ setCurrentItemIndex,
79
+ setResultsActionView,
80
+ resultsActionView,
81
+ domain,
82
+ currentId,
83
+ setActionViewTotalItems,
84
+ });
85
+
86
+ if (!visible) {
87
+ return null;
88
+ }
89
+
90
+ if (!viewData) {
91
+ return null;
92
+ }
93
+
94
+ return (
95
+ <>
96
+ <TitleHeader title={viewData.name}>
97
+ <GraphActionBar
98
+ refreshGraph={() => {
99
+ (graphRef.current as any).refresh();
100
+ }}
101
+ />
102
+ </TitleHeader>
103
+ <SearchFilter
104
+ fields={{ ...treeView.fields, ...formView.fields }}
105
+ searchFields={mergeSearchFields([
106
+ formView.search_fields,
107
+ treeView.search_fields,
108
+ ])}
109
+ limit={limit!}
110
+ onClear={clear}
111
+ offset={offset}
112
+ isSearching={searchFilterLoading}
113
+ onSubmit={submit}
114
+ searchError={searchError}
115
+ searchVisible={searchVisible}
116
+ searchValues={searchValues}
117
+ />
118
+ {tableRefreshing ? (
119
+ <Spin />
120
+ ) : (
121
+ <>
122
+ <p style={{ textAlign: "right" }}>
123
+ {`${t("totalRegisters")} ${results?.length}`}
124
+ </p>
125
+ <Graph
126
+ ref={graphRef}
127
+ view_id={viewData.view_id}
128
+ model={model}
129
+ context={context}
130
+ domain={searchParams || domain}
131
+ />
132
+ </>
133
+ )}
134
+ </>
135
+ );
136
+ };
@@ -0,0 +1,77 @@
1
+ import TreeActionBar from "@/actionbar/TreeActionBar";
2
+ import { FormView, TreeView, View } from "@/types";
3
+ import TitleHeader from "@/ui/TitleHeader";
4
+ import SearchTree from "@/widgets/views/SearchTree";
5
+ import React from "react";
6
+
7
+ export type TreeActionViewProps = {
8
+ formView?: FormView;
9
+ treeView?: TreeView;
10
+ visible: boolean;
11
+ searchTreeRef: any;
12
+ model: string;
13
+ domain: any;
14
+ context: any;
15
+ results: any[];
16
+ setCurrentItemIndex: (value?: number) => void;
17
+ setCurrentId: (id?: number) => void;
18
+ setCurrentView: (view: View) => void;
19
+ availableViews: View[];
20
+ searchTreeNameSearch?: string;
21
+ };
22
+
23
+ export const TreeActionView = (props: TreeActionViewProps) => {
24
+ const {
25
+ visible,
26
+ searchTreeRef,
27
+ model,
28
+ context,
29
+ formView,
30
+ treeView,
31
+ domain,
32
+ setCurrentItemIndex,
33
+ results,
34
+ setCurrentId,
35
+ setCurrentView,
36
+ availableViews,
37
+ searchTreeNameSearch,
38
+ } = props;
39
+
40
+ if (!visible) {
41
+ return null;
42
+ }
43
+
44
+ return (
45
+ <>
46
+ <TitleHeader>
47
+ <TreeActionBar
48
+ toolbar={formView?.toolbar}
49
+ parentContext={context}
50
+ treeExpandable={treeView?.isExpandable || false}
51
+ />
52
+ </TitleHeader>
53
+ <SearchTree
54
+ ref={searchTreeRef}
55
+ rootTree={true}
56
+ model={model}
57
+ parentContext={context}
58
+ nameSearch={searchTreeNameSearch}
59
+ formView={formView}
60
+ treeView={treeView}
61
+ domain={domain}
62
+ onRowClicked={(event: any) => {
63
+ const { id } = event;
64
+ setCurrentId(id);
65
+ const itemIndex = results.findIndex((item: any) => {
66
+ return item.id === id;
67
+ });
68
+ setCurrentItemIndex(itemIndex);
69
+ const formView = availableViews.find(
70
+ (v) => v.type === "form"
71
+ ) as FormView;
72
+ setCurrentView(formView);
73
+ }}
74
+ />
75
+ </>
76
+ );
77
+ };
@@ -53,7 +53,7 @@ export const Button = (props: Props) => {
53
53
  function getButtonIcon() {
54
54
  if (isRunning) return <LoadingOutlined />;
55
55
  if (icon) {
56
- const Icon: React.ElementType = iconMapper(icon);
56
+ const Icon: React.ElementType = iconMapper(icon) as any;
57
57
  return Icon && <Icon />;
58
58
  }
59
59
  return undefined;
@@ -21,7 +21,7 @@ export const Image = (props: Props) => {
21
21
  const { ooui } = props;
22
22
  const { required, id } = ooui;
23
23
 
24
- const Icon: React.ElementType = iconMapper(id);
24
+ const Icon: React.ElementType = iconMapper(id) as any;
25
25
 
26
26
  if (Icon) {
27
27
  return <Icon />;
@@ -58,7 +58,7 @@ export const Many2oneSuffix = (props: Props) => {
58
58
  model,
59
59
  type: "form",
60
60
  context,
61
- });
61
+ }) as FormView;
62
62
  setFormView(formView);
63
63
  const { fields, arch } = formView;
64
64
 
@@ -2,7 +2,7 @@ import React, { useContext, useState } from "react";
2
2
  import { One2many as One2manyOoui } from "@gisce/ooui";
3
3
  import Field from "@/common/Field";
4
4
  import { Spin, Alert } from "antd";
5
- import { Views } from "@/types";
5
+ import { Views, ViewType } from "@/types";
6
6
  import ConnectionProvider from "@/ConnectionProvider";
7
7
  import One2manyProvider from "@/context/One2manyContext";
8
8
  import { One2manyInput } from "@/widgets/base/one2many/One2manyInput";
@@ -13,13 +13,11 @@ type Props = {
13
13
  ooui: One2manyOoui;
14
14
  };
15
15
 
16
- export type ViewModes = "tree" | "form" | "graph";
17
-
18
16
  export const One2many = (props: Props) => {
19
17
  const { ooui } = props;
20
18
  const { mode, relation, views: oouiViews, required, context } = ooui;
21
19
 
22
- let initialView: ViewModes;
20
+ let initialView: ViewType;
23
21
  const [isLoading, setIsLoading] = useState<boolean>(true);
24
22
  const [error, setError] = useState<string>();
25
23
  const [views, setViews] = useState<Views>(new Map<string, any>());
@@ -30,7 +28,7 @@ export const One2many = (props: Props) => {
30
28
  fetchData();
31
29
  }, [ooui]);
32
30
 
33
- const getViewData = async (type: ViewModes) => {
31
+ const getViewData = async (type: ViewType) => {
34
32
  if (oouiViews && oouiViews[type]) {
35
33
  return oouiViews[type];
36
34
  }
@@ -47,7 +45,7 @@ export const One2many = (props: Props) => {
47
45
 
48
46
  try {
49
47
  if (mode && mode.length > 0) {
50
- for (const m of mode as ViewModes[]) {
48
+ for (const m of mode as ViewType[]) {
51
49
  const v = await getViewData(m);
52
50
  views.set(m, v)
53
51
  }
@@ -67,7 +65,7 @@ export const One2many = (props: Props) => {
67
65
  };
68
66
 
69
67
  if (mode && mode.length > 0) {
70
- initialView = mode[0] as ViewModes;
68
+ initialView = mode[0] as ViewType;
71
69
  } else {
72
70
  initialView = "tree";
73
71
  }
@@ -10,7 +10,7 @@ import {
10
10
  parseGraph,
11
11
  transformDomainForChildWidget,
12
12
  } from "@gisce/ooui";
13
- import { Views } from "@/types";
13
+ import { Views, ViewType } from "@/types";
14
14
  import ConnectionProvider from "@/ConnectionProvider";
15
15
  import { FormModal } from "@/widgets/modals/FormModal";
16
16
  import showUnsavedChangesDialog from "@/ui/UnsavedChangesDialog";
@@ -25,7 +25,6 @@ import { One2manyTopBar } from "@/widgets/base/one2many/One2manyTopBar";
25
25
  import { readObjectValues, getNextPendingId } from "@/helpers/one2manyHelper";
26
26
  import { SearchModal } from "@/widgets/modals/SearchModal";
27
27
  import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
28
- import { ViewModes } from "@/widgets/base/one2many/One2many";
29
28
  import { sortResults, sortResultsWithOrder } from "@/helpers/treeHelper";
30
29
 
31
30
  type One2manyValue = {
@@ -90,9 +89,8 @@ const One2manyInput: React.FC<One2manyInputProps> = (
90
89
  const [showSearchModal, setShowSearchModal] = useState<boolean>(false);
91
90
  const [modalItem, setModalItem] = useState<One2manyItem>();
92
91
  const [selectedRowKeys, setSelectedRowKeys] = useState<any[]>([]);
93
- const [continuousEntryMode, setContinuousEntryMode] = useState<boolean>(
94
- false
95
- );
92
+ const [continuousEntryMode, setContinuousEntryMode] =
93
+ useState<boolean>(false);
96
94
  const transformedDomain = useRef<any[]>([]);
97
95
  const [sorter, setSorter] = useState<any>();
98
96
  const originalSortItemIds = useRef<number[]>();
@@ -185,7 +183,7 @@ const One2manyInput: React.FC<One2manyInputProps> = (
185
183
  const keys = Array.from(views.keys());
186
184
  const nextView = keys[
187
185
  (keys.indexOf(currentView) + 1) % keys.length
188
- ] as ViewModes;
186
+ ] as ViewType;
189
187
  if (currentView === "form") {
190
188
  showFormChangesDialogIfNeeded(() => {
191
189
  setCurrentView(nextView);
@@ -486,7 +484,7 @@ const One2manyInput: React.FC<One2manyInputProps> = (
486
484
 
487
485
  // TODO: improve this. Do we really have to parse the entire object just to get the title?
488
486
  function getTitle() {
489
- const ViewType: any = ViewObjects[currentView];
487
+ const ViewType: any = (ViewObjects as any)[currentView];
490
488
  if (currentView === "graph") {
491
489
  const parsedGraph = parseGraph(views.get("graph").arch);
492
490
  return parsedGraph.string!;
@@ -1,6 +1,5 @@
1
1
  import React from "react";
2
2
  import ButtonWithTooltip from "@/common/ButtonWithTooltip";
3
- import { ViewModes } from "@/widgets/base/one2many/One2many";
4
3
 
5
4
  import {
6
5
  FileAddOutlined,
@@ -11,10 +10,11 @@ import {
11
10
  SearchOutlined,
12
11
  ApiOutlined,
13
12
  } from "@ant-design/icons";
13
+ import { ViewType } from "@/types";
14
14
 
15
15
  type One2manyTopBarProps = {
16
16
  title: string;
17
- mode: ViewModes;
17
+ mode: ViewType;
18
18
  isMany2Many: boolean;
19
19
  readOnly: boolean;
20
20
  formHasChanges: boolean;
@@ -56,8 +56,8 @@ export const One2manyTopBar = (props: One2manyTopBarProps) => {
56
56
 
57
57
  function title() {
58
58
  return (
59
- <div className="h-8 flex flex-grow bg-gray-700 text-gray-200">
60
- <div className="h-full flex flex-col justify-center items-center">
59
+ <div className="flex flex-grow h-8 text-gray-200 bg-gray-700">
60
+ <div className="flex flex-col items-center justify-center h-full">
61
61
  <span className="pl-2 font-bold">{titleString}</span>
62
62
  </div>
63
63
  </div>
@@ -115,7 +115,7 @@ export const One2manyTopBar = (props: One2manyTopBarProps) => {
115
115
  return (
116
116
  <div className="flex mb-2">
117
117
  {title()}
118
- <div className="h-8 flex-none pl-2">
118
+ <div className="flex-none h-8 pl-2">
119
119
  {mode !== "graph" && showCreateButton && (
120
120
  <ButtonWithTooltip
121
121
  tooltip={"Create new item"}
@@ -17,7 +17,7 @@ function Notebook(props: Props): React.ReactElement {
17
17
 
18
18
  function getPageIcon(icon: string) {
19
19
  if (icon) {
20
- const Icon: React.ElementType = iconMapper(icon);
20
+ const Icon: React.ElementType = iconMapper(icon) as any;
21
21
  return Icon && <Icon />;
22
22
  }
23
23
  return undefined;
@@ -1,8 +1,12 @@
1
1
  import React, { useContext, useState } from "react";
2
2
  import Field from "@/common/Field";
3
- import { DownOutlined } from '@ant-design/icons';
3
+ import { DownOutlined } from "@ant-design/icons";
4
4
  import { Dropdown, Menu } from "antd";
5
- import { ButtonGroup as ButtonGroupOoui, Button as ButtonOoui, Field as FieldOoui } from "@gisce/ooui";
5
+ import {
6
+ ButtonGroup as ButtonGroupOoui,
7
+ Button as ButtonOoui,
8
+ Field as FieldOoui,
9
+ } from "@gisce/ooui";
6
10
  import showConfirmDialog from "@/ui/ConfirmDialog";
7
11
  import { FormContext, FormContextType } from "@/context/FormContext";
8
12
  import { LoadingOutlined } from "@ant-design/icons";
@@ -41,7 +45,7 @@ export const ButtonGroup = (props: ButtonGroupProps) => {
41
45
  function getButtonIcon() {
42
46
  if (isRunning) return <LoadingOutlined />;
43
47
  if (icon) {
44
- const Icon: React.ElementType = iconMapper(icon);
48
+ const Icon: React.ElementType = iconMapper(icon) as any;
45
49
  return Icon && <Icon />;
46
50
  }
47
51
  return undefined;
@@ -71,21 +75,22 @@ export const ButtonGroup = (props: ButtonGroupProps) => {
71
75
  }
72
76
 
73
77
  return (
74
- <Field ooui={new FieldOoui({...{ooui}})}>
78
+ <Field ooui={new FieldOoui({ ...{ ooui } })}>
75
79
  <Dropdown.Button
76
80
  disabled={!activated || readOnly}
77
81
  onClick={onClick}
78
- icon={<DownOutlined/>}
82
+ icon={<DownOutlined />}
79
83
  type={primary ? "primary" : undefined}
80
84
  //danger={danger ? true : undefined} This works but typescript
81
85
  // doesn't accept
82
86
  overlay={<Items ooui={secondaryButtons} />}
83
87
  >
84
- {getButtonIcon()}{caption}
88
+ {getButtonIcon()}
89
+ {caption}
85
90
  </Dropdown.Button>
86
91
  </Field>
87
- )
88
- }
92
+ );
93
+ };
89
94
 
90
95
  const Items = (props: ItemsProps) => {
91
96
  const { ooui } = props;
@@ -130,7 +135,7 @@ const Items = (props: ItemsProps) => {
130
135
  function getButtonIcon() {
131
136
  if (isRunning) return <LoadingOutlined />;
132
137
  if (icon) {
133
- const Icon: React.ElementType = iconMapper(icon);
138
+ const Icon: React.ElementType = iconMapper(icon) as any;
134
139
  return Icon && <Icon />;
135
140
  }
136
141
  return undefined;
@@ -147,9 +152,5 @@ const Items = (props: ItemsProps) => {
147
152
  </Menu.Item>
148
153
  );
149
154
  });
150
- return (
151
- <Menu>
152
- {items}
153
- </Menu>
154
- )
155
+ return <Menu>{items}</Menu>;
155
156
  };
@@ -34,12 +34,12 @@ const IndicatorInput = (props: IndicatorInputProps) => {
34
34
  <span>{ooui.label} </span>
35
35
  {ooui.tooltip &&
36
36
  <Tooltip title={ooui.tooltip}>
37
- <QuestionCircleOutlined className="text-xs text-blue-400 pr-1"/>
37
+ <QuestionCircleOutlined className="pr-1 text-xs text-blue-400"/>
38
38
  </Tooltip>
39
39
  }
40
40
  </>
41
41
  );
42
- const Icon: React.ElementType = iconMapper(ooui.icon);
42
+ const Icon: React.ElementType = iconMapper(ooui.icon) as any;
43
43
  let formattedValue = value;
44
44
  if (ooui.selectionValues.size) {
45
45
  formattedValue = ooui.selectionValues.get(value);
@@ -7,14 +7,13 @@ import React, {
7
7
  useState,
8
8
  } from "react";
9
9
  import ActionView from "@/views/ActionView";
10
- import { DashboardProps } from "./Dashboard.types";
11
10
  import { fetchAction } from "./dashboardHelper";
12
11
  import "react-resizable/css/styles.css";
13
12
  import "react-grid-layout/css/styles.css";
14
13
  import { Graph } from "../Graph/Graph";
15
14
  import { DashboardGrid, DashboardGridItem } from "../DashboardGrid";
16
15
  import ConnectionProvider from "@/ConnectionProvider";
17
- import { FormView } from "@/types";
16
+ import { DashboardProps, FormView } from "@/types";
18
17
  import { One2manyItem } from "@/index";
19
18
  import { readObjectValues } from "@/helpers/one2manyHelper";
20
19
  import { LoadingOutlined } from "@ant-design/icons";
@@ -60,7 +59,7 @@ function Dashboard(props: DashboardProps, ref: any) {
60
59
  setError(undefined);
61
60
 
62
61
  try {
63
- const view = await fetchView();
62
+ const view: FormView = (await fetchView()) as FormView;
64
63
  const values = await fetchValues(view);
65
64
  const model = view.fields[itemsField].relation;
66
65
  const items: One2manyItem[] = values[itemsField].items;
@@ -99,11 +98,11 @@ function Dashboard(props: DashboardProps, ref: any) {
99
98
  context: any;
100
99
  }) {
101
100
  itemsFields.current = (
102
- await ConnectionProvider.getHandler().getView({
101
+ (await ConnectionProvider.getHandler().getView({
103
102
  model,
104
103
  type: "form",
105
104
  context,
106
- })
105
+ })) as FormView
107
106
  ).fields;
108
107
 
109
108
  return await readObjectValues({
@@ -101,20 +101,18 @@ function DashboardTree(props: Props) {
101
101
  const searchParams = mergeParams(paramsRef.current, domainParams);
102
102
  const { colors } = getTree(treeView!);
103
103
 
104
- const {
105
- totalItems,
106
- results,
107
- attrsEvaluated,
108
- } = await ConnectionProvider.getHandler().searchForTree({
109
- params: searchParams,
110
- limit: limitRef.current,
111
- offset,
112
- model: currentModel!,
113
- fields: treeView!.fields,
114
- context: parentContext,
115
- attrs: colors && { colors },
116
- });
117
- setTotalItems(totalItems);
104
+ const { totalItems, results, attrsEvaluated } =
105
+ await ConnectionProvider.getHandler().searchForTree({
106
+ params: searchParams,
107
+ limit: limitRef.current,
108
+ offset,
109
+ model: currentModel!,
110
+ fields: treeView!.fields,
111
+ context: parentContext,
112
+ attrs: colors && { colors },
113
+ });
114
+ const totalItemsResult = await totalItems;
115
+ setTotalItems(totalItemsResult);
118
116
  setColorsForResults(getColorMap(attrsEvaluated));
119
117
 
120
118
  const resultsSorted = sortResults({
@@ -167,12 +165,11 @@ function DashboardTree(props: Props) {
167
165
  };
168
166
 
169
167
  const fetchActionData = async () => {
170
- const dataForAction = await ConnectionProvider.getHandler().getViewsForAction(
171
- {
168
+ const dataForAction =
169
+ await ConnectionProvider.getHandler().getViewsForAction({
172
170
  action: action!,
173
171
  context: parentContext,
174
- }
175
- );
172
+ });
176
173
  actionDomain.current = dataForAction.domain;
177
174
  setFormView(dataForAction.views.get("form"));
178
175
  setTreeView(dataForAction.views.get("tree"));
@@ -1,4 +1,10 @@
1
- import React, { useState, useEffect } from "react";
1
+ import React, {
2
+ useState,
3
+ useEffect,
4
+ useContext,
5
+ forwardRef,
6
+ useImperativeHandle,
7
+ } from "react";
2
8
  import {
3
9
  Graph as GraphOoui,
4
10
  parseGraph,
@@ -9,20 +15,35 @@ import { LoadingOutlined } from "@ant-design/icons";
9
15
  import ConnectionProvider from "@/ConnectionProvider";
10
16
  import { GraphIndicator } from "./GraphIndicator";
11
17
  import { GraphChart } from "./GraphChart";
18
+ import { GraphView } from "@/types";
19
+ import {
20
+ ActionViewContext,
21
+ ActionViewContextType,
22
+ } from "@/context/ActionViewContext";
12
23
 
13
24
  export type GraphProps = {
14
25
  view_id: number;
15
26
  model: string;
16
27
  domain: any;
17
28
  context: any;
18
- limit: number;
29
+ limit?: number;
19
30
  };
20
31
 
21
- export const Graph = (props: GraphProps) => {
32
+ const GraphComp = (props: GraphProps, ref: any) => {
22
33
  const { view_id, model, context, domain, limit } = props;
23
34
  const [loading, setLoading] = useState(false);
24
35
  const [graphOoui, setGraphOoui] = useState<GraphOoui>();
25
36
  const [graphXml, setGraphXml] = useState<string>();
37
+ const actionViewContext = useContext(
38
+ ActionViewContext
39
+ ) as ActionViewContextType;
40
+ const { setGraphIsLoading = undefined } = actionViewContext || {};
41
+
42
+ useImperativeHandle(ref, () => ({
43
+ refresh: () => {
44
+ fetchData();
45
+ },
46
+ }));
26
47
 
27
48
  useEffect(() => {
28
49
  fetchData();
@@ -30,14 +51,15 @@ export const Graph = (props: GraphProps) => {
30
51
 
31
52
  async function fetchData() {
32
53
  setLoading(true);
54
+ setGraphIsLoading?.(true);
33
55
 
34
56
  try {
35
- const viewData = await ConnectionProvider.getHandler().getView({
57
+ const viewData = (await ConnectionProvider.getHandler().getView({
36
58
  model,
37
59
  id: view_id,
38
60
  type: "graph",
39
61
  context,
40
- });
62
+ })) as GraphView;
41
63
 
42
64
  setGraphXml(viewData.arch);
43
65
  const graph = parseGraph(viewData.arch);
@@ -48,11 +70,21 @@ export const Graph = (props: GraphProps) => {
48
70
  }
49
71
 
50
72
  setLoading(false);
73
+ setGraphIsLoading?.(false);
51
74
  }
52
75
 
53
76
  if (loading) {
54
77
  return (
55
- <div style={{ padding: "1rem" }}>
78
+ <div
79
+ style={{
80
+ width: "100%",
81
+ display: "flex",
82
+ height: "20%",
83
+ justifyContent: "center",
84
+ alignContent: "center",
85
+ padding: "1rem",
86
+ }}
87
+ >
56
88
  <LoadingOutlined style={{ height: "12px" }} />
57
89
  </div>
58
90
  );
@@ -106,3 +138,5 @@ export const Graph = (props: GraphProps) => {
106
138
  }
107
139
  }
108
140
  };
141
+
142
+ export const Graph = forwardRef(GraphComp);
@@ -16,7 +16,7 @@ export type GraphChartProps = {
16
16
  domain: any;
17
17
  context: any;
18
18
  xml: string;
19
- limit: number;
19
+ limit?: number;
20
20
  };
21
21
 
22
22
  export const GraphChart = (props: GraphChartProps) => {