@gisce/react-ooui 1.0.18 → 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 (112) 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 +4915 -4469
  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/containers/Container.d.ts.map +1 -1
  50. package/dist/widgets/custom/ButtonGroup.d.ts.map +1 -1
  51. package/dist/widgets/views/Dashboard/Dashboard.d.ts +1 -1
  52. package/dist/widgets/views/Dashboard/Dashboard.d.ts.map +1 -1
  53. package/dist/widgets/views/Dashboard/DashboardTree.d.ts.map +1 -1
  54. package/dist/widgets/views/Form.d.ts.map +1 -1
  55. package/dist/widgets/views/Graph/Graph.d.ts +3 -3
  56. package/dist/widgets/views/Graph/Graph.d.ts.map +1 -1
  57. package/dist/widgets/views/Graph/GraphChart.d.ts +1 -1
  58. package/dist/widgets/views/Graph/GraphChart.d.ts.map +1 -1
  59. package/dist/widgets/views/Graph/useGraphData.d.ts +1 -1
  60. package/dist/widgets/views/Graph/useGraphData.d.ts.map +1 -1
  61. package/dist/widgets/views/SearchTree.d.ts.map +1 -1
  62. package/dist/widgets/views/searchFilter/SearchFilter.d.ts +4 -0
  63. package/dist/widgets/views/searchFilter/SearchFilter.d.ts.map +1 -1
  64. package/package.json +3 -3
  65. package/src/actionbar/ChangeViewButton.tsx +34 -39
  66. package/src/actionbar/FormActionBar.tsx +6 -6
  67. package/src/actionbar/GraphActionBar.tsx +67 -0
  68. package/src/actionbar/TreeActionBar.tsx +10 -11
  69. package/src/context/ActionViewContext.tsx +27 -8
  70. package/src/context/One2manyContext.tsx +5 -5
  71. package/src/context/TabManagerContext.tsx +2 -3
  72. package/src/helpers/{searchFilterHelper.ts → searchHelper.ts} +32 -7
  73. package/src/hooks/useFetchViews.ts +0 -0
  74. package/src/hooks/useSearch.ts +404 -0
  75. package/src/locales/ca_ES.tsx +1 -0
  76. package/src/locales/en_US.tsx +1 -0
  77. package/src/locales/es_ES.tsx +1 -0
  78. package/src/stories/forms/ActivacioContracteForm.stories.tsx +25 -0
  79. package/src/stories/mocks/index.ts +2 -0
  80. package/src/stories/mocks/models/activacioContracte.ts +112 -0
  81. package/src/types/index.ts +37 -3
  82. package/src/ui/FavouriteButton.tsx +2 -2
  83. package/src/ui/TitleHeader.tsx +4 -3
  84. package/src/views/ActionView.tsx +185 -171
  85. package/src/views/RootView.tsx +5 -6
  86. package/src/views/actionViews/DashboardActionView.tsx +47 -0
  87. package/src/views/actionViews/FormActionView.tsx +70 -0
  88. package/src/views/actionViews/GraphActionView.tsx +136 -0
  89. package/src/views/actionViews/TreeActionView.tsx +77 -0
  90. package/src/widgets/base/Button.tsx +1 -1
  91. package/src/widgets/base/Image.tsx +1 -1
  92. package/src/widgets/base/many2one/Many2oneSuffix.tsx +1 -1
  93. package/src/widgets/base/one2many/One2many.tsx +5 -7
  94. package/src/widgets/base/one2many/One2manyInput.tsx +5 -7
  95. package/src/widgets/base/one2many/One2manyTopBar.tsx +5 -5
  96. package/src/widgets/containers/Container.tsx +2 -4
  97. package/src/widgets/containers/Notebook.tsx +1 -1
  98. package/src/widgets/custom/ButtonGroup.tsx +15 -14
  99. package/src/widgets/custom/Indicator.tsx +2 -2
  100. package/src/widgets/views/Dashboard/Dashboard.tsx +4 -5
  101. package/src/widgets/views/Dashboard/DashboardTree.tsx +15 -18
  102. package/src/widgets/views/Form.tsx +0 -1
  103. package/src/widgets/views/Graph/Graph.tsx +40 -6
  104. package/src/widgets/views/Graph/GraphChart.tsx +1 -1
  105. package/src/widgets/views/Graph/useGraphData.tsx +2 -2
  106. package/src/widgets/views/SearchTree.tsx +81 -331
  107. package/src/widgets/views/searchFilter/SearchFilter.tsx +58 -23
  108. package/dist/helpers/searchFilterHelper.d.ts +0 -5
  109. package/dist/helpers/searchFilterHelper.d.ts.map +0 -1
  110. package/dist/widgets/views/Dashboard/Dashboard.types.d.ts +0 -8
  111. package/dist/widgets/views/Dashboard/Dashboard.types.d.ts.map +0 -1
  112. package/src/widgets/views/Dashboard/Dashboard.types.ts +0 -8
