@gisce/react-ooui 1.1.34 → 1.1.35-rc.0

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.1.34",
3
+ "version": "1.1.35-rc.0",
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.13",
39
+ "@gisce/ooui": "^0.17.14-rc.0",
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,13 +343,9 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
343
343
  if (!action) {
344
344
  return;
345
345
  }
346
+ const savedSucceed = await onFormSave?.();
346
347
 
347
- const result = await saveNewDocumentIfNeeded({
348
- onFormSave,
349
- currentId,
350
- });
351
-
352
- if (!result.succeed) {
348
+ if (!savedSucceed) {
353
349
  return;
354
350
  }
355
351
 
@@ -365,21 +361,15 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
365
361
  if (!report) {
366
362
  return;
367
363
  }
368
- const result = await saveNewDocumentIfNeeded({
369
- onFormSave,
370
- currentId,
371
- });
364
+ const savedSucceed = await onFormSave?.();
372
365
 
373
- if (!result.succeed) {
366
+ if (!savedSucceed) {
374
367
  return;
375
368
  }
376
369
 
377
370
  runAction({
378
371
  ...report,
379
- datas: {
380
- ...(report.datas || {}),
381
- ids: [result.currentId as number],
382
- },
372
+ datas: { ...(report.datas || {}), ids: [currentId as number] },
383
373
  });
384
374
  }}
385
375
  />
@@ -393,12 +383,9 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
393
383
  return;
394
384
  }
395
385
 
396
- const result = await saveNewDocumentIfNeeded({
397
- onFormSave,
398
- currentId,
399
- });
386
+ const savedSucceed = await onFormSave?.();
400
387
 
401
- if (!result.succeed) {
388
+ if (!savedSucceed) {
402
389
  return;
403
390
  }
404
391
 
@@ -415,16 +402,13 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
415
402
  disabled={mustDisableButtons}
416
403
  attachments={attachments}
417
404
  onAddNewAttachment={async () => {
418
- const result = await saveNewDocumentIfNeeded({
419
- onFormSave,
420
- currentId,
421
- });
405
+ const savedSucceed = await onFormSave?.();
422
406
 
423
- if (!result.succeed) {
407
+ if (!savedSucceed) {
424
408
  return;
425
409
  }
426
410
 
427
- const res_id = result.currentId as number;
411
+ const res_id = currentId as number;
428
412
  const res_model = currentModel as string;
429
413
  openDefaultActionForModel({
430
414
  model: "ir.attachment",
@@ -439,16 +423,13 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
439
423
  });
440
424
  }}
441
425
  onListAllAttachments={async () => {
442
- const result = await saveNewDocumentIfNeeded({
443
- onFormSave,
444
- currentId,
445
- });
426
+ const savedSucceed = await onFormSave?.();
446
427
 
447
- if (!result.succeed) {
428
+ if (!savedSucceed) {
448
429
  return;
449
430
  }
450
431
 
451
- const res_id = result.currentId as number;
432
+ const res_id = currentId as number;
452
433
  const res_model = currentModel as string;
453
434
  openDefaultActionForModel({
454
435
  model: "ir.attachment",
@@ -460,12 +441,9 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
460
441
  });
461
442
  }}
462
443
  onViewAttachmentDetails={async (attachment: Attachment) => {
463
- const result = await saveNewDocumentIfNeeded({
464
- onFormSave,
465
- currentId,
466
- });
444
+ const savedSucceed = await onFormSave?.();
467
445
 
468
- if (!result.succeed) {
446
+ if (!savedSucceed) {
469
447
  return;
470
448
  }
471
449
 
@@ -484,23 +462,4 @@ function separator() {
484
462
  return <div className="inline-block w-2" />;
485
463
  }
486
464
 
487
- async function saveNewDocumentIfNeeded({
488
- onFormSave,
489
- currentId,
490
- }: {
491
- onFormSave?: () => Promise<{ succeed: boolean; id: number }>;
492
- currentId: number | undefined;
493
- }): Promise<{ succeed: boolean; currentId?: number }> {
494
- if (currentId !== undefined) {
495
- return { succeed: true, currentId: currentId };
496
- }
497
- const result = await onFormSave?.();
498
-
499
- if (result?.succeed) {
500
- return { succeed: true, currentId: result.id };
501
- } else {
502
- return { succeed: false, currentId: undefined };
503
- }
504
- }
505
-
506
465
  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<{ succeed: boolean; id: number }>;
14
+ onFormSave?: () => Promise<void>;
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<{ succeed: boolean; id: number }>;
25
+ }) => Promise<boolean>;
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 { succeed: true, id: getCurrentId()! };
617
+ return true;
618
618
  }
619
619
 
620
620
  if (await checkIfFormHasErrors()) {
621
621
  formSubmitting.current = false;
622
622
  formErrorsDialog(lang);
623
- return { succeed: false, id: getCurrentId()! };
623
+ return false;
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 { succeed: submitSucceed, id: getCurrentId()! };
656
+ return submitSucceed;
657
657
  };
658
658
 
659
659
  const parseForm = ({