@veloceapps/sdk 12.0.0-1 → 12.0.0-10
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/core/modules/configuration/services/configuration-runtime.service.d.ts +4 -2
- package/core/modules/configuration/services/configuration.service.d.ts +2 -0
- package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +13 -4
- package/esm2020/core/modules/configuration/services/configuration.service.mjs +15 -2
- package/esm2020/core/modules/configuration/services/test-mode-configuration.service.mjs +2 -2
- package/esm2020/core/utils/transaction-item.utils.mjs +10 -2
- package/fesm2015/veloceapps-sdk-core.mjs +33 -5
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +35 -5
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +1 -1
@@ -6,7 +6,7 @@ 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 {
|
9
|
+
import { BehaviorSubject, tap, map, filter, switchMap, of, forkJoin, noop, throwError, distinctUntilChanged, Subject, catchError as catchError$1, combineLatest, finalize as finalize$1, buffer, debounceTime, share, take, 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
12
|
import { filter as filter$1, map as map$1, tap as tap$1, catchError, finalize } from 'rxjs/operators';
|
@@ -18,18 +18,27 @@ class ConfigurationRuntimeService {
|
|
18
18
|
constructor(pcmApiService) {
|
19
19
|
this.pcmApiService = pcmApiService;
|
20
20
|
this.uiDefinitionContainer = null;
|
21
|
+
this.pcmModelSubj$ = new BehaviorSubject(null);
|
21
22
|
}
|
22
23
|
get uiDefinitionProps() {
|
23
24
|
return this.uiDefinitionContainer?.source.properties ?? {};
|
24
25
|
}
|
26
|
+
get pcmModel() {
|
27
|
+
return this.pcmModelSubj$.value;
|
28
|
+
}
|
29
|
+
get pcmModel$() {
|
30
|
+
return this.pcmModelSubj$;
|
31
|
+
}
|
25
32
|
reset() {
|
26
33
|
this.uiDefinitionContainer = null;
|
27
34
|
this.initializationProps = undefined;
|
28
|
-
this.
|
35
|
+
this.pcmModelSubj$.next(null);
|
29
36
|
}
|
30
37
|
init$(props) {
|
31
38
|
this.initializationProps = props;
|
32
|
-
return this.pcmApiService
|
39
|
+
return this.pcmApiService
|
40
|
+
.fetchPCMByProductId(props.productId)
|
41
|
+
.pipe(tap(pcmModel => this.pcmModelSubj$.next(pcmModel)));
|
33
42
|
}
|
34
43
|
}
|
35
44
|
ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.PCMApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
@@ -362,6 +371,10 @@ const generateTransactionItemFromPCM = (option, salesTransactionId, parentTi) =>
|
|
362
371
|
productName: option.name,
|
363
372
|
productCode: option.productCode,
|
364
373
|
productRelatedComponentId: option.productRelatedComponent?.id,
|
374
|
+
constraintEngineNodeStatus: {
|
375
|
+
attributes: [],
|
376
|
+
cfgStatus: 'User',
|
377
|
+
},
|
365
378
|
stiAttributes: [],
|
366
379
|
attributes: {
|
367
380
|
ParentReference: salesTransactionId,
|
@@ -421,11 +434,15 @@ const updateQuantity = (ti, qty, pcm, parentQty = 1) => {
|
|
421
434
|
else if (parentPrevQty !== parentNewQty) {
|
422
435
|
nextQty = calcNewQty(item, parentPrevQty, parentNewQty, pcm, qty, false);
|
423
436
|
}
|
424
|
-
|
437
|
+
const sti = {
|
425
438
|
...item,
|
426
439
|
qty: nextQty,
|
427
440
|
children: item.children.map(child => updateItem(child, item.qty, nextQty, false)),
|
428
441
|
};
|
442
|
+
if (nextQty !== item.qty) {
|
443
|
+
sti.constraintEngineNodeStatus = { ...sti.constraintEngineNodeStatus, cfgStatus: 'User' };
|
444
|
+
}
|
445
|
+
return sti;
|
429
446
|
};
|
430
447
|
return updateItem(ti, parentQty, parentQty, false);
|
431
448
|
};
|
@@ -644,6 +661,19 @@ class ConfigurationService {
|
|
644
661
|
}
|
645
662
|
return pcmModel;
|
646
663
|
}
|
664
|
+
getPCMModel$() {
|
665
|
+
return this.configurationRuntimeService.pcmModel$.pipe(distinctUntilChanged((prev, curr) => prev?.id === curr?.id));
|
666
|
+
}
|
667
|
+
swapProduct$(productId) {
|
668
|
+
const rootTransactionItem = this.root;
|
669
|
+
this.flowInfoService.updateContext({ productId });
|
670
|
+
return this.configurationRuntimeService.init$({ productId }).pipe(map$1(pcm => generateTransactionItem(pcm, this.state?.salesTransaction.id, rootTransactionItem?.qty)), switchMap(salesTransactionItem => {
|
671
|
+
return this.patch$({
|
672
|
+
...salesTransactionItem,
|
673
|
+
id: rootTransactionItem?.id ?? salesTransactionItem.id,
|
674
|
+
});
|
675
|
+
}));
|
676
|
+
}
|
647
677
|
}
|
648
678
|
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: FlowInfoService }, { token: i2.MessageService }, { token: ConfigurationRuntimeService }, { token: SalesTransactionService }, { token: i1.OrchestrationsApiService }, { token: GuidedSellingService }], target: i0.ɵɵFactoryTarget.Injectable });
|
649
679
|
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
|
@@ -795,7 +825,7 @@ class TestModeConfigurationService {
|
|
795
825
|
initTestMode$(uiDefinitionContainer, options) {
|
796
826
|
this.configurationRuntimeService.uiDefinitionContainer = uiDefinitionContainer;
|
797
827
|
if (this.checkInitialized(uiDefinitionContainer)) {
|
798
|
-
this.configurationRuntimeService.pcmModel
|
828
|
+
this.configurationRuntimeService.pcmModelSubj$.next(this.pcmModel || null);
|
799
829
|
return of(undefined);
|
800
830
|
}
|
801
831
|
this.configurationService.reset();
|