@dsivd/prestations-ng 19.2.0-beta.17 → 19.2.0-beta.18

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/CHANGELOG.md CHANGED
@@ -14,7 +14,8 @@
14
14
  - New `prestationsNg.configs.specTsRecommended` ESLint config for the Vitest specs, to use in the `extends` of a
15
15
  `**/*.spec.ts` block: the `recommended` config of `@vitest/eslint-plugin`, which also counts the assertions of
16
16
  the `HttpTestingController` and of the helpers of the specs. It needs `@vitest/eslint-plugin` in the
17
- devDependencies of your project, only when you use it. See
17
+ devDependencies of your project, only when you use it: 1.6.27 with the TypeScript 5.9 of Angular 21, later
18
+ versions need TypeScript 6. See
18
19
  [UPGRADING_V19.md](UPGRADING_V19.md#migrate-to-eslint-flat-configuration).
19
20
  - [foehn-bo-multi-upload.component.ts](projects/prestations-ng/src/foehn-upload/foehn-bo-multi-upload/foehn-bo-multi-upload.component.ts)
20
21
  - New `localUpload` input. When set to `true`, selected files are kept purely local
package/GOOD_PRACTICES.md CHANGED
@@ -418,8 +418,8 @@ export class PageOneComponent
418
418
  ### Displaying an asynchronous state
419
419
 
420
420
  > ⚠️ A field modified elsewhere (in a `subscribe()`, a `setTimeout()`, a `Promise`, a
421
- > callback, ...) is no longer displayed until something else refreshes the component. Hold it in
422
- > a **signal**.
421
+ > callback, an `effect()`, ...) is no longer displayed until something else refreshes the component.
422
+ > Hold it in a **signal**.
423
423
 
424
424
  What **not** to do:
425
425
 
