@gisce/react-ooui 2.0.0-alpha.61 → 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 (246) hide show
  1. package/dist/react-ooui.es.js +5 -2
  2. package/dist/react-ooui.es.js.map +1 -1
  3. package/dist/widgets/views/Tree/treeComponents.d.ts.map +1 -1
  4. package/package.json +6 -8
  5. package/src/ConnectionProvider.ts +0 -16
  6. package/src/__tests__/iconMapper.test.ts +0 -30
  7. package/src/__tests__/searchFilterHelper.spec.ts +0 -386
  8. package/src/actionbar/ActionButton.tsx +0 -40
  9. package/src/actionbar/AttachmentsButton.tsx +0 -132
  10. package/src/actionbar/AttachmentsButtonWrapper.tsx +0 -157
  11. package/src/actionbar/ButtonWithBadge.tsx +0 -44
  12. package/src/actionbar/ChangeViewButton.tsx +0 -137
  13. package/src/actionbar/DashboardActionBar.tsx +0 -63
  14. package/src/actionbar/DropdownButton.tsx +0 -124
  15. package/src/actionbar/FormActionBar.tsx +0 -491
  16. package/src/actionbar/GraphActionBar.tsx +0 -67
  17. package/src/actionbar/NewButton.tsx +0 -46
  18. package/src/actionbar/SearchBar.tsx +0 -73
  19. package/src/actionbar/TreeActionBar.tsx +0 -383
  20. package/src/common/ButtonWithTooltip.tsx +0 -18
  21. package/src/common/DatePicker.tsx +0 -98
  22. package/src/common/Field.tsx +0 -93
  23. package/src/common/SelectAllRecordsRow.tsx +0 -94
  24. package/src/common/TimePicker.tsx +0 -38
  25. package/src/context/ActionViewContext.tsx +0 -213
  26. package/src/context/ConfigContext.tsx +0 -28
  27. package/src/context/ContentRootContext.tsx +0 -461
  28. package/src/context/DashboardActionContext.tsx +0 -44
  29. package/src/context/FormContext.tsx +0 -79
  30. package/src/context/FormModalContext.tsx +0 -28
  31. package/src/context/LocaleContext.tsx +0 -50
  32. package/src/context/One2manyContext.tsx +0 -45
  33. package/src/context/TabManagerContext.tsx +0 -117
  34. package/src/helpers/containerHelper.ts +0 -145
  35. package/src/helpers/dayjs.ts +0 -21
  36. package/src/helpers/dynamicColumnsHelper.ts +0 -73
  37. package/src/helpers/errorHelper.ts +0 -27
  38. package/src/helpers/filesHelper.ts +0 -41
  39. package/src/helpers/formHelper.ts +0 -301
  40. package/src/helpers/iconMapper.ts +0 -164
  41. package/src/helpers/logInfoHelper.tsx +0 -30
  42. package/src/helpers/one2manyHelper.ts +0 -194
  43. package/src/helpers/searchHelper.ts +0 -196
  44. package/src/helpers/timeHelper.ts +0 -58
  45. package/src/helpers/treeHelper.tsx +0 -226
  46. package/src/helpers/viewHelper.ts +0 -23
  47. package/src/hooks/useEffectDebugger.ts +0 -43
  48. package/src/hooks/useExport.ts +0 -439
  49. package/src/hooks/useFetchViews.ts +0 -0
  50. package/src/hooks/useSearch.ts +0 -434
  51. package/src/hooks/useWindowDimensions.ts +0 -33
  52. package/src/index.ts +0 -168
  53. package/src/locales/ca_ES.tsx +0 -99
  54. package/src/locales/en_US.tsx +0 -96
  55. package/src/locales/es_ES.tsx +0 -101
  56. package/src/stories/Binary.stories.tsx +0 -23
  57. package/src/stories/Boolean.stories.tsx +0 -22
  58. package/src/stories/Button.stories.tsx +0 -130
  59. package/src/stories/Char.stories.tsx +0 -76
  60. package/src/stories/FiberGrid.stories.tsx +0 -109
  61. package/src/stories/Float.stories.tsx +0 -22
  62. package/src/stories/FloatTime.stories.tsx +0 -32
  63. package/src/stories/Image.stories.tsx +0 -25
  64. package/src/stories/Integer.stories.tsx +0 -22
  65. package/src/stories/Label.stories.tsx +0 -100
  66. package/src/stories/Many2one.stories.tsx +0 -31
  67. package/src/stories/One2many.stories.tsx +0 -288
  68. package/src/stories/ProgressBar.stories.tsx +0 -22
  69. package/src/stories/Reference.stories.tsx +0 -43
  70. package/src/stories/Selection.stories.tsx +0 -34
  71. package/src/stories/Separator.stories.tsx +0 -53
  72. package/src/stories/Text.stories.tsx +0 -35
  73. package/src/stories/Time.stories.tsx +0 -31
  74. package/src/stories/Utils.stories.tsx +0 -14
  75. package/src/stories/containers/Group.stories.tsx +0 -84
  76. package/src/stories/containers/NewLine.stories.tsx +0 -52
  77. package/src/stories/containers/Notebook.stories.tsx +0 -188
  78. package/src/stories/custom/Avatar.stories.tsx +0 -22
  79. package/src/stories/custom/ButtonGroup.stories.tsx +0 -74
  80. package/src/stories/custom/CodeEditor.stories.tsx +0 -25
  81. package/src/stories/custom/Comments.stories.tsx +0 -197
  82. package/src/stories/custom/Indicator.stories.tsx +0 -36
  83. package/src/stories/custom/Markdown.stories.tsx +0 -38
  84. package/src/stories/custom/MultiCheckbox.stories.tsx +0 -60
  85. package/src/stories/custom/Radio.stories.tsx +0 -68
  86. package/src/stories/custom/Steps.stories.tsx +0 -43
  87. package/src/stories/custom/Switch.stories.tsx +0 -23
  88. package/src/stories/custom/Tag.stories.tsx +0 -66
  89. package/src/stories/custom/Tags.stories.tsx +0 -74
  90. package/src/stories/dashboard/Dashboard.stories.tsx +0 -23
  91. package/src/stories/dashboard/DashboardGrid.stories.tsx +0 -43
  92. package/src/stories/forms/ActivacioContracteForm.stories.tsx +0 -25
  93. package/src/stories/forms/Attachment.stories.tsx +0 -24
  94. package/src/stories/forms/CUPSForm.stories.tsx +0 -25
  95. package/src/stories/forms/Company.stories.tsx +0 -25
  96. package/src/stories/forms/CrmCaseForm.stories.tsx +0 -25
  97. package/src/stories/forms/Documents.stories.tsx +0 -25
  98. package/src/stories/forms/FormWithGridFiber.stories.tsx +0 -25
  99. package/src/stories/forms/FormWithLinks.stories.tsx +0 -30
  100. package/src/stories/forms/Lead.stories.tsx +0 -25
  101. package/src/stories/forms/ModContractForm.stories.tsx +0 -26
  102. package/src/stories/forms/PartnersForm.stories.tsx +0 -25
  103. package/src/stories/forms/PolissaForm.stories.tsx +0 -25
  104. package/src/stories/forms/PreferencesForm.stories.tsx +0 -691
  105. package/src/stories/forms/Signatures.stories.tsx +0 -25
  106. package/src/stories/forms/Switching.stories.tsx +0 -25
  107. package/src/stories/graphs/GraphIndicator.stories.tsx +0 -20
  108. package/src/stories/graphs/PieGraph.stories.tsx +0 -78
  109. package/src/stories/mocks/index.ts +0 -46
  110. package/src/stories/mocks/mockProvider.ts +0 -189
  111. package/src/stories/mocks/models/activacioContracte.ts +0 -112
  112. package/src/stories/mocks/models/attachment.ts +0 -1326
  113. package/src/stories/mocks/models/butlleti.ts +0 -296
  114. package/src/stories/mocks/models/company.ts +0 -135
  115. package/src/stories/mocks/models/crm_case.ts +0 -595
  116. package/src/stories/mocks/models/cups.ts +0 -937
  117. package/src/stories/mocks/models/document.ts +0 -223
  118. package/src/stories/mocks/models/factura.ts +0 -2713
  119. package/src/stories/mocks/models/form_with_gridfiber.ts +0 -141
  120. package/src/stories/mocks/models/hist_autoconsum.ts +0 -146
  121. package/src/stories/mocks/models/lead.ts +0 -2101
  122. package/src/stories/mocks/models/modcontractual.ts +0 -952
  123. package/src/stories/mocks/models/partner.ts +0 -1340
  124. package/src/stories/mocks/models/polissa.ts +0 -3127
  125. package/src/stories/mocks/models/res_partner_category.ts +0 -15
  126. package/src/stories/mocks/models/signatura.ts +0 -558
  127. package/src/stories/mocks/models/switching.ts +0 -767
  128. package/src/stories/modals/FormModal.stories.tsx +0 -36
  129. package/src/stories/modals/SearchModal.stories.tsx +0 -37
  130. package/src/stories/trees/FacturesTree.stories.tsx +0 -16
  131. package/src/stories/ui/ActionBar.stories.tsx +0 -21
  132. package/src/stories/ui/FavouriteButton.stories.tsx +0 -16
  133. package/src/stories/ui/GoToResourceModal.stories.tsx +0 -25
  134. package/src/stories/views/ActionView.stories.tsx +0 -28
  135. package/src/stories/views/SearchTree.stories.tsx +0 -1064
  136. package/src/stories/views/Tab.stories.tsx +0 -93
  137. package/src/stories/views/TabsAndContent.stories.tsx +0 -88
  138. package/src/stories/views/Tree.stories.jsx +0 -178
  139. package/src/stories/views/searchFilter/DateRangePicker.stories.tsx +0 -22
  140. package/src/stories/views/searchFilter/DateTimeRangePicker.stories.tsx +0 -23
  141. package/src/stories/views/searchFilter/PairFields.stories.tsx +0 -23
  142. package/src/stories/views/searchFilter/SearchFilter.stories.tsx +0 -165
  143. package/src/stories/views/searchFilter/examples/PartnersSearchFilter.stories.tsx +0 -409
  144. package/src/types/index.ts +0 -392
  145. package/src/ui/ActionErrorDialog.tsx +0 -24
  146. package/src/ui/ConfirmDialog.tsx +0 -28
  147. package/src/ui/ErrorAlert.tsx +0 -37
  148. package/src/ui/FavouriteButton.tsx +0 -271
  149. package/src/ui/FormErrorsDialog.tsx +0 -17
  150. package/src/ui/GenericErrorDialog.tsx +0 -16
  151. package/src/ui/GoToResourceModal.tsx +0 -76
  152. package/src/ui/InfoDialog.tsx +0 -13
  153. package/src/ui/RefreshItemDialog.tsx +0 -29
  154. package/src/ui/RemoveItemDialog.tsx +0 -20
  155. package/src/ui/TitleHeader.tsx +0 -117
  156. package/src/ui/UnlinkItemDialog.tsx +0 -20
  157. package/src/ui/UnsavedChangesDialog.tsx +0 -29
  158. package/src/ui/WarningDialog.tsx +0 -17
  159. package/src/views/ActionView.tsx +0 -526
  160. package/src/views/CurrentTabContent.tsx +0 -21
  161. package/src/views/RootView.tsx +0 -509
  162. package/src/views/TabContent.tsx +0 -31
  163. package/src/views/TabSelector.tsx +0 -31
  164. package/src/views/Welcome.tsx +0 -18
  165. package/src/views/actionViews/DashboardActionView.tsx +0 -52
  166. package/src/views/actionViews/FormActionView.tsx +0 -70
  167. package/src/views/actionViews/GraphActionView.tsx +0 -152
  168. package/src/views/actionViews/TreeActionView.tsx +0 -87
  169. package/src/views/tabs/Tab.tsx +0 -82
  170. package/src/widgets/WidgetFactory.tsx +0 -142
  171. package/src/widgets/base/Binary.tsx +0 -145
  172. package/src/widgets/base/Boolean.tsx +0 -44
  173. package/src/widgets/base/Button.tsx +0 -77
  174. package/src/widgets/base/Char.tsx +0 -157
  175. package/src/widgets/base/Date.tsx +0 -12
  176. package/src/widgets/base/DateTime.tsx +0 -12
  177. package/src/widgets/base/Email.tsx +0 -27
  178. package/src/widgets/base/Float.tsx +0 -38
  179. package/src/widgets/base/FloatTime.tsx +0 -73
  180. package/src/widgets/base/Image.tsx +0 -120
  181. package/src/widgets/base/Integer.tsx +0 -55
  182. package/src/widgets/base/Label.tsx +0 -56
  183. package/src/widgets/base/LinkInput.tsx +0 -106
  184. package/src/widgets/base/MultiSelection.tsx +0 -90
  185. package/src/widgets/base/ProgressBar.tsx +0 -38
  186. package/src/widgets/base/Reference.tsx +0 -115
  187. package/src/widgets/base/ReferenceTree.tsx +0 -62
  188. package/src/widgets/base/Selection.tsx +0 -71
  189. package/src/widgets/base/Separator.tsx +0 -25
  190. package/src/widgets/base/Text.tsx +0 -162
  191. package/src/widgets/base/Time.tsx +0 -40
  192. package/src/widgets/base/Url.tsx +0 -26
  193. package/src/widgets/base/many2one/Many2one.tsx +0 -322
  194. package/src/widgets/base/many2one/Many2oneSuffix.tsx +0 -232
  195. package/src/widgets/base/many2one/Many2oneSuffixModal.tsx +0 -42
  196. package/src/widgets/base/many2one/Many2oneTree.tsx +0 -18
  197. package/src/widgets/base/one2many/One2many.tsx +0 -100
  198. package/src/widgets/base/one2many/One2manyInput.tsx +0 -724
  199. package/src/widgets/base/one2many/One2manyTopBar.tsx +0 -158
  200. package/src/widgets/containers/Container.tsx +0 -99
  201. package/src/widgets/containers/Group.tsx +0 -37
  202. package/src/widgets/containers/Notebook.tsx +0 -52
  203. package/src/widgets/custom/Avatar.tsx +0 -40
  204. package/src/widgets/custom/ButtonGroup.tsx +0 -169
  205. package/src/widgets/custom/CodeEditor.tsx +0 -32
  206. package/src/widgets/custom/Comments.tsx +0 -147
  207. package/src/widgets/custom/FiberGrid.tsx +0 -48
  208. package/src/widgets/custom/Indicator.tsx +0 -66
  209. package/src/widgets/custom/Markdown.tsx +0 -32
  210. package/src/widgets/custom/MultiCheckbox.tsx +0 -165
  211. package/src/widgets/custom/Radio.tsx +0 -47
  212. package/src/widgets/custom/Steps.tsx +0 -56
  213. package/src/widgets/custom/Switch.tsx +0 -26
  214. package/src/widgets/custom/Tag.tsx +0 -53
  215. package/src/widgets/custom/Tags.tsx +0 -164
  216. package/src/widgets/custom/Timeline.tsx +0 -196
  217. package/src/widgets/modals/ExportModal.tsx +0 -75
  218. package/src/widgets/modals/FormModal.tsx +0 -125
  219. package/src/widgets/modals/SearchModal.tsx +0 -130
  220. package/src/widgets/modals/TranslationModal.tsx +0 -202
  221. package/src/widgets/views/Dashboard/Dashboard.tsx +0 -381
  222. package/src/widgets/views/Dashboard/DashboardForm.tsx +0 -30
  223. package/src/widgets/views/Dashboard/DashboardTree.tsx +0 -238
  224. package/src/widgets/views/Dashboard/dashboardHelper.ts +0 -79
  225. package/src/widgets/views/DashboardGrid/DashboardGrid.tsx +0 -53
  226. package/src/widgets/views/DashboardGrid/DashboardGrid.types.ts +0 -4
  227. package/src/widgets/views/DashboardGrid/DashboardGridItem.tsx +0 -62
  228. package/src/widgets/views/DashboardGrid/DashboardGridItem.types.ts +0 -10
  229. package/src/widgets/views/DashboardGrid/index.ts +0 -4
  230. package/src/widgets/views/Form.tsx +0 -1152
  231. package/src/widgets/views/Graph/Graph.tsx +0 -145
  232. package/src/widgets/views/Graph/GraphChart.tsx +0 -113
  233. package/src/widgets/views/Graph/GraphDefaults.ts +0 -170
  234. package/src/widgets/views/Graph/GraphIndicator.tsx +0 -421
  235. package/src/widgets/views/Graph/useGraphData.tsx +0 -176
  236. package/src/widgets/views/SearchTree.tsx +0 -367
  237. package/src/widgets/views/Tree/Tree.tsx +0 -295
  238. package/src/widgets/views/Tree/index.ts +0 -1
  239. package/src/widgets/views/Tree/treeComponents.tsx +0 -276
  240. package/src/widgets/views/searchFilter/DateRangePicker.tsx +0 -16
  241. package/src/widgets/views/searchFilter/DateTimeRangePicker.tsx +0 -87
  242. package/src/widgets/views/searchFilter/PairFields.tsx +0 -56
  243. package/src/widgets/views/searchFilter/SearchBottomBar.tsx +0 -54
  244. package/src/widgets/views/searchFilter/SearchField.tsx +0 -63
  245. package/src/widgets/views/searchFilter/SearchFilter.tsx +0 -160
  246. package/src/widgets/views/searchFilter/SearchParams.tsx +0 -35