@@ -0,0 +1,67 @@
1
+ import React, { useContext } from "react";
2
+ import { Space } from "antd";
3
+ import ChangeViewButton from "./ChangeViewButton";
4
+ import {
5
+ ActionViewContext,
6
+ ActionViewContextType,
7
+ } from "@/context/ActionViewContext";
8
+ import ActionButton from "./ActionButton";
9
+ import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
10
+ import ButtonWithBadge from "./ButtonWithBadge";
11
+ import { ReloadOutlined, FilterOutlined } from "@ant-design/icons";
12
+ import { View } from "@/types";
13
+
14
+ function GraphActionBar({ refreshGraph }: { refreshGraph: () => void }) {
15
+ const { t } = useContext(LocaleContext) as LocaleContextType;
16
+ const {
17
+ availableViews,
18
+ currentView,
19
+ setCurrentView,
20
+ searchParams,
21
+ searchVisible,
22
+ setSearchVisible,
23
+ graphIsLoading,
24
+ previousView,
25
+ setPreviousView,
26
+ } = useContext(ActionViewContext) as ActionViewContextType;
27
+
28
+ return (
29
+ <Space wrap={true}>
30
+ <ButtonWithBadge
31
+ icon={
32
+ <FilterOutlined
33
+ style={{ color: searchVisible ? "white" : undefined }}
34
+ />
35
+ }
36
+ tooltip={t("advanced_search")}
37
+ type={searchVisible ? "primary" : "default"}
38
+ onClick={() => {
39
+ setSearchVisible?.(!searchVisible);
40
+ }}
41
+ disabled={graphIsLoading}
42
+ badgeNumber={searchParams?.length}
43
+ />
44
+ <ActionButton
45
+ icon={<ReloadOutlined />}
46
+ tooltip={t("refresh")}
47
+ disabled={graphIsLoading}
48
+ loading={false}
49
+ onClick={() => {
50
+ refreshGraph();
51
+ }}
52
+ />
53
+ <ChangeViewButton
54
+ currentView={currentView}
55
+ availableViews={availableViews}
56
+ onChangeView={(newView: View) => {
57
+ setPreviousView?.(currentView);
58
+ setCurrentView?.(newView);
59
+ }}
60
+ disabled={false}
61
+ previousView={previousView}
62
+ />
63
+ </Space>
64
+ );
65
+ }
66
+
67
+ export default GraphActionBar;
@@ -28,11 +28,11 @@ import {
28
28
  import ButtonWithBadge from "./ButtonWithBadge";
29
29
  import { showLogInfo } from "@/helpers/logInfoHelper";
30
30
  import SearchBar from "./SearchBar";
31
- import { View } from "@/views/ActionView";
32
31
 
33
32
  type Props = {
34
33
  parentContext?: any;
35
34
  treeExpandable: boolean;
35
+ toolbar: any;
36
36
  };
37
37
 
38
38
  function TreeActionBar(props: Props) {
@@ -49,16 +49,17 @@ function TreeActionBar(props: Props) {
49
49
  searchTreeRef,
50
50
  setCurrentId,
51
51
  setCurrentItemIndex,
52
- toolbar,
53
52
  searchParams,
54
53
  searchVisible,
55
54
  setSearchVisible,
56
55
  setSearchTreeNameSearch,
57
56
  searchTreeNameSearch,
58
57
  treeIsLoading,
58
+ setPreviousView,
59
+ previousView,
59
60
  } = useContext(ActionViewContext) as ActionViewContextType;
60
61
 
61
- const { parentContext = {}, treeExpandable } = props;
62
+ const { parentContext = {}, treeExpandable, toolbar } = props;
62
63
 
63
64
  const { t, lang } = useContext(LocaleContext) as LocaleContextType;
64
65
  const contentRootContext = useContext(
@@ -137,10 +138,6 @@ function TreeActionBar(props: Props) {
137
138
  });
138
139
  }
139
140
 
140
- if (!currentView) {
141
- return null;
142
- }
143
-
144
141
  return (
145
142
  <Space wrap={true}>
146
143
  {treeExpandable ? null : (
@@ -225,10 +222,12 @@ function TreeActionBar(props: Props) {
225
222
  {separator()}
226
223
  <ChangeViewButton
227
224
  currentView={currentView}
228
- availableViews={availableViews.filter(
229
- (view: View) => view.type === "tree" || view.type === "form"
230
- )}
231
- onChangeView={setCurrentView}
225
+ availableViews={availableViews}
226
+ onChangeView={(newView) => {
227
+ setPreviousView?.(currentView);
228
+ setCurrentView?.(newView);
229
+ }}
230
+ previousView={previousView}
232
231
  disabled={treeIsLoading}
233
232
  />
234
233
  </>
@@ -1,4 +1,4 @@
1
- import { View } from "@/views/ActionView";
1
+ import { View } from "@/types";
2
2
  import React, { useEffect, useState } from "react";
3
3
 
4
4
  export type ActionViewContextType = {
@@ -27,8 +27,8 @@ export type ActionViewContextType = {
27
27
  setFormIsLoading?: (value: boolean) => void;
28
28
  treeIsLoading?: boolean;
29
29
  setTreeIsLoading?: (value: boolean) => void;
30
- toolbar?: any;
31
- setToolbar?: (value: any) => void;
30
+ graphIsLoading?: boolean;
31
+ setGraphIsLoading?: (value: boolean) => void;
32
32
  attachments?: any;
33
33
  setAttachments?: (value: any) => void;
34
34
  selectedRowItems?: any[];
@@ -45,7 +45,11 @@ export type ActionViewContextType = {
45
45
  setTotalItems: (totalItems: number) => void;
46
46
  searchTreeNameSearch?: string;
47
47
  setSearchTreeNameSearch?: (searchString?: string) => void;
48
+ previousView?: View;
49
+ setPreviousView?: (view: View) => void;
48
50
  goToResourceId?: (id: number) => Promise<void>;
51
+ searchValues?: any;
52
+ setSearchValues?: (value: any) => void;
49
53
  };
50
54
 
51
55
  export const ActionViewContext =
@@ -59,12 +63,15 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
59
63
  const [formIsSaving, setFormIsSaving] = useState<boolean>(false);
60
64
  const [formHasChanges, setFormHasChanges] = useState<boolean>(false);
61
65
  const [removingItem, setRemovingItem] = useState<boolean>(false);
62
- const [formIsLoading, setFormIsLoading] = useState<boolean>(false);
66
+ const [formIsLoading, setFormIsLoading] = useState<boolean>(true);
63
67
  const [treeIsLoading, setTreeIsLoading] = useState<boolean>(true);
64
68
  const [attachments, setAttachments] = useState<any>([]);
65
69
  const [duplicatingItem, setDuplicatingItem] = useState<boolean>(false);
66
70
  const [searchParams, setSearchParams] = useState<any[]>([]);
67
71
  const [searchVisible, setSearchVisible] = useState<boolean>(false);
72
+ const [graphIsLoading, setGraphIsLoading] = useState<boolean>(true);
73
+ const [previousView, setPreviousView] = useState<View>();
74
+ const [searchValues, setSearchValues] = useState<any>({});
68
75
 
69
76
  const {
70
77
  children,
@@ -82,8 +89,6 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
82
89
  currentItemIndex,
83
90
  setCurrentItemIndex,
84
91
  currentModel,
85
- toolbar,
86
- setToolbar,
87
92
  sorter,
88
93
  setSorter,
89
94
  totalItems,
@@ -102,6 +107,16 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
102
107
  }
103
108
  }, [results]);
104
109
 
110
+ useEffect(() => {
111
+ if (availableViews.length === 1) {
112
+ setPreviousView(availableViews[0]);
113
+ } else if (availableViews.length > 1) {
114
+ setPreviousView(
115
+ availableViews.filter((view) => view.view_id !== currentView.view_id)[0]
116
+ );
117
+ }
118
+ }, [availableViews]);
119
+
105
120
  const callOnFormSave = () => {
106
121
  (formRef.current as any)?.submitForm();
107
122
  };
@@ -134,8 +149,6 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
134
149
  setFormIsLoading,
135
150
  treeIsLoading,
136
151
  setTreeIsLoading,
137
- toolbar,
138
- setToolbar,
139
152
  attachments,
140
153
  setAttachments,
141
154
  selectedRowItems,
@@ -152,7 +165,13 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
152
165
  setTotalItems,
153
166
  searchTreeNameSearch,
154
167
  setSearchTreeNameSearch,
168
+ setGraphIsLoading,
169
+ graphIsLoading,
170
+ previousView,
171
+ setPreviousView,
155
172
  goToResourceId,
173
+ searchValues,
174
+ setSearchValues,
156
175
  }}
157
176
  >
158
177
  {children}
@@ -1,9 +1,9 @@
1
+ import { ViewType } from "@/types";
1
2
  import React, { useState } from "react";
2
- import { ViewModes } from "@/widgets/base/one2many/One2many";
3
3
 
4
4
  export type One2manyContextType = {
5
- currentView: ViewModes;
6
- setCurrentView: (view: ViewModes) => void;
5
+ currentView: ViewType;
6
+ setCurrentView: (view: ViewType) => void;
7
7
  itemIndex: number;
8
8
  setItemIndex: (value: number) => void;
9
9
  manualTriggerChange: boolean;
@@ -19,9 +19,9 @@ const One2manyProvider = ({
19
19
  initialView,
20
20
  }: {
21
21
  children: React.ReactNode;
22
- initialView: ViewModes;
22
+ initialView: ViewType;
23
23
  }): any => {
24
- const [currentView, setCurrentView] = useState<ViewModes>(initialView);
24
+ const [currentView, setCurrentView] = useState<ViewType>(initialView);
25
25
  const [itemIndex, setItemIndex] = useState<number>(0);
26
26
  const [manualTriggerChange, setManualTriggerChange] = useState<boolean>(
27
27
  false
@@ -1,6 +1,5 @@
1
- import { ViewType } from "@/types";
1
+ import { InitialViewData, View, ViewType } from "@/types";
2
2
  import { ShortcutApi } from "@/ui/FavouriteButton";
3
- import { View } from "@/views/ActionView";
4
3
  import React, { useState } from "react";
5
4
 
6
5
  export type TabManagerContextType = {
@@ -24,7 +23,7 @@ export type TabManagerContextType = {
24
23
  views: Array<any>;
25
24
  title: string;
26
25
  target: string;
27
- initialView: View;
26
+ initialView: InitialViewData;
28
27
  action_id: number;
29
28
  action_type: string;
30
29
  res_id?: number | boolean;
@@ -5,7 +5,7 @@ const convertBooleanParamIfNeeded = (value: any) => {
5
5
  return value;
6
6
  };
7
7
 
8
- const getParamsForFields = (values: any, fields: any) => {
8
+ export const getParamsForFields = (values: any, fields: any) => {
9
9
  const filteredValues = removeUndefinedFields(values);
10
10
  const groupedDateTime = groupDateTimeValuesIfNeeded(filteredValues);
11
11
  const groupedValues = ungroupDateValuesIfNeeded(groupedDateTime, fields);
@@ -88,7 +88,7 @@ const removeDateTimeSingleFields = (values: any) => {
88
88
  return newValues;
89
89
  };
90
90
 
91
- const groupDateTimeValuesIfNeeded = (values: any) => {
91
+ export const groupDateTimeValuesIfNeeded = (values: any) => {
92
92
  const newValues: any = { ...removeDateTimeSingleFields(values) };
93
93
 
94
94
  const datetimeDateFields = getDatetimeDateFields(values);
@@ -148,7 +148,7 @@ const ungroupDateValuesIfNeeded = (values: any, fields: any) => {
148
148
  return newValues;
149
149
  };
150
150
 
151
- const removeUndefinedFields = (values: any) => {
151
+ export const removeUndefinedFields = (values: any) => {
152
152
  const newValues = { ...values };
153
153
  Object.keys(newValues).forEach(
154
154
  (key) =>
@@ -160,8 +160,33 @@ const removeUndefinedFields = (values: any) => {
160
160
  return newValues;
161
161
  };
162
162
 
163
- export {
164
- removeUndefinedFields,
165
- groupDateTimeValuesIfNeeded,
166
- getParamsForFields,
163
+ export const getUniqueFieldsForParams = (params: any[]) => {
164
+ const uniqueFields: any = {};
165
+
166
+ params.forEach((param) => {
167
+ if (Array.isArray(param) && param[0]) {
168
+ uniqueFields[param[0]] = true;
169
+ } else {
170
+ uniqueFields[param] = true;
171
+ }
172
+ });
173
+
174
+ return Object.keys(uniqueFields);
175
+ };
176
+
177
+ export const mergeParams = (searchParams: any[], domainParams: any[]) => {
178
+ const finalParams = searchParams;
179
+ const uniqueParams = getUniqueFieldsForParams(searchParams);
180
+
181
+ domainParams.forEach((element) => {
182
+ if (Array.isArray(element) && element[0]) {
183
+ if (!uniqueParams.includes(element[0])) {
184
+ finalParams.push(element);
185
+ }
186
+ } else if (!uniqueParams.includes(element)) {
187
+ finalParams.push(element);
188
+ }
189
+ });
190
+
191
+ return finalParams;
167
192
  };
File without changes