@gisce/react-ooui 1.5.6-rc.0 → 1.5.6-rc.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.
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  declare type Props = {
3
3
  visible: boolean;
4
- onIdSubmitted: (id: number) => void;
4
+ onIdSubmitted: (ids: number[]) => void;
5
5
  onCancel: () => void;
6
6
  isSearching: boolean;
7
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"GoToResourceModal.d.ts","sourceRoot":"","sources":["GoToResourceModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAKlD,aAAK,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,sBA8D7C,CAAC"}
1
+ {"version":3,"file":"GoToResourceModal.d.ts","sourceRoot":"","sources":["GoToResourceModal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6B,MAAM,OAAO,CAAC;AAKlD,aAAK,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,sBA+D7C,CAAC"}
@@ -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;AAoBvB,aA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O,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;;AAkdF,wBAAsC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.5.6-rc.0",
3
+ "version": "1.5.6-rc.1",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
@@ -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,7 @@ 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: "Se puede utilizar un ID o una lista de IDs separados por comas",
75
76
  idNotFound: "No se encuentra ésta ID de recursos para el objeto",
76
77
  selectedRegisters: "registros seleccionados",
77
78
  translate: "Traducir",
@@ -15,11 +15,12 @@ export const Default = (): React.ReactElement => {
15
15
  <LocaleProvider lang="en_US">
16
16
  <GoToResourceModal
17
17
  visible={true}
18
+ isSearching={false}
18
19
  onCancel={() => {
19
20
  alert("cancel");
20
21
  }}
21
- onIdSubmitted={(id) => {
22
- alert(id);
22
+ onIdSubmitted={(ids) => {
23
+ alert(ids);
23
24
  }}
24
25
  />
25
26
  </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, Checkbox } 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,11 +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 style={{ width: "100%" }} autoFocus ref={inputRef as any}/>
47
+ <Input style={{ width: "100%" }} autoFocus ref={inputRef as any}/>
47
48
  </Form.Item>
48
49
  <Row align="middle" justify="end">
49
50
  <Col>
@@ -318,52 +318,60 @@ function ActionView(props: Props, ref: any) {
318
318
  setGtResourceModalVisible(true);
319
319
  }
320
320
 
321
- async function goToResourceId(id: number) {
321
+ async function goToResourceId(ids: number[]) {
322
322
  setSearchingForResourceId(true);
323
323
 
324
- const itemIndex = results!.findIndex((item: any) => {
325
- return item.id === id;
326
- });
327
-
328
- let resource;
324
+ let mode: ViewType;
325
+ let domain: any[];
326
+ if (ids.length === 1) {
327
+ mode = "form";
328
+ domain = [];
329
+ const id = ids[0];
330
+ const itemIndex = results!.findIndex((item: any) => {
331
+ return item.id === id;
332
+ });
333
+ let resource;
334
+
335
+ if (itemIndex === -1) {
336
+ try {
337
+ resource = (
338
+ await ConnectionProvider.getHandler().readObjects({
339
+ model,
340
+ ids: [id],
341
+ context,
342
+ })
343
+ )?.[0];
344
+ } catch (err) {
345
+ }
329
346
 
330
- if (itemIndex === -1) {
331
- try {
332
- resource = (
333
- await ConnectionProvider.getHandler().readObjects({
334
- model,
335
- ids: [id],
336
- context,
337
- })
338
- )?.[0];
339
- } catch (err) {}
340
-
341
- if (!resource) {
342
- setSearchingForResourceId(false);
343
- setGtResourceModalVisible(false);
344
- showInfo(t("idNotFound"));
345
- return;
347
+ if (!resource) {
348
+ setSearchingForResourceId(false);
349
+ setGtResourceModalVisible(false);
350
+ showInfo(t("idNotFound"));
351
+ return;
352
+ }
353
+ } else {
354
+ resource = results[itemIndex];
346
355
  }
347
356
  } else {
348
- resource = results[itemIndex];
357
+ mode = "tree";
358
+ domain = [["id", "in", ids]]
349
359
  }
350
360
 
351
361
  setSearchingForResourceId(false);
352
362
  setGtResourceModalVisible(false);
353
-
354
- const viewForm = views.find((v) => v[1] === "form");
355
-
363
+ const viewForm = views.find((v) => v[1] === mode);
356
364
  openAction({
357
- domain: [],
365
+ domain: domain,
358
366
  context,
359
367
  model,
360
368
  views,
361
369
  title,
362
370
  target: "current",
363
- initialView: { id: viewForm?.[0]!, type: "form" },
371
+ initialView: {id: viewForm?.[0]!, type: mode},
364
372
  action_id,
365
373
  action_type,
366
- res_id: id,
374
+ res_id: ids[0],
367
375
  });
368
376
  }
369
377