@gisce/react-ooui 1.2.0-rc.31 → 1.2.0-rc.33
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 -0
- package/dist/context/ActionViewContext.d.ts.map +1 -1
- package/dist/helpers/one2manyHelper.d.ts +2 -1
- package/dist/helpers/one2manyHelper.d.ts.map +1 -1
- package/dist/react-ooui.es.js +2499 -2483
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +20 -20
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/widgets/views/Form.d.ts.map +1 -1
- package/dist/widgets/views/SearchTree.d.ts.map +1 -1
- package/dist/widgets/views/Tree.d.ts +1 -0
- package/dist/widgets/views/Tree.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/context/ActionViewContext.tsx +4 -1
- package/src/helpers/one2manyHelper.ts +27 -9
- package/src/widgets/views/Form.tsx +14 -4
- package/src/widgets/views/SearchTree.tsx +1 -0
- package/src/widgets/views/Tree.tsx +16 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAkCf,OAAO,EAAE,QAAQ,EAAgB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["Form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAkCf,OAAO,EAAE,QAAQ,EAAgB,MAAM,SAAS,CAAC;AAkBjD,oBAAY,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,UAAU,CAAC,EAAE,O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C,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,CAAC;CACf,CAAC;AAmEF,iBAAS,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CAuM9C;AAED,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -53,6 +53,7 @@ export type ActionViewContextType = {
|
|
|
53
53
|
setSearchValues?: (value: any) => void;
|
|
54
54
|
limit?: number;
|
|
55
55
|
setLimit?: (value: number) => void;
|
|
56
|
+
setTitle?: (value: string) => void;
|
|
56
57
|
};
|
|
57
58
|
|
|
58
59
|
export const ActionViewContext =
|
|
@@ -66,7 +67,7 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
|
|
|
66
67
|
const {
|
|
67
68
|
children,
|
|
68
69
|
currentView,
|
|
69
|
-
title,
|
|
70
|
+
title: titleProps,
|
|
70
71
|
setCurrentView,
|
|
71
72
|
availableViews,
|
|
72
73
|
formRef,
|
|
@@ -106,6 +107,7 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
|
|
|
106
107
|
const [limit, setLimit] = useState<number>(
|
|
107
108
|
limitProps !== undefined ? limitProps : DEFAULT_SEARCH_LIMIT
|
|
108
109
|
);
|
|
110
|
+
const [title, setTitle] = useState<string>(titleProps);
|
|
109
111
|
|
|
110
112
|
useEffect(() => {
|
|
111
113
|
if (results && results.length > 0 && !currentItemIndex) {
|
|
@@ -196,6 +198,7 @@ const ActionViewProvider = (props: ActionViewProviderProps): any => {
|
|
|
196
198
|
setSearchValues,
|
|
197
199
|
limit,
|
|
198
200
|
setLimit,
|
|
201
|
+
setTitle,
|
|
199
202
|
}}
|
|
200
203
|
>
|
|
201
204
|
{children}
|
|
@@ -79,14 +79,8 @@ type RemoveItemOptions = {
|
|
|
79
79
|
};
|
|
80
80
|
|
|
81
81
|
const removeItems = async (options: RemoveItemOptions) => {
|
|
82
|
-
const {
|
|
83
|
-
|
|
84
|
-
activeId,
|
|
85
|
-
fieldName,
|
|
86
|
-
idsToRemove,
|
|
87
|
-
fields,
|
|
88
|
-
isMany2many,
|
|
89
|
-
} = options;
|
|
82
|
+
const { model, activeId, fieldName, idsToRemove, fields, isMany2many } =
|
|
83
|
+
options;
|
|
90
84
|
|
|
91
85
|
const values: any = {};
|
|
92
86
|
values[fieldName] = [];
|
|
@@ -136,4 +130,28 @@ const getNextPendingId = (items: One2manyItem[]) => {
|
|
|
136
130
|
}
|
|
137
131
|
};
|
|
138
132
|
|
|
139
|
-
|
|
133
|
+
const convertToPlain2ManyValues = (values: any, fields: any) => {
|
|
134
|
+
const result: any = {};
|
|
135
|
+
Object.keys(values).forEach((key) => {
|
|
136
|
+
if (
|
|
137
|
+
fields.hasOwnProperty(key) &&
|
|
138
|
+
(fields[key].type === "one2many" || fields[key].type === "many2many") &&
|
|
139
|
+
values[key] &&
|
|
140
|
+
values[key]?.items
|
|
141
|
+
) {
|
|
142
|
+
result[key] = values[key].items.filter(
|
|
143
|
+
(item: One2manyItem) => item.operation !== "pendingRemove"
|
|
144
|
+
);
|
|
145
|
+
} else {
|
|
146
|
+
result[key] = values[key];
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
return result;
|
|
150
|
+
};
|
|
151
|
+
export {
|
|
152
|
+
readObjectValues,
|
|
153
|
+
removeItems,
|
|
154
|
+
linkItem,
|
|
155
|
+
getNextPendingId,
|
|
156
|
+
convertToPlain2ManyValues,
|
|
157
|
+
};
|
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
ContentRootContextType,
|
|
56
56
|
} from "@/context/ContentRootContext";
|
|
57
57
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
58
|
+
import { convertToPlain2ManyValues } from "@/helpers/one2manyHelper";
|
|
58
59
|
|
|
59
60
|
export type FormProps = {
|
|
60
61
|
model: string;
|
|
@@ -139,6 +140,8 @@ function Form(props: FormProps, ref: any) {
|
|
|
139
140
|
setCurrentId = undefined,
|
|
140
141
|
setFormIsLoading = undefined,
|
|
141
142
|
setAttachments = undefined,
|
|
143
|
+
title = undefined,
|
|
144
|
+
setTitle = undefined,
|
|
142
145
|
} = (rootForm ? actionViewContext : {}) || {};
|
|
143
146
|
|
|
144
147
|
const contentRootContext = useContext(
|
|
@@ -663,13 +666,20 @@ function Form(props: FormProps, ref: any) {
|
|
|
663
666
|
// TODO: Here we must inject `values` to the ooui parser in order to evaluate arch+values and get the new form container
|
|
664
667
|
ooui.parse(arch, {
|
|
665
668
|
readOnly,
|
|
666
|
-
values:
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
669
|
+
values: convertToPlain2ManyValues(
|
|
670
|
+
{
|
|
671
|
+
...values,
|
|
672
|
+
...getAdditionalValues(),
|
|
673
|
+
},
|
|
674
|
+
fields
|
|
675
|
+
),
|
|
670
676
|
});
|
|
671
677
|
setFormOoui(ooui);
|
|
672
678
|
|
|
679
|
+
if (ooui.string && ooui.string !== title) {
|
|
680
|
+
setTitle?.(ooui.string);
|
|
681
|
+
}
|
|
682
|
+
|
|
673
683
|
if (formModalContext && ooui.string)
|
|
674
684
|
formModalContext.setTitle?.(ooui.string);
|
|
675
685
|
};
|
|
@@ -5,7 +5,6 @@ import { Tree as TreeOoui } from "@gisce/ooui";
|
|
|
5
5
|
|
|
6
6
|
import { TreeView, Column } from "@/types";
|
|
7
7
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
8
|
-
import { Many2oneSuffix } from "../base/many2one/Many2oneSuffix";
|
|
9
8
|
import { calculateColumnsWidth } from "@/helpers/dynamicColumnsHelper";
|
|
10
9
|
import { parseFloatToString } from "@/helpers/timeHelper";
|
|
11
10
|
import { ProgressBarInput } from "../base/ProgressBar";
|
|
@@ -17,6 +16,10 @@ import {
|
|
|
17
16
|
} from "@ant-design/icons";
|
|
18
17
|
import { One2manyValue } from "../base/one2many/One2manyInput";
|
|
19
18
|
import { Interweave } from "interweave";
|
|
19
|
+
import {
|
|
20
|
+
ActionViewContext,
|
|
21
|
+
ActionViewContextType,
|
|
22
|
+
} from "@/context/ActionViewContext";
|
|
20
23
|
import { Many2oneTree } from "../base/many2one/Many2oneTree";
|
|
21
24
|
import { ReferenceTree } from "../base/ReferenceTree";
|
|
22
25
|
|
|
@@ -37,6 +40,7 @@ type Props = {
|
|
|
37
40
|
sorter?: any;
|
|
38
41
|
onFetchChildrenForRecord?: (item: any) => Promise<any[]>;
|
|
39
42
|
childField?: string;
|
|
43
|
+
rootTree?: boolean;
|
|
40
44
|
context?: any;
|
|
41
45
|
};
|
|
42
46
|
|
|
@@ -123,6 +127,7 @@ function Tree(props: Props): React.ReactElement {
|
|
|
123
127
|
sorter,
|
|
124
128
|
onFetchChildrenForRecord,
|
|
125
129
|
childField,
|
|
130
|
+
rootTree = false,
|
|
126
131
|
context,
|
|
127
132
|
} = props;
|
|
128
133
|
|
|
@@ -136,6 +141,12 @@ function Tree(props: Props): React.ReactElement {
|
|
|
136
141
|
const { t } = useContext(LocaleContext) as LocaleContextType;
|
|
137
142
|
const internalLimit = useRef(limit);
|
|
138
143
|
|
|
144
|
+
const actionViewContext = useContext(
|
|
145
|
+
ActionViewContext
|
|
146
|
+
) as ActionViewContextType;
|
|
147
|
+
const { title = undefined, setTitle = undefined } =
|
|
148
|
+
(rootTree ? actionViewContext : {}) || {};
|
|
149
|
+
|
|
139
150
|
useEffect(() => {
|
|
140
151
|
treeOoui.current = getTree(treeView);
|
|
141
152
|
|
|
@@ -158,6 +169,10 @@ function Tree(props: Props): React.ReactElement {
|
|
|
158
169
|
);
|
|
159
170
|
|
|
160
171
|
setColumns(columns);
|
|
172
|
+
|
|
173
|
+
if (treeOoui.current.string && title !== treeOoui.current.string) {
|
|
174
|
+
setTitle?.(treeOoui.current.string);
|
|
175
|
+
}
|
|
161
176
|
}, [treeView]);
|
|
162
177
|
|
|
163
178
|
useEffect(() => {
|