@gisce/react-ooui 1.2.0-rc.31 → 1.2.0-rc.32
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/helpers/one2manyHelper.d.ts +2 -1
- package/dist/helpers/one2manyHelper.d.ts.map +1 -1
- package/dist/react-ooui.es.js +10 -2
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +1 -1
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/widgets/views/Form.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/helpers/one2manyHelper.ts +27 -9
- package/src/widgets/views/Form.tsx +8 -4
|
@@ -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,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,UAAU,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC9B,eAAe,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,UAAU,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IACxE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,YAAY,CAAC,EAAE,GAAG,CAAC;CACpB,CAAC;;AAm+BF,wBAAgC"}
|
package/package.json
CHANGED
|
@@ -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;
|
|
@@ -663,10 +664,13 @@ function Form(props: FormProps, ref: any) {
|
|
|
663
664
|
// TODO: Here we must inject `values` to the ooui parser in order to evaluate arch+values and get the new form container
|
|
664
665
|
ooui.parse(arch, {
|
|
665
666
|
readOnly,
|
|
666
|
-
values:
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
667
|
+
values: convertToPlain2ManyValues(
|
|
668
|
+
{
|
|
669
|
+
...values,
|
|
670
|
+
...getAdditionalValues(),
|
|
671
|
+
},
|
|
672
|
+
fields
|
|
673
|
+
),
|
|
670
674
|
});
|
|
671
675
|
setFormOoui(ooui);
|
|
672
676
|
|