@gisce/react-ooui 1.2.0-rc.4 → 1.2.0-rc.6

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ActionView.d.ts","sourceRoot":"","sources":["ActionView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAIf,OAAO,EAIL,eAAe,EAGf,QAAQ,EACT,MAAM,eAAe,CAAC;AAiBvB,aAAK,KAAK,GAAG;IACX,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,WAAW,EAAE,eAAe,CAAC;IAC7B,iBAAiB,CAAC,EAAE,GAAG,CAAC;IACxB,gBAAgB,CAAC,EAAE,GAAG,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;;AAkbF,wBAAsC"}
1
+ {"version":3,"file":"ActionView.d.ts","sourceRoot":"","sources":["ActionView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAIf,OAAO,EAIL,eAAe,EAGf,QAAQ,EACT,MAAM,eAAe,CAAC;AAkBvB,aAAK,KAAK,GAAG;IACX,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,WAAW,EAAE,eAAe,CAAC;IAC7B,iBAAiB,CAAC,EAAE,GAAG,CAAC;IACxB,gBAAgB,CAAC,EAAE,GAAG,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;;AA4bF,wBAAsC"}
@@ -8,7 +8,6 @@ export declare type ExportModalProps = {
8
8
  model: string;
9
9
  domain: any[];
10
10
  limit?: number;
11
- treeFields?: any;
12
11
  context?: any;
13
12
  };
14
13
  export declare const ExportModal: (props: ExportModalProps) => JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"ExportModal.d.ts","sourceRoot":"","sources":["ExportModal.tsx"],"names":[],"mappings":";AAWA,oBAAY,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,WAAW,UAAW,gBAAgB,gBA6FlD,CAAC"}
