@veloceapps/sdk 11.0.0-70 → 11.0.0-72

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.
@@ -6,10 +6,10 @@ import { ApiModule } from '@veloceapps/api';
6
6
  import * as i6 from '@veloceapps/components';
7
7
  import { ToastType, ConfirmationDialogModule } from '@veloceapps/components';
8
8
  import * as i1 from '@veloceapps/api/v2';
9
- import { tap, BehaviorSubject, map, filter, switchMap, of, forkJoin, throwError, noop, Subject, catchError as catchError$1, combineLatest, finalize as finalize$1, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil, first } from 'rxjs';
9
+ import { tap, BehaviorSubject, map, filter, switchMap, of, forkJoin, noop, throwError, Subject, catchError as catchError$1, combineLatest, finalize as finalize$1, buffer, debounceTime, share, take, distinctUntilChanged, shareReplay, takeUntil, first } from 'rxjs';
10
10
  import { uniqBy, flatten, omit, cloneDeep, assign, isEqual } from 'lodash';
11
11
  import * as i2 from 'primeng/api';
12
- import { filter as filter$1, map as map$1, catchError, tap as tap$1, finalize } from 'rxjs/operators';
12
+ import { filter as filter$1, map as map$1, tap as tap$1, catchError, finalize } from 'rxjs/operators';
13
13
  import { NgControl } from '@angular/forms';
14
14
  import 'primeng/calendar';
15
15
  import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
@@ -399,14 +399,18 @@ class ConfigurationService {
399
399
  init$() {
400
400
  const { state } = this.salesTransactionService;
401
401
  const { productId, transactionItemId } = this.flowInfoService.context;
402
- if (!state) {
402
+ if (!state || !productId) {
403
403
  return of(undefined);
404
404
  }
405
405
  const salesTransactionItems = state?.salesTransaction.salesTransactionItems ?? [];
406
+ let isRootGenerated = false;
406
407
  let transactionItem = salesTransactionItems.find(item => item.id === transactionItemId);
407
- if (!transactionItem && productId) {
408
- transactionItem =
409
- salesTransactionItems.find(item => item.productId === productId) ?? generateTransactionItem(productId);
408
+ if (!transactionItem) {
409
+ transactionItem = salesTransactionItems.find(item => item.productId === productId);
410
+ }
411
+ if (!transactionItem) {
412
+ transactionItem = generateTransactionItem(productId);
413
+ isRootGenerated = true;
410
414
  }
411
415
  const configurationState = {
412
416
  ...state,
@@ -415,9 +419,10 @@ class ConfigurationService {
415
419
  salesTransactionItems: transactionItem ? [transactionItem] : [],
416
420
  },
417
421
  };
418
- this.configurationStateSubj$.next(configurationState);
419
- this.previousConfigurationStateSubj$.next(configurationState);
420
- return of(undefined);
422
+ return (isRootGenerated ? this.configureRequest$(configurationState) : of(configurationState)).pipe(tap$1(configurationState => {
423
+ this.configurationStateSubj$.next(configurationState);
424
+ this.previousConfigurationStateSubj$.next(configurationState);
425
+ }), map$1(noop));
421
426
  }
422
427
  patch$(transactionItem) {
423
428
  const { state, root } = this;
@@ -459,7 +464,7 @@ class ConfigurationService {
459
464
  return this.orchestrationsApiService.apply$(request).pipe(tap$1(result => {
460
465
  this.configurationStateSubj$.next(result);
461
466
  this.previousConfigurationStateSubj$.next(cloneDeep(result));
462
- }), map$1(response => response.salesTransaction), catchError(error => throwError(() => {
467
+ }), catchError(error => throwError(() => {
463
468
  const resetState = this.previousConfigurationStateSubj$.getValue();
464
469
  if (resetState) {
465
470
  this.previousConfigurationStateSubj$.next(cloneDeep(resetState));