@gisce/react-ooui 1.0.20 → 1.1.1

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 +2 -2
  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,404 @@
1
+ import { mergeParams } from "@/helpers/searchHelper";
2
+ import {
3
+ getColorMap,
4
+ getTableItems,
5
+ getTree,
6
+ sortResults,
7
+ } from "@/helpers/treeHelper";
8
+ import { useState, useCallback, useRef } from "react";
9
+ import { ConnectionProvider, FormView, TreeView } from "..";
10
+
11
+ type UseSearchOpts = {
12
+ model: string;
13
+ setSearchTreeNameSearch?: (searchString?: string) => void;
14
+ setSelectedRowItems?: (value: any[]) => void;
15
+ searchParams?: any[];
16
+ setSearchParams?: (value: any[]) => void;
17
+ setSearchVisible?: (value: boolean) => void;
18
+ setTreeIsLoading?: (value: boolean) => void;
19
+ nameSearch?: string;
20
+ searchNameGetDoneRef?: any;
21
+ context?: any;
22
+ setActionViewTotalItems?: (totalItems: number) => void;
23
+ formView: FormView;
24
+ treeView: TreeView;
25
+ sorter: any;
26
+ setSorter?: (sorter: any) => void;
27
+ setCurrentItemIndex?: (value?: number) => void;
28
+ setResultsActionView?: (value: any[]) => void;
29
+ resultsActionView?: any[];
30
+ domain: any;
31
+ currentId?: number;
32
+ limitFromAction?: number;
33
+ limit?: number;
34
+ setLimit?: (value: number) => void;
35
+ setSearchValues?: (value: any) => void;
36
+ };
37
+
38
+ export const DEFAULT_SEARCH_LIMIT = 80;
39
+
40
+ export const useSearch = (opts: UseSearchOpts) => {
41
+ const {
42
+ model,
43
+ setSearchTreeNameSearch,
44
+ setSelectedRowItems,
45
+ setSearchParams,
46
+ setSearchVisible,
47
+ setTreeIsLoading,
48
+ nameSearch,
49
+ searchNameGetDoneRef,
50
+ context,
51
+ setActionViewTotalItems,
52
+ treeView,
53
+ formView,
54
+ sorter,
55
+ setSorter,
56
+ setCurrentItemIndex,
57
+ setResultsActionView,
58
+ resultsActionView,
59
+ domain,
60
+ currentId,
61
+ limitFromAction,
62
+ limit,
63
+ setLimit,
64
+ searchParams = [],
65
+ setSearchValues,
66
+ } = opts;
67
+
68
+ const [tableRefreshing, setTableRefreshing] = useState<boolean>(false);
69
+ const [searchFilterLoading, setSearchFilterLoading] =
70
+ useState<boolean>(false);
71
+ const [searchError, setSearchError] = useState<string>();
72
+ const [page, setPage] = useState<number>(1);
73
+ const [offset, setOffset] = useState<number>(0);
74
+ const [totalItems, setTotalItems] = useState<number>();
75
+ const [resultsInternal, setResultsInternal] = useState<any>([]);
76
+ const [colorsForResults, setColorsForResults] = useState<any>(undefined);
77
+
78
+ const originalResults = useRef<any[]>([]);
79
+ const internalLimit = useRef(80);
80
+ const actionDomain = useRef<any>([]);
81
+
82
+ const setResults = useCallback((results: any) => {
83
+ setResultsActionView?.([...results]);
84
+ setResultsInternal([...results]);
85
+ }, []);
86
+
87
+ const getResults = useCallback(() => {
88
+ if (!resultsActionView) {
89
+ return resultsInternal;
90
+ }
91
+ return resultsActionView;
92
+ }, [resultsActionView, resultsInternal]);
93
+
94
+ const searchByNameSearch = useCallback(async () => {
95
+ const searchResults = await ConnectionProvider.getHandler().nameSearch({
96
+ model,
97
+ payload: nameSearch,
98
+ limit: internalLimit.current,
99
+ attrs: actionDomain.current.length > 0 ? actionDomain.current : domain,
100
+ context,
101
+ });
102
+
103
+ setTotalItems(searchResults.length);
104
+ setActionViewTotalItems?.(searchResults.length);
105
+
106
+ if (searchResults.length > 0) {
107
+ const resultsIds = searchResults.map((item: any) => {
108
+ return item?.[0];
109
+ });
110
+
111
+ const { colors } = getTree(treeView!);
112
+
113
+ const resultsWithData =
114
+ await ConnectionProvider.getHandler().readEvalUiObjects({
115
+ model,
116
+ ids: resultsIds,
117
+ arch: treeView?.arch!,
118
+ fields: treeView!.field_parent
119
+ ? { ...treeView!.fields, [treeView!.field_parent]: {} }
120
+ : treeView!.fields,
121
+ context,
122
+ attrs: colors && {
123
+ colors,
124
+ },
125
+ });
126
+ const resultsData = resultsWithData[0];
127
+
128
+ originalResults.current = [...resultsData];
129
+
130
+ setColorsForResults(getColorMap(resultsWithData[1]));
131
+
132
+ const newResultIds = resultsData.map((item: any) => item.id);
133
+
134
+ const resultsSorted =
135
+ sorter !== undefined
136
+ ? sortResults({
137
+ resultsToSort: resultsData,
138
+ sorter,
139
+ fields: { ...treeView!.fields, ...formView!.fields },
140
+ })
141
+ : [...originalResults.current];
142
+
143
+ setResults(resultsSorted);
144
+
145
+ if (newResultIds.length > 0) {
146
+ setCurrentItemIndex?.(0);
147
+ } else {
148
+ setCurrentItemIndex?.(undefined);
149
+ }
150
+ } else {
151
+ setResults([]);
152
+ setCurrentItemIndex?.(undefined);
153
+ }
154
+
155
+ searchNameGetDoneRef.current = true;
156
+ }, [
157
+ setResults,
158
+ searchNameGetDoneRef,
159
+ nameSearch,
160
+ model,
161
+ context,
162
+ domain,
163
+ treeView,
164
+ formView,
165
+ sorter,
166
+ setCurrentItemIndex,
167
+ setActionViewTotalItems,
168
+ internalLimit,
169
+ actionDomain,
170
+ ]);
171
+
172
+ const searchResults = useCallback(async () => {
173
+ const domainParams =
174
+ actionDomain.current.length > 0 ? actionDomain.current : domain;
175
+
176
+ const mergedParams = mergeParams(searchParams, domainParams);
177
+ const { colors } = getTree(treeView!);
178
+
179
+ const { totalItems, results, attrsEvaluated } =
180
+ await ConnectionProvider.getHandler().searchForTree({
181
+ params: mergedParams,
182
+ limit,
183
+ offset,
184
+ model,
185
+ fields: treeView!.field_parent
186
+ ? { ...treeView!.fields, [treeView!.field_parent]: {} }
187
+ : treeView!.fields,
188
+ context,
189
+ attrs: colors && { colors },
190
+ });
191
+ setColorsForResults(getColorMap(attrsEvaluated));
192
+
193
+ originalResults.current = [...results];
194
+
195
+ const resultsSorted =
196
+ sorter !== undefined
197
+ ? sortResults({
198
+ resultsToSort: results,
199
+ sorter: sorter,
200
+ fields: { ...treeView!.fields, ...formView!.fields },
201
+ })
202
+ : [...originalResults.current];
203
+
204
+ setResults(resultsSorted);
205
+
206
+ if (resultsActionView && resultsSorted.length > 0) {
207
+ const newCurrentItemIndex = resultsSorted.findIndex(
208
+ (item) => currentId === item.id
209
+ );
210
+
211
+ if (newCurrentItemIndex === -1) {
212
+ setCurrentItemIndex?.(0);
213
+ } else {
214
+ setCurrentItemIndex?.(newCurrentItemIndex);
215
+ }
216
+ } else {
217
+ setCurrentItemIndex?.(undefined);
218
+ }
219
+
220
+ const totalItemsValue = await totalItems;
221
+
222
+ setTotalItems(totalItemsValue);
223
+ setActionViewTotalItems?.(totalItemsValue);
224
+ }, [
225
+ setCurrentItemIndex,
226
+ resultsActionView,
227
+ setResults,
228
+ currentId,
229
+ model,
230
+ context,
231
+ domain,
232
+ treeView,
233
+ formView,
234
+ sorter,
235
+ setActionViewTotalItems,
236
+ limit,
237
+ offset,
238
+ actionDomain,
239
+ searchParams,
240
+ ]);
241
+
242
+ const fetchResults = useCallback(async () => {
243
+ try {
244
+ setTableRefreshing(true);
245
+ setTreeIsLoading?.(true);
246
+ if (nameSearch && !searchNameGetDoneRef.current) {
247
+ await searchByNameSearch();
248
+ } else {
249
+ await searchResults();
250
+ }
251
+ } catch (error) {
252
+ setSearchError(error.message);
253
+ } finally {
254
+ setTableRefreshing(false);
255
+ setSearchFilterLoading(false);
256
+ setTreeIsLoading?.(false);
257
+ }
258
+ }, [
259
+ actionDomain,
260
+ context,
261
+ currentId,
262
+ domain,
263
+ formView,
264
+ internalLimit,
265
+ limit,
266
+ model,
267
+ nameSearch,
268
+ offset,
269
+ resultsActionView,
270
+ searchNameGetDoneRef,
271
+ setActionViewTotalItems,
272
+ setCurrentItemIndex,
273
+ setResults,
274
+ setSearchError,
275
+ setSearchFilterLoading,
276
+ setTableRefreshing,
277
+ setTreeIsLoading,
278
+ sorter,
279
+ treeView,
280
+ ]);
281
+
282
+ const changeSort = useCallback(
283
+ (newSorter: any) => {
284
+ setSorter?.(newSorter);
285
+ const sortedResults =
286
+ newSorter !== undefined
287
+ ? sortResults({
288
+ resultsToSort: getResults(),
289
+ sorter: newSorter,
290
+ fields: { ...treeView.fields, ...formView.fields },
291
+ })
292
+ : [...originalResults.current];
293
+ setResults(sortedResults);
294
+ },
295
+ [setSorter, getResults, treeView, formView, setResults]
296
+ );
297
+
298
+ const submit = useCallback(
299
+ ({
300
+ params: newParams,
301
+ limit: newLimit,
302
+ offset: newOffset,
303
+ searchValues,
304
+ }: {
305
+ params: any;
306
+ limit: number;
307
+ offset: number;
308
+ searchValues: any;
309
+ }) => {
310
+ if (tableRefreshing) return;
311
+ setSearchTreeNameSearch?.(undefined);
312
+ setSelectedRowItems?.([]);
313
+ setSearchValues?.(searchValues);
314
+ setSearchParams?.(newParams);
315
+ setSearchVisible?.(false);
316
+ setSearchFilterLoading(true);
317
+ setSearchError(undefined);
318
+ setPage(1);
319
+ if (newLimit) setLimit?.(newLimit);
320
+ if (newOffset) setOffset(newOffset);
321
+ fetchResults();
322
+ },
323
+ [
324
+ tableRefreshing,
325
+ setSearchTreeNameSearch,
326
+ setSelectedRowItems,
327
+ setSearchParams,
328
+ setSearchVisible,
329
+ setSearchFilterLoading,
330
+ setSearchError,
331
+ setPage,
332
+ setLimit,
333
+ setOffset,
334
+ fetchResults,
335
+ ]
336
+ );
337
+
338
+ const requestPageChange = useCallback(
339
+ (page: number) => {
340
+ setTableRefreshing(true);
341
+ setPage(page);
342
+ setOffset((page - 1) * limit!);
343
+ },
344
+ [setTableRefreshing, limit, setOffset, setPage]
345
+ );
346
+
347
+ const clear = useCallback(() => {
348
+ if (tableRefreshing) return;
349
+ setSearchTreeNameSearch?.(undefined);
350
+ setSearchParams?.([]);
351
+ setSearchValues?.({});
352
+ setSearchError(undefined);
353
+ setOffset(0);
354
+ setPage(1);
355
+ setLimit?.(limitFromAction || DEFAULT_SEARCH_LIMIT);
356
+ }, [
357
+ tableRefreshing,
358
+ setSearchTreeNameSearch,
359
+ setSearchParams,
360
+ setSearchError,
361
+ setOffset,
362
+ setPage,
363
+ setLimit,
364
+ limitFromAction,
365
+ ]);
366
+
367
+ const fetchChildrenForRecord = useCallback(
368
+ async (record: any) => {
369
+ const child_id = record[treeView?.field_parent || "child_id"];
370
+
371
+ const children = await ConnectionProvider.getHandler().readObjects({
372
+ model,
373
+ ids: child_id,
374
+ fields: treeView!.field_parent
375
+ ? { ...treeView!.fields, [treeView!.field_parent]: {} }
376
+ : treeView!.fields,
377
+ context,
378
+ });
379
+
380
+ setResults([...getResults(), ...children]);
381
+
382
+ return getTableItems(getTree(treeView!), children);
383
+ },
384
+ [treeView, model, context, getResults, setResults]
385
+ );
386
+
387
+ return {
388
+ submit,
389
+ clear,
390
+ fetchResults,
391
+ tableRefreshing,
392
+ searchFilterLoading,
393
+ searchError,
394
+ page,
395
+ offset,
396
+ limit,
397
+ getResults,
398
+ requestPageChange,
399
+ changeSort,
400
+ fetchChildrenForRecord,
401
+ colorsForResults,
402
+ totalItems,
403
+ };
404
+ };
@@ -83,4 +83,5 @@ export default {
83
83
  openAttachment: "Veure detall de l'adjunt",
84
84
  openAttachmentLink: "Obrir enllaç de l'adjunt",
85
85
  uninformed: "Sense informar",
86
+ totalRegisters: "Registres totals:",
86
87
  };
