@veloceapps/sdk 2.0.13 → 2.0.14

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,13 @@ 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';
21
24
  import { transform } from '@babel/standalone';
22
- import * as i5 from '@veloce/components';
23
- import { LoaderModule } from '@veloce/components';
24
25
 
25
26
  const DEFAULT_PLUGINS_TOKEN = new InjectionToken('DEFAULT_PLUGINS_TOKEN');
26
27
  const UI_DEFINITION_METADATA = new InjectionToken('UI_DEFINITION_METADATA_TOKEN');
@@ -436,7 +437,7 @@ const extractElementMetadata = (script) => {
436
437
  const metadataString = ((_a = METADATA_DECORATOR_REGEX.exec(script)) !== null && _a !== void 0 ? _a : [])[1];
437
438
  // need to reset regex last index to prevent null result for next execution
438
439
  METADATA_DECORATOR_REGEX.lastIndex = 0;
439
- return eval(`(${metadataString})`);
440
+ return new Function(`return ${metadataString}`)();
440
441
  };
441
442
  const extendElementMetadata = (script, extend) => {
442
443
  var _a;
@@ -446,7 +447,7 @@ const extendElementMetadata = (script, extend) => {
446
447
  if (!metadataString) {
447
448
  return script;
448
449
  }
449
- const updated = Object.assign(Object.assign({}, eval(`(${metadataString})`)), extend);
450
+ const updated = Object.assign(Object.assign({}, new Function(`return ${metadataString}`)()), extend);
450
451
  return script.replace(metadataString, stringifyElementMetadata(updated));
451
452
  };
452
453
  const getElementConfig = (type) => {
@@ -737,11 +738,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
737
738
  }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: i2$1.ContextService }, { type: RuntimeContextService }]; } });
738
739
 
739
740
  class ConfigurationService {
740
- constructor(runtimeService, contextService, configurationApiService, messageService) {
741
+ constructor(runtimeService, contextService, configurationApiService, messageService, dialogService) {
741
742
  this.runtimeService = runtimeService;
742
743
  this.contextService = contextService;
743
744
  this.configurationApiService = configurationApiService;
744
745
  this.messageService = messageService;
746
+ this.dialogService = dialogService;
745
747
  this.mode = ConfigurationMode.SEARCH;
746
748
  this.states = {};
747
749
  this.lineItem = new BehaviorSubject(undefined);
@@ -806,20 +808,20 @@ class ConfigurationService {
806
808
  const configurationRequest = this.createRequest(lineItem);
807
809
  configurationRequest.lineItems = this.states.currentState || [];
808
810
  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)); })));
811
+ const pricingEnabled = uiDefinitionProperties.pricingEnabled;
812
+ return this.configurationApiService
813
+ .configureLineItem({ configurationRequest, runtimeModel, pricingEnabled })
814
+ .pipe(map(({ lineItem, context, charges, deletedLineItems }) => {
815
+ if (context) {
816
+ this.contextService.update({ properties: context.properties });
817
+ }
818
+ this.charges.next(charges !== null && charges !== void 0 ? charges : {});
819
+ if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
820
+ this.showInactiveProductsConfirmation();
821
+ }
822
+ return lineItem;
823
+ }))
824
+ .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
825
  }
824
826
  createRequest(lineItem) {
825
827
  return {
@@ -830,12 +832,37 @@ class ConfigurationService {
830
832
  context: this.contextService.resolve(),
831
833
  };
832
834
  }
835
+ showInactiveProductsConfirmation() {
836
+ this.dialogService
837
+ .open(ConfirmationComponent, {
838
+ dismissableMask: false,
839
+ closeOnEscape: false,
840
+ closable: false,
841
+ showHeader: true,
842
+ header: `Inactive Products in Quote`,
843
+ width: '440px',
844
+ data: {
845
+ confirmationConfig: {
846
+ title: ' ',
847
+ description: 'This quote contains inactive products. Do you want to remove them?',
848
+ submitBtn: 'Remove products',
849
+ cancelBtn: 'Back to Quote',
850
+ },
851
+ },
852
+ })
853
+ .onClose.subscribe(result => {
854
+ if (!result) {
855
+ const context = this.contextService.resolve();
856
+ window['VELO_BACK_FN'].apply(null, [(context === null || context === void 0 ? void 0 : context.headerId) || '']);
857
+ }
858
+ });
859
+ }
833
860
  }
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 });
861
+ 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
862
  ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService });
836
863
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationService, decorators: [{
837
864
  type: Injectable
838
- }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: i2$1.ContextService }, { type: i1.ConfigurationApiService }, { type: i2.MessageService }]; } });
865
+ }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: i2$1.ContextService }, { type: i1.ConfigurationApiService }, { type: i2.MessageService }, { type: i5.DialogService }]; } });
839
866
 
840
867
  class ElementRendererComponent {
841
868
  constructor(parentInjector, dynamicModuleService, elementContext, ioProviderService, configurationService, elementRef, cdr) {
@@ -1484,7 +1511,7 @@ class PreviewComponent {
1484
1511
  }
1485
1512
  }
1486
1513
  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 });
1514
+ 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
1515
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: PreviewComponent, decorators: [{
1489
1516
  type: Component,
1490
1517
  args: [{
@@ -1552,7 +1579,7 @@ function ElementDefinition(definition) {
1552
1579
  class ConfigurationModule {
1553
1580
  }
1554
1581
  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 });
1582
+ ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
1556
1583
  ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, providers: [
1557
1584
  ContextService,
1558
1585
  ContextApiService,
@@ -1561,10 +1588,11 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
1561
1588
  ConfigurationRuntimeService,
1562
1589
  RuntimeContextService,
1563
1590
  ConfigurationService,
1564
- ] });
1591
+ ], imports: [[ConfirmationDialogModule]] });
1565
1592
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ConfigurationModule, decorators: [{
1566
1593
  type: NgModule,
1567
1594
  args: [{
1595
+ imports: [ConfirmationDialogModule],
1568
1596
  providers: [
1569
1597
  ContextService,
1570
1598
  ContextApiService,