@veloceapps/sdk 2.0.13 → 2.0.15

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.
@@ -15,12 +15,14 @@ import * as i2$1 from '@veloce/sdk/runtime';
15
15
  import { RuntimeMode, RuntimeStep, ContextService } from '@veloce/sdk/runtime';
16
16
  import * as rxjsOperators from 'rxjs/operators';
17
17
  import { map, first, tap, catchError } from 'rxjs/operators';
18
+ import * as i5$1 from '@veloce/components';
19
+ import { ConfirmationComponent, LoaderModule, ConfirmationDialogModule } from '@veloce/components';
18
20
  import * as i1 from '@veloce/api';
19
21
  import { SalesforceApiService, QuoteApiService, DocumentTemplatesApiService, DocumentAttachmentApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloce/api';
20
22
  import * as i2 from 'primeng/api';
23
+ import * as i5 from 'primeng/dynamicdialog';
24
+ import { DialogService } from 'primeng/dynamicdialog';
21
25
  import { transform } from '@babel/standalone';
22
- import * as i5 from '@veloce/components';
23
- import { LoaderModule } from '@veloce/components';
24
26
 
25
27
  const DEFAULT_PLUGINS_TOKEN = new InjectionToken('DEFAULT_PLUGINS_TOKEN');
26
28
  const UI_DEFINITION_METADATA = new InjectionToken('UI_DEFINITION_METADATA_TOKEN');
@@ -436,7 +438,7 @@ const extractElementMetadata = (script) => {
436
438
  const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
437
439
  // need to reset regex last index to prevent null result for next execution
438
440
  METADATA_DECORATOR_REGEX.lastIndex = 0;
439
- return eval(`(${metadataString})`);
441
+ return new Function(`return ${metadataString}`)();
440
442
  };
441
443
  const extendElementMetadata = (script, extend) => {
442
444
  var _a;
@@ -446,7 +448,7 @@ const extendElementMetadata = (script, extend) => {
446
448
  if (!metadataString) {
447
449
  return script;
448
450
  }
449
- const updated = Object.assign(Object.assign({}, eval(`(${metadataString})`)), extend);
451
+ const updated = Object.assign(Object.assign({}, new Function(`return ${metadataString}`)()), extend);
450
452
  return script.replace(metadataString, stringifyElementMetadata(updated));
451
453
  };
452
454
  const getElementConfig = (type) => {
@@ -737,11 +739,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
737
739
  }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: i2$1.ContextService }, { type: RuntimeContextService }]; } });
738
740
 
739
741
  class ConfigurationService {
740
- constructor(runtimeService, contextService, configurationApiService, messageService) {
742
+ constructor(runtimeService, contextService, configurationApiService, messageService, dialogService) {
741
743
  this.runtimeService = runtimeService;
742
744
  this.contextService = contextService;
743
745
  this.configurationApiService = configurationApiService;
744
746
  this.messageService = messageService;
747
+ this.dialogService = dialogService;
745
748
  this.mode = ConfigurationMode.SEARCH;
746
749
  this.states = {};
747
750
  this.lineItem = new BehaviorSubject(undefined);
@@ -806,20 +809,20 @@ class ConfigurationService {
806
809
  const configurationRequest = this.createRequest(lineItem);
807
810
  configurationRequest.lineItems = this.states.currentState || [];
808
811
  configurationRequest.asset = this.states.asset;
809
- let request$;
810
- if (uiDefinitionProperties.pricingEnabled) {
811
- request$ = this.configurationApiService.configureAndPriceLineItem(configurationRequest, runtimeModel).pipe(map(({ lineItem, context, charges }) => {
812
- if (context) {
813
- this.contextService.update({ properties: context.properties });
814
- }
815
- this.charges.next(charges !== null && charges !== void 0 ? charges : {});
816
- return lineItem;
817
- }));
818
- }
819
- else {
820
- request$ = this.configurationApiService.configureLineItem(configurationRequest, runtimeModel);
821
- }
822
- return request$.pipe(tap(lineItem => lineItem && this.lineItem.next(lineItem)), catchError(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })));
812
+ const pricingEnabled = uiDefinitionProperties.pricingEnabled;
813
+ return this.configurationApiService
814
+ .configureLineItem({ configurationRequest, runtimeModel, pricingEnabled })
815
+ .pipe(map(({ lineItem, context, charges, deletedLineItems }) => {
816
+ if (context) {
817
+ this.contextService.update({ properties: context.properties });
818
+ }
819
+ this.charges.next(charges !== null && charges !== void 0 ? charges : {});
820
+ if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
821
+ this.showInactiveProductsConfirmation();
822
+ }
823
+ return lineItem;
824
+ }))
825
+ .pipe(tap(lineItem => lineItem && this.lineItem.next(lineItem)), catchError(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })));
823
826
  }