@@ -80,4 +80,5 @@ export default {
80
80
  openAttachment: "Open attachment detail",
81
81
  openAttachmentLink: "Open attachment link",
82
82
  uninformed: "Uninformed",
83
+ totalRegisters: "Total registers:",
83
84
  };
@@ -84,4 +84,5 @@ export default {
84
84
  openAttachment: "Ver detalle del adjunto",
85
85
  openAttachmentLink: "Abrir enlace del adjunto",
86
86
  uninformed: "Sin informar",
87
+ totalRegisters: "Registros totales:",
87
88
  };
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+
3
+ import { Form } from "../..";
4
+ import LocaleProvider from "../../context/LocaleContext";
5
+
6
+ export default {
7
+ title: "Components/Widgets/Forms/ActivacioContracte",
8
+ };
9
+
10
+ export const Default = (): React.ReactElement => {
11
+ return (
12
+ <LocaleProvider lang="en_US">
13
+ <Form
14
+ id={6}
15
+ model={"giscedata.polissa.crear.contracte"}
16
+ onCancel={() => {
17
+ console.log();
18
+ }}
19
+ onSubmitSucceed={(value: any) => {
20
+ console.log();
21
+ }}
22
+ />
23
+ </LocaleProvider>
24
+ );
25
+ };
@@ -14,6 +14,7 @@ import attachment from "./models/attachment";
14
14
  import crm_case from "./models/crm_case";