1
+ {"version":3,"file":"ExportModal.d.ts","sourceRoot":"","sources":["ExportModal.tsx"],"names":[],"mappings":";AAWA,oBAAY,gBAAgB,GAAG;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,GAAG,EAAE,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,GAAG,CAAC;CACf,CAAC;AAEF,eAAO,MAAM,WAAW,UAAW,gBAAgB,gBAgGlD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.2.0-rc.4",
3
+ "version": "1.2.0-rc.6",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@ant-design/plots": "^1.0.9",
39
39
  "@gisce/ooui": "^0.17.7",
40
- "@gisce/react-formiga-components": "^1.0.9-rc.8",
40
+ "@gisce/react-formiga-components": "^1.0.9-rc.9",
41
41
  "@gisce/react-formiga-table": "^0.5.0",
42
42
  "@monaco-editor/react": "^4.4.5",
43
43
  "@tabler/icons": "^1.96.0",
@@ -61,7 +61,6 @@ function TreeActionBar(props: Props) {
61
61
  previousView,
62
62
  results,
63
63
  limit,
64
- totalItems,
65
64
  } = useContext(ActionViewContext) as ActionViewContextType;
66
65
 
67
66
  const { parentContext = {}, treeExpandable, toolbar } = props;
@@ -73,6 +72,10 @@ function TreeActionBar(props: Props) {
73
72
  const { processAction } = contentRootContext || {};
74
73
  const [exportModalVisible, setExportModalVisible] = useState(false);
75
74
 
75
+ const hasNameSearch: boolean =
76
+ searchTreeNameSearch !== undefined &&
77
+ searchTreeNameSearch.trim().length > 0;
78
+
76
79
  function tryDelete() {
77
80
  showConfirmDialog({
78
81
  confirmMessage: t("confirmRemove"),
@@ -239,6 +242,43 @@ function TreeActionBar(props: Props) {
239
242
  </>
240
243
  )}
241
244
  {separator()}
245
+ <DropdownButton
246
+ icon={<ThunderboltOutlined />}
247
+ disabled={
248
+ !(selectedRowItems && selectedRowItems?.length > 0) || treeIsLoading
249
+ }
250
+ tooltip={t("actions")}
251
+ items={toolbar?.action}
252
+ onItemClick={(action: any) => {
253
+ if (!action) {
254
+ return;
255
+ }
256
+
257
+ runAction(action);
258
+ }}
259
+ />
260
+ <DropdownButton
261
+ icon={<PrinterOutlined />}
262
+ disabled={
263
+ !(selectedRowItems && selectedRowItems?.length > 0) || treeIsLoading
264
+ }
265
+ tooltip={t("reports")}
266
+ items={toolbar?.print}
267
+ onItemClick={(report: any) => {
268
+ if (!report) {
269
+ return;
270
+ }
271
+
272
+ runAction({
273
+ ...report,
274
+ datas: {
275
+ ...(report.datas || {}),
276
+ ids: selectedRowItems!.map((item) => item.id),
277
+ },
278
+ });
279
+ }}
280
+ />
281
+ {separator()}
242
282
  <DropdownButton
243
283
  icon={
244
284
  <Icon
@@ -246,12 +286,12 @@ function TreeActionBar(props: Props) {
246
286
  <svg
247
287
  xmlns="http://www.w3.org/2000/svg"
248
288
  className="icon icon-tabler icon-tabler-database-export"
249
- width="18"
250
- height="18"
289
+ width="1em"
290
+ height="1em"
251
291
  viewBox="0 0 24 24"
252
292
  stroke-width="1.5"
253
- stroke="#2c3e50"
254
293
  fill="none"
294
+ stroke="currentColor"
255
295
  stroke-linecap="round"
256
296
  stroke-linejoin="round"
257
297
  >
@@ -267,74 +307,56 @@ function TreeActionBar(props: Props) {
267
307
  items={[
268
308
  {
269
309
  id: "print_screen",
270
- name: "Imprimir pantalla",
310
+ name: t("printScreen"),
271
311
  },
272
312
  {
273
313
  id: "export",
274
- name: "Exportación avanzada",
314
+ name: t("advancedExport"),
275
315
  },
276
316
  ]}
277
- onItemClick={(action: any) => {
278
- if (!action) {
279
- return;
280
- }
317
+ onItemClick={(itemClicked: any) => {
318
+ if (itemClicked.id === "print_screen") {
319
+ let idsToExport = selectedRowItems?.map((item) => item.id) || [];
281
320
 
282
- runAction(action);
283
- }}
284
- disabled={duplicatingItem || removingItem || treeIsLoading}
285
- />
286
- {separator()}
287
- <DropdownButton
288
- icon={<ThunderboltOutlined />}
289
- disabled={
290
- !(selectedRowItems && selectedRowItems?.length > 0) || treeIsLoading
291
- }
292
- tooltip={t("actions")}
293
- items={toolbar?.action}
294
- onItemClick={(action: any) => {
295
- if (!action) {
321
+ if (idsToExport.length === 0) {
322
+ idsToExport = results?.map((item) => item.id) || [];
323
+ }
324
+
325
+ runAction({
326
+ id: -1,
327
+ model: currentModel,
328
+ report_name: "printscreen.list",
329
+ type: "ir.actions.report.xml",
330
+ datas: {
331
+ model: currentModel,
332
+ ids: idsToExport,
333
+ },
334
+ });
296
335
  return;
297
336
  }
298
337
 
299
- runAction(action);
338
+ setExportModalVisible(true);
300
339
  }}
301
- />
302
- <DropdownButton
303
- icon={<PrinterOutlined />}
304
340
  disabled={
305
- !(selectedRowItems && selectedRowItems?.length > 0) || treeIsLoading
341
+ duplicatingItem || removingItem || treeIsLoading || hasNameSearch
306
342
  }
307
- tooltip={t("reports")}
308
- items={toolbar?.print}
309
- onItemClick={(report: any) => {
310
- if (!report) {
311
- return;
312
- }
313
-
314
- runAction({
315
- ...report,
316
- datas: {
317
- ...(report.datas || {}),
318
- ids: selectedRowItems!.map((item) => item.id),
319
- },
320
- });
321
- }}
322
343
  />
323
344
  <ExportModal
324
345
  visible={exportModalVisible}
325
346
  locale={lang}
326
347
  onClose={() => setExportModalVisible(false)}
327
348
  model={currentModel!}
328
- treeFields={searchTreeRef?.current?.getFields()}
329
349
  domain={mergeParams(
330
350
  searchTreeRef?.current?.getDomain() || [],
331
351
  searchParams || []
332
352
  )}
333
353
  limit={limit}
334
- totalRegisters={totalItems}
354
+ totalRegisters={results?.length || 0}
335
355
  selectedRegistersToExport={
336
- results && results.length && results.length > 0
337
- ? results.length
356
+ selectedRowItems &&
357
+ selectedRowItems.length &&
358
+ selectedRowItems.length > 0
359
+ ? selectedRowItems.length
338
360
  : undefined
339
361
  }
340
362
  context={parentContext}
@@ -86,4 +86,6 @@ export default {
86
86
  totalRegisters: "Registres totals:",
87
87
  export: "Exportar",
88
88
  selectAtLeastOneField: "Selecciona almenys un camp per a l'exportació",
89
+ printScreen: "Imprimir pantalla",
90
+ advancedExport: "Exportació avançada",
89
91
  };
@@ -83,4 +83,6 @@ export default {
83
83
  totalRegisters: "Total registers:",
84
84
  export: "Export",
85
85
  selectAtLeastOneField: "Select at least one field for the export",
86
+ printScreen: "Print screen",
87
+ advancedExport: "Advanced export",
86
88
  };
@@ -87,4 +87,6 @@ export default {
87
87
  totalRegisters: "Registros totales:",
88
88
  export: "Exportar",
89
89
  selectAtLeastOneField: "Selecciona al menos un campo para la exportación",
90
+ printScreen: "Imprimir pantalla",
91
+ advancedExport: "Exportación avanzada",
90
92
  };
@@ -28,6 +28,7 @@ import {
28
28
  import { useHotkeys } from "react-hotkeys-hook";
29
29
  import { GoToResourceModal } from "@/ui/GoToResourceModal";
30
30
  import showInfo from "@/ui/InfoDialog";
31
+ import showErrorDialog from "@/ui/ActionErrorDialog";
31
32
  import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
32
33
  import { GraphActionView } from "@/views/actionViews/GraphActionView";
33
34
  import { FormActionView } from "./actionViews/FormActionView";
@@ -191,6 +192,7 @@ function ActionView(props: Props, ref: any) {
191
192
  case "form": {
192
193
  viewDataRetrieved.push({
193
194
  ...(viewInfo as FormView),
195
+ type: viewType,
194
196
  });
195
197
  break;
196
198
  }
@@ -198,12 +200,14 @@ function ActionView(props: Props, ref: any) {
198
200
  viewDataRetrieved.push({
199
201
  ...(viewInfo as TreeView),
200
202
  isExpandable: treeExpandable,
203
+ type: viewType,
201
204
  });
202
205
  break;
203
206
  }
204
207
  case "graph": {
205
208
  viewDataRetrieved.push({
206
209
  ...(viewInfo as GraphView),
210
+ type: viewType,
207
211
  });
208
212
  break;
209
213
  }
@@ -211,18 +215,18 @@ function ActionView(props: Props, ref: any) {
211
215
  break;
212
216
  }
213
217
  }
218
+ let currentViewToAssign = undefined;
214
219
 
215
220
  if (!initialView && viewDataRetrieved.find((v) => v.type === "tree")) {
216
221
  const treeView: TreeView = viewDataRetrieved.find(
217
222
  (v) => v.type === "tree"
218
223
  ) as TreeView;
219
- setCurrentView(treeView);
224
+ currentViewToAssign = treeView;
220
225
  } else if (!initialView) {
221
226
  const formView: TreeView = viewDataRetrieved.find(
222
227
  (v) => v.type === "form"
223
228
  ) as TreeView;
224
-
225
- setCurrentView(formView);
229
+ currentViewToAssign = formView;
226
230
  } else {
227
231
  const view = viewDataRetrieved.find((v) => {
228
232
  if (!initialView.id) {
@@ -231,9 +235,16 @@ function ActionView(props: Props, ref: any) {
231
235
  return v.type === initialView.type && v.view_id === initialView.id;
232
236
  }
233
237
  });
234
- setCurrentView(view);
238
+ currentViewToAssign = view;
239
+ }
240
+
241
+ if (!currentViewToAssign) {
242
+ showErrorDialog(
243
+ "Error determining the first view to show.\nPlease, make sure the view ids on the fields_view_get responses are the same as the ones defined in the action"
244
+ );
235
245
  }
236
246
 
247
+ setCurrentView(currentViewToAssign);
237
248
  setAvailableViews(viewDataRetrieved);
238
249
  setIsLoading(false);
239
250
  };
@@ -18,7 +18,6 @@ export type ExportModalProps = {
18
18
  model: string;
19
19
  domain: any[];
20
20
  limit?: number;
21
- treeFields?: any;
22
21
  context?: any;
23
22
  };
24
23
 
@@ -29,7 +28,6 @@ export const ExportModal = (props: ExportModalProps) => {
29
28
  onClose,
30
29
  model,
31
30
  context,
32
- treeFields,
33
31
  selectedRegistersToExport,
34
32
  totalRegisters,
35
33
  domain,
@@ -77,13 +75,18 @@ export const ExportModal = (props: ExportModalProps) => {
77
75
  async ({ key, title }: any) => {
78
76
  let fieldDefinition;
79
77
 
80
- if (key.indexOf("/") === -1) {
78
+ const sanitizedKey =
79
+ key.split("/")[key.split("/").length - 1] === "id"
80
+ ? key.split("/").slice(0, -1).join("/")
81
+ : key;
82
+
83
+ if (sanitizedKey.indexOf("/") === -1) {
81
84
  fieldDefinition = fields.current["/"];
82
85
  } else {
83
- fieldDefinition = fields.current[getParentKey(key)];
86
+ fieldDefinition = fields.current[getParentKey(sanitizedKey)];
84
87
  }
85
88
 
86
- const optsForField = fieldDefinition[getChildKey(key)];
89
+ const optsForField = fieldDefinition[getChildKey(sanitizedKey)];
87
90
  const relation = optsForField.relation;
88
91
  const viewData = await ConnectionProvider.getHandler().getFields({
89
92
  model: relation,
@@ -91,12 +94,12 @@ export const ExportModal = (props: ExportModalProps) => {
91
94
  fields: [],
92
95
  });
93
96
 
94
- fields.current[key] = viewData;
97
+ fields.current[sanitizedKey] = viewData;
95
98
 
96
99
  return convertToExportField({
97
100
  fields: viewData,
98
101
  parentTitle: title,
99
- parentKey: key,
102
+ parentKey: sanitizedKey,
100
103
  });
101
104
  },
102
105
  [fields, model, context]
@@ -112,7 +115,6 @@ export const ExportModal = (props: ExportModalProps) => {
112
115
  totalRegisters={totalRegisters}
113
116
  onGetFieldChilds={onGetFieldChilds}
114
117
  onGetFields={onGetFields}
115
- selectedKeys={treeFields ? Object.keys(treeFields) : undefined}
116
118
  />
117
119
  );
118
120
  };
@@ -130,13 +132,24 @@ const convertToExportField = ({
130
132
 
131
133
  for (const key of Object.keys(fields)) {
132
134
  const valuesForField = fields[key];
135
+
136
+ if (valuesForField.relation && valuesForField.is_function === true) {
137
+ continue;
138
+ }
139
+
133
140
  const relationField =
134
141
  valuesForField.type === "many2one" ||
135
142
  valuesForField.type === "one2many" ||
136
143
  valuesForField.type === "many2many";
137
144
 
145
+ let newKey = `${parentKey ? parentKey + "/" : ""}${key}`;
146
+
147
+ if (relationField) {
148
+ newKey += "/id";
149
+ }
150
+
138
151
  exportFields.push({
139
- key: `${parentKey ? parentKey + "/" : ""}${key}`,
152
+ key: newKey,
140
153
  title: `${parentTitle ? parentTitle + "/" : ""}${valuesForField.string}`,
141
154
  tooltip: valuesForField.help,
142
155
  required: valuesForField.required,