@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.
- package/dist/context/ActionViewContext.d.ts +1 -1
- package/dist/context/ActionViewContext.d.ts.map +1 -1
- package/dist/locales/ca_ES.d.ts +1 -0
- package/dist/locales/ca_ES.d.ts.map +1 -1
- package/dist/locales/en_US.d.ts +1 -0
- package/dist/locales/en_US.d.ts.map +1 -1
- package/dist/locales/es_ES.d.ts +1 -0
- package/dist/locales/es_ES.d.ts.map +1 -1
- package/dist/react-ooui.es.js +951 -949
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/ui/GoToResourceModal.d.ts +1 -1
- package/dist/ui/GoToResourceModal.d.ts.map +1 -1
- package/dist/views/ActionView.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/context/ActionViewContext.tsx +1 -1
- package/src/locales/ca_ES.tsx +1 -0
- package/src/locales/en_US.tsx +1 -0
- package/src/locales/es_ES.tsx +2 -0
- package/src/stories/ui/GoToResourceModal.stories.tsx +3 -2
- package/src/ui/GoToResourceModal.tsx +6 -9
- package/src/views/ActionView.tsx +37 -30
- package/src/widgets/base/Button.tsx +1 -1
|
@@ -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,
|
|
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,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;;
|
|
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,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;;AAkdF,wBAAsC"}
|
package/package.json
CHANGED
|
@@ -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?: (
|
|
51
|
+
goToResourceId?: (ids: number[]) => Promise<void>;
|
|
52
52
|
searchValues?: any;
|
|
53
53
|
setSearchValues?: (value: any) => void;
|
|
54
54
|
limit?: number;
|
package/src/locales/ca_ES.tsx
CHANGED
|
@@ -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",
|
package/src/locales/en_US.tsx
CHANGED
|
@@ -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",
|
package/src/locales/es_ES.tsx
CHANGED
|
@@ -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={(
|
|
19
|
-
alert(
|
|
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,
|
|
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: (
|
|
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
|
-
|
|
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
|
-
<
|
|
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>
|
package/src/views/ActionView.tsx
CHANGED
|
@@ -319,52 +319,59 @@ function ActionView(props: Props, ref: any) {
|
|
|
319
319
|
setGtResourceModalVisible(true);
|
|
320
320
|
}
|
|
321
321
|
|
|
322
|
-
async function goToResourceId(
|
|
322
|
+
async function goToResourceId(ids: number[]) {
|
|
323
323
|
setSearchingForResourceId(true);
|
|
324
324
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
|
|
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:
|
|
371
|
+
initialView: { id: viewForm?.[0]!, type: mode },
|
|
365
372
|
action_id,
|
|
366
373
|
action_type,
|
|
367
|
-
res_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"}
|