15
15
  import form_with_gridfiber from "./models/form_with_gridfiber";
16
16
  import partner_category from "./models/res_partner_category";
17
+ import activacioContracte from "./models/activacioContracte";
17
18
 
18
19
  const allModels = [
19
20
  cups,
@@ -32,6 +33,7 @@ const allModels = [
32
33
  crm_case,
33
34
  form_with_gridfiber,
34
35
  partner_category,
36
+ activacioContracte,
35
37
  ];
36
38
 
37
39
  const getMock = (model: string) => {
@@ -0,0 +1,112 @@
1
+ export default {
2
+ model: "giscedata.polissa.crear.contracte",
3
+ exampleValues: {
4
+ id: 6,
5
+ accio: "nou",
6
+ data_final: undefined,
7
+ duracio: undefined,
8
+ data_firma_contracte: "2017-06-01 00:00:00",
9
+ data_inici: "2022-10-05",
10
+ first_onchange: true,
11
+ observacions:
12
+ "Cambios realizados detectados autom\u00e1ticamente:\n\u2022 C\u00f3digo DH: E2 \u2192 G0\n\u2022 C\u00f3digo Tarifa: 2A \u2192 2T\n",
13
+ state: "ok",
14
+ parent_id: undefined,
15
+ },
16
+ form: {
17
+ arch: '<form string="Activación del contrato">\n <field name="state" invisible="1"/>\n <field name="first_onchange" invisible="1"/>\n <group colspan="4" col="4" attrs="{\'invisible\': [(\'state\', \'=\', \'fail\')]}">\n <field name="accio"/>\n <group colspan="4" col="4" attrs="{\'invisible\': [(\'accio\', \'=\', \'modificar\')]}">\n <label string="Solo cambiar para fechas inferiores a la fecha mostrada, si no se escogerá ésta, ya que es la fecha final del contrato vigente" colspan="4"/>\n <field name="data_inici" attrs="{\'required\': [(\'accio\', \'=\', \'nou\')]}" on_change="onchange_duracio_first(data_inici, duracio, first_onchange, context)"/>\n <field name="duracio" attrs="{\'required\': [(\'accio\', \'=\', \'nou\')]}" on_change="onchange_duracio_first(data_inici, duracio, first_onchange, context)"/>\n <field name="data_final" attrs="{\'required\': [(\'accio\', \'=\', \'nou\')]}"/>\n <field name="data_firma_contracte"/>\n </group>\n <separator colspan="4" string="Observaciones"/>\n <field name="observacions" colspan="4" required="1" nolabel="1" width="600" height="120"/>\n <group col="2" colspan="4">\n <button icon="gtk-cancel" special="cancel" string="Cancelar" name="action_cancel" type="object"/>\n <button icon="gtk-ok" name="action_crear_contracte" string="Crear contrato" type="object"/>\n </group>\n </group>\n <group colspan="4" col="4" attrs="{\'invisible\': [(\'state\', \'=\', \'ok\')]}">\n <group col="1" colspan="1" rowspan="2">\n <image name="gtk-dialog-warning"/>\n </group>\n <group colspan="3" col="3">\n <label colspan="3" string="&lt;b&gt;Atención!&lt;/b&gt;"/>\n <label colspan="3" string="Este contrato tiene modificaciones contractuales en estado &lt;b&gt;pendiente&lt;/b&gt;. No se puede crear otra sin cancelarlas"/>\n <button icon="gtk-close" special="cancel" string="Cerrar" name="action_cancel" type="object"/>\n </group>\n </group>\n </form>',
18
+ field_parent: false,
19
+ fields: {
20
+ accio: {
21
+ required: true,
22
+ selection: [
23
+ ["modificar", "Modificar el contrato existente"],
24
+ ["nou", "Crear una modificaci\u00f3n contractual nueva"],
25
+ ],
26
+ string: "Acci\u00f3n",
27
+ type: "selection",
28
+ views: {},
29
+ },
30
+ data_final: { string: "Fecha final", type: "date", views: {} },
31
+ data_firma_contracte: {
32
+ string: "Fecha firma",
33
+ type: "datetime",
34
+ views: {},
35
+ },
36
+ data_inici: {
37
+ string: "Fecha de activaci\u00f3n",
38
+ type: "date",
39
+ views: {},
40
+ },
41
+ duracio: {
42
+ selection: [
43
+ ["actual", "Final del contrato actual"],
44
+ ["nou", "Nuevo periodo completo de contrato"],
45
+ ],
46
+ string: "Duraci\u00f3n",
47
+ type: "selection",
48
+ views: {},
49
+ },
50
+ first_onchange: { string: "First onchange", type: "boolean", views: {} },
51
+ observacions: {
52
+ required: true,
53
+ string: "Observaciones",
54
+ type: "text",
55
+ views: {},
56
+ },
57
+ state: {
58
+ selection: [
59
+ ["ok", "OK"],
60
+ ["fail", "Error"],
61
+ ],
62
+ string: "Estado",
63
+ type: "selection",
64
+ views: {},
65
+ },
66
+ },
67
+ model: "giscedata.polissa.crear.contracte",
68
+ name: "giscedata.polissa.crear.contracte.form",
69
+ search_fields: { primary: [], secondary: [] },
70
+ toolbar: {
71
+ action: [],
72
+ print: [
73
+ {
74
+ datas: { model: "giscedata.polissa.crear.contracte" },
75
+ id: -1,
76
+ model: "giscedata.polissa.crear.contracte",
77
+ name: "Export to XLSX",
78
+ report_name: "printscreen.list",
79
+ string: "Export to XLSX",
80
+ type: "ir.actions.report.xml",
81
+ },
82
+ ],
83
+ relate: [
84
+ {
85
+ auto_refresh: 0,
86
+ context: "{'active_test': False}",
87
+ domain: "[('id', '=', active_id)]",
88
+ groups_id: [],
89
+ id: -1,
90
+ limit: 0,
91
+ name: "giscedata.polissa.crear.contracte",
92
+ res_model: "giscedata.polissa.crear.contracte",
93
+ src_model: "giscedata.polissa.crear.contracte",
94
+ string: "giscedata.polissa.crear.contracte",
95
+ target: "current",
96
+ type: "ir.actions.act_window",
97
+ usage: "",
98
+ view_id: false,
99
+ view_ids: [],
100
+ view_mode: "tree,form",
101
+ view_type: "form",
102
+ views: [
103
+ [false, "tree"],
104
+ [false, "form"],
105
+ ],
106
+ },
107
+ ],
108
+ },
109
+ type: "form",
110
+ view_id: 476,
111
+ },
112
+ };
@@ -1,3 +1,4 @@
1
+ import { ShortcutApi } from "@/ui/FavouriteButton";
1
2
  import { Field as FieldOoui } from "@gisce/ooui";
2
3
 
3
4
  type Strings = {
@@ -22,7 +23,18 @@ type SearchFields = {
22
23
  secondary: string[];
23
24
  };
24
25
 
25
- type TreeView = {
26
+ export type InitialViewData = {
27
+ id: number;
28
+ type: ViewType;
29
+ };
30
+
31
+ export type BaseView = {
32
+ type: ViewType;
33
+ view_id: number;
34
+ name: string;
35
+ };
36
+
37
+ type TreeView = BaseView & {
26
38
  view_id: number;
27
39
  arch: string;
28
40
  fields: any;
@@ -36,6 +48,26 @@ type FormView = TreeView & {
36
48
  toolbar?: any;
37
49
  };
38
50
 
51
+ export type DashboardView = {
52
+ view_id?: number;
53
+ type: ViewType;
54
+ model: string;
55
+ id: number;
56
+ context?: any;
57
+ configAction?: ShortcutApi;
58
+ };
59
+
60
+ export type DashboardProps = Omit<DashboardView, "type">;
61
+
62
+ export type GraphView = {
63
+ arch: string;
64
+ type: ViewType;
65
+ view_id: number;
66
+ name: string;
67
+ };
68
+
69
+ export type View = TreeView | FormView | DashboardView | GraphView;
70
+
39
71
  type SearchResponse = {
40
72
  totalItems: Promise<number>;
41
73
  results: any[];
@@ -216,7 +248,9 @@ type ConnectionProviderType = {
216
248
  action: string;
217
249
  context?: any;
218
250
  }) => Promise<ViewData>;
219
- getView: (options: GetViewRequest) => Promise<FormView | TreeView>;
251
+ getView: (
252
+ options: GetViewRequest
253
+ ) => Promise<FormView | TreeView | GraphView>;
220
254
  getFields: (options: GetFieldsRequest) => Promise<any>;
221
255
  searchAllIds: (options: SearchAllIdsRequest) => Promise<number[]>;
222
256
  searchCount: (options: SearchCountRequest) => Promise<number>;
@@ -253,7 +287,7 @@ type ConnectionProviderType = {
253
287
  treeButOpen: (options: TreeButOpenOptions) => Promise<any>;
254
288
  };
255
289
 
256
- type ViewType = "tree" | "form" | "dashboard" | "graph";
290
+ type ViewType = "tree" | "form" | "dashboard" | "graph" | "calendar";
257
291
 
258
292
  export type {
259
293
  Strings,
@@ -121,7 +121,7 @@ const FavouriteButton = (props: Props) => {
121
121
  return;
122
122
  }
123
123
 
124
- const view_id = currentView.id;
124
+ const view_id = currentView.view_id!;
125
125
  let res_id: boolean | number = false;
126
126
 
127
127
  if (currentView.type === "form") {
@@ -205,7 +205,7 @@ const FavouriteButton = (props: Props) => {
205
205
 
206
206
  const currentTab = tabs.find((t) => t.key === activeKey);
207
207
  const { id: action_id, type: action_type } = currentTab?.action || {};
208
- const view_id = currentView.id;
208
+ const view_id = currentView.view_id!;
209
209
  let res_id: boolean | number = false;
210
210
 
211
211
  if (!action_id || !action_type) {
@@ -9,11 +9,12 @@ import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
9
9
  const { Title, Text } = Typography;
10
10
 
11
11
  type Props = {
12
+ title?: string;
12
13
  children?: any;
13
14
  };
14
15
 
15
16
  function TitleHeader(props: Props) {
16
- const { children } = props;
17
+ const { title: titleProps, children } = props;
17
18
  const {
18
19
  title,
19
20
  currentView,
@@ -73,13 +74,13 @@ function TitleHeader(props: Props) {
73
74
  return (
74
75
  <div style={{ position: "sticky", top: 80, zIndex: 3 }}>
75
76
  <Row
76
- className="bg-blueGray-100 shadow-md rounded"
77
+ className="rounded shadow-md bg-blueGray-100"
77
78
  style={{ padding: "1em" }}
78
79
  align="middle"
79
80
  >
80
81
  <Col flex={2}>
81
82
  <Title level={3} style={{ marginBottom: 0 }}>
82
- {title}
83
+ {titleProps || title}
83
84
  </Title>
84
85
  {getSummary()}
85
86
  </Col>