@gisce/react-ooui 2.0.0-alpha.62 → 2.0.0-alpha.63

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 (245) hide show
  1. package/dist/react-ooui.es.js +1 -1
  2. package/dist/react-ooui.es.js.map +1 -1
  3. package/package.json +6 -8
  4. package/src/ConnectionProvider.ts +0 -16
  5. package/src/__tests__/iconMapper.test.ts +0 -30
  6. package/src/__tests__/searchFilterHelper.spec.ts +0 -386
  7. package/src/actionbar/ActionButton.tsx +0 -40
  8. package/src/actionbar/AttachmentsButton.tsx +0 -132
  9. package/src/actionbar/AttachmentsButtonWrapper.tsx +0 -157
  10. package/src/actionbar/ButtonWithBadge.tsx +0 -44
  11. package/src/actionbar/ChangeViewButton.tsx +0 -137
  12. package/src/actionbar/DashboardActionBar.tsx +0 -63
  13. package/src/actionbar/DropdownButton.tsx +0 -124
  14. package/src/actionbar/FormActionBar.tsx +0 -491
  15. package/src/actionbar/GraphActionBar.tsx +0 -67
  16. package/src/actionbar/NewButton.tsx +0 -46
  17. package/src/actionbar/SearchBar.tsx +0 -73
  18. package/src/actionbar/TreeActionBar.tsx +0 -383
  19. package/src/common/ButtonWithTooltip.tsx +0 -18
  20. package/src/common/DatePicker.tsx +0 -98
  21. package/src/common/Field.tsx +0 -93
  22. package/src/common/SelectAllRecordsRow.tsx +0 -94
  23. package/src/common/TimePicker.tsx +0 -38
  24. package/src/context/ActionViewContext.tsx +0 -213
  25. package/src/context/ConfigContext.tsx +0 -28
  26. package/src/context/ContentRootContext.tsx +0 -461
  27. package/src/context/DashboardActionContext.tsx +0 -44
  28. package/src/context/FormContext.tsx +0 -79
  29. package/src/context/FormModalContext.tsx +0 -28
  30. package/src/context/LocaleContext.tsx +0 -50
  31. package/src/context/One2manyContext.tsx +0 -45
  32. package/src/context/TabManagerContext.tsx +0 -117
  33. package/src/helpers/containerHelper.ts +0 -145
  34. package/src/helpers/dayjs.ts +0 -21
  35. package/src/helpers/dynamicColumnsHelper.ts +0 -73
  36. package/src/helpers/errorHelper.ts +0 -27
  37. package/src/helpers/filesHelper.ts +0 -41
  38. package/src/helpers/formHelper.ts +0 -301
  39. package/src/helpers/iconMapper.ts +0 -164
  40. package/src/helpers/logInfoHelper.tsx +0 -30
  41. package/src/helpers/one2manyHelper.ts +0 -194
  42. package/src/helpers/searchHelper.ts +0 -196
  43. package/src/helpers/timeHelper.ts +0 -58
  44. package/src/helpers/treeHelper.tsx +0 -226
  45. package/src/helpers/viewHelper.ts +0 -23
  46. package/src/hooks/useEffectDebugger.ts +0 -43
  47. package/src/hooks/useExport.ts +0 -439
  48. package/src/hooks/useFetchViews.ts +0 -0
  49. package/src/hooks/useSearch.ts +0 -434
  50. package/src/hooks/useWindowDimensions.ts +0 -33
  51. package/src/index.ts +0 -168
  52. package/src/locales/ca_ES.tsx +0 -99
  53. package/src/locales/en_US.tsx +0 -96
  54. package/src/locales/es_ES.tsx +0 -101
  55. package/src/stories/Binary.stories.tsx +0 -23
  56. package/src/stories/Boolean.stories.tsx +0 -22
  57. package/src/stories/Button.stories.tsx +0 -130
  58. package/src/stories/Char.stories.tsx +0 -76
  59. package/src/stories/FiberGrid.stories.tsx +0 -109
  60. package/src/stories/Float.stories.tsx +0 -22
  61. package/src/stories/FloatTime.stories.tsx +0 -32
  62. package/src/stories/Image.stories.tsx +0 -25
  63. package/src/stories/Integer.stories.tsx +0 -22
  64. package/src/stories/Label.stories.tsx +0 -100
  65. package/src/stories/Many2one.stories.tsx +0 -31
  66. package/src/stories/One2many.stories.tsx +0 -288
  67. package/src/stories/ProgressBar.stories.tsx +0 -22
  68. package/src/stories/Reference.stories.tsx +0 -43
  69. package/src/stories/Selection.stories.tsx +0 -34
  70. package/src/stories/Separator.stories.tsx +0 -53
  71. package/src/stories/Text.stories.tsx +0 -35
  72. package/src/stories/Time.stories.tsx +0 -31
  73. package/src/stories/Utils.stories.tsx +0 -14
  74. package/src/stories/containers/Group.stories.tsx +0 -84
  75. package/src/stories/containers/NewLine.stories.tsx +0 -52
  76. package/src/stories/containers/Notebook.stories.tsx +0 -188
  77. package/src/stories/custom/Avatar.stories.tsx +0 -22
  78. package/src/stories/custom/ButtonGroup.stories.tsx +0 -74
  79. package/src/stories/custom/CodeEditor.stories.tsx +0 -25
  80. package/src/stories/custom/Comments.stories.tsx +0 -197
  81. package/src/stories/custom/Indicator.stories.tsx +0 -36
  82. package/src/stories/custom/Markdown.stories.tsx +0 -38
  83. package/src/stories/custom/MultiCheckbox.stories.tsx +0 -60
  84. package/src/stories/custom/Radio.stories.tsx +0 -68
  85. package/src/stories/custom/Steps.stories.tsx +0 -43
  86. package/src/stories/custom/Switch.stories.tsx +0 -23
  87. package/src/stories/custom/Tag.stories.tsx +0 -66
  88. package/src/stories/custom/Tags.stories.tsx +0 -74
  89. package/src/stories/dashboard/Dashboard.stories.tsx +0 -23
  90. package/src/stories/dashboard/DashboardGrid.stories.tsx +0 -43
  91. package/src/stories/forms/ActivacioContracteForm.stories.tsx +0 -25
  92. package/src/stories/forms/Attachment.stories.tsx +0 -24
  93. package/src/stories/forms/CUPSForm.stories.tsx +0 -25
  94. package/src/stories/forms/Company.stories.tsx +0 -25
  95. package/src/stories/forms/CrmCaseForm.stories.tsx +0 -25
  96. package/src/stories/forms/Documents.stories.tsx +0 -25
  97. package/src/stories/forms/FormWithGridFiber.stories.tsx +0 -25
  98. package/src/stories/forms/FormWithLinks.stories.tsx +0 -30
  99. package/src/stories/forms/Lead.stories.tsx +0 -25
  100. package/src/stories/forms/ModContractForm.stories.tsx +0 -26
  101. package/src/stories/forms/PartnersForm.stories.tsx +0 -25
  102. package/src/stories/forms/PolissaForm.stories.tsx +0 -25
  103. package/src/stories/forms/PreferencesForm.stories.tsx +0 -691
  104. package/src/stories/forms/Signatures.stories.tsx +0 -25
  105. package/src/stories/forms/Switching.stories.tsx +0 -25
  106. package/src/stories/graphs/GraphIndicator.stories.tsx +0 -20
  107. package/src/stories/graphs/PieGraph.stories.tsx +0 -78
  108. package/src/stories/mocks/index.ts +0 -46
  109. package/src/stories/mocks/mockProvider.ts +0 -189
  110. package/src/stories/mocks/models/activacioContracte.ts +0 -112
  111. package/src/stories/mocks/models/attachment.ts +0 -1326
  112. package/src/stories/mocks/models/butlleti.ts +0 -296
  113. package/src/stories/mocks/models/company.ts +0 -135
  114. package/src/stories/mocks/models/crm_case.ts +0 -595
  115. package/src/stories/mocks/models/cups.ts +0 -937
  116. package/src/stories/mocks/models/document.ts +0 -223
  117. package/src/stories/mocks/models/factura.ts +0 -2713
  118. package/src/stories/mocks/models/form_with_gridfiber.ts +0 -141
  119. package/src/stories/mocks/models/hist_autoconsum.ts +0 -146
  120. package/src/stories/mocks/models/lead.ts +0 -2101
  121. package/src/stories/mocks/models/modcontractual.ts +0 -952
  122. package/src/stories/mocks/models/partner.ts +0 -1340
  123. package/src/stories/mocks/models/polissa.ts +0 -3127
  124. package/src/stories/mocks/models/res_partner_category.ts +0 -15
  125. package/src/stories/mocks/models/signatura.ts +0 -558
  126. package/src/stories/mocks/models/switching.ts +0 -767
  127. package/src/stories/modals/FormModal.stories.tsx +0 -36
  128. package/src/stories/modals/SearchModal.stories.tsx +0 -37
  129. package/src/stories/trees/FacturesTree.stories.tsx +0 -16
  130. package/src/stories/ui/ActionBar.stories.tsx +0 -21
  131. package/src/stories/ui/FavouriteButton.stories.tsx +0 -16
  132. package/src/stories/ui/GoToResourceModal.stories.tsx +0 -25
  133. package/src/stories/views/ActionView.stories.tsx +0 -28
  134. package/src/stories/views/SearchTree.stories.tsx +0 -1064
  135. package/src/stories/views/Tab.stories.tsx +0 -93
  136. package/src/stories/views/TabsAndContent.stories.tsx +0 -88
  137. package/src/stories/views/Tree.stories.jsx +0 -178
  138. package/src/stories/views/searchFilter/DateRangePicker.stories.tsx +0 -22
  139. package/src/stories/views/searchFilter/DateTimeRangePicker.stories.tsx +0 -23
  140. package/src/stories/views/searchFilter/PairFields.stories.tsx +0 -23
  141. package/src/stories/views/searchFilter/SearchFilter.stories.tsx +0 -165
  142. package/src/stories/views/searchFilter/examples/PartnersSearchFilter.stories.tsx +0 -409
  143. package/src/types/index.ts +0 -392
  144. package/src/ui/ActionErrorDialog.tsx +0 -24
  145. package/src/ui/ConfirmDialog.tsx +0 -28
  146. package/src/ui/ErrorAlert.tsx +0 -37
  147. package/src/ui/FavouriteButton.tsx +0 -271
  148. package/src/ui/FormErrorsDialog.tsx +0 -17
  149. package/src/ui/GenericErrorDialog.tsx +0 -16
  150. package/src/ui/GoToResourceModal.tsx +0 -76
  151. package/src/ui/InfoDialog.tsx +0 -13
  152. package/src/ui/RefreshItemDialog.tsx +0 -29
  153. package/src/ui/RemoveItemDialog.tsx +0 -20
  154. package/src/ui/TitleHeader.tsx +0 -117
  155. package/src/ui/UnlinkItemDialog.tsx +0 -20
  156. package/src/ui/UnsavedChangesDialog.tsx +0 -29
  157. package/src/ui/WarningDialog.tsx +0 -17
  158. package/src/views/ActionView.tsx +0 -526
  159. package/src/views/CurrentTabContent.tsx +0 -21
  160. package/src/views/RootView.tsx +0 -509
  161. package/src/views/TabContent.tsx +0 -31
  162. package/src/views/TabSelector.tsx +0 -31
  163. package/src/views/Welcome.tsx +0 -18
  164. package/src/views/actionViews/DashboardActionView.tsx +0 -52
  165. package/src/views/actionViews/FormActionView.tsx +0 -70
  166. package/src/views/actionViews/GraphActionView.tsx +0 -152
  167. package/src/views/actionViews/TreeActionView.tsx +0 -87
  168. package/src/views/tabs/Tab.tsx +0 -82
  169. package/src/widgets/WidgetFactory.tsx +0 -142
  170. package/src/widgets/base/Binary.tsx +0 -145
  171. package/src/widgets/base/Boolean.tsx +0 -44
  172. package/src/widgets/base/Button.tsx +0 -77
  173. package/src/widgets/base/Char.tsx +0 -157
  174. package/src/widgets/base/Date.tsx +0 -12
  175. package/src/widgets/base/DateTime.tsx +0 -12
  176. package/src/widgets/base/Email.tsx +0 -27
  177. package/src/widgets/base/Float.tsx +0 -38
  178. package/src/widgets/base/FloatTime.tsx +0 -73
  179. package/src/widgets/base/Image.tsx +0 -120
  180. package/src/widgets/base/Integer.tsx +0 -55
  181. package/src/widgets/base/Label.tsx +0 -56
  182. package/src/widgets/base/LinkInput.tsx +0 -106
  183. package/src/widgets/base/MultiSelection.tsx +0 -90
  184. package/src/widgets/base/ProgressBar.tsx +0 -38
  185. package/src/widgets/base/Reference.tsx +0 -115
  186. package/src/widgets/base/ReferenceTree.tsx +0 -62
  187. package/src/widgets/base/Selection.tsx +0 -71
  188. package/src/widgets/base/Separator.tsx +0 -25
  189. package/src/widgets/base/Text.tsx +0 -162
  190. package/src/widgets/base/Time.tsx +0 -40
  191. package/src/widgets/base/Url.tsx +0 -26
  192. package/src/widgets/base/many2one/Many2one.tsx +0 -322
  193. package/src/widgets/base/many2one/Many2oneSuffix.tsx +0 -232
  194. package/src/widgets/base/many2one/Many2oneSuffixModal.tsx +0 -42
  195. package/src/widgets/base/many2one/Many2oneTree.tsx +0 -18
  196. package/src/widgets/base/one2many/One2many.tsx +0 -100
  197. package/src/widgets/base/one2many/One2manyInput.tsx +0 -724
  198. package/src/widgets/base/one2many/One2manyTopBar.tsx +0 -158
  199. package/src/widgets/containers/Container.tsx +0 -99
  200. package/src/widgets/containers/Group.tsx +0 -37
  201. package/src/widgets/containers/Notebook.tsx +0 -52
  202. package/src/widgets/custom/Avatar.tsx +0 -40
  203. package/src/widgets/custom/ButtonGroup.tsx +0 -169
  204. package/src/widgets/custom/CodeEditor.tsx +0 -32
  205. package/src/widgets/custom/Comments.tsx +0 -147
  206. package/src/widgets/custom/FiberGrid.tsx +0 -48
  207. package/src/widgets/custom/Indicator.tsx +0 -66
  208. package/src/widgets/custom/Markdown.tsx +0 -32
  209. package/src/widgets/custom/MultiCheckbox.tsx +0 -165
  210. package/src/widgets/custom/Radio.tsx +0 -47
  211. package/src/widgets/custom/Steps.tsx +0 -56
  212. package/src/widgets/custom/Switch.tsx +0 -26
  213. package/src/widgets/custom/Tag.tsx +0 -53
  214. package/src/widgets/custom/Tags.tsx +0 -164
  215. package/src/widgets/custom/Timeline.tsx +0 -196
  216. package/src/widgets/modals/ExportModal.tsx +0 -75
  217. package/src/widgets/modals/FormModal.tsx +0 -125
  218. package/src/widgets/modals/SearchModal.tsx +0 -130
  219. package/src/widgets/modals/TranslationModal.tsx +0 -202
  220. package/src/widgets/views/Dashboard/Dashboard.tsx +0 -381
  221. package/src/widgets/views/Dashboard/DashboardForm.tsx +0 -30
  222. package/src/widgets/views/Dashboard/DashboardTree.tsx +0 -238
  223. package/src/widgets/views/Dashboard/dashboardHelper.ts +0 -79
  224. package/src/widgets/views/DashboardGrid/DashboardGrid.tsx +0 -53
  225. package/src/widgets/views/DashboardGrid/DashboardGrid.types.ts +0 -4
  226. package/src/widgets/views/DashboardGrid/DashboardGridItem.tsx +0 -62
  227. package/src/widgets/views/DashboardGrid/DashboardGridItem.types.ts +0 -10
  228. package/src/widgets/views/DashboardGrid/index.ts +0 -4
  229. package/src/widgets/views/Form.tsx +0 -1152
  230. package/src/widgets/views/Graph/Graph.tsx +0 -145
  231. package/src/widgets/views/Graph/GraphChart.tsx +0 -113
  232. package/src/widgets/views/Graph/GraphDefaults.ts +0 -170
  233. package/src/widgets/views/Graph/GraphIndicator.tsx +0 -421
  234. package/src/widgets/views/Graph/useGraphData.tsx +0 -176
  235. package/src/widgets/views/SearchTree.tsx +0 -367
  236. package/src/widgets/views/Tree/Tree.tsx +0 -295
  237. package/src/widgets/views/Tree/index.ts +0 -1
  238. package/src/widgets/views/Tree/treeComponents.tsx +0 -283
  239. package/src/widgets/views/searchFilter/DateRangePicker.tsx +0 -16
  240. package/src/widgets/views/searchFilter/DateTimeRangePicker.tsx +0 -87
  241. package/src/widgets/views/searchFilter/PairFields.tsx +0 -56
  242. package/src/widgets/views/searchFilter/SearchBottomBar.tsx +0 -54
  243. package/src/widgets/views/searchFilter/SearchField.tsx +0 -63
  244. package/src/widgets/views/searchFilter/SearchFilter.tsx +0 -160
  245. package/src/widgets/views/searchFilter/SearchParams.tsx +0 -35