@@ -1,276 +0,0 @@
1
- import { ReactElement, useCallback, useEffect, useMemo, useState } from "react";
2
- import { Checkbox, Spin } from "antd";
3
- import { parseFloatToString } from "@/helpers/timeHelper";
4
- import { ProgressBarInput } from "../../base/ProgressBar";
5
- import { One2manyValue } from "../../base/one2many/One2manyInput";
6
- import { Interweave } from "interweave";
7
- import { Many2oneTree } from "../../base/many2one/Many2oneTree";
8
- import { ReferenceTree } from "../../base/ReferenceTree";
9
- import dayjs from "@/helpers/dayjs";
10
- import Avatar from "../../custom/Avatar";
11
- import { CustomTag, TagInput } from "../../custom/Tag";
12
- import { DatePickerConfig } from "@/common/DatePicker";
13
- import ConnectionProvider from "@/ConnectionProvider";
14
- import { colorFromString } from "@/helpers/formHelper";
15
-
16
- export const BooleanComponent = ({
17
- value,
18
- }: {
19
- value: boolean;
20
- }): ReactElement => {
21
- return useMemo(
22
- () => (
23
- <div
24
- style={{
25
- display: "flex",
26
- justifyContent: "center",
27
- alignContent: "center",
28
- }}
29
- >
30
- <Checkbox checked={value} disabled />
31
- </div>
32
- ),
33
- [value],
34
- );
35
- };
36
-
37
- export const Many2OneComponent = ({ value }: { value: any }): ReactElement => {
38
- return useMemo(() => <Many2oneTree m2oField={value} />, [value]);
39
- };
40
-
41
- export const TextComponent = ({ value }: { value: any }): ReactElement => {
42
- return useMemo(
43
- () => (
44
- <Interweave
45
- content={value?.toString().replace(/(?:\r\n|\r|\n)/g, "<br>")}
46
- />
47
- ),
48
- [value],
49
- );
50
- };
51
-
52
- export const DateComponent = ({ value }: { value: any }): ReactElement => {
53
- return useMemo(() => {
54
- if (!value || (value && value.length === 0)) return <></>;
55
-
56
- const formattedValue = dayjs(
57
- value,
58
- DatePickerConfig.date.dateInternalFormat,
59
- ).format(DatePickerConfig.date.dateDisplayFormat);
60
- return <>{formattedValue}</>;
61
- }, [value]);
62
- };
63
-
64
- export const DateTimeComponent = ({ value }: { value: any }): ReactElement => {
65
- return useMemo(() => {
66
- if (!value || (value && value.length === 0)) return <></>;
67
- const formattedValue = dayjs(
68
- value,
69
- DatePickerConfig.time.dateInternalFormat,
70
- ).format(DatePickerConfig.time.dateDisplayFormat);
71
- return <>{formattedValue}</>;
72
- }, [value]);
73
- };
74
-
75
- export const One2ManyComponent = ({
76
- value,
77
- }: {
78
- value: One2manyValue;
79
- }): ReactElement => {
80
- return useMemo(() => {
81
- const length = Array.isArray(value?.items) ? value?.items.length : 0;
82
- return <>{`( ${length} )`}</>;
83
- }, [value]);
84
- };
85
-
86
- export const ProgressBarComponent = ({
87
- value,
88
- }: {
89
- value: any;
90
- }): ReactElement => {
91
- return useMemo(() => <ProgressBarInput value={value} />, [value]);
92
- };
93
-
94
- export const FloatTimeComponent = ({ value }: { value: any }): ReactElement => {
95
- return useMemo(() => <>{parseFloatToString(value)}</>, [value]);
96
- };
97
-
98
- export const NumberComponent = ({ value }: { value: number }): ReactElement => {
99
- return useMemo(
100
- () => <div style={{ textAlign: "right" }}>{value}</div>,
101
- [value],
102
- );
103
- };
104
-
105
- export const ImageComponent = ({ value }: { value: string }): ReactElement => {
106
- return useMemo(
107
- () => (
108
- <img
109
- src={`data:image/*;base64,${value}`}
110
- style={{ maxWidth: "50px", padding: "5px" }}
111
- />
112
- ),
113
- [value],
114
- );
115
- };
116
-
117
- export const TagComponent = ({
118
- value,
119
- key,
120
- ooui,
121
- context,
122
- }: {
123
- value: any;
124
- key: string;
125
- ooui: any;
126
- context: any;
127
- }): ReactElement => {
128
- return useMemo(() => <TagInput ooui={ooui} value={value} />, [ooui, value]);
129
- };
130
-
131
- export const SelectionComponent = ({
132
- value,
133
- key,
134
- ooui,
135
- context,
136
- }: {
137
- value: any;
138
- key: string;
139
- ooui: any;
140
- context: any;
141
- }): ReactElement => {
142
- return useMemo(() => <>{ooui.selectionValues.get(value)}</>, [ooui, value]);
143
- };
144
-
145
- export const ReferenceComponent = ({
146
- value,
147
- key,
148
- ooui,
149
- context,
150
- }: {
151
- value: any;
152
- key: string;
153
- ooui: any;
154
- context: any;
155
- }): ReactElement => {
156
- return useMemo(
157
- () => (
158
- <ReferenceTree
159
- value={value}
160
- selectionValues={ooui.selectionValues}
161
- context={context}
162
- />
163
- ),
164
- [context, ooui.selectionValues, value],
165
- );
166
- };
167
-
168
- export const AvatarComponent = ({
169
- value,
170
- key,
171
- ooui,
172
- context,
173
- }: {
174
- value: any;
175
- key: string;
176
- ooui: any;
177
- context: any;
178
- }): ReactElement => {
179
- return useMemo(() => <Avatar ooui={ooui} value={value} />, [ooui, value]);
180
- };
181
-
182
- export const TagsComponent = ({
183
- value,
184
- key,
185
- ooui,
186
- context,
187
- }: {
188
- value: any;
189
- key: string;
190
- ooui: any;
191
- context: any;
192
- }): ReactElement => {
193
- const [values, setValues] = useState<Array<{ id: number; name: string }>>([]);
194
- const [loading, setLoading] = useState<boolean>(false);
195
- const { relation, field } = ooui;
196
-
197
- const loadValues = useCallback(async () => {
198
- try {
199
- setLoading(true);
200
- const optionsRead = await ConnectionProvider.getHandler().search({
201
- model: relation,
202
- params: [["id", "in", value.items.map((v: any) => v.id)]],
203
- fields: [field],
204
- context,
205
- });
206
- setValues(
207
- optionsRead.map((i: any) => {
208
- const { id, name } = i;
209
- return { id, name };
210
- }),
211
- );
212
- } catch (error) {
213
- console.error("Error loading data", error);
214
- } finally {
215
- setLoading(false);
216
- }
217
- }, [context, field, relation, value.items]);
218
-
219
- useEffect(() => {
220
- if (value?.items && value?.items.length > 0) {
221
- loadValues();
222
- }
223
- // eslint-disable-next-line react-hooks/exhaustive-deps
224
- }, [value?.items]);
225
-
226
- const tags = useMemo(
227
- () =>
228
- values.map((entry) => {
229
- const { id, name } = entry;
230
- const color = colorFromString(name);
231
- return (
232
- <CustomTag key={`${id}`} color={color}>
233
- {name}
234
- </CustomTag>
235
- );
236
- }),
237
- [values],
238
- );
239
-
240
- return useMemo(() => {
241
- if (loading) {
242
- return <Spin />;
243
- }
244
- return (
245
- <div
246
- style={{
247
- maxWidth: "300px",
248
- whiteSpace: "break-spaces",
249
- lineHeight: "30px",
250
- }}
251
- >
252
- {tags}
253
- </div>
254
- );
255
- }, [tags, loading]);
256
- };
257
-
258
- export const COLUMN_COMPONENTS = {
259
- boolean: BooleanComponent,
260
- many2one: Many2OneComponent,
261
- text: TextComponent,
262
- one2many: One2ManyComponent,
263
- many2many: One2ManyComponent,
264
- progressbar: ProgressBarComponent,
265
- float_time: FloatTimeComponent,
266
- image: ImageComponent,
267
- integer: NumberComponent,
268
- float: NumberComponent,
269
- reference: ReferenceComponent,
270
- tag: TagComponent,
271
- selection: SelectionComponent,
272
- date: DateComponent,
273
- datetime: DateTimeComponent,
274
- avatar: AvatarComponent,
275
- tags: TagsComponent,
276
- };
@@ -1,16 +0,0 @@
1
- import { DatePicker } from "antd";
2
-
3
- import React from "react";
4
- import Field from "@/common/Field";
5
- import { WidgetProps } from "@/types";
6
-
7
- export const DateRangePicker = (props: WidgetProps) => {
8
- return (
9
- <Field {...props} layout={"vertical"}>
10
- <DatePicker.RangePicker
11
- allowEmpty={[true, true]}
12
- format={"DD/MM/YYYY"}
13
- ></DatePicker.RangePicker>
14
- </Field>
15
- );
16
- };
@@ -1,87 +0,0 @@
1
- import { DatePicker, Row, Col } from "antd";
2
- import Field from "@/common/Field";
3
- import { Field as FieldOoui, Label as LabelOoui } from "@gisce/ooui";
4
- import { WidgetProps } from "@/types";
5
- import Label from "@/widgets/base/Label";
6
- import { TimePicker } from "../../../common/TimePicker";
7
-
8
- export const DateTimeRangePicker = (props: WidgetProps) => {
9
- const { ooui, showLabel = false } = props;
10
- const { label, id } = ooui;
11
-
12
- const fields = [
13
- new FieldOoui({
14
- name: id + "#date",
15
- label: "",
16
- }),
17
- new FieldOoui({
18
- name: id + "#time",
19
- label: "",
20
- }),
21
- ];
22
-
23
- return (
24
- <>
25
- {showLabel && (
26
- <Label
27
- ooui={
28
- new LabelOoui({
29
- name: id + "_label",
30
- string: label,
31
- help: ooui.tooltip,
32
- fieldForLabel: id,
33
- })
34
- }
35
- align={"left"}
36
- />
37
- )}
38
- <Row align={"bottom"} className="p-0">
39
- <Col className="mr-2">
40
- <Field {...props} ooui={fields[0]} showLabel={false}>
41
- <DatePicker.RangePicker
42
- className="w-60"
43
- allowEmpty={[true, true]}
44
- format={"DD/MM/YYYY"}
45
- ></DatePicker.RangePicker>
46
- </Field>
47
- </Col>
48
- <Col>
49
- <Field {...props} ooui={fields[1]} showLabel={false}>
50
- <TimeRangePicker />
51
- </Field>
52
- </Col>
53
- </Row>
54
- </>
55
- );
56
- };
57
-
58
- const TimeRangePicker = ({
59
- value,
60
- onChange,
61
- }: {
62
- value?: any;
63
- onChange?: (newValue: any) => void;
64
- }) => {
65
- return (
66
- <div style={{ marginTop: 5 }}>
67
- <TimePicker
68
- placeholder="Start time"
69
- format={"HH:mm"}
70
- style={{ width: 115, marginRight: 10 }}
71
- value={value?.[0]}
72
- onChange={(newValue) => {
73
- onChange?.([newValue, value?.[1]]);
74
- }}
75
- />
76
- <TimePicker
77
- placeholder="End time"
78
- style={{ width: 115 }}
79
- format={"HH:mm"}
80
- value={value?.[1]}
81
- onChange={(newValue) => {
82
- onChange?.([value?.[0], newValue]);
83
- }}
84
- />
85
- </div>
86
- );
87
- };
@@ -1,56 +0,0 @@
1
- import React from "react";
2
- import { Row, Col } from "antd";
3
- import { Float } from "@/widgets/base/Float";
4
- import { Integer } from "@/widgets/base/Integer";
5
- import { Integer as IntegerOoui, Label as LabelOoui } from "@gisce/ooui";
6
- import Label from "@/widgets/base/Label";
7
- import { WidgetProps } from "@/types";
8
-
9
- type Props = {
10
- ooui: any;
11
- };
12
-
13
- export function PairFields(props: WidgetProps): React.ReactElement {
14
- const { ooui, showLabel } = props;
15
- const { id, label, tooltip } = ooui;
16
- const Widget = ooui instanceof IntegerOoui ? Integer : Float;
17
-
18
- const getWidget = (suffix: string) => {
19
- return (
20
- <Widget
21
- ooui={{
22
- ...(ooui as any),
23
- id: id + suffix,
24
- label: "",
25
- tooltip: undefined,
26
- }}
27
- layout="vertical"
28
- />
29
- );
30
- };
31
-
32
- return (
33
- <>
34
- {showLabel && (
35
- <Label
36
- ooui={
37
- new LabelOoui({
38
- name: id + "_label",
39
- string: label,
40
- help: tooltip,
41
- fieldForLabel: id,
42
- })
43
- }
44
- align={"left"}
45
- />
46
- )}
47
- <Row align={"bottom"} className="mt-0" wrap={false}>
48
- <Col>{getWidget("#from")}</Col>
49
- <Col className="pb-1">
50
- <span className="pl-2 pr-2 h-full"> - </span>
51
- </Col>
52
- <Col>{getWidget("#to")}</Col>
53
- </Row>
54
- </>
55
- );
56
- }
@@ -1,54 +0,0 @@
1
- import { ReactElement, useContext } from "react";
2
-
3
- import { Row, Col, Button } from "antd";
4
- import {
5
- DownOutlined,
6
- UpOutlined,
7
- SearchOutlined,
8
- ClearOutlined,
9
- } from "@ant-design/icons";
10
-
11
- import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
12
-
13
- type Props = {
14
- advancedFilter: boolean;
15
- isSearching: boolean;
16
- onAdvancedFilterToggle: () => void;
17
- onClear: () => void;
18
- };
19
-
20
- export function SearchBottomBar(props: Props): ReactElement {
21
- const { onAdvancedFilterToggle, advancedFilter, onClear, isSearching } =
22
- props;
23
-
24
- const { t } = useContext(LocaleContext) as LocaleContextType;
25
-
26
- return (
27
- <Row>
28
- <Col span={12} className="text-left pt-4 pb-2 pl-2">
29
- <a className="text-xs" onClick={onAdvancedFilterToggle}>
30
- {advancedFilter ? (
31
- <UpOutlined className="pr-1" />
32
- ) : (
33
- <DownOutlined className="pr-1" />
34
- )}
35
- {advancedFilter ? t("simple_search") : t("advanced_search")}
36
- </a>
37
- </Col>
38
- <Col span={12} className="text-right pb-2">
39
- <Button className="mr-5" icon={<ClearOutlined />} onClick={onClear}>
40
- {t("clear")}
41
- </Button>
42
- <Button
43
- icon={<SearchOutlined />}
44
- loading={isSearching}
45
- className="mr-2"
46
- type="primary"
47
- htmlType="submit"
48
- >
49
- {t("search")}
50
- </Button>
51
- </Col>
52
- </Row>
53
- );
54
- }
@@ -1,63 +0,0 @@
1
- import React, { useContext } from "react";
2
-
3
- import { Char } from "@/widgets/base/Char";
4
- import { Selection } from "@/widgets/base/Selection";
5
- import { DateRangePicker } from "./DateRangePicker";
6
- import { DateTimeRangePicker } from "./DateTimeRangePicker";
7
- import { PairFields } from "./PairFields";
8
-
9
- import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
10
-
11
- import {
12
- Field,
13
- SearchFieldTypes,
14
- Selection as SelectionOoui,
15
- } from "@gisce/ooui";
16
- import { MultiSelection } from "@/widgets/base/MultiSelection";
17
-
18
- type Props = {
19
- field: Field;
20
- };
21
-
22
- export function SearchField(props: Props) {
23
- const { field } = props;
24
- field.readOnly = false;
25
- field.required = false;
26
-
27
- const { t } = useContext(LocaleContext) as LocaleContextType;
28
-
29
- const widgetType = field.type;
30
-
31
- switch (widgetType) {
32
- case SearchFieldTypes.boolean: {
33
- const ooui = new SelectionOoui({
34
- name: field._id,
35
- string: field.label,
36
- selection: [
37
- ["true", t("true")],
38
- ["false", t("false")],
39
- ],
40
- });
41
-
42
- return <Selection layout="vertical" ooui={ooui} showLabel />;
43
- }
44
- case SearchFieldTypes.float:
45
- case SearchFieldTypes.progressbar:
46
- case SearchFieldTypes.float_time:
47
- case SearchFieldTypes.integer: {
48
- return <PairFields ooui={field} showLabel />;
49
- }
50
- case SearchFieldTypes.date: {
51
- return <DateRangePicker ooui={field} layout="vertical" showLabel />;
52
- }
53
- case SearchFieldTypes.datetime: {
54
- return <DateTimeRangePicker ooui={field} layout="vertical" showLabel />;
55
- }
56
- case SearchFieldTypes.selection: {
57
- return <MultiSelection layout="vertical" ooui={field} showLabel />;
58
- }
59
- default: {
60
- return <Char ooui={field} layout="vertical" showLabel isSearchField />;
61
- }
62
- }
63
- }
@@ -1,160 +0,0 @@
1
- import { useEffect, useRef, useState } from "react";
2
- import { Form, Row, Col, Alert, theme } from "antd";
3
- import useDeepCompareEffect from "use-deep-compare-effect";
4
-
5
- import {
6
- SearchFilter as SearchFilterOoui,
7
- Container,
8
- Field,
9
- } from "@gisce/ooui";
10
-
11
- import { SearchField } from "./SearchField";
12
- import { SearchBottomBar } from "./SearchBottomBar";
13
- import { SearchFields } from "@/types";
14
- import { SearchParams } from "./SearchParams";
15
-
16
- import { getParamsForFields } from "@/helpers/searchHelper";
17
- import Measure from "react-measure";
18
- const { useToken } = theme;
19
-
20
- type Props = {
21
- fields: any;
22
- searchFields: SearchFields;
23
- onClear: () => void;
24
- onSubmit: (values: any) => void;
25
- isSearching: boolean;
26
- limit: number;
27
- offset: number;
28
- onLimitChange?: (limit: number) => void;
29
- searchVisible?: boolean;
30
- setSearchFilterHeight?: (height: number) => void;
31
- searchError?: string;
32
- searchValues?: any;
33
- showLimitOptions?: boolean;
34
- };
35
-
36
- function SearchFilter(props: Props) {
37
- const {
38
- fields,
39
- searchFields = { primary: [], secondary: [] },
40
- onClear,
41
- onSubmit,
42
- isSearching,
43
- offset,
44
- limit,
45
- onLimitChange,
46
- searchVisible,
47
- setSearchFilterHeight,
48
- searchError,
49
- searchValues,
50
- showLimitOptions = true,
51
- } = props;
52
-
53
- const [simpleSearchFields, setSimpleSearchFields] = useState<Container>();
54
- const [advancedSearchFields, setAdvancedSearchFields] = useState<Container>();
55
- const [advancedFilter, setAdvancedFilter] = useState(false);
56
- const sfo = useRef<SearchFilterOoui>();
57
- const { token } = useToken();
58
-
59
- const [form] = Form.useForm();
60
-
61
- useEffect(() => {
62
- form.setFieldsValue(searchValues);
63
- // eslint-disable-next-line react-hooks/exhaustive-deps
64
- }, [searchValues]);
65
-
66
- const getRowsAndCols = () => {
67
- if (!advancedSearchFields) {
68
- return;
69
- }
70
-
71
- const fields = advancedFilter ? advancedSearchFields : simpleSearchFields;
72
- const rows = fields?.rows;
73
-
74
- return rows?.map((row, i) => {
75
- return (
76
- <Row key={i}>
77
- {row.map((item, j) => {
78
- return (
79
- <Col xs={24} className="p-2" xl={6} key={j}>
80
- <SearchField field={item as Field} />
81
- </Col>
82
- );
83
- })}
84
- </Row>
85
- );
86
- });
87
- };
88
-
89
- useDeepCompareEffect(() => {
90
- setAdvancedFilter(false);
91
- sfo.current = new SearchFilterOoui(searchFields, fields);
92
- sfo.current.parse();
93
- setSimpleSearchFields(sfo.current._simpleSearchContainer);
94
- setAdvancedSearchFields(sfo.current._advancedSearchContainer);
95
- }, [fields, searchFields]);
96
-
97
- const rows = getRowsAndCols();
98
-
99
- const onFinish = (values: any) => {
100
- const { limit, offset } = values;
101
- delete values.offset;
102
- delete values.limit;
103
- const newParams = getParamsForFields(
104
- values,
105
- sfo.current?._advancedSearchContainer,
106
- );
107
-
108
- onSubmit({ params: newParams, offset, limit, searchValues: values });
109
- };
110
-
111
- return (
112
- <Measure
113
- bounds
114
- onResize={(contentRect) => {
115
- setSearchFilterHeight?.(contentRect.bounds?.height!);
116
- }}
117
- >
118
- {({ measureRef }) => (
119
- <div ref={measureRef}>
120
- <div style={{ display: searchVisible ? "block" : "none" }}>
121
- <Form
122
- className="p-3 shadow-md"
123
- style={{ borderRadius: token.borderRadius }}
124
- form={form}
125
- onFinish={onFinish}
126
- initialValues={{ offset, limit }}
127
- >
128
- {rows}
129
- {advancedFilter && showLimitOptions && (
130
- <SearchParams onLimitChange={onLimitChange} />
131
- )}
132
- <SearchBottomBar
133
- advancedFilter={advancedFilter}
134
- onAdvancedFilterToggle={() => {
135
- setAdvancedFilter(!advancedFilter);
136
- }}
137
- onClear={() => {
138
- form.resetFields();
139
- onClear();
140
- }}
141
- isSearching={isSearching}
142
- />
143
- </Form>
144
- {searchError && (
145
- <Alert
146
- className="mt-10"
147
- message={searchError}
148
- type="error"
149
- banner
150
- />
151
- )}
152
- <div className="pb-5" />
153
- </div>
154
- </div>
155
- )}
156
- </Measure>
157
- );
158
- }
159
-
160
- export default SearchFilter;