@gisce/react-ooui 2.0.0-alpha.26 → 2.0.0-alpha.28

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,6 +1,6 @@
1
1
  type Props = {
2
2
  visible: boolean;
3
- onIdSubmitted: (id: number) => void;
3
+ onIdSubmitted: (ids: number[]) => void;
4
4
  onCancel: () => void;
5
5
  isSearching: boolean;
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"GoToResourceModal.d.ts","sourceRoot":"","sources":["../../src/ui/GoToResourceModal.tsx"],"names":[],"mappings":"AAKA,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAW,KAAK,4CAkE7C,CAAC"}
1
+ {"version":3,"file":"GoToResourceModal.d.ts","sourceRoot":"","sources":["../../src/ui/GoToResourceModal.tsx"],"names":[],"mappings":"AAKA,KAAK,KAAK,GAAG;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAAW,KAAK,4CA+D7C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ActionView.d.ts","sourceRoot":"","sources":["../../src/views/ActionView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAIf,OAAO,EAIL,eAAe,EAGf,QAAQ,EACT,MAAM,eAAe,CAAC;AAoBvB,KAAK,KAAK,GAAG;IACX,MAAM,EAAE,GAAG,CAAC;IACZ,OAAO,EAAE,GAAG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AM,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;;AAkdF,wBAAsC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "2.0.0-alpha.26",
3
+ "version": "2.0.0-alpha.28",
4
4
  "engines": {
5
5
  "node": "20.5.0"
6
6
  },
@@ -48,7 +48,7 @@ export type ActionViewContextType = {
48
48
  setSearchTreeNameSearch?: (searchString?: string) => void;
49
49
  previousView?: View;
50
50
  setPreviousView?: (view: View) => void;
51
- goToResourceId?: (id: number) => Promise<void>;
51
+ goToResourceId?: (ids: number[]) => Promise<void>;
52
52
  searchValues?: any;
53
53
  setSearchValues?: (value: any) => void;
54
54
  limit?: number;
@@ -71,6 +71,7 @@ export default {
71
71
  lastUpdatedDate: "Data última modificació",
72
72
  goToResourceId: "Vés al recurs amb ID",
73
73
  searchId: "ID de cerca:",
74
+ searchIdHelp: "Es pot utiltizar un ID o una llista d'IDs separats per comes",
74
75
  idNotFound: "No es troba aquesta id de recurs per l'objecte",
75
76
  selectedRegisters: "registres seleccionats",
76
77
  translate: "Traduïr",
@@ -69,6 +69,7 @@ export default {
69
69
  lastUpdatedDate: "Date of last modification",
70
70
  goToResourceId: "Go to resource ID",
71
71
  searchId: "Search ID:",
72
+ searchIdHelp: "You can use an ID or a list of IDs separated by commas.",
72
73
  idNotFound: "Resource ID does not exist for this object!",
73
74
  selectedRegisters: "selected registers",
74
75
  translate: "Translate",
@@ -72,6 +72,8 @@ export default {
72
72
  lastUpdatedDate: "Fecha última modificación",
73
73
  goToResourceId: "Ir al recurso con ID",
74
74
  searchId: "ID de búsqueda:",
75
+ searchIdHelp:
76
+ "Se puede utilizar un ID o una lista de IDs separados por comas",
75
77
  idNotFound: "No se encuentra ésta ID de recursos para el objeto",
76
78
  selectedRegisters: "registros seleccionados",
77
79
  translate: "Traducir",
@@ -12,11 +12,12 @@ export const Default = (): React.ReactElement => {
12
12
  <LocaleProvider lang="en_US">
13
13
  <GoToResourceModal
14
14
  visible={true}
15
+ isSearching={false}
15
16
  onCancel={() => {
16
17
  alert("cancel");
17
18
  }}
18
- onIdSubmitted={(id) => {
19
- alert(id);
19
+ onIdSubmitted={(ids) => {
20
+ alert(ids);
20
21
  }}
21
22
  />
22
23
  </LocaleProvider>
@@ -1,11 +1,11 @@
1
1
  import React, { useContext, useRef } from "react";
2
- import { Button, Col, Form, InputNumber, Modal, Row, Space } from "antd";
2
+ import { Button, Col, Form, Input, Modal, Row, Space } from "antd";
3
3
  import { CheckOutlined, CloseOutlined } from "@ant-design/icons";
4
4
  import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
5
5
 
6
6
  type Props = {
7
7
  visible: boolean;
8
- onIdSubmitted: (id: number) => void;
8
+ onIdSubmitted: (ids: number[]) => void;
9
9
  onCancel: () => void;
10
10
  isSearching: boolean;
11
11
  };
@@ -18,7 +18,8 @@ export const GoToResourceModal = (props: Props) => {
18
18
  const inputRef = useRef<null | HTMLElement>();
19
19
 
20
20
  function handleSubmit(values: any) {
21
- onIdSubmitted(values.id);
21
+ const ids = values.id.split(",").map((id: string) => parseInt(id.trim()));
22
+ onIdSubmitted(ids);
22
23
  }
23
24
 
24
25
  return (
@@ -39,15 +40,11 @@ export const GoToResourceModal = (props: Props) => {
39
40
  rules={[
40
41
  {
41
42
  required: true,
42
- type: "number",
43
43
  },
44
44
  ]}
45
+ help={t("searchIdHelp")}
45
46
  >
46
- <InputNumber
47
- style={{ width: "100%" }}
48
- autoFocus
49
- ref={inputRef as any}
50
- />
47
+ <Input style={{ width: "100%" }} autoFocus ref={inputRef as any} />
51
48
  </Form.Item>
52
49
  <Row align="middle" justify="end">
53
50
  <Col>
@@ -319,52 +319,59 @@ function ActionView(props: Props, ref: any) {
319
319
  setGtResourceModalVisible(true);
320
320
  }
321
321
 
322
- async function goToResourceId(id: number) {
322
+ async function goToResourceId(ids: number[]) {
323
323
  setSearchingForResourceId(true);
324
324
 
325
- const itemIndex = results!.findIndex((item: any) => {
326
- return item.id === id;
327
- });
328
-
329
- let resource;
330
-
331
- if (itemIndex === -1) {
332
- try {
333
- resource = (
334
- await ConnectionProvider.getHandler().readObjects({
335
- model,
336
- ids: [id],
337
- context,
338
- })
339
- )?.[0];
340
- } catch (err) {}
341
-
342
- if (!resource) {
343
- setSearchingForResourceId(false);
344
- setGtResourceModalVisible(false);
345
- showInfo(t("idNotFound"));
346
- return;
325
+ let mode: ViewType;
326
+ let domain: any[];
327
+ if (ids.length === 1) {
328
+ mode = "form";
329
+ domain = [];
330
+ const id = ids[0];
331
+ const itemIndex = results!.findIndex((item: any) => {
332
+ return item.id === id;
333
+ });
334
+ let resource;
335
+
336
+ if (itemIndex === -1) {
337
+ try {
338
+ resource = (
339
+ await ConnectionProvider.getHandler().readObjects({
340
+ model,
341
+ ids: [id],
342
+ context,
343
+ })
344
+ )?.[0];
345
+ } catch (err) {}
346
+
347
+ if (!resource) {
348
+ setSearchingForResourceId(false);
349
+ setGtResourceModalVisible(false);
350
+ showInfo(t("idNotFound"));
351
+ return;
352
+ }
353
+ } else {
354
+ resource = results[itemIndex];
347
355
  }
348
356
  } else {
349
- resource = results[itemIndex];
357
+ mode = "tree";
358
+ domain = [["id", "in", ids]];
350
359
  }
351
360
 
352
361
  setSearchingForResourceId(false);
353
362
  setGtResourceModalVisible(false);
354
-
355
- const viewForm = views.find((v) => v[1] === "form");
356
-
363
+ const viewForm = views.find((v) => v[1] === mode);
357
364
  openAction({
358
- domain: [],
365
+ domain,
359
366
  context,
360
367
  model,
361
368
  views,
362
369
  title,
363
370
  target: "current",
364
- initialView: { id: viewForm?.[0]!, type: "form" },
371
+ initialView: { id: viewForm?.[0]!, type: mode },
365
372
  action_id,
366
373
  action_type,
367
- res_id: id,
374
+ res_id: ids[0],
368
375
  });
369
376
  }
370
377
 
@@ -63,7 +63,7 @@ export const Button = (props: Props) => {
63
63
  <Field ooui={ooui}>
64
64
  <AntButton
65
65
  block
66
- disabled={!activated || readOnly}
66
+ disabled={!activated || readOnly || isRunning}
67
67
  onClick={onClick}
68
68
  icon={getButtonIcon()}
69
69
  type={ooui.primary ? "primary" : "default"}