@idsoftsource/initial-process 4.2.7 → 4.2.8

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.
@@ -8,7 +8,7 @@ import * as i2 from '@angular/router';
8
8
  import { RouterModule, Router } from '@angular/router';
9
9
  import * as i1$1 from 'ngx-bootstrap/modal';
10
10
  import { ModalModule } from 'ngx-bootstrap/modal';
11
- import { catchError, throwError, shareReplay, map, Subject, takeUntil, of, firstValueFrom, tap as tap$1, Subscription, switchMap, forkJoin, finalize } from 'rxjs';
11
+ import { catchError, throwError, shareReplay, map, Subject, takeUntil, of, firstValueFrom, tap as tap$1, Subscription, switchMap, concat, toArray, finalize } from 'rxjs';
12
12
  import * as i1 from '@angular/common/http';
13
13
  import { HttpClient, HttpParams, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
14
14
  import * as i9 from '@auth0/auth0-angular';
@@ -35590,8 +35590,9 @@ class Step2CoverageComponent {
35590
35590
  userId;
35591
35591
  emailId;
35592
35592
  userDetail;
35593
- // Saved coverage row id per state, used to decide create / update / delete on save
35594
- existingIdByState = new Map();
35593
+ // Saved coverage record per state, used to decide create / update / delete on save.
35594
+ // The full record is kept because BulkUpdate checks its audit fields for concurrency.
35595
+ existingByState = new Map();
35595
35596
  initialCoverageSnapshot;
35596
35597
  constructor(store, usMapService, userCoverageAreaService, alertService, roleContextService, tokenService) {
35597
35598
  this.store = store;
@@ -35724,7 +35725,7 @@ class Step2CoverageComponent {
35724
35725
  next: (res) => {
35725
35726
  console.log(res);
35726
35727
  this.prefillCoverage(res.data);
35727
- this.existingIdByState = new Map((res.data || []).map((x) => [x.state, x.id]));
35728
+ this.existingByState = new Map((res.data || []).map((x) => [x.state, x]));
35728
35729
  if (this.selectedStates.length > 0) {
35729
35730
  this.store.selectedStates.set([...this.selectedStates]);
35730
35731
  }
@@ -35736,7 +35737,7 @@ class Step2CoverageComponent {
35736
35737
  refreshCoverageIds() {
35737
35738
  this.userCoverageAreaService.getUserCoverageAreaByUserId(this.userId).subscribe({
35738
35739
  next: (res) => {
35739
- this.existingIdByState = new Map((res.data || []).map((x) => [x.state, x.id]));
35740
+ this.existingByState = new Map((res.data || []).map((x) => [x.state, x]));
35740
35741
  },
35741
35742
  error: (err) => console.error(err)
35742
35743
  });
@@ -35782,22 +35783,23 @@ class Step2CoverageComponent {
35782
35783
  const toUpdate = [];
35783
35784
  const toDeleteIds = [];
35784
35785
  for (const e of entries) {
35785
- const id = this.existingIdByState.get(e.state);
35786
+ const existing = this.existingByState.get(e.state);
35786
35787
  if (e.counties.length === 0) {
35787
- if (id)
35788
- toDeleteIds.push(id);
35788
+ if (existing)
35789
+ toDeleteIds.push(existing.id);
35789
35790
  }
35790
- else if (id) {
35791
- toUpdate.push({ ...e, id, userId: this.userId, providerId: this.providerId });
35791
+ else if (existing) {
35792
+ // Start from the loaded record so audit/concurrency fields go back unchanged
35793
+ toUpdate.push({ ...existing, ...e, id: existing.id, userId: this.userId, providerId: this.providerId });
35792
35794
  }
35793
35795
  else {
35794
35796
  toCreate.push(e);
35795
35797
  }
35796
35798
  }
35797
35799
  // States removed from the dropdown entirely
35798
- this.existingIdByState.forEach((id, state) => {
35800
+ this.existingByState.forEach((existing, state) => {
35799
35801
  if (!entries.some(e => e.state === state))
35800
- toDeleteIds.push(id);
35802
+ toDeleteIds.push(existing.id);
35801
35803
  });
35802
35804
  const calls = [];
35803
35805
  if (toCreate.length)
@@ -35811,8 +35813,9 @@ class Step2CoverageComponent {
35811
35813
  this.store.nextStep();
35812
35814
  return;
35813
35815
  }
35814
- forkJoin(calls)
35815
- .pipe(finalize(() => (this.coverageSave = false)))
35816
+ // Run one after another; parallel writes for the same user trip the server's concurrency check
35817
+ concat(...calls)
35818
+ .pipe(toArray(), finalize(() => (this.coverageSave = false)))
35816
35819
  .subscribe({
35817
35820
  next: (results) => {
35818
35821
  const failed = results.find(r => r?.failed);