@gisce/react-ooui 2.0.0-rc.0 → 2.0.0-rc.2
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/actionbar/TreeActionBar.d.ts.map +1 -1
- package/dist/context/ContentRootContext.d.ts.map +1 -1
- package/dist/helpers/formHelper.d.ts +1 -0
- package/dist/helpers/formHelper.d.ts.map +1 -1
- package/dist/hooks/useSearch.d.ts.map +1 -1
- package/dist/react-ooui.es.js +3312 -3175
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +14 -14
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/widgets/views/Tree.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actionbar/TreeActionBar.tsx +8 -1
- package/src/context/ContentRootContext.tsx +4 -2
- package/src/helpers/formHelper.ts +5 -0
- package/src/hooks/useSearch.ts +1 -0
- package/src/widgets/views/SearchTree.tsx +1 -1
- package/src/widgets/views/Tree.tsx +29 -45
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["Tree.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["Tree.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAKvE,OAAO,EAAE,QAAQ,EAAU,MAAM,SAAS,CAAC;AAwB3C,aAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACtC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,wBAAwB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAmHF,iBAAS,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CAmN9C;AAED,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext, useState } from "react";
|
|
2
|
-
import { Space } from "antd";
|
|
2
|
+
import { Space, Spin } from "antd";
|
|
3
3
|
import ChangeViewButton from "./ChangeViewButton";
|
|
4
4
|
import {
|
|
5
5
|
ActionViewContext,
|
|
@@ -151,6 +151,13 @@ function TreeActionBar(props: Props) {
|
|
|
151
151
|
|
|
152
152
|
return (
|
|
153
153
|
<Space wrap={true}>
|
|
154
|
+
{treeIsLoading && (
|
|
155
|
+
<>
|
|
156
|
+
<Spin />
|
|
157
|
+
{separator()}
|
|
158
|
+
{separator()}
|
|
159
|
+
</>
|
|
160
|
+
)}
|
|
154
161
|
{treeExpandable ? null : (
|
|
155
162
|
<>
|
|
156
163
|
<SearchBar
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
} from "@/context/TabManagerContext";
|
|
18
18
|
import { FormModal } from "@/widgets/modals/FormModal";
|
|
19
19
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
20
|
-
import { transformPlainMany2Ones } from "@/helpers/formHelper";
|
|
20
|
+
import { transformPlainMany2Ones, stringFormat } from "@/helpers/formHelper";
|
|
21
21
|
|
|
22
22
|
export type ContentRootContextType = {
|
|
23
23
|
processAction: ({
|
|
@@ -182,7 +182,9 @@ const ContentRootProvider = (
|
|
|
182
182
|
context,
|
|
183
183
|
});
|
|
184
184
|
} else if (type === "ir.actions.act_window") {
|
|
185
|
-
return await runAction({
|
|
185
|
+
return await runAction({actionData, fields, values, context});
|
|
186
|
+
} else if (type === "ir.actions.act_url") {
|
|
187
|
+
window.open(stringFormat(actionData.url, {...values, context}), "_blank");
|
|
186
188
|
} else {
|
|
187
189
|
showErrorDialog(`${type} action not supported`);
|
|
188
190
|
return {};
|
|
@@ -295,3 +295,8 @@ export const colorTextFromBackground = (color: string) => {
|
|
|
295
295
|
return getTextColor(color);
|
|
296
296
|
|
|
297
297
|
}
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
export const stringFormat = (text: string, values: any): string => {
|
|
301
|
+
return text.replace(/\{([^}]+)\}/g, (match, key) => values[key] !== undefined ? values[key] : match);
|
|
302
|
+
}
|
package/src/hooks/useSearch.ts
CHANGED
|
@@ -293,6 +293,7 @@ export const useSearch = (opts: UseSearchOpts) => {
|
|
|
293
293
|
|
|
294
294
|
const changeSort = useCallback(
|
|
295
295
|
(newSorter: any) => {
|
|
296
|
+
if (JSON.stringify(newSorter) === JSON.stringify(sorter)) return;
|
|
296
297
|
setSorter?.(newSorter);
|
|
297
298
|
const sortedResults =
|
|
298
299
|
newSorter !== undefined
|
|
@@ -182,9 +182,9 @@ function SearchTree(props: Props, ref: any) {
|
|
|
182
182
|
setInitialFetchDone(true);
|
|
183
183
|
} catch (error) {
|
|
184
184
|
setInitialError(error);
|
|
185
|
+
setTreeIsLoading?.(false);
|
|
185
186
|
} finally {
|
|
186
187
|
setIsLoading(false);
|
|
187
|
-
setTreeIsLoading?.(false);
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
190
|
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useCallback,
|
|
3
|
-
useContext,
|
|
4
|
-
useEffect,
|
|
5
|
-
useRef,
|
|
6
|
-
useState,
|
|
7
|
-
} from "react";
|
|
1
|
+
import React, { useContext, useEffect, useRef, useState } from "react";
|
|
8
2
|
import { Pagination, Checkbox, Space, Row, Col, Spin, Tag, Badge } from "antd";
|
|
9
3
|
import { getTree, getTableColumns, getTableItems } from "@/helpers/treeHelper";
|
|
10
4
|
import { Tree as TreeOoui } from "@gisce/ooui";
|
|
@@ -114,8 +108,8 @@ const floatTimeComponent = (value: number): React.ReactElement => {
|
|
|
114
108
|
return <>{parseFloatToString(value)}</>;
|
|
115
109
|
};
|
|
116
110
|
|
|
117
|
-
const numberComponent = (value:
|
|
118
|
-
return <div style={{ textAlign: "right" }}>{
|
|
111
|
+
const numberComponent = (value: number): React.ReactElement => {
|
|
112
|
+
return <div style={{ textAlign: "right" }}>{value}</div>;
|
|
119
113
|
};
|
|
120
114
|
|
|
121
115
|
const imageComponent = (value: string): React.ReactElement => {
|
|
@@ -215,22 +209,22 @@ function Tree(props: Props): React.ReactElement {
|
|
|
215
209
|
const columns = getTableColumns(
|
|
216
210
|
treeOoui.current,
|
|
217
211
|
{
|
|
218
|
-
boolean:
|
|
219
|
-
many2one:
|
|
220
|
-
text:
|
|
221
|
-
one2many:
|
|
222
|
-
many2many:
|
|
223
|
-
progressbar:
|
|
224
|
-
float_time:
|
|
225
|
-
image:
|
|
212
|
+
boolean: booleanComponentFn,
|
|
213
|
+
many2one: many2OneComponentFn,
|
|
214
|
+
text: textComponentFn,
|
|
215
|
+
one2many: one2ManyComponentFn,
|
|
216
|
+
many2many: one2ManyComponentFn,
|
|
217
|
+
progressbar: progressBarComponentFn,
|
|
218
|
+
float_time: floatTimeComponent,
|
|
219
|
+
image: imageComponent,
|
|
226
220
|
integer: numberComponent,
|
|
227
221
|
float: numberComponent,
|
|
228
|
-
reference:
|
|
229
|
-
tag:
|
|
230
|
-
selection:
|
|
231
|
-
date:
|
|
232
|
-
datetime:
|
|
233
|
-
avatar:
|
|
222
|
+
reference: referenceComponent,
|
|
223
|
+
tag: TagComponent,
|
|
224
|
+
selection: SelectionComponent,
|
|
225
|
+
date: dateComponentFn,
|
|
226
|
+
datetime: dateTimeComponentFn,
|
|
227
|
+
avatar: AvatarFn,
|
|
234
228
|
},
|
|
235
229
|
context
|
|
236
230
|
);
|
|
@@ -337,26 +331,6 @@ function Tree(props: Props): React.ReactElement {
|
|
|
337
331
|
}
|
|
338
332
|
}
|
|
339
333
|
|
|
340
|
-
const onRowStyle = useCallback(
|
|
341
|
-
(record: any) => {
|
|
342
|
-
if (colorsForResults![record.id]) {
|
|
343
|
-
return { color: colorsForResults![record.id] };
|
|
344
|
-
}
|
|
345
|
-
return undefined;
|
|
346
|
-
},
|
|
347
|
-
[colorsForResults]
|
|
348
|
-
);
|
|
349
|
-
|
|
350
|
-
const onRowStatus = useCallback(
|
|
351
|
-
(record: any) => {
|
|
352
|
-
if (statusForResults![record.id]) {
|
|
353
|
-
return <Badge color={statusForResults[record.id]} />;
|
|
354
|
-
}
|
|
355
|
-
return undefined;
|
|
356
|
-
},
|
|
357
|
-
[statusForResults]
|
|
358
|
-
);
|
|
359
|
-
|
|
360
334
|
return treeOoui.current === null ? (
|
|
361
335
|
<Spin style={{ padding: "2rem" }} />
|
|
362
336
|
) : (
|
|
@@ -368,8 +342,18 @@ function Tree(props: Props): React.ReactElement {
|
|
|
368
342
|
dataSource={items}
|
|
369
343
|
loading={loading}
|
|
370
344
|
loadingComponent={<Spin />}
|
|
371
|
-
onRowStyle={
|
|
372
|
-
|
|
345
|
+
onRowStyle={(record: any) => {
|
|
346
|
+
if (colorsForResults![record.id]) {
|
|
347
|
+
return { color: colorsForResults![record.id] };
|
|
348
|
+
}
|
|
349
|
+
return undefined;
|
|
350
|
+
}}
|
|
351
|
+
onRowStatus={(record: any) => {
|
|
352
|
+
if (statusForResults![record.id]) {
|
|
353
|
+
return <Badge color={statusForResults[record.id]} />;
|
|
354
|
+
}
|
|
355
|
+
return undefined;
|
|
356
|
+
}}
|
|
373
357
|
onRowDoubleClick={onRowClicked}
|
|
374
358
|
onRowSelectionChange={rowSelection?.onChange}
|
|
375
359
|
onChangeSort={onChangeSort}
|