@veloceapps/sdk 5.0.14-GOOGLE → 5.0.15-0
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/bundles/{veloce-sdk-cms.umd.js → veloceapps-sdk-cms.umd.js} +149 -81
- package/bundles/veloceapps-sdk-cms.umd.js.map +1 -0
- package/bundles/{veloce-sdk-core.umd.js → veloceapps-sdk-core.umd.js} +765 -543
- package/bundles/veloceapps-sdk-core.umd.js.map +1 -0
- package/bundles/{veloce-sdk-runtime.umd.js → veloceapps-sdk-runtime.umd.js} +213 -146
- package/bundles/veloceapps-sdk-runtime.umd.js.map +1 -0
- package/bundles/{veloce-sdk.umd.js → veloceapps-sdk.umd.js} +225 -154
- package/bundles/veloceapps-sdk.umd.js.map +1 -0
- package/cms/cms.default.d.ts +1 -1
- package/cms/components/element-renderer/element-renderer.component.d.ts +1 -1
- package/cms/components/preview/preview.component.d.ts +1 -1
- package/cms/components/preview/preview.module.d.ts +1 -1
- package/cms/injection-tokens.d.ts +1 -1
- package/cms/launcher.module.d.ts +3 -3
- package/cms/modules/federated/federated.module.d.ts +1 -1
- package/cms/package.json +7 -7
- package/cms/services/launcher.service.d.ts +1 -1
- package/cms/types/configuration.types.d.ts +1 -1
- package/cms/utils/element.utils.d.ts +1 -1
- package/cms/utils/elements-resolver.d.ts +1 -1
- package/{core/veloce-sdk-core.d.ts → cms/veloceapps-sdk-cms.d.ts} +1 -1
- package/cms/vendor-map.d.ts +86 -82
- package/core/modules/configuration/configuration.module.d.ts +1 -1
- package/core/modules/configuration/helpers.d.ts +1 -1
- package/core/modules/configuration/services/configuration-runtime.service.d.ts +3 -3
- package/core/modules/configuration/services/configuration.service.d.ts +4 -3
- package/core/modules/configuration/services/runtime-context.service.d.ts +1 -1
- package/core/modules/configuration/types/configuration-runtime.types.d.ts +1 -1
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +5 -4
- package/core/modules/flow-configuration/services/flow-update.service.d.ts +1 -1
- package/core/package.json +7 -7
- package/core/services/context.service.d.ts +2 -2
- package/core/services/index.d.ts +1 -0
- package/core/services/metric-calculation/metric-calculation.service.d.ts +21 -0
- package/core/services/metric-calculation/metric-calculation.types.d.ts +1 -0
- package/core/services/metric-calculation/metric-calculation.utils.d.ts +5 -0
- package/core/services/product-images.service.d.ts +1 -1
- package/core/services/quote-draft.service.d.ts +5 -3
- package/core/types/quote-states.types.d.ts +1 -1
- package/core/types/runtime.types.d.ts +1 -1
- package/core/utils/line-item.utils.d.ts +2 -1
- package/core/utils/line-item.worker.d.ts +1 -1
- package/{runtime/veloce-sdk-runtime.d.ts → core/veloceapps-sdk-core.d.ts} +1 -1
- package/esm2015/cms/cms.default.js +1 -1
- package/esm2015/cms/components/element-children/element-children.component.js +3 -3
- package/esm2015/cms/components/element-children/element-children.module.js +4 -4
- package/esm2015/cms/components/element-renderer/element-renderer.component.js +6 -6
- package/esm2015/cms/components/element-renderer/element-renderer.module.js +4 -4
- package/esm2015/cms/components/plugin.component.js +3 -3
- package/esm2015/cms/components/preview/preview.component.js +6 -6
- package/esm2015/cms/components/preview/preview.module.js +6 -6
- package/esm2015/cms/directives/custom-template.directive.js +3 -3
- package/esm2015/cms/injection-tokens.js +1 -1
- package/esm2015/cms/launcher.module.js +8 -8
- package/esm2015/cms/modules/federated/federated.component.js +4 -4
- package/esm2015/cms/modules/federated/federated.module.js +6 -6
- package/esm2015/cms/plugins/configuration.plugin.js +5 -5
- package/esm2015/cms/plugins/io.plugin.js +3 -3
- package/esm2015/cms/plugins/script.plugin.js +5 -5
- package/esm2015/cms/services/dynamic-module.service.js +3 -3
- package/esm2015/cms/services/element-context.service.js +3 -3
- package/esm2015/cms/services/integration.state.js +3 -3
- package/esm2015/cms/services/io-provider.service.js +3 -3
- package/esm2015/cms/services/launcher.service.js +6 -5
- package/esm2015/cms/services/templates.service.js +3 -3
- package/esm2015/cms/types/configuration.types.js +1 -1
- package/esm2015/cms/utils/element.utils.js +1 -1
- package/esm2015/cms/utils/elements-resolver.js +1 -1
- package/esm2015/cms/veloceapps-sdk-cms.js +5 -0
- package/esm2015/cms/vendor-map.js +9 -12
- package/esm2015/core/core.module.js +7 -7
- package/esm2015/core/modules/configuration/configuration.module.js +7 -7
- package/esm2015/core/modules/configuration/helpers.js +2 -2
- package/esm2015/core/modules/configuration/services/configuration-runtime.service.js +7 -7
- package/esm2015/core/modules/configuration/services/configuration.service.js +13 -12
- package/esm2015/core/modules/configuration/services/runtime-context.service.js +6 -6
- package/esm2015/core/modules/configuration/types/configuration-runtime.types.js +1 -1
- package/esm2015/core/modules/flow-configuration/flow-configuration.module.js +6 -6
- package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +18 -10
- package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +5 -5
- package/esm2015/core/services/context.service.js +6 -6
- package/esm2015/core/services/index.js +2 -1
- package/esm2015/core/services/metric-calculation/metric-calculation.service.js +74 -0
- package/esm2015/core/services/metric-calculation/metric-calculation.types.js +2 -0
- package/esm2015/core/services/metric-calculation/metric-calculation.utils.js +42 -0
- package/esm2015/core/services/product-images.service.js +5 -5
- package/esm2015/core/services/quote-draft.service.js +20 -10
- package/esm2015/core/types/quote-states.types.js +1 -1
- package/esm2015/core/types/runtime.types.js +1 -1
- package/esm2015/core/utils/line-item.utils.js +14 -3
- package/esm2015/core/utils/line-item.worker.js +1 -1
- package/esm2015/core/veloceapps-sdk-core.js +5 -0
- package/esm2015/runtime/components/component-preview/component-preview.component.js +7 -7
- package/esm2015/runtime/components/section-renderer/section-renderer.component.js +4 -4
- package/esm2015/runtime/components/ui-runtime/runtime.component.js +8 -8
- package/esm2015/runtime/components/ui-runtime-preview/runtime-preview.component.js +8 -8
- package/esm2015/runtime/execution/components/children-placeholder/children-placeholder.component.js +8 -8
- package/esm2015/runtime/execution/components/context-provider/context-provider.component.js +5 -5
- package/esm2015/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.js +4 -4
- package/esm2015/runtime/execution/components/federated/federated.component.js +4 -4
- package/esm2015/runtime/execution/components/velo-attribute/velo-attribute.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-multiselect/velo-multiselect.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.js +4 -4
- package/esm2015/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.js +6 -6
- package/esm2015/runtime/execution/components/velo-port-radio/velo-port-radio.component.js +4 -4
- package/esm2015/runtime/execution/components/velo-type/velo-type.component.js +5 -5
- package/esm2015/runtime/execution/directives/section-script.directive.js +6 -6
- package/esm2015/runtime/execution/directives/sf-query.directive.js +5 -5
- package/esm2015/runtime/execution/directives/velo-attribute.directive.js +5 -5
- package/esm2015/runtime/execution/directives/velo-port.directive.js +21 -21
- package/esm2015/runtime/execution/directives/vl-approval.directive.js +5 -5
- package/esm2015/runtime/execution/directives/vl-document-attachments.directive.js +5 -5
- package/esm2015/runtime/execution/directives/vl-document-templates.directive.js +5 -5
- package/esm2015/runtime/execution/directives/vl-quote.directive.js +6 -6
- package/esm2015/runtime/execution/directives/vl-ramp.directive.js +6 -6
- package/esm2015/runtime/execution/runtime-execution.module.js +10 -10
- package/esm2015/runtime/runtime.module.js +10 -10
- package/esm2015/runtime/services/cart.service.js +6 -6
- package/esm2015/runtime/services/collapsible-state.service.js +3 -3
- package/esm2015/runtime/services/configuration.service.js +9 -9
- package/esm2015/runtime/services/current-state.service.js +4 -4
- package/esm2015/runtime/services/form-scope.service.js +3 -3
- package/esm2015/runtime/services/product-model-cache.service.js +5 -5
- package/esm2015/runtime/services/runtime-context.service.js +8 -8
- package/esm2015/runtime/services/runtime-form.service.js +5 -5
- package/esm2015/runtime/services/runtime.service.js +6 -6
- package/esm2015/runtime/services/section-helper.service.js +5 -5
- package/esm2015/runtime/services/section-scope.service.js +4 -4
- package/esm2015/runtime/services/section-store.service.js +4 -4
- package/esm2015/runtime/services/section.service.js +9 -9
- package/esm2015/runtime/types/bound-data.types.js +1 -1
- package/esm2015/runtime/types/runtime.types.js +1 -1
- package/esm2015/runtime/types/script-registry.types.js +2 -2
- package/esm2015/runtime/utils/line-item.util.js +2 -2
- package/esm2015/runtime/utils/section.utils.js +2 -2
- package/esm2015/runtime/utils/sections-binder.helper.js +2 -2
- package/esm2015/runtime/veloceapps-sdk-runtime.js +5 -0
- package/esm2015/src/components/dialog/dialog.component.js +3 -3
- package/esm2015/src/components/dialog/dialog.module.js +4 -4
- package/esm2015/src/components/doc-gen/doc-gen.component.js +11 -11
- package/esm2015/src/components/doc-gen/doc-gen.module.js +6 -6
- package/esm2015/src/components/header/cart-overlay/cart-preview.component.js +6 -6
- package/esm2015/src/components/header/cart-overlay/cart-preview.module.js +6 -6
- package/esm2015/src/components/header/header.component.js +10 -10
- package/esm2015/src/components/header/header.module.js +6 -6
- package/esm2015/src/components/header/metrics/metrics.component.js +20 -16
- package/esm2015/src/components/header/metrics/metrics.definitions.js +6 -6
- package/esm2015/src/components/header/metrics/metrics.module.js +6 -6
- package/esm2015/src/flow-routing.module.js +4 -4
- package/esm2015/src/flow.component.js +7 -7
- package/esm2015/src/flow.module.js +9 -9
- package/esm2015/src/guards/context.guard.js +6 -6
- package/esm2015/src/guards/product-unload.guard.js +5 -5
- package/esm2015/src/guards/root.guard.js +3 -3
- package/esm2015/src/pages/catalog/catalog.component.js +10 -10
- package/esm2015/src/pages/catalog/catalog.module.js +7 -7
- package/esm2015/src/pages/debug/debug.component.js +6 -6
- package/esm2015/src/pages/debug/debug.module.js +4 -4
- package/esm2015/src/pages/empty-account/empty-account.component.js +4 -4
- package/esm2015/src/pages/empty-account/empty-account.module.js +7 -7
- package/esm2015/src/pages/legacy-product/legacy-product.component.js +9 -9
- package/esm2015/src/pages/legacy-product/legacy-product.module.js +6 -6
- package/esm2015/src/pages/product/product.component.js +7 -7
- package/esm2015/src/pages/product/product.module.js +7 -7
- package/esm2015/src/pages/record-not-found/record-not-found.component.js +3 -3
- package/esm2015/src/pages/record-not-found/record-not-found.module.js +4 -4
- package/esm2015/src/pages/remote/remote.component.js +10 -10
- package/esm2015/src/pages/remote/remote.module.js +7 -7
- package/esm2015/src/pages/remote/remote.types.js +1 -1
- package/esm2015/src/pages/shopping-cart/shopping-cart.component.js +10 -10
- package/esm2015/src/pages/shopping-cart/shopping-cart.module.js +7 -7
- package/esm2015/src/resolvers/flow.resolver.js +6 -6
- package/esm2015/src/resolvers/quote.resolver.js +14 -14
- package/esm2015/src/services/doc-gen.service.js +6 -6
- package/esm2015/src/services/flow-dialog.service.js +5 -5
- package/esm2015/src/services/flow-router.service.js +6 -6
- package/esm2015/src/services/flow.service.js +7 -7
- package/esm2015/src/types/context-route.types.js +1 -1
- package/esm2015/src/types/flow-customization.types.js +1 -1
- package/esm2015/src/utils/flow.utils.js +2 -2
- package/esm2015/veloceapps-sdk.js +5 -0
- package/fesm2015/{veloce-sdk-cms.js → veloceapps-sdk-cms.js} +77 -79
- package/fesm2015/veloceapps-sdk-cms.js.map +1 -0
- package/fesm2015/{veloce-sdk-core.js → veloceapps-sdk-core.js} +420 -284
- package/fesm2015/veloceapps-sdk-core.js.map +1 -0
- package/fesm2015/{veloce-sdk-runtime.js → veloceapps-sdk-runtime.js} +148 -148
- package/fesm2015/veloceapps-sdk-runtime.js.map +1 -0
- package/fesm2015/{veloce-sdk.js → veloceapps-sdk.js} +163 -159
- package/fesm2015/veloceapps-sdk.js.map +1 -0
- package/package.json +14 -13
- package/runtime/components/component-preview/component-preview.component.d.ts +1 -1
- package/runtime/components/section-renderer/section-renderer.component.d.ts +1 -1
- package/runtime/components/ui-runtime/runtime.component.d.ts +2 -2
- package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +3 -3
- package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +1 -1
- package/runtime/execution/components/context-provider/context-provider.component.d.ts +2 -2
- package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +1 -1
- package/runtime/execution/components/federated/federated.component.d.ts +1 -1
- package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +1 -1
- package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +1 -1
- package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +1 -1
- package/runtime/execution/components/velo-type/velo-type.component.d.ts +1 -1
- package/runtime/execution/directives/section-script.directive.d.ts +1 -1
- package/runtime/execution/directives/sf-query.directive.d.ts +2 -2
- package/runtime/execution/directives/velo-attribute.directive.d.ts +1 -1
- package/runtime/execution/directives/velo-port.directive.d.ts +1 -1
- package/runtime/execution/directives/vl-approval.directive.d.ts +2 -2
- package/runtime/execution/directives/vl-document-attachments.directive.d.ts +2 -2
- package/runtime/execution/directives/vl-document-templates.directive.d.ts +2 -2
- package/runtime/execution/directives/vl-quote.directive.d.ts +2 -2
- package/runtime/execution/directives/vl-ramp.directive.d.ts +3 -3
- package/runtime/execution/runtime-execution.module.d.ts +5 -5
- package/runtime/package.json +7 -7
- package/runtime/runtime.module.d.ts +5 -5
- package/runtime/services/cart.service.d.ts +3 -3
- package/runtime/services/configuration.service.d.ts +3 -3
- package/runtime/services/current-state.service.d.ts +1 -1
- package/runtime/services/product-model-cache.service.d.ts +2 -2
- package/runtime/services/runtime-context.service.d.ts +2 -2
- package/runtime/services/runtime-form.service.d.ts +1 -1
- package/runtime/services/runtime.service.d.ts +2 -2
- package/runtime/services/section-helper.service.d.ts +1 -1
- package/runtime/services/section-scope.service.d.ts +1 -1
- package/runtime/services/section-store.service.d.ts +1 -1
- package/runtime/services/section.service.d.ts +1 -1
- package/runtime/types/bound-data.types.d.ts +1 -1
- package/runtime/types/runtime.types.d.ts +2 -2
- package/runtime/utils/line-item.util.d.ts +1 -1
- package/runtime/utils/section.utils.d.ts +1 -1
- package/runtime/utils/sections-binder.helper.d.ts +1 -1
- package/{veloce-sdk.d.ts → runtime/veloceapps-sdk-runtime.d.ts} +1 -1
- package/src/components/doc-gen/doc-gen.component.d.ts +3 -3
- package/src/components/doc-gen/doc-gen.module.d.ts +1 -1
- package/src/components/header/cart-overlay/cart-preview.component.d.ts +1 -1
- package/src/components/header/cart-overlay/cart-preview.module.d.ts +1 -1
- package/src/components/header/header.component.d.ts +4 -4
- package/src/components/header/header.module.d.ts +1 -1
- package/src/components/header/metrics/metrics.component.d.ts +5 -4
- package/src/components/header/metrics/metrics.definitions.d.ts +1 -1
- package/src/components/header/metrics/metrics.module.d.ts +1 -1
- package/src/flow.component.d.ts +2 -2
- package/src/flow.module.d.ts +4 -4
- package/src/guards/context.guard.d.ts +1 -1
- package/src/guards/product-unload.guard.d.ts +1 -1
- package/src/pages/catalog/catalog.component.d.ts +3 -3
- package/src/pages/catalog/catalog.module.d.ts +2 -2
- package/src/pages/debug/debug.component.d.ts +3 -3
- package/src/pages/empty-account/empty-account.module.d.ts +2 -2
- package/src/pages/legacy-product/legacy-product.component.d.ts +4 -4
- package/src/pages/legacy-product/legacy-product.module.d.ts +1 -1
- package/src/pages/product/product.component.d.ts +1 -1
- package/src/pages/product/product.module.d.ts +2 -2
- package/src/pages/remote/remote.component.d.ts +3 -3
- package/src/pages/remote/remote.module.d.ts +2 -2
- package/src/pages/remote/remote.types.d.ts +1 -1
- package/src/pages/shopping-cart/shopping-cart.component.d.ts +3 -3
- package/src/pages/shopping-cart/shopping-cart.module.d.ts +2 -2
- package/src/resolvers/flow.resolver.d.ts +2 -2
- package/src/resolvers/quote.resolver.d.ts +1 -1
- package/src/services/doc-gen.service.d.ts +1 -1
- package/src/services/flow-dialog.service.d.ts +1 -1
- package/src/services/flow-router.service.d.ts +1 -1
- package/src/services/flow.service.d.ts +2 -2
- package/src/types/context-route.types.d.ts +1 -1
- package/src/types/flow-customization.types.d.ts +2 -2
- package/src/utils/flow.utils.d.ts +1 -1
- package/{cms/veloce-sdk-cms.d.ts → veloceapps-sdk.d.ts} +1 -1
- package/bundles/veloce-sdk-cms.umd.js.map +0 -1
- package/bundles/veloce-sdk-core.umd.js.map +0 -1
- package/bundles/veloce-sdk-runtime.umd.js.map +0 -1
- package/bundles/veloce-sdk.umd.js.map +0 -1
- package/esm2015/cms/veloce-sdk-cms.js +0 -5
- package/esm2015/core/veloce-sdk-core.js +0 -5
- package/esm2015/runtime/veloce-sdk-runtime.js +0 -5
- package/esm2015/veloce-sdk.js +0 -5
- package/fesm2015/veloce-sdk-cms.js.map +0 -1
- package/fesm2015/veloce-sdk-core.js.map +0 -1
- package/fesm2015/veloce-sdk-runtime.js.map +0 -1
- package/fesm2015/veloce-sdk.js.map +0 -1
@@ -1,14 +1,14 @@
|
|
1
1
|
import * as i0 from '@angular/core';
|
2
2
|
import { Injectable, NgModule } from '@angular/core';
|
3
|
-
import { UUID, ConfigurationContext,
|
4
|
-
import { BehaviorSubject,
|
5
|
-
import { filter, tap, map, switchMap, skip, take, shareReplay,
|
6
|
-
import * as i1 from '@
|
7
|
-
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@
|
8
|
-
import { merge, flatten, sortBy, cloneDeep } from 'lodash';
|
9
|
-
import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@
|
10
|
-
import * as
|
11
|
-
import * as
|
3
|
+
import { UUID, ConfigurationContext, RuntimeModel, ConfigurationContextMode, SalesforceIdUtils, ConfigurationMode, ChargeGroupUtils } from '@veloceapps/core';
|
4
|
+
import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1, tap as tap$1, map as map$2, of, switchMap as switchMap$1, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
|
5
|
+
import { filter, tap, map, first, switchMap, skip, take, shareReplay, catchError, finalize } from 'rxjs/operators';
|
6
|
+
import * as i1 from '@veloceapps/api';
|
7
|
+
import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
|
8
|
+
import { merge, flatten, sortBy, map as map$1, isEqual, cloneDeep, uniq } from 'lodash';
|
9
|
+
import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
|
10
|
+
import * as i5 from 'primeng/api';
|
11
|
+
import * as i6 from 'primeng/dynamicdialog';
|
12
12
|
import moment from 'moment';
|
13
13
|
|
14
14
|
const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
|
@@ -72,239 +72,13 @@ class ContextService {
|
|
72
72
|
this.context.next(null);
|
73
73
|
}
|
74
74
|
}
|
75
|
-
ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
76
|
-
ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
77
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
75
|
+
ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
76
|
+
ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ContextService, providedIn: 'root' });
|
77
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ContextService, decorators: [{
|
78
78
|
type: Injectable,
|
79
79
|
args: [{ providedIn: 'root' }]
|
80
80
|
}], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
|
81
81
|
|
82
|
-
class ProductImagesService {
|
83
|
-
constructor(productApiService) {
|
84
|
-
this.productApiService = productApiService;
|
85
|
-
this.imagesMap$ = new BehaviorSubject({});
|
86
|
-
}
|
87
|
-
getImageUrl$(productId) {
|
88
|
-
if (this.imagesMap$.value[productId] == null) {
|
89
|
-
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
|
90
|
-
this.fetchProductImage(productId);
|
91
|
-
}
|
92
|
-
return this.imagesMap$.pipe(map$1(imagesMap => imagesMap[productId]), distinctUntilChanged());
|
93
|
-
}
|
94
|
-
fetchProductImage(productId) {
|
95
|
-
this.productApiService
|
96
|
-
.fetchImage$(productId)
|
97
|
-
.pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
|
98
|
-
.subscribe();
|
99
|
-
}
|
100
|
-
}
|
101
|
-
ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
102
|
-
ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ProductImagesService, providedIn: 'root' });
|
103
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: ProductImagesService, decorators: [{
|
104
|
-
type: Injectable,
|
105
|
-
args: [{ providedIn: 'root' }]
|
106
|
-
}], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
|
107
|
-
|
108
|
-
class QuoteDraftService {
|
109
|
-
constructor(context, quoteApiService, priceApiService) {
|
110
|
-
this.context = context;
|
111
|
-
this.quoteApiService = quoteApiService;
|
112
|
-
this.priceApiService = priceApiService;
|
113
|
-
this.quoteSubj$ = new BehaviorSubject(null);
|
114
|
-
this.resetSubj$ = new BehaviorSubject(true);
|
115
|
-
this.isInitializedSubj$ = new BehaviorSubject(false);
|
116
|
-
this.initialCurrentState = [];
|
117
|
-
this.allPriceLists = [];
|
118
|
-
this.assetPriceLists = [];
|
119
|
-
this.hasUnsavedChanges = false;
|
120
|
-
this.reset$ = this.resetSubj$.asObservable();
|
121
|
-
this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), map(priceList => priceList !== null && priceList !== void 0 ? priceList : null));
|
122
|
-
this.isInitializedSubj$
|
123
|
-
.pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
|
124
|
-
.subscribe();
|
125
|
-
}
|
126
|
-
get isInitialized() {
|
127
|
-
return this.isInitializedSubj$.getValue();
|
128
|
-
}
|
129
|
-
set isInitialized(value) {
|
130
|
-
if (this.isInitialized !== value) {
|
131
|
-
this.isInitializedSubj$.next(value);
|
132
|
-
}
|
133
|
-
}
|
134
|
-
get hasAssets$() {
|
135
|
-
return this.quoteSubj$.pipe(map(() => this.hasAssets));
|
136
|
-
}
|
137
|
-
get hasAssets() {
|
138
|
-
const quoteDraft = this.quoteSubj$.value;
|
139
|
-
return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
|
140
|
-
}
|
141
|
-
reset() {
|
142
|
-
this.resetSubj$.next(true);
|
143
|
-
this.quoteSubj$.next(null);
|
144
|
-
this.initialCurrentState = [];
|
145
|
-
}
|
146
|
-
init(quoteId, params) {
|
147
|
-
return zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(tap(([quote, allPriceLists]) => {
|
148
|
-
this.allPriceLists = allPriceLists;
|
149
|
-
this.quoteSubj$.next(quote);
|
150
|
-
this.initialCurrentState = quote.currentState;
|
151
|
-
this.context.update(quote.context);
|
152
|
-
this.populateActivePriceLists$();
|
153
|
-
}), map(() => noop()), take(1));
|
154
|
-
}
|
155
|
-
setCurrentLineItemState(lineItems) {
|
156
|
-
const quoteDraft = this.quoteSubj$.value;
|
157
|
-
if (!quoteDraft) {
|
158
|
-
return;
|
159
|
-
}
|
160
|
-
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
|
161
|
-
}
|
162
|
-
updateQuoteDraft(update) {
|
163
|
-
const quoteDraft = this.quoteSubj$.value;
|
164
|
-
if (!quoteDraft) {
|
165
|
-
return;
|
166
|
-
}
|
167
|
-
if (update.context) {
|
168
|
-
this.context.set(update.context);
|
169
|
-
}
|
170
|
-
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
|
171
|
-
}
|
172
|
-
updateByPriceSummary(priceSummary) {
|
173
|
-
const quoteDraft = this.quoteSubj$.value;
|
174
|
-
if (!quoteDraft) {
|
175
|
-
return;
|
176
|
-
}
|
177
|
-
const updatedCurrentState = this.currentState.map(lineItem => {
|
178
|
-
const updated = priceSummary.lineItems.find(li => li.id === lineItem.id);
|
179
|
-
return updated !== null && updated !== void 0 ? updated : lineItem;
|
180
|
-
});
|
181
|
-
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
|
182
|
-
}
|
183
|
-
get quoteDraft$() {
|
184
|
-
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
|
185
|
-
}
|
186
|
-
get quoteDraft() {
|
187
|
-
const quote = this.quoteSubj$.value;
|
188
|
-
if (!quote) {
|
189
|
-
return null;
|
190
|
-
}
|
191
|
-
return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
|
192
|
-
}
|
193
|
-
get quoteDraftForActivePriceList() {
|
194
|
-
const quoteDraft = this.quoteDraft;
|
195
|
-
if (!quoteDraft) {
|
196
|
-
return null;
|
197
|
-
}
|
198
|
-
return Object.assign(Object.assign({}, quoteDraft), { initialState: this.filterByActivePriceList(quoteDraft.initialState), currentState: this.filterByActivePriceList(quoteDraft.currentState) });
|
199
|
-
}
|
200
|
-
get currentState$() {
|
201
|
-
return this.quoteDraft$.pipe(map(quote => quote.currentState));
|
202
|
-
}
|
203
|
-
get currentState() {
|
204
|
-
var _a, _b;
|
205
|
-
return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
206
|
-
}
|
207
|
-
/**
|
208
|
-
* Stream of activeCurrentState
|
209
|
-
*/
|
210
|
-
get activeCurrentState$() {
|
211
|
-
return this.quoteDraft$.pipe(map(() => this.activeCurrentState));
|
212
|
-
}
|
213
|
-
/**
|
214
|
-
* activeCurrentState is currentState passed through additional filters
|
215
|
-
*/
|
216
|
-
get activeCurrentState() {
|
217
|
-
var _a, _b;
|
218
|
-
let currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
219
|
-
currentState = this.filterByActivePriceList(currentState);
|
220
|
-
return currentState;
|
221
|
-
}
|
222
|
-
/**
|
223
|
-
* Stream of activeInitialState
|
224
|
-
*/
|
225
|
-
get activeInitialState$() {
|
226
|
-
return this.quoteDraft$.pipe(map(() => this.activeInitialState));
|
227
|
-
}
|
228
|
-
/**
|
229
|
-
* activeInitialState is initialState passed through additional filters
|
230
|
-
*/
|
231
|
-
get activeInitialState() {
|
232
|
-
var _a, _b;
|
233
|
-
const ctx = this.context.resolve();
|
234
|
-
let initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
|
235
|
-
if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
|
236
|
-
initialState = this.filterByActivePriceList(initialState);
|
237
|
-
}
|
238
|
-
return initialState;
|
239
|
-
}
|
240
|
-
get isStandalone() {
|
241
|
-
return this.context.resolve().properties.standalone === 'true';
|
242
|
-
}
|
243
|
-
get isStandalone$() {
|
244
|
-
return this.context.resolve$().pipe(map(() => this.isStandalone));
|
245
|
-
}
|
246
|
-
getInitialCurrentState() {
|
247
|
-
return this.initialCurrentState;
|
248
|
-
}
|
249
|
-
isEditMode$() {
|
250
|
-
return this.context.resolve$().pipe(map(() => this.isEditMode()));
|
251
|
-
}
|
252
|
-
isEditMode() {
|
253
|
-
const context = this.context.resolve();
|
254
|
-
if (context.mode === ConfigurationContextMode.ACCOUNT) {
|
255
|
-
return true;
|
256
|
-
}
|
257
|
-
if (context.mode === ConfigurationContextMode.QUOTE) {
|
258
|
-
return context.properties.Status === 'Draft';
|
259
|
-
}
|
260
|
-
return false;
|
261
|
-
}
|
262
|
-
updateActivePriceList(priceListId) {
|
263
|
-
this.context.update({ properties: { PriceListId: priceListId } });
|
264
|
-
}
|
265
|
-
populateActivePriceLists$() {
|
266
|
-
const ctx = this.context.resolve();
|
267
|
-
const quoteDraft = this.quoteDraft;
|
268
|
-
if (!quoteDraft) {
|
269
|
-
return;
|
270
|
-
}
|
271
|
-
// In ACCOUNT mode populate price lists from related assets
|
272
|
-
if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
|
273
|
-
// Populate list of price lists
|
274
|
-
this.assetPriceLists = quoteDraft.currentState
|
275
|
-
.map(({ priceListId }) => priceListId)
|
276
|
-
.reduce((trunk, priceListId) => {
|
277
|
-
var _a, _b;
|
278
|
-
if (!priceListId || trunk.some(item => item.id === priceListId)) {
|
279
|
-
return trunk;
|
280
|
-
}
|
281
|
-
return [
|
282
|
-
...trunk,
|
283
|
-
{ id: priceListId, name: (_b = (_a = this.allPriceLists.find(item => item.id === priceListId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '' },
|
284
|
-
];
|
285
|
-
}, []);
|
286
|
-
}
|
287
|
-
}
|
288
|
-
filterByActivePriceList(lineItems) {
|
289
|
-
const ctx = this.context.resolve();
|
290
|
-
return lineItems.filter(li => !li.priceListId || li.priceListId === ctx.properties.PriceListId);
|
291
|
-
}
|
292
|
-
markAsUpdated(quote) {
|
293
|
-
if ((quote === null || quote === void 0 ? void 0 : quote.context.properties.mode) === ConfigurationContextMode.ACCOUNT) {
|
294
|
-
this.hasUnsavedChanges = !!quote && !quote.currentState.every(li => li.actionCode === 'EXIST');
|
295
|
-
}
|
296
|
-
else {
|
297
|
-
this.hasUnsavedChanges = true;
|
298
|
-
}
|
299
|
-
}
|
300
|
-
}
|
301
|
-
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
302
|
-
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteDraftService, providedIn: 'root' });
|
303
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0, type: QuoteDraftService, decorators: [{
|
304
|
-
type: Injectable,
|
305
|
-
args: [{ providedIn: 'root' }]
|
306
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }]; } });
|
307
|
-
|
308
82
|
class RuntimeContextService {
|
309
83
|
constructor(configurationApiService) {
|
310
84
|
this.configurationApiService = configurationApiService;
|
@@ -344,9 +118,9 @@ class RuntimeContextService {
|
|
344
118
|
return uiDefinition;
|
345
119
|
}
|
346
120
|
}
|
347
|
-
RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
348
|
-
RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
349
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
121
|
+
RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
122
|
+
RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeContextService });
|
123
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: RuntimeContextService, decorators: [{
|
350
124
|
type: Injectable
|
351
125
|
}], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
|
352
126
|
|
@@ -427,9 +201,9 @@ class ConfigurationRuntimeService {
|
|
427
201
|
return this._runtimeContext;
|
428
202
|
}
|
429
203
|
}
|
430
|
-
ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
431
|
-
ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
432
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
204
|
+
ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
|
205
|
+
ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationRuntimeService });
|
206
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
|
433
207
|
type: Injectable
|
434
208
|
}], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
|
435
209
|
|
@@ -530,6 +304,17 @@ const getRecommendedPrices = (portDomain, type) => {
|
|
530
304
|
}, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0];
|
531
305
|
return { net, list };
|
532
306
|
};
|
307
|
+
const multiplyLineItems = (lineItem, qty, split) => {
|
308
|
+
if (split) {
|
309
|
+
const unifyIds = (lineItem) => (Object.assign(Object.assign({}, lineItem), { id: UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds) }));
|
310
|
+
return map$1(new Array(qty), () => unifyIds(lineItem));
|
311
|
+
}
|
312
|
+
else {
|
313
|
+
return [
|
314
|
+
Object.assign(Object.assign({}, lineItem), { qty: qty }),
|
315
|
+
];
|
316
|
+
}
|
317
|
+
};
|
533
318
|
|
534
319
|
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
535
320
|
__proto__: null,
|
@@ -544,7 +329,8 @@ var lineItem_utils = /*#__PURE__*/Object.freeze({
|
|
544
329
|
patchAttributes: patchAttributes,
|
545
330
|
getAttributeValue: getAttributeValue,
|
546
331
|
generateLineItem: generateLineItem,
|
547
|
-
getRecommendedPrices: getRecommendedPrices
|
332
|
+
getRecommendedPrices: getRecommendedPrices,
|
333
|
+
multiplyLineItems: multiplyLineItems
|
548
334
|
});
|
549
335
|
|
550
336
|
class LineItemWorker {
|
@@ -565,6 +351,215 @@ class LineItemWorker {
|
|
565
351
|
}
|
566
352
|
}
|
567
353
|
|
354
|
+
class QuoteDraftService {
|
355
|
+
constructor(context, quoteApiService, priceApiService) {
|
356
|
+
this.context = context;
|
357
|
+
this.quoteApiService = quoteApiService;
|
358
|
+
this.priceApiService = priceApiService;
|
359
|
+
this.quoteSubj$ = new BehaviorSubject(null);
|
360
|
+
this.resetSubj$ = new BehaviorSubject(true);
|
361
|
+
this.isInitializedSubj$ = new BehaviorSubject(false);
|
362
|
+
this.initialCurrentState = [];
|
363
|
+
this._hasUnsavedChanges = false;
|
364
|
+
this.allPriceLists = [];
|
365
|
+
this.assetPriceLists = [];
|
366
|
+
this.reset$ = this.resetSubj$.asObservable();
|
367
|
+
this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), map(priceList => priceList !== null && priceList !== void 0 ? priceList : null));
|
368
|
+
this.isInitializedSubj$
|
369
|
+
.pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
|
370
|
+
.subscribe();
|
371
|
+
}
|
372
|
+
get isInitialized() {
|
373
|
+
return this.isInitializedSubj$.getValue();
|
374
|
+
}
|
375
|
+
set isInitialized(value) {
|
376
|
+
if (this.isInitialized !== value) {
|
377
|
+
this.isInitializedSubj$.next(value);
|
378
|
+
}
|
379
|
+
}
|
380
|
+
get hasUnsavedChanges() {
|
381
|
+
return this._hasUnsavedChanges;
|
382
|
+
}
|
383
|
+
set hasUnsavedChanges(value) {
|
384
|
+
var _a, _b;
|
385
|
+
this._hasUnsavedChanges = value;
|
386
|
+
if (!this._hasUnsavedChanges) {
|
387
|
+
this.initialCurrentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
388
|
+
}
|
389
|
+
}
|
390
|
+
get hasAssets$() {
|
391
|
+
return this.quoteSubj$.pipe(map(() => this.hasAssets));
|
392
|
+
}
|
393
|
+
get hasAssets() {
|
394
|
+
const quoteDraft = this.quoteSubj$.value;
|
395
|
+
return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
|
396
|
+
}
|
397
|
+
reset() {
|
398
|
+
this.resetSubj$.next(true);
|
399
|
+
this.quoteSubj$.next(null);
|
400
|
+
this.hasUnsavedChanges = false;
|
401
|
+
}
|
402
|
+
init(quoteId, params) {
|
403
|
+
return zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(tap(([quote, allPriceLists]) => {
|
404
|
+
this.allPriceLists = allPriceLists;
|
405
|
+
this.quoteSubj$.next(quote);
|
406
|
+
this.context.update(quote.context);
|
407
|
+
this.populateActivePriceLists$();
|
408
|
+
}), map(() => noop()), take(1));
|
409
|
+
}
|
410
|
+
setCurrentLineItemState(lineItems) {
|
411
|
+
const quoteDraft = this.quoteSubj$.value;
|
412
|
+
if (!quoteDraft) {
|
413
|
+
return;
|
414
|
+
}
|
415
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
|
416
|
+
}
|
417
|
+
updateQuoteDraft(update) {
|
418
|
+
const quoteDraft = this.quoteSubj$.value;
|
419
|
+
if (!quoteDraft) {
|
420
|
+
return;
|
421
|
+
}
|
422
|
+
if (update.context) {
|
423
|
+
this.context.set(update.context);
|
424
|
+
}
|
425
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
|
426
|
+
}
|
427
|
+
updateByPriceSummary(priceSummary) {
|
428
|
+
const quoteDraft = this.quoteSubj$.value;
|
429
|
+
if (!quoteDraft) {
|
430
|
+
return;
|
431
|
+
}
|
432
|
+
const updatedCurrentState = this.currentState.map(lineItem => {
|
433
|
+
const updated = priceSummary.lineItems.find(li => li.id === lineItem.id);
|
434
|
+
return updated !== null && updated !== void 0 ? updated : lineItem;
|
435
|
+
});
|
436
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
|
437
|
+
}
|
438
|
+
get quoteDraft$() {
|
439
|
+
return combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(map(() => this.quoteDraft), filter((quote) => Boolean(quote)), shareReplay());
|
440
|
+
}
|
441
|
+
get quoteDraft() {
|
442
|
+
const quote = this.quoteSubj$.value;
|
443
|
+
if (!quote) {
|
444
|
+
return null;
|
445
|
+
}
|
446
|
+
return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
|
447
|
+
}
|
448
|
+
get quoteDraftForActivePriceList() {
|
449
|
+
const quoteDraft = this.quoteDraft;
|
450
|
+
if (!quoteDraft) {
|
451
|
+
return null;
|
452
|
+
}
|
453
|
+
return Object.assign(Object.assign({}, quoteDraft), { initialState: this.filterByActivePriceList(quoteDraft.initialState), currentState: this.filterByActivePriceList(quoteDraft.currentState) });
|
454
|
+
}
|
455
|
+
get currentState$() {
|
456
|
+
return this.quoteDraft$.pipe(map(quote => quote.currentState));
|
457
|
+
}
|
458
|
+
get currentState() {
|
459
|
+
var _a, _b;
|
460
|
+
return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
461
|
+
}
|
462
|
+
/**
|
463
|
+
* Stream of activeCurrentState
|
464
|
+
*/
|
465
|
+
get activeCurrentState$() {
|
466
|
+
return this.quoteDraft$.pipe(map(() => this.activeCurrentState));
|
467
|
+
}
|
468
|
+
/**
|
469
|
+
* activeCurrentState is currentState passed through additional filters
|
470
|
+
*/
|
471
|
+
get activeCurrentState() {
|
472
|
+
var _a, _b;
|
473
|
+
let currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
474
|
+
currentState = this.filterByActivePriceList(currentState);
|
475
|
+
return currentState;
|
476
|
+
}
|
477
|
+
/**
|
478
|
+
* Stream of activeInitialState
|
479
|
+
*/
|
480
|
+
get activeInitialState$() {
|
481
|
+
return this.quoteDraft$.pipe(map(() => this.activeInitialState));
|
482
|
+
}
|
483
|
+
/**
|
484
|
+
* activeInitialState is initialState passed through additional filters
|
485
|
+
*/
|
486
|
+
get activeInitialState() {
|
487
|
+
var _a, _b;
|
488
|
+
const ctx = this.context.resolve();
|
489
|
+
let initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
|
490
|
+
if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
|
491
|
+
initialState = this.filterByActivePriceList(initialState);
|
492
|
+
}
|
493
|
+
return initialState;
|
494
|
+
}
|
495
|
+
get isStandalone() {
|
496
|
+
return this.context.resolve().properties.standalone === 'true';
|
497
|
+
}
|
498
|
+
get isStandalone$() {
|
499
|
+
return this.context.resolve$().pipe(map(() => this.isStandalone));
|
500
|
+
}
|
501
|
+
getInitialCurrentState() {
|
502
|
+
return this.initialCurrentState;
|
503
|
+
}
|
504
|
+
isEditMode$() {
|
505
|
+
return this.context.resolve$().pipe(map(() => this.isEditMode()));
|
506
|
+
}
|
507
|
+
isEditMode() {
|
508
|
+
const context = this.context.resolve();
|
509
|
+
if (context.mode === ConfigurationContextMode.ACCOUNT) {
|
510
|
+
return true;
|
511
|
+
}
|
512
|
+
if (context.mode === ConfigurationContextMode.QUOTE) {
|
513
|
+
return context.properties.Status === 'Draft';
|
514
|
+
}
|
515
|
+
return false;
|
516
|
+
}
|
517
|
+
updateActivePriceList(priceListId) {
|
518
|
+
this.context.update({ properties: { PriceListId: priceListId } });
|
519
|
+
}
|
520
|
+
populateActivePriceLists$() {
|
521
|
+
const ctx = this.context.resolve();
|
522
|
+
const quoteDraft = this.quoteDraft;
|
523
|
+
if (!quoteDraft) {
|
524
|
+
return;
|
525
|
+
}
|
526
|
+
// In ACCOUNT mode populate price lists from related assets
|
527
|
+
if (ctx.mode === ConfigurationContextMode.ACCOUNT) {
|
528
|
+
// Populate list of price lists
|
529
|
+
this.assetPriceLists = quoteDraft.currentState
|
530
|
+
.map(({ priceListId }) => priceListId)
|
531
|
+
.reduce((trunk, priceListId) => {
|
532
|
+
var _a, _b;
|
533
|
+
if (!priceListId || trunk.some(item => item.id === priceListId)) {
|
534
|
+
return trunk;
|
535
|
+
}
|
536
|
+
return [
|
537
|
+
...trunk,
|
538
|
+
{ id: priceListId, name: (_b = (_a = this.allPriceLists.find(item => item.id === priceListId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '' },
|
539
|
+
];
|
540
|
+
}, []);
|
541
|
+
}
|
542
|
+
}
|
543
|
+
filterByActivePriceList(lineItems) {
|
544
|
+
const ctx = this.context.resolve();
|
545
|
+
return lineItems.filter(li => !li.priceListId || li.priceListId === ctx.properties.PriceListId);
|
546
|
+
}
|
547
|
+
markAsUpdated(quote) {
|
548
|
+
if ((quote === null || quote === void 0 ? void 0 : quote.context.properties.mode) === ConfigurationContextMode.ACCOUNT) {
|
549
|
+
this.hasUnsavedChanges = !!quote && !quote.currentState.every(li => li.actionCode === 'EXIST');
|
550
|
+
}
|
551
|
+
else {
|
552
|
+
this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
|
553
|
+
}
|
554
|
+
}
|
555
|
+
}
|
556
|
+
QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
557
|
+
QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: QuoteDraftService, providedIn: 'root' });
|
558
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: QuoteDraftService, decorators: [{
|
559
|
+
type: Injectable,
|
560
|
+
args: [{ providedIn: 'root' }]
|
561
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }]; } });
|
562
|
+
|
568
563
|
class ConfigurationService {
|
569
564
|
constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
|
570
565
|
this.quoteDraftService = quoteDraftService;
|
@@ -596,7 +591,7 @@ class ConfigurationService {
|
|
596
591
|
this.states.asset = this.states.configurableRamp
|
597
592
|
? this.runtimeService.getAsset(this.states.configurableRamp)
|
598
593
|
: undefined;
|
599
|
-
return this.configure().pipe(catchError
|
594
|
+
return this.configure().pipe(catchError(error => {
|
600
595
|
console.error(error);
|
601
596
|
if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
602
597
|
this.messageService.add({ severity: 'error', summary: error });
|
@@ -670,13 +665,13 @@ class ConfigurationService {
|
|
670
665
|
}
|
671
666
|
return lineItem;
|
672
667
|
}))
|
673
|
-
.pipe(tap(lineItem => lineItem && this.lineItem.next(lineItem)), catchError
|
668
|
+
.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)); })));
|
674
669
|
}
|
675
670
|
configureExternal$(productId, qty) {
|
676
671
|
this.updateCurrentStates({
|
677
672
|
currentState: this.quoteDraftService.currentState,
|
678
673
|
});
|
679
|
-
return this.runtimeService.init({ productId, defaultQty: qty }).pipe(switchMap(() => this.configure()), first(), catchError
|
674
|
+
return this.runtimeService.init({ productId, defaultQty: qty }).pipe(switchMap(() => this.configure()), first(), catchError(error => {
|
680
675
|
this.messageService.add({ severity: ToastType.error, summary: error });
|
681
676
|
throw error;
|
682
677
|
}), finalize(() => this.reset()));
|
@@ -718,11 +713,11 @@ class ConfigurationService {
|
|
718
713
|
});
|
719
714
|
}
|
720
715
|
}
|
721
|
-
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
722
|
-
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
723
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
716
|
+
ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6.DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
|
717
|
+
ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationService });
|
718
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationService, decorators: [{
|
724
719
|
type: Injectable
|
725
|
-
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type:
|
720
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6.DialogService }]; } });
|
726
721
|
|
727
722
|
class FlowUpdateService {
|
728
723
|
update(rootLineItems, updates) {
|
@@ -841,9 +836,9 @@ class FlowUpdateService {
|
|
841
836
|
return true;
|
842
837
|
}
|
843
838
|
}
|
844
|
-
FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
845
|
-
FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
846
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
839
|
+
FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
840
|
+
FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowUpdateService });
|
841
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowUpdateService, decorators: [{
|
847
842
|
type: Injectable
|
848
843
|
}] });
|
849
844
|
|
@@ -863,7 +858,7 @@ class FlowConfigurationService {
|
|
863
858
|
.slice()
|
864
859
|
.sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
|
865
860
|
this.quoteDraftService.updateQuoteDraft(result);
|
866
|
-
}), map$
|
861
|
+
}), map$2(noop));
|
867
862
|
}
|
868
863
|
calculate(quoteDraft) {
|
869
864
|
this.calculate$(quoteDraft).subscribe();
|
@@ -873,11 +868,11 @@ class FlowConfigurationService {
|
|
873
868
|
if (!quoteDraft) {
|
874
869
|
return of(null);
|
875
870
|
}
|
876
|
-
return of([]).pipe(map$
|
871
|
+
return of([]).pipe(map$2(() => {
|
877
872
|
const updatedState = cloneDeep(quoteDraft.currentState);
|
878
873
|
this.updateService.update(updatedState, updates);
|
879
874
|
return updatedState;
|
880
|
-
}), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$
|
875
|
+
}), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
|
881
876
|
}
|
882
877
|
update(updates) {
|
883
878
|
this.update$(updates).subscribe();
|
@@ -896,7 +891,7 @@ class FlowConfigurationService {
|
|
896
891
|
updatedState.splice(currentLineItemIndex, 1, initialLineItem);
|
897
892
|
return of([]).pipe(tap$1(() => {
|
898
893
|
this.quoteDraftService.setCurrentLineItemState(updatedState);
|
899
|
-
}), switchMap$1(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$
|
894
|
+
}), switchMap$1(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
|
900
895
|
}
|
901
896
|
revert(lineItemId) {
|
902
897
|
this.revert$(lineItemId).subscribe();
|
@@ -907,7 +902,7 @@ class FlowConfigurationService {
|
|
907
902
|
if (!quoteDraft) {
|
908
903
|
return of(null);
|
909
904
|
}
|
910
|
-
return of([]).pipe(map$
|
905
|
+
return of([]).pipe(map$2(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
|
911
906
|
}
|
912
907
|
delete(ids) {
|
913
908
|
this.delete$(ids).subscribe();
|
@@ -918,27 +913,33 @@ class FlowConfigurationService {
|
|
918
913
|
return of(null);
|
919
914
|
}
|
920
915
|
const updatedState = [...quoteDraft.currentState, term];
|
921
|
-
return of([]).pipe(switchMap$1(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$
|
916
|
+
return of([]).pipe(switchMap$1(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
|
922
917
|
}
|
923
918
|
addToCart$(productId, qty) {
|
924
919
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
925
920
|
if (!quoteDraft) {
|
926
921
|
return of(null);
|
927
922
|
}
|
928
|
-
return this.configurationService.configureExternal$(productId, qty).pipe(map$
|
923
|
+
return this.configurationService.configureExternal$(productId, qty).pipe(map$2(lineItem => {
|
924
|
+
var _a, _b;
|
925
|
+
const model = this.configurationService.getRuntimeModel();
|
926
|
+
const split = (_b = (_a = model === null || model === void 0 ? void 0 : model.types.find(type => type.name === lineItem.type)) === null || _a === void 0 ? void 0 : _a.split) !== null && _b !== void 0 ? _b : false;
|
927
|
+
const lineItems = multiplyLineItems(lineItem, qty !== null && qty !== void 0 ? qty : 1, split);
|
928
|
+
return [...quoteDraft.currentState, ...lineItems];
|
929
|
+
}), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
|
929
930
|
}
|
930
931
|
get() {
|
931
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$
|
932
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$2(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
|
932
933
|
}
|
933
934
|
getSnapshot() {
|
934
935
|
var _a, _b;
|
935
936
|
return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
|
936
937
|
}
|
937
938
|
get charges$() {
|
938
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$
|
939
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$2(({ charges }) => charges));
|
939
940
|
}
|
940
941
|
get pricePlans$() {
|
941
|
-
return this.quoteDraftService.quoteDraft$.pipe(map$
|
942
|
+
return this.quoteDraftService.quoteDraft$.pipe(map$2(({ pricePlans }) => pricePlans));
|
942
943
|
}
|
943
944
|
get chargesSnapshot() {
|
944
945
|
var _a, _b;
|
@@ -956,7 +957,7 @@ class FlowConfigurationService {
|
|
956
957
|
}
|
957
958
|
handleErrorAndBounceBack() {
|
958
959
|
return (source$) => {
|
959
|
-
return source$.pipe(catchError(error => {
|
960
|
+
return source$.pipe(catchError$1(error => {
|
960
961
|
console.error(error);
|
961
962
|
// bounce back if configuration call has failed
|
962
963
|
const quoteDraft = this.quoteDraftService.quoteDraft;
|
@@ -968,18 +969,18 @@ class FlowConfigurationService {
|
|
968
969
|
};
|
969
970
|
}
|
970
971
|
}
|
971
|
-
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
972
|
-
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
973
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
972
|
+
FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
|
973
|
+
FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowConfigurationService });
|
974
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowConfigurationService, decorators: [{
|
974
975
|
type: Injectable
|
975
976
|
}], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
976
977
|
|
977
978
|
class FlowConfigurationModule {
|
978
979
|
}
|
979
|
-
FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
980
|
-
FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
981
|
-
FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
982
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
980
|
+
FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
981
|
+
FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowConfigurationModule });
|
982
|
+
FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService], imports: [[]] });
|
983
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: FlowConfigurationModule, decorators: [{
|
983
984
|
type: NgModule,
|
984
985
|
args: [{
|
985
986
|
imports: [],
|
@@ -989,9 +990,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
989
990
|
|
990
991
|
class ConfigurationModule {
|
991
992
|
}
|
992
|
-
ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
993
|
-
ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
994
|
-
ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
993
|
+
ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
994
|
+
ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
|
995
|
+
ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationModule, providers: [
|
995
996
|
ContextApiService,
|
996
997
|
ProductModelApiService,
|
997
998
|
ConfigurationApiService,
|
@@ -999,7 +1000,7 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
|
|
999
1000
|
RuntimeContextService,
|
1000
1001
|
ConfigurationService,
|
1001
1002
|
], imports: [[ConfirmationDialogModule]] });
|
1002
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1003
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ConfigurationModule, decorators: [{
|
1003
1004
|
type: NgModule,
|
1004
1005
|
args: [{
|
1005
1006
|
imports: [ConfirmationDialogModule],
|
@@ -1014,16 +1015,151 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
1014
1015
|
}]
|
1015
1016
|
}] });
|
1016
1017
|
|
1018
|
+
function calculateMetricByMethod(lineItems, metric, method) {
|
1019
|
+
const items = getLineItemsByMethod(lineItems, method);
|
1020
|
+
return items.reduce((acc, li) => {
|
1021
|
+
let value = li.reduce((accProduct, item) => accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0), 0);
|
1022
|
+
if (method === 'avg' && li.length > 0) {
|
1023
|
+
value /= li.length;
|
1024
|
+
}
|
1025
|
+
return acc + value;
|
1026
|
+
}, 0);
|
1027
|
+
}
|
1028
|
+
function getLineItemsByMethod(lineItems, method) {
|
1029
|
+
switch (method) {
|
1030
|
+
case 'first': {
|
1031
|
+
return lineItems.filter(li => !li.rampInstanceId).map(item => [item]);
|
1032
|
+
}
|
1033
|
+
case 'last': {
|
1034
|
+
const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
|
1035
|
+
const products = rootTermItems.map(lineItem => [
|
1036
|
+
lineItem,
|
1037
|
+
...lineItems.filter(li => li.rampInstanceId === lineItem.id),
|
1038
|
+
]);
|
1039
|
+
return products
|
1040
|
+
.map(items => [...items].sort((a, b) => getDateValue(a.endDate || '') - getDateValue(b.endDate || '')).pop())
|
1041
|
+
.filter((li) => Boolean(li))
|
1042
|
+
.map(item => [item]);
|
1043
|
+
}
|
1044
|
+
case 'avg': {
|
1045
|
+
const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
|
1046
|
+
return rootTermItems.map(lineItem => [lineItem, ...lineItems.filter(li => li.rampInstanceId === lineItem.id)]);
|
1047
|
+
}
|
1048
|
+
case 'sum': {
|
1049
|
+
return lineItems.map(item => [item]);
|
1050
|
+
}
|
1051
|
+
default: {
|
1052
|
+
return lineItems.map(item => [item]);
|
1053
|
+
}
|
1054
|
+
}
|
1055
|
+
}
|
1056
|
+
function getDateValue(date) {
|
1057
|
+
return date ? new Date(date).getTime() : 0;
|
1058
|
+
}
|
1059
|
+
|
1060
|
+
class MetricsCalculationService {
|
1061
|
+
constructor(quoteDraftService, settingsService) {
|
1062
|
+
this.quoteDraftService = quoteDraftService;
|
1063
|
+
this.settingsService = settingsService;
|
1064
|
+
this.metricsUpdated$ = new Subject();
|
1065
|
+
this.quoteMetricsSettings = {};
|
1066
|
+
this.metricsCalculationMethodMap = {};
|
1067
|
+
this.metricsData = {};
|
1068
|
+
combineLatest([
|
1069
|
+
this.quoteDraftService.currentState$,
|
1070
|
+
this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(take$1(1)),
|
1071
|
+
]).subscribe(([lineItems, setting]) => {
|
1072
|
+
let settingsData = {};
|
1073
|
+
try {
|
1074
|
+
settingsData = JSON.parse((setting === null || setting === void 0 ? void 0 : setting.value) || '{}');
|
1075
|
+
}
|
1076
|
+
catch (error) {
|
1077
|
+
settingsData = {};
|
1078
|
+
}
|
1079
|
+
this.quoteMetricsSettings = settingsData;
|
1080
|
+
this.updateMetrics(lineItems);
|
1081
|
+
});
|
1082
|
+
}
|
1083
|
+
get onMetricsUpdate$() {
|
1084
|
+
return this.metricsUpdated$.asObservable();
|
1085
|
+
}
|
1086
|
+
getMetricValue(metric) {
|
1087
|
+
return this.metricsData[metric] || 0;
|
1088
|
+
}
|
1089
|
+
updateMetrics(lineItems) {
|
1090
|
+
const metricKeys = this.collectMetricKeys(lineItems).filter(key => !key.includes('Effective_'));
|
1091
|
+
this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
|
1092
|
+
this.metricsData = metricKeys.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: this.calculateMetric(lineItems, key) })), {});
|
1093
|
+
this.metricsUpdated$.next();
|
1094
|
+
}
|
1095
|
+
calculateMetric(lineItems, metric) {
|
1096
|
+
return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
|
1097
|
+
}
|
1098
|
+
buildMetricsCalculationMethods(metricKeys, initial) {
|
1099
|
+
return metricKeys.reduce((acc, name) => {
|
1100
|
+
if (acc[name]) {
|
1101
|
+
return acc;
|
1102
|
+
}
|
1103
|
+
acc = Object.assign(Object.assign({}, acc), { [name]: 'sum' });
|
1104
|
+
const settingKey = name.replace(/VDM_|Total_/g, '');
|
1105
|
+
if (this.quoteMetricsSettings[settingKey]) {
|
1106
|
+
acc = Object.assign(Object.assign({}, acc), { [name]: this.quoteMetricsSettings[settingKey] });
|
1107
|
+
}
|
1108
|
+
return acc;
|
1109
|
+
}, initial);
|
1110
|
+
}
|
1111
|
+
collectMetricKeys(lineItems) {
|
1112
|
+
const keys = [];
|
1113
|
+
lineItems.forEach(lineItem => {
|
1114
|
+
keys.push(...Object.keys(lineItem.totalMetrics || {}));
|
1115
|
+
keys.push(...this.collectMetricKeys(lineItem.lineItems));
|
1116
|
+
});
|
1117
|
+
return uniq(keys);
|
1118
|
+
}
|
1119
|
+
}
|
1120
|
+
MetricsCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1121
|
+
MetricsCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MetricsCalculationService, providedIn: 'root' });
|
1122
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: MetricsCalculationService, decorators: [{
|
1123
|
+
type: Injectable,
|
1124
|
+
args: [{ providedIn: 'root' }]
|
1125
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: i1.ConfigurationSettingsApiService }]; } });
|
1126
|
+
|
1127
|
+
class ProductImagesService {
|
1128
|
+
constructor(productApiService) {
|
1129
|
+
this.productApiService = productApiService;
|
1130
|
+
this.imagesMap$ = new BehaviorSubject({});
|
1131
|
+
}
|
1132
|
+
getImageUrl$(productId) {
|
1133
|
+
if (this.imagesMap$.value[productId] == null) {
|
1134
|
+
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
|
1135
|
+
this.fetchProductImage(productId);
|
1136
|
+
}
|
1137
|
+
return this.imagesMap$.pipe(map$2(imagesMap => imagesMap[productId]), distinctUntilChanged());
|
1138
|
+
}
|
1139
|
+
fetchProductImage(productId) {
|
1140
|
+
this.productApiService
|
1141
|
+
.fetchImage$(productId)
|
1142
|
+
.pipe(map$2(file => URL.createObjectURL(file)), catchError$1(() => of('')), tap$1(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
|
1143
|
+
.subscribe();
|
1144
|
+
}
|
1145
|
+
}
|
1146
|
+
ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
|
1147
|
+
ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ProductImagesService, providedIn: 'root' });
|
1148
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: ProductImagesService, decorators: [{
|
1149
|
+
type: Injectable,
|
1150
|
+
args: [{ providedIn: 'root' }]
|
1151
|
+
}], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
|
1152
|
+
|
1017
1153
|
class SdkCoreModule {
|
1018
1154
|
}
|
1019
|
-
SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1020
|
-
SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
1021
|
-
SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
1022
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1155
|
+
SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
1156
|
+
SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
1157
|
+
SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SdkCoreModule, providers: [ContextService, QuoteDraftService, ProductImagesService, MetricsCalculationService], imports: [[ConfigurationModule, FlowConfigurationModule]] });
|
1158
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0, type: SdkCoreModule, decorators: [{
|
1023
1159
|
type: NgModule,
|
1024
1160
|
args: [{
|
1025
1161
|
imports: [ConfigurationModule, FlowConfigurationModule],
|
1026
|
-
providers: [ContextService, QuoteDraftService, ProductImagesService],
|
1162
|
+
providers: [ContextService, QuoteDraftService, ProductImagesService, MetricsCalculationService],
|
1027
1163
|
}]
|
1028
1164
|
}] });
|
1029
1165
|
|
@@ -1031,5 +1167,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImpo
|
|
1031
1167
|
* Generated bundle index. Do not edit.
|
1032
1168
|
*/
|
1033
1169
|
|
1034
|
-
export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeStep, SdkCoreModule, findLineItem, findLineItemWithComparator, generateLineItem, getAttributeValue, getAttributes, getDefaultLineItem, getRecommendedPrices, insertLineItem, lineItem_utils as lineItemUtils, mapAttributes, patchAttributes, removeLineItem, replaceLineItem, upsertAttributes };
|
1035
|
-
//# sourceMappingURL=
|
1170
|
+
export { ConfigurationRuntimeService, ConfigurationService, ContextService, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeStep, SdkCoreModule, findLineItem, findLineItemWithComparator, generateLineItem, getAttributeValue, getAttributes, getDefaultLineItem, getRecommendedPrices, insertLineItem, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, removeLineItem, replaceLineItem, upsertAttributes };
|
1171
|
+
//# sourceMappingURL=veloceapps-sdk-core.js.map
|