@@ -454,9 +454,14 @@ ngOnInit(): void {
454
454
  > 💡 For an observable displayed as is, `toSignal(this.myService.load())` or the `async` pipe do
455
455
  > the job for you.
456
456
 
457
- In your pages (`AbstractPageComponent`), prestations-ng refreshes the page when it loads `form`
458
- and `reference`. If you modify the form yourself in an asynchronous callback, call
459
- `markForCheck()` afterwards:
457
+ Do the same for a field read by the template that only a method called by a listener of the template
458
+ modifies: the listener notifies Angular, but the same method can later be called from a `subscribe()`
459
+ or an `effect()`, and the field would no longer be displayed. A signal notifies Angular whoever
460
+ modifies it.
461
+
462
+ In your pages (`AbstractPageComponent`), `form` can't be a signal. prestations-ng refreshes the page
463
+ when it loads `form` and `reference`, but whenever your code modifies the form, call `markForCheck()`
464
+ after the modifications, whoever calls the method (a listener, a callback, an `effect()`, ...):
460
465
 
461
466
  ```ts
462
467
  private readonly changeDetectorRef = inject(ChangeDetectorRef);
@@ -465,13 +470,19 @@ ngOnInit(): void {
465
470
  super.ngOnInit();
466
471
  this.sessionInfoWithApplicationService.prefillForm((info) => {
467
472
  if (this.form) {
468
- this.form.email = info?.email ?? null;
473
+ this.form.firstName = info?.firstName ?? null;
474
+ this.form.lastName = info?.lastName ?? null;
469
475
  this.changeDetectorRef.markForCheck();
470
476
  }
471
477
  });
472
478
  }
473
479
  ```
474
480
 
481
+ - Once after the last modification is enough: Angular refreshes the page later, with all the
482
+ modifications of the method. After an `await`, or in another callback, call it again.
483
+ - A signal modified next to the form doesn't replace it: `set()` notifies Angular only when the value
484
+ changes (e.g. an amount recalculated identical), and only refreshes the views reading the signal.
485
+
475
486
  If a service fills the form for the page, the page must still be notified: let the service return an
476
487
  `Observable` (or take a callback), and call `markForCheck()` in the page.
477
488
 
package/UPGRADING_V19.md CHANGED
@@ -1065,9 +1065,12 @@ npm install --save-dev eslint-config-prettier@10
1065
1065
  npm install --save-dev eslint-plugin-import-x@4
1066
1066
  npm install --save-dev prettier
1067
1067
  # only if your project has Vitest specs (see "Migrate to vitest")
1068
- npm install --save-dev @vitest/eslint-plugin@1
1068
+ npm install --save-dev --save-exact @vitest/eslint-plugin@1.6.27
1069
1069
  ```
1070
1070
 
1071
+ `@vitest/eslint-plugin` 1.6.28 and later need TypeScript 6: with the TypeScript 5.9 of Angular 21, `npm install` fails
1072
+ with `ERESOLVE`. Keep 1.6.27 until your project moves to TypeScript 6.
1073
+
1071
1074
  In your `front` folder, add a `.prettierrc` file with the following content:
1072
1075
 
1073
1076
  ```json
@@ -1621,9 +1624,10 @@ Without zone.js, Angular refreshes a component only when it is notified that som
1621
1624
  - a signal read by its template has changed (`signal()`, `computed()`, `input()`, `model()`, `toSignal()`...)
1622
1625
  - `ChangeDetectorRef.markForCheck()` has been called, which is what the `async` pipe does when an observable emits
1623
1626
 
1624
- A field modified elsewhere (in a `subscribe()`, a `setTimeout()`, a `Promise`, a callback...) is not displayed
1625
- anymore until something else refreshes the component. Hold it in a signal (see
1626
- [INTRODUCTION_ANGULAR_SIGNALS.md](INTRODUCTION_ANGULAR_SIGNALS.md)):
1627
+ A field modified elsewhere (in a `subscribe()`, a `setTimeout()`, a `Promise`, a callback, an `effect()`...) is not
1628
+ displayed anymore until something else refreshes the component. Hold it in a signal (see
1629
+ [INTRODUCTION_ANGULAR_SIGNALS.md](INTRODUCTION_ANGULAR_SIGNALS.md)), as well as the fields read by the template that
1630
+ only a method called by a listener modifies: this method can later be called from elsewhere.
1627
1631
 
1628
1632
  ```diff
1629
1633
  - isLoading = true;
@@ -1644,10 +1648,11 @@ anymore until something else refreshes the component. Hold it in a signal (see
1644
1648
 
1645
1649
  Pay attention to:
1646
1650
 
1647
- - your pages (`AbstractPageComponent` and its subclasses): prestations-ng refreshes them when it sets `form` and
1648
- `reference`. But if you modify the form yourself in an asynchronous callback, e.g. the one given to
1649
- `SessionInfoWithApplicationService.prefillForm()` or a `subscribe()` of your own service, call
1650
- `markForCheck()` afterwards:
1651
+ - your pages (`AbstractPageComponent` and its subclasses): `form` can't be a signal. prestations-ng refreshes them
1652
+ when it sets `form` and `reference`, but whenever your code modifies the form, call `markForCheck()` once after the
1653
+ modifications, whoever calls the method: a listener, an asynchronous callback (e.g. the one given to
1654
+ `SessionInfoWithApplicationService.prefillForm()` or a `subscribe()` of your own service), an `effect()`... A
1655
+ signal modified next to the form doesn't replace it: `set()` notifies Angular only when the value changes.
1651
1656
 
1652
1657
  ```ts
1653
1658
  private readonly changeDetectorRef = inject(ChangeDetectorRef);
@@ -1656,7 +1661,8 @@ Pay attention to:
1656
1661
  super.ngOnInit();
1657
1662
  this.sessionInfoWithApplicationService.prefillForm((info) => {
1658
1663
  if (this.form) {
1659
- this.form.email = info?.email ?? null;
1664
+ this.form.firstName = info?.firstName ?? null;
1665
+ this.form.lastName = info?.lastName ?? null;
1660
1666
  this.changeDetectorRef.markForCheck();
1661
1667
  }
1662
1668
  });
package/package.json CHANGED
@@ -39,7 +39,7 @@
39
39
  "ng-update": {
40
40
  "migrations": "./schematics/migration-collection.json"
41
41
  },
42
- "version": "19.2.0-beta.17",
42
+ "version": "19.2.0-beta.18",
43
43
  "module": "fesm2022/dsivd-prestations-ng.mjs",
44
44
  "typings": "types/dsivd-prestations-ng.d.ts",
45
45
  "exports": {