@gisce/react-ooui 1.1.35-rc.0 → 1.1.35
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/FormActionBar.d.ts.map +1 -1
- package/dist/context/ActionViewContext.d.ts +4 -1
- package/dist/context/ActionViewContext.d.ts.map +1 -1
- package/dist/context/FormContext.d.ts +4 -1
- package/dist/context/FormContext.d.ts.map +1 -1
- package/dist/react-ooui.es.js +112 -74
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +6 -6
- package/dist/react-ooui.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/actionbar/FormActionBar.tsx +44 -15
- package/src/context/ActionViewContext.tsx +1 -1
- package/src/context/FormContext.tsx +1 -1
- package/src/widgets/views/Form.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gisce/react-ooui",
|
|
3
|
-
"version": "1.1.35
|
|
3
|
+
"version": "1.1.35",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist",
|
|
6
6
|
"src",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ant-design/plots": "^1.0.9",
|
|
39
|
-
"@gisce/ooui": "^0.17.
|
|
39
|
+
"@gisce/ooui": "^0.17.13",
|
|
40
40
|
"@gisce/react-formiga-table": "^0.5.0",
|
|
41
41
|
"@monaco-editor/react": "^4.4.5",
|
|
42
42
|
"@tabler/icons-react": "^2.11.0",
|
|
@@ -343,9 +343,12 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
|
|
|
343
343
|
if (!action) {
|
|
344
344
|
return;
|
|
345
345
|
}
|
|
346
|
-
const savedSucceed = await onFormSave?.();
|
|
347
346
|
|
|
348
|
-
|
|
347
|
+
const result = await saveDocument({
|
|
348
|
+
onFormSave,
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
if (!result.succeed) {
|
|
349
352
|
return;
|
|
350
353
|
}
|
|
351
354
|
|
|
@@ -361,15 +364,20 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
|
|
|
361
364
|
if (!report) {
|
|
362
365
|
return;
|
|
363
366
|
}
|
|
364
|
-
const
|
|
367
|
+
const result = await saveDocument({
|
|
368
|
+
onFormSave,
|
|
369
|
+
});
|
|
365
370
|
|
|
366
|
-
if (!
|
|
371
|
+
if (!result.succeed) {
|
|
367
372
|
return;
|
|
368
373
|
}
|
|
369
374
|
|
|
370
375
|
runAction({
|
|
371
376
|
...report,
|
|
372
|
-
datas: {
|
|
377
|
+
datas: {
|
|
378
|
+
...(report.datas || {}),
|
|
379
|
+
ids: [result.currentId as number],
|
|
380
|
+
},
|
|
373
381
|
});
|
|
374
382
|
}}
|
|
375
383
|
/>
|
|
@@ -383,9 +391,11 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
|
|
|
383
391
|
return;
|
|
384
392
|
}
|
|
385
393
|
|
|
386
|
-
const
|
|
394
|
+
const result = await saveDocument({
|
|
395
|
+
onFormSave,
|
|
396
|
+
});
|
|
387
397
|
|
|
388
|
-
if (!
|
|
398
|
+
if (!result.succeed) {
|
|
389
399
|
return;
|
|
390
400
|
}
|
|
391
401
|
|
|
@@ -402,13 +412,15 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
|
|
|
402
412
|
disabled={mustDisableButtons}
|
|
403
413
|
attachments={attachments}
|
|
404
414
|
onAddNewAttachment={async () => {
|
|
405
|
-
const
|
|
415
|
+
const result = await saveDocument({
|
|
416
|
+
onFormSave,
|
|
417
|
+
});
|
|
406
418
|
|
|
407
|
-
if (!
|
|
419
|
+
if (!result.succeed) {
|
|
408
420
|
return;
|
|
409
421
|
}
|
|
410
422
|
|
|
411
|
-
const res_id = currentId as number;
|
|
423
|
+
const res_id = result.currentId as number;
|
|
412
424
|
const res_model = currentModel as string;
|
|
413
425
|
openDefaultActionForModel({
|
|
414
426
|
model: "ir.attachment",
|
|
@@ -423,13 +435,15 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
|
|
|
423
435
|
});
|
|
424
436
|
}}
|
|
425
437
|
onListAllAttachments={async () => {
|
|
426
|
-
const
|
|
438
|
+
const result = await saveDocument({
|
|
439
|
+
onFormSave,
|
|
440
|
+
});
|
|
427
441
|
|
|
428
|
-
if (!
|
|
442
|
+
if (!result.succeed) {
|
|
429
443
|
return;
|
|
430
444
|
}
|
|
431
445
|
|
|
432
|
-
const res_id = currentId as number;
|
|
446
|
+
const res_id = result.currentId as number;
|
|
433
447
|
const res_model = currentModel as string;
|
|
434
448
|
openDefaultActionForModel({
|
|
435
449
|
model: "ir.attachment",
|
|
@@ -441,9 +455,11 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
|
|
|
441
455
|
});
|
|
442
456
|
}}
|
|
443
457
|
onViewAttachmentDetails={async (attachment: Attachment) => {
|
|
444
|
-
const
|
|
458
|
+
const result = await saveDocument({
|
|
459
|
+
onFormSave,
|
|
460
|
+
});
|
|
445
461
|
|
|
446
|
-
if (!
|
|
462
|
+
if (!result.succeed) {
|
|
447
463
|
return;
|
|
448
464
|
}
|
|
449
465
|
|
|
@@ -462,4 +478,17 @@ function separator() {
|
|
|
462
478
|
return <div className="inline-block w-2" />;
|
|
463
479
|
}
|
|
464
480
|
|
|
481
|
+
async function saveDocument({
|
|
482
|
+
onFormSave,
|
|
483
|
+
}: {
|
|
484
|
+
onFormSave?: () => Promise<{ succeed: boolean; id: number }>;
|
|
485
|
+
}): Promise<{ succeed: boolean; currentId?: number }> {
|
|
486
|
+
const result = await onFormSave?.();
|
|
487
|
+
if (result?.succeed) {
|
|
488
|
+
return { succeed: true, currentId: result.id };
|
|
489
|
+
} else {
|
|
490
|
+
return { succeed: false, currentId: undefined };
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
465
494
|
export default FormActionBar;
|
|
@@ -11,7 +11,7 @@ export type ActionViewContextType = {
|
|
|
11
11
|
setFormIsSaving?: (value: boolean) => void;
|
|
12
12
|
formHasChanges?: boolean;
|
|
13
13
|
setFormHasChanges?: (value: boolean) => void;
|
|
14
|
-
onFormSave?: () => Promise<
|
|
14
|
+
onFormSave?: () => Promise<{ succeed: boolean; id: number }>;
|
|
15
15
|
formRef?: any;
|
|
16
16
|
searchTreeRef?: any;
|
|
17
17
|
onNewClicked: () => void;
|
|
@@ -22,7 +22,7 @@ export type FormContextType = {
|
|
|
22
22
|
domain: any[];
|
|
23
23
|
submitForm?: (options?: {
|
|
24
24
|
callOnSubmitSucceed?: boolean;
|
|
25
|
-
}) => Promise<boolean>;
|
|
25
|
+
}) => Promise<{ succeed: boolean; id: number }>;
|
|
26
26
|
fetchValues?: () => void;
|
|
27
27
|
formHasChanges?: () => boolean;
|
|
28
28
|
elementHasLostFocus?: () => void;
|
|
@@ -614,13 +614,13 @@ function Form(props: FormProps, ref: any) {
|
|
|
614
614
|
formSubmitting.current = false;
|
|
615
615
|
setFormHasChanges?.(false);
|
|
616
616
|
onCancel?.();
|
|
617
|
-
return true;
|
|
617
|
+
return { succeed: true, id: getCurrentId()! };
|
|
618
618
|
}
|
|
619
619
|
|
|
620
620
|
if (await checkIfFormHasErrors()) {
|
|
621
621
|
formSubmitting.current = false;
|
|
622
622
|
formErrorsDialog(lang);
|
|
623
|
-
return false;
|
|
623
|
+
return { succeed: false, id: getCurrentId()! };
|
|
624
624
|
}
|
|
625
625
|
|
|
626
626
|
setIsSubmitting(true);
|
|
@@ -653,7 +653,7 @@ function Form(props: FormProps, ref: any) {
|
|
|
653
653
|
setIsSubmitting(false);
|
|
654
654
|
}
|
|
655
655
|
|
|
656
|
-
return submitSucceed;
|
|
656
|
+
return { succeed: submitSucceed, id: getCurrentId()! };
|
|
657
657
|
};
|
|
658
658
|
|
|
659
659
|
const parseForm = ({
|