824
827
  createRequest(lineItem) {
825
828
  return {
@@ -830,12 +833,37 @@ class ConfigurationService {
830
833
  context: this.contextService.resolve(),
831
834
  };
832
835
  }
836
+ showInactiveProductsConfirmation() {
837
+ this.dialogService
838
+ .open(ConfirmationComponent, {
839
+ dismissableMask: false,
840
+ closeOnEscape: false,
841
+ closable: false,
842
+ showHeader: true,
843
+ header: `Inactive Products in Quote`,
844
+ width: '440px',
845
+ data: {
846
+ confirmationConfig: {
847
+ title: ' ',
848
+ description: 'This quote contains inactive products. Do you want to remove them?',
849
+ submitBtn: 'Remove products',
850
+ cancelBtn: 'Back to Quote',
851
+ },
852
+ },
853
+ })
854
+ .onClose.subscribe(result => {
855
+ if (!result) {
856
+ const context = this.contextService.resolve();
857
+ window['VELO_BACK_FN'].apply(null, [(context === null || context === void 0 ? void 0 : context.headerId) || '']);
858
+ }
859
+ });
860
+ }
833
861
  }
834
- ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService, deps: [{ token: ConfigurationRuntimeService }, { token: i2$1.ContextService }, { token: i1.ConfigurationApiService }, { token: i2.MessageService }], target: i0.ɵɵFactoryTarget.Injectable });
862
+ ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService, deps: [{ token: ConfigurationRuntimeService }, { token: i2$1.ContextService }, { token: i1.ConfigurationApiService }, { token: i2.MessageService }, { token: i5.DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
835
863
  ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService });
836
864
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService, decorators: [{
837
865
  type: Injectable
838
- }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: i2$1.ContextService }, { type: i1.ConfigurationApiService }, { type: i2.MessageService }]; } });
866
+ }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: i2$1.ContextService }, { type: i1.ConfigurationApiService }, { type: i2.MessageService }, { type: i5.DialogService }]; } });
839
867
 
840
868
  class ElementRendererComponent {
841
869
  constructor(parentInjector, dynamicModuleService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
@@ -1484,7 +1512,7 @@ class PreviewComponent {
1484
1512
  }
1485
1513
  }
1486
1514
  PreviewComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewComponent, deps: [{ token: LauncherService }, { token: ConfigurationService }, { token: i2.MessageService }, { token: ConfigurationRuntimeService }], target: i0.ɵɵFactoryTarget.Component });
1487
- PreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition" }, providers: [IOProviderService, TemplatesService], ngImport: i0, template: "<ng-container *ngIf=\"state$ | async as state\">\n <vl-loader *ngIf=\"state.loading; else content\" [label]=\"'Loading UI'\"></vl-loader>\n\n <ng-template #content>\n <ng-container *ngIf=\"!state.failure\">\n <vl-cms-element-renderer *ngFor=\"let el of elements\" [meta]=\"el\"></vl-cms-element-renderer>\n </ng-container>\n </ng-template>\n</ng-container>\n", styles: [":host{flex-grow:1;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: i5.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i7.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
1515
+ PreviewComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.15", type: PreviewComponent, selector: "vl-cms-preview", inputs: { modelId: "modelId", uiDefinition: "uiDefinition" }, providers: [IOProviderService, TemplatesService], ngImport: i0, template: "<ng-container *ngIf=\"state$ | async as state\">\n <vl-loader *ngIf=\"state.loading; else content\" [label]=\"'Loading UI'\"></vl-loader>\n\n <ng-template #content>\n <ng-container *ngIf=\"!state.failure\">\n <vl-cms-element-renderer *ngFor=\"let el of elements\" [meta]=\"el\"></vl-cms-element-renderer>\n </ng-container>\n </ng-template>\n</ng-container>\n", styles: [":host{flex-grow:1;display:flex;flex-direction:column;height:100%}\n"], components: [{ type: i5$1.LoaderComponent, selector: "vl-loader", inputs: ["label", "overlayVisible"] }, { type: ElementRendererComponent, selector: "vl-cms-element-renderer", inputs: ["meta"] }], directives: [{ type: i7.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i7.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i7.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
1488
1516
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewComponent, decorators: [{
1489
1517
  type: Component,
1490
1518
  args: [{
@@ -1552,7 +1580,7 @@ function ElementDefinition(definition) {
1552
1580
  class ConfigurationModule {
1553
1581
  }
1554
1582
  ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1555
- ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule });
1583
+ ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
1556
1584
  ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, providers: [
1557
1585
  ContextService,
1558
1586
  ContextApiService,
@@ -1561,10 +1589,11 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
1561
1589
  ConfigurationRuntimeService,
1562
1590
  RuntimeContextService,
1563
1591
  ConfigurationService,
1564
- ] });
1592
+ ], imports: [[ConfirmationDialogModule]] });
1565
1593
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, decorators: [{
1566
1594
  type: NgModule,
1567
1595
  args: [{
1596
+ imports: [ConfirmationDialogModule],
1568
1597
  providers: [
1569
1598
  ContextService,
1570
1599
  ContextApiService,
@@ -1588,6 +1617,7 @@ LauncherModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version:
1588
1617
  QuoteApiService,
1589
1618
  DocumentTemplatesApiService,
1590
1619
  DocumentAttachmentApiService,
1620
+ DialogService,
1591
1621
  ], imports: [[CommonModule, CoreModule, ConfigurationModule]] });
1592
1622
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: LauncherModule, decorators: [{
1593
1623
  type: NgModule,
@@ -1600,6 +1630,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
1600
1630
  QuoteApiService,
1601
1631
  DocumentTemplatesApiService,
1602
1632
  DocumentAttachmentApiService,
1633
+ DialogService,
1603
1634
  ],
1604
1635
  }]
1605
1636
  }] });