@gisce/react-ooui 1.2.0-rc.46 → 1.2.0-rc.48

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gisce/react-ooui",
3
- "version": "1.2.0-rc.46",
3
+ "version": "1.2.0-rc.48",
4
4
  "files": [
5
5
  "dist",
6
6
  "src",
@@ -37,7 +37,7 @@
37
37
  "dependencies": {
38
38
  "@ant-design/plots": "^1.0.9",
39
39
  "@gisce/ooui": "^0.17.14-rc.1",
40
- "@gisce/react-formiga-components": "^1.0.9-rc.14",
40
+ "@gisce/react-formiga-components": "^1.0.9-rc.18",
41
41
  "@gisce/react-formiga-table": "^0.5.0",
42
42
  "@monaco-editor/react": "^4.4.5",
43
43
  "@tabler/icons-react": "^2.11.0",
@@ -28,6 +28,7 @@ export const useExport = ({
28
28
  onClose: () => void;
29
29
  }) => {
30
30
  const fields = useRef<any>({});
31
+ const exportModelFields = useRef<Map<string, any>>(new Map<string, any>());
31
32
 
32
33
  const onExport = useCallback(
33
34
  async (options: ExportOptions) => {
@@ -144,16 +145,67 @@ export const useExport = ({
144
145
 
145
146
  const onSavePredefinedExport = useCallback(
146
147
  async (pExport: PredefinedExport) => {
147
- return {};
148
+ const fieldsForExport = await getModelFields("ir.exports");
149
+ const fieldsForExportLine = await getModelFields("ir.exports.line");
150
+
151
+ // First we must create the parent object
152
+ const exportId = await ConnectionProvider.getHandler().create({
153
+ model: "ir.exports",
154
+ values: {
155
+ name: pExport.name,
156
+ resource: model,
157
+ },
158
+ fields: fieldsForExport,
159
+ context,
160
+ });
161
+
162
+ // We create the lines
163
+ await Promise.all(
164
+ pExport.fields.map(async (field) => {
165
+ return await ConnectionProvider.getHandler().create({
166
+ model: "ir.exports.line",
167
+ values: {
168
+ name: field.key,
169
+ export_id: exportId,
170
+ },
171
+ fields: fieldsForExportLine,
172
+ context,
173
+ });
174
+ })
175
+ );
176
+
177
+ return { ...pExport, id: exportId };
148
178
  },
149
179
  []
150
180
  );
151
181
 
152
182
  const onRemovePredefinedExport = useCallback(
153
- async (pExport: PredefinedExport) => {},
183
+ async (pExport: PredefinedExport) => {
184
+ await ConnectionProvider.getHandler().delete({
185
+ model: "ir.exports",
186
+ ids: [pExport.id!],
187
+ });
188
+ },
154
189
  []
155
190
  );
156
191
 
192
+ const getModelFields = useCallback(
193
+ async (model: string) => {
194
+ if (exportModelFields.current.has(model)) {
195
+ return exportModelFields.current.get(model);
196
+ }
197
+
198
+ const fieldsForModel = ConnectionProvider.getHandler().getFields({
199
+ model,
200
+ context,
201
+ fields: [],
202
+ });
203
+
204
+ exportModelFields.current.set(model, fieldsForModel);
205
+ },
206
+ [exportModelFields, context]
207
+ );
208
+
157
209
  return {
158
210
  onGetFields,
159
211
  onGetFieldChilds,