@@ -1,383 +0,0 @@
1
- import React, { useContext, useState } from "react";
2
- import { Space, Spin } from "antd";
3
- import ChangeViewButton from "./ChangeViewButton";
4
- import {
5
- ActionViewContext,
6
- ActionViewContextType,
7
- } from "@/context/ActionViewContext";
8
- import NewButton from "./NewButton";
9
- import ActionButton from "./ActionButton";
10
- import Icon, {
11
- DeleteOutlined,
12
- PrinterOutlined,
13
- ThunderboltOutlined,
14
- CopyOutlined,
15
- ReloadOutlined,
16
- InfoCircleOutlined,
17
- FilterOutlined,
18
- } from "@ant-design/icons";
19
- import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
20
- import showConfirmDialog from "@/ui/ConfirmDialog";
21
- import ConnectionProvider from "@/ConnectionProvider";
22
- import showErrorDialog from "@/ui/ActionErrorDialog";
23
- import DropdownButton from "./DropdownButton";
24
- import {
25
- ContentRootContext,
26
- ContentRootContextType,
27
- } from "@/context/ContentRootContext";
28
- import ButtonWithBadge from "./ButtonWithBadge";
29
- import { showLogInfo } from "@/helpers/logInfoHelper";
30
- import SearchBar from "./SearchBar";
31
- import { ExportModal } from "..";
32
- import { mergeParams } from "@/helpers/searchHelper";
33
- import { ErpFeatureKeys, useFeatureIsEnabled } from "@/context/ConfigContext";
34
-
35
- type Props = {
36
- parentContext?: any;
37
- treeExpandable: boolean;
38
- toolbar: any;
39
- };
40
-
41
- function TreeActionBar(props: Props) {
42
- const {
43
- availableViews,
44
- currentView,
45
- setCurrentView,
46
- selectedRowItems,
47
- setRemovingItem,
48
- removingItem,
49
- duplicatingItem,
50
- setDuplicatingItem,
51
- currentModel,
52
- searchTreeRef,
53
- setCurrentId,
54
- setCurrentItemIndex,
55
- searchParams,
56
- searchVisible,
57
- setSearchVisible,
58
- setSearchTreeNameSearch,
59
- searchTreeNameSearch,
60
- treeIsLoading,
61
- setPreviousView,
62
- previousView,
63
- results,
64
- limit,
65
- totalItems,
66
- } = useContext(ActionViewContext) as ActionViewContextType;
67
-
68
- const { parentContext = {}, treeExpandable, toolbar } = props;
69
- const advancedExportEnabled = useFeatureIsEnabled(
70
- ErpFeatureKeys.FEATURE_ADVANCED_EXPORT,
71
- );
72
- const { t, lang } = useContext(LocaleContext) as LocaleContextType;
73
- const contentRootContext = useContext(
74
- ContentRootContext,
75
- ) as ContentRootContextType;
76
- const { processAction } = contentRootContext || {};
77
- const [exportModalVisible, setExportModalVisible] = useState(false);
78
-
79
- const hasNameSearch: boolean =
80
- searchTreeNameSearch !== undefined &&
81
- searchTreeNameSearch.trim().length > 0;
82
-
83
- function tryDelete() {
84
- showConfirmDialog({
85
- confirmMessage: t("confirmRemove"),
86
- lang,
87
- onOk: () => {
88
- remove();
89
- },
90
- });
91
- }
92
-
93
- async function remove() {
94
- try {
95
- setRemovingItem?.(true);
96
-
97
- await ConnectionProvider.getHandler().deleteObjects({
98
- model: currentModel!,
99
- ids: selectedRowItems!.map((item) => item.id),
100
- context: { ...parentContext },
101
- });
102
-
103
- setCurrentId?.(undefined);
104
- setCurrentItemIndex?.(undefined);
105
-
106
- searchTreeRef?.current?.refreshResults();
107
- } catch (e) {
108
- showErrorDialog(e);
109
- } finally {
110
- setRemovingItem?.(false);
111
- }
112
- }
113
-
114
- async function duplicate() {
115
- try {
116
- setDuplicatingItem?.(true);
117
-
118
- const currentId = selectedRowItems![0].id;
119
-
120
- const newId = await ConnectionProvider.getHandler().duplicate({
121
- id: currentId,
122
- model: currentModel!,
123
- context: { ...parentContext },
124
- });
125
-
126
- if (newId) {
127
- searchTreeRef?.current?.refreshResults();
128
- }
129
- } catch (e) {
130
- showErrorDialog(e);
131
- } finally {
132
- setDuplicatingItem?.(false);
133
- }
134
- }
135
-
136
- function runAction(actionData: any) {
137
- processAction?.({
138
- actionData,
139
- values: {
140
- active_id: selectedRowItems?.map((item) => item.id)[0],
141
- active_ids: selectedRowItems?.map((item) => item.id),
142
- },
143
- fields: {},
144
- context: {
145
- ...parentContext,
146
- active_id: selectedRowItems?.map((item) => item.id)[0],
147
- active_ids: selectedRowItems?.map((item) => item.id),
148
- },
149
- onRefreshParentValues: () => {
150
- searchTreeRef?.current?.refreshResults();
151
- },
152
- });
153
- }
154
-
155
- return (
156
- <Space wrap={true}>
157
- {treeIsLoading && (
158
- <>
159
- <Spin />
160
- {separator()}
161
- {separator()}
162
- </>
163
- )}
164
- {treeExpandable ? null : (
165
- <>
166
- <SearchBar
167
- disabled={duplicatingItem || removingItem || treeIsLoading}
168
- searchText={searchTreeNameSearch}
169
- onSearch={(searchString?: string) => {
170
- if (searchString && searchString.trim().length > 0) {
171
- setSearchTreeNameSearch?.(searchString);
172
- } else {
173
- setSearchTreeNameSearch?.(undefined);
174
- }
175
- }}
176
- />
177
- {!treeExpandable && (
178
- <ButtonWithBadge
179
- icon={
180
- <FilterOutlined
181
- style={{ color: searchVisible ? "white" : undefined }}
182
- />
183
- }
184
- tooltip={t("advanced_search")}
185
- type={searchVisible ? "primary" : "default"}
186
- onClick={() => {
187
- setSearchVisible?.(!searchVisible);
188
- }}
189
- disabled={duplicatingItem || removingItem || treeIsLoading}
190
- badgeNumber={searchParams?.length}
191
- />
192
- )}
193
- {separator()}
194
- <NewButton disabled={treeIsLoading} />
195
- <ActionButton
196
- icon={<CopyOutlined />}
197
- tooltip={t("duplicate")}
198
- disabled={
199
- !selectedRowItems ||
200
- selectedRowItems?.length !== 1 ||
201
- duplicatingItem ||
202
- treeIsLoading
203
- }
204
- loading={duplicatingItem}
205
- onClick={duplicate}
206
- />
207
- <ActionButton
208
- icon={<DeleteOutlined />}
209
- tooltip={t("delete")}
210
- disabled={
211
- !(selectedRowItems && selectedRowItems?.length > 0) ||
212
- treeIsLoading
213
- }
214
- loading={removingItem}
215
- onClick={tryDelete}
216
- />
217
- {separator()}
218
- </>
219
- )}
220
- <ActionButton
221
- icon={<InfoCircleOutlined />}
222
- tooltip={t("showLogs")}
223
- disabled={
224
- !(selectedRowItems && selectedRowItems?.length > 0) || treeIsLoading
225
- }
226
- loading={false}
227
- onClick={() => {
228
- showLogInfo(currentModel!, selectedRowItems![0].id, t);
229
- }}
230
- />
231
- <ActionButton
232
- icon={<ReloadOutlined />}
233
- tooltip={t("refresh")}
234
- disabled={duplicatingItem || removingItem || treeIsLoading}
235
- loading={false}
236
- onClick={() => {
237
- searchTreeRef?.current?.refreshResults();
238
- }}
239
- />
240
- {!treeExpandable && (
241
- <>
242
- {separator()}
243
- <ChangeViewButton
244
- currentView={currentView}
245
- availableViews={availableViews}
246
- onChangeView={(newView) => {
247
- setPreviousView?.(currentView);
248
- setCurrentView?.(newView);
249
- }}
250
- previousView={previousView}
251
- disabled={treeIsLoading}
252
- />
253
- </>
254
- )}
255
- {separator()}
256
- <DropdownButton
257
- icon={<ThunderboltOutlined />}
258
- disabled={
259
- !(selectedRowItems && selectedRowItems?.length > 0) || treeIsLoading
260
- }
261
- tooltip={t("actions")}
262
- items={toolbar?.action}
263
- onItemClick={(action: any) => {
264
- if (!action) {
265
- return;
266
- }
267
-
268
- runAction(action);
269
- }}
270
- />
271
- <DropdownButton
272
- icon={<PrinterOutlined />}
273
- disabled={
274
- !(selectedRowItems && selectedRowItems?.length > 0) || treeIsLoading
275
- }
276
- tooltip={t("reports")}
277
- items={toolbar?.print}
278
- onItemClick={(report: any) => {
279
- if (!report) {
280
- return;
281
- }
282
-
283
- runAction({
284
- ...report,
285
- datas: {
286
- ...(report.datas || {}),
287
- ids: selectedRowItems!.map((item) => item.id),
288
- },
289
- });
290
- }}
291
- />
292
- {advancedExportEnabled && (
293
- <>
294
- {separator()}
295
- <DropdownButton
296
- icon={
297
- <Icon
298
- component={() => (
299
- <svg
300
- xmlns="http://www.w3.org/2000/svg"
301
- className="icon icon-tabler icon-tabler-database-export"
302
- width="1em"
303
- height="1em"
304
- viewBox="0 0 24 24"
305
- strokeWidth="1.5"
306
- fill="none"
307
- stroke="currentColor"
308
- strokeLinecap="round"
309
- strokeLinejoin="round"
310
- >
311
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
312
- <ellipse cx="12" cy="6" rx="8" ry="3" />
313
- <path d="M4 6v6c0 1.657 3.582 3 8 3a19.84 19.84 0 0 0 3.302 -.267m4.698 -2.733v-6" />
314
- <path d="M4 12v6c0 1.599 3.335 2.905 7.538 2.995m8.462 -6.995v-2m-6 7h7m-3 -3l3 3l-3 3" />
315
- </svg>
316
- )}
317
- />
318
- }
319
- tooltip={t("export")}
320
- items={[
321
- {
322
- id: "print_screen",
323
- name: t("printScreen"),
324
- },
325
- {
326
- id: "export",
327
- name: t("advancedExport"),
328
- },
329
- ]}
330
- onItemClick={(itemClicked: any) => {
331
- if (itemClicked.id === "print_screen") {
332
- let idsToExport =
333
- selectedRowItems?.map((item) => item.id) || [];
334
-
335
- if (idsToExport.length === 0) {
336
- idsToExport = results?.map((item) => item.id) || [];
337
- }
338
-
339
- runAction({
340
- id: -1,
341
- model: currentModel,
342
- report_name: "printscreen.list",
343
- type: "ir.actions.report.xml",
344
- datas: {
345
- model: currentModel,
346
- ids: idsToExport,
347
- },
348
- });
349
- return;
350
- }
351
-
352
- setExportModalVisible(true);
353
- }}
354
- disabled={
355
- duplicatingItem || removingItem || treeIsLoading || hasNameSearch
356
- }
357
- />
358
- <ExportModal
359
- visible={exportModalVisible}
360
- locale={lang}
361
- onClose={() => setExportModalVisible(false)}
362
- model={currentModel!}
363
- domain={mergeParams(
364
- searchTreeRef?.current?.getDomain() || [],
365
- searchParams || [],
366
- )}
367
- limit={limit}
368
- totalRegisters={totalItems || 0}
369
- selectedRegistersToExport={selectedRowItems}
370
- visibleRegisters={results?.length || 0}
371
- context={parentContext}
372
- />
373
- </>
374
- )}
375
- </Space>
376
- );
377
- }
378
-
379
- function separator() {
380
- return <div className="inline-block w-2" />;
381
- }
382
-
383
- export default TreeActionBar;
@@ -1,18 +0,0 @@
1
- import React from "react";
2
- import { Button, Tooltip, ButtonProps } from "antd";
3
-
4
- export type Props = ButtonProps & {
5
- tooltip: string;
6
- };
7
-
8
- function ButtonWithTooltip(props: Props) {
9
- const { tooltip, ...restProps } = props;
10
-
11
- return (
12
- <Tooltip title={tooltip}>
13
- <Button {...restProps} />
14
- </Tooltip>
15
- );
16
- }
17
-
18
- export default ButtonWithTooltip;
@@ -1,98 +0,0 @@
1
- import { DatePicker as AntDatePicker, theme } from "antd";
2
-
3
- import React from "react";
4
- import Field from "@/common/Field";
5
- import { WidgetProps } from "@/types";
6
- import { Date as DateOoui } from "@gisce/ooui";
7
- import dayjs from "@/helpers/dayjs";
8
- const { useToken } = theme;
9
-
10
- type DatePickerProps = WidgetProps & {
11
- showTime?: boolean;
12
- };
13
-
14
- export const DatePickerConfig = {
15
- date: {
16
- placeholder: "__/__/____",
17
- dateDisplayFormat: "DD/MM/YYYY",
18
- dateInternalFormat: "YYYY-MM-DD",
19
- },
20
- time: {
21
- placeholder: "__/__/____ __:__:__",
22
- dateDisplayFormat: "DD/MM/YYYY HH:mm:ss",
23
- dateInternalFormat: "YYYY-MM-DD HH:mm:ss",
24
- },
25
- };
26
-
27
- const DatePicker = (props: DatePickerProps) => {
28
- const { ooui, showTime = false } = props;
29
- const { required } = ooui;
30
-
31
- return (
32
- <Field required={required} {...props}>
33
- <DatePickerInput ooui={ooui} showTime={showTime} />
34
- </Field>
35
- );
36
- };
37
-
38
- interface DatePickerInputProps {
39
- ooui: DateOoui;
40
- value?: undefined | string;
41
- onChange?: (value: undefined | string) => void;
42
- showTime?: boolean;
43
- }
44
-
45
- const DatePickerInput: React.FC<DatePickerInputProps> = (
46
- props: DatePickerInputProps,
47
- ) => {
48
- const { value, onChange, ooui, showTime } = props;
49
- const { id, readOnly, required } = ooui as DateOoui;
50
- const { token } = useToken();
51
-
52
- const requiredStyle =
53
- required && !readOnly
54
- ? { backgroundColor: token.colorPrimaryBg }
55
- : undefined;
56
-
57
- const mode = showTime ? "time" : "date";
58
-
59
- const triggerChange = (changedValue: undefined | string) => {
60
- onChange?.(changedValue);
61
- };
62
-
63
- const onValueStringChange = (momentDate: any) => {
64
- if (momentDate === null) {
65
- triggerChange(undefined);
66
- return;
67
- }
68
-
69
- triggerChange(momentDate.format(DatePickerConfig[mode].dateInternalFormat));
70
- };
71
-
72
- const dateValue = value
73
- ? dayjs(value, DatePickerConfig[mode].dateInternalFormat)
74
- : undefined;
75
-
76
- return (
77
- <AntDatePicker
78
- style={{ width: "100%", ...requiredStyle }}
79
- placeholder={
80
- showTime
81
- ? DatePickerConfig.time.placeholder
82
- : DatePickerConfig.date.placeholder
83
- }
84
- disabled={readOnly}
85
- id={id}
86
- picker={"date"}
87
- showTime={showTime}
88
- format={DatePickerConfig[mode].dateDisplayFormat}
89
- value={dateValue}
90
- onChange={onValueStringChange}
91
- showNow={false}
92
- showToday={false}
93
- changeOnBlur={true}
94
- />
95
- );
96
- };
97
-
98
- export default DatePicker;
@@ -1,93 +0,0 @@
1
- import React, { useContext } from "react";
2
- import { Form, Row, Col } from "antd";
3
- import { Field as FieldOoui, Label as LabelOoui } from "@gisce/ooui";
4
- import Label from "@/widgets/base/Label";
5
- import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
6
-
7
- export default function Field({
8
- ooui,
9
- children,
10
- layout = "horizontal",
11
- valuePropName,
12
- showLabel = false,
13
- alignLabel = "left",
14
- required = false,
15
- type,
16
- validator,
17
- }: {
18
- ooui: FieldOoui;
19
- children?: React.ReactNode;
20
- layout?: "horizontal" | "vertical";
21
- valuePropName?: string;
22
- showLabel?: boolean;
23
- alignLabel?: "left" | "center" | "right";
24
- required?: boolean;
25
- type?: any;
26
- validator?: any;
27
- }) {
28
- const { id, label, tooltip } = ooui;
29
- const { t } = useContext(LocaleContext) as LocaleContextType;
30
-
31
- const rules = required
32
- ? [
33
- {
34
- required: true,
35
- message: t("fillRequiredField"),
36
- type,
37
- validator,
38
- },
39
- ]
40
- : undefined;
41
-
42
- const formItem = () => (
43
- <Form.Item
44
- className="mb-0"
45
- name={id}
46
- valuePropName={valuePropName}
47
- rules={rules}
48
- help={ooui.tooltipInline ? ooui.tooltip : null}
49
- >
50
- {children}
51
- </Form.Item>
52
- );
53
-
54
- if (!showLabel) {
55
- return formItem();
56
- }
57
-
58
- const labelWidget = (
59
- <Label
60
- ooui={
61
- new LabelOoui({
62
- name: id + "_label",
63
- string: label,
64
- help: ooui.tooltipInline ? false : tooltip,
65
- fieldForLabel: id,
66
- })
67
- }
68
- align={alignLabel}
69
- />
70
- );
71
-
72
- const horizontalMode = () => {
73
- return (
74
- <Row align="middle" className="pb-1 pt-1">
75
- <Col className="ml-2" flex="7rem">
76
- <div className="flex flex-col items-end">{labelWidget}</div>
77
- </Col>
78
- <Col flex="auto">{formItem()}</Col>
79
- </Row>
80
- );
81
- };
82
-
83
- const verticalMode = () => {
84
- return (
85
- <>
86
- {labelWidget}
87
- {formItem()}
88
- </>
89
- );
90
- };
91
-
92
- return layout === "horizontal" ? horizontalMode() : verticalMode();
93
- }
@@ -1,94 +0,0 @@
1
- import styled from "styled-components";
2
- import React, { useContext, useState } from "react";
3
- import { Spin } from "antd";
4
- import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
5
- import Link from "antd/es/typography/Link";
6
-
7
- export const Container = styled.div`
8
- display: flex;
9
- align-items: center;
10
- justify-content: center;
11
- `;
12
-
13
- export const SelectAllRecordsRow = ({
14
- numberOfVisibleSelectedRows,
15
- totalRecords,
16
- numberOfTotalRows,
17
- onSelectAllRecords,
18
- numberOfRealSelectedRows,
19
- }: {
20
- numberOfVisibleSelectedRows: number;
21
- totalRecords: number;
22
- numberOfTotalRows: number;
23
- numberOfRealSelectedRows: number;
24
- onSelectAllRecords: () => Promise<void>;
25
- }) => {
26
- const [loading, setLoading] = useState(false);
27
- const { t } = useContext(LocaleContext) as LocaleContextType;
28
-
29
- const translations = {
30
- recordsSelected: t("recordsSelected"),
31
- selectAllRecords: t("selectAllRecords"),
32
- allRecordsSelected: t("allRecordsSelected"),
33
- };
34
-
35
- if (numberOfTotalRows === 0) {
36
- return null;
37
- }
38
-
39
- if (
40
- numberOfVisibleSelectedRows < numberOfTotalRows &&
41
- numberOfRealSelectedRows <= numberOfTotalRows
42
- ) {
43
- return null;
44
- }
45
-
46
- if (totalRecords === numberOfVisibleSelectedRows) {
47
- return null;
48
- }
49
-
50
- const handleClick = async (event: any) => {
51
- event.preventDefault(); // prevent the default action (navigation) from happening
52
- event.stopPropagation();
53
- setLoading(true);
54
- await onSelectAllRecords();
55
- setLoading(false);
56
- };
57
-
58
- const selectRowsComponent = (
59
- <span>
60
- {translations.recordsSelected.replace(
61
- "{numberOfSelectedRows}",
62
- numberOfVisibleSelectedRows.toString(),
63
- ) + " "}
64
-
65
- {loading ? (
66
- <Spin />
67
- ) : (
68
- <Link onClick={handleClick} style={{ fontWeight: 600 }}>
69
- {translations.selectAllRecords.replace(
70
- "{totalRecords}",
71
- totalRecords.toString(),
72
- )}
73
- </Link>
74
- )}
75
- </span>
76
- );
77
-
78
- const allRowsAreSelected = (
79
- <span style={{ fontWeight: 600 }}>
80
- {translations.allRecordsSelected.replace(
81
- "{totalRecords}",
82
- numberOfRealSelectedRows.toString(),
83
- ) + " "}
84
- </span>
85
- );
86
-
87
- return (
88
- <Container>
89
- {numberOfRealSelectedRows > numberOfTotalRows
90
- ? allRowsAreSelected
91
- : selectRowsComponent}
92
- </Container>
93
- );
94
- };