@veloceapps/sdk 6.0.0-10 → 6.0.0-100
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/README.md +10 -2
- package/bundles/veloceapps-sdk-cms.umd.js +1269 -798
- package/bundles/veloceapps-sdk-cms.umd.js.map +1 -1
- package/bundles/veloceapps-sdk-core.umd.js +765 -650
- package/bundles/veloceapps-sdk-core.umd.js.map +1 -1
- package/bundles/veloceapps-sdk-runtime.umd.js +216 -150
- package/bundles/veloceapps-sdk-runtime.umd.js.map +1 -1
- package/bundles/veloceapps-sdk.umd.js +574 -309
- package/bundles/veloceapps-sdk.umd.js.map +1 -1
- package/cms/cms.actions.d.ts +2 -4
- package/cms/components/element-children/element-children.component.d.ts +13 -3
- package/cms/components/element-children/element-children.module.d.ts +4 -2
- package/cms/components/element-drop-handle/element-drop-handle.component.d.ts +12 -0
- package/cms/components/element-drop-handle/element-drop-handle.module.d.ts +9 -0
- package/cms/components/element-renderer/element-renderer.component.d.ts +3 -3
- package/cms/components/preview/index.d.ts +1 -0
- package/cms/components/preview/preview.component.d.ts +9 -8
- package/cms/components/preview/preview.module.d.ts +2 -1
- package/cms/components/preview/preview.types.d.ts +11 -0
- package/cms/index.d.ts +2 -0
- package/cms/launcher.module.d.ts +3 -1
- package/cms/modules/migrations/index.d.ts +2 -0
- package/cms/modules/migrations/migrations.d.ts +2 -0
- package/cms/modules/migrations/migrations.module.d.ts +6 -0
- package/cms/modules/migrations/services/migrations.service.d.ts +10 -0
- package/cms/modules/migrations/types/migrations.types.d.ts +2 -0
- package/cms/modules/runtime/index.d.ts +2 -0
- package/cms/modules/runtime/runtime.module.d.ts +8 -0
- package/cms/modules/runtime/services/compilation.service.d.ts +18 -0
- package/cms/modules/runtime/services/runtime-editor.service.d.ts +18 -0
- package/cms/modules/runtime/services/runtime.service.d.ts +27 -0
- package/cms/modules/runtime/tokens.d.ts +3 -0
- package/cms/{types → modules/runtime/types}/compilation.types.d.ts +1 -1
- package/cms/modules/runtime/types/runtime.actions.d.ts +9 -0
- package/cms/services/index.d.ts +1 -1
- package/cms/services/integration.state.d.ts +2 -3
- package/cms/services/io-provider.service.d.ts +3 -3
- package/cms/services/resources.service.d.ts +10 -0
- package/cms/types/common.types.d.ts +1 -1
- package/cms/types/configuration.types.d.ts +1 -0
- package/cms/types/index.d.ts +1 -1
- package/cms/types/integration.types.d.ts +5 -0
- package/cms/utils/elements-resolver.d.ts +3 -2
- package/cms/utils/index.d.ts +1 -0
- package/cms/utils/path.utils.d.ts +0 -1
- package/cms/utils/ui-definition.utils.d.ts +6 -0
- package/cms/vendor-map.d.ts +51 -31
- package/core/modules/configuration/services/configuration-runtime.service.d.ts +2 -4
- package/core/modules/configuration/services/configuration.service.d.ts +6 -4
- package/core/modules/configuration/types/configuration-runtime.types.d.ts +0 -2
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +3 -2
- package/core/modules/flow-configuration/services/flow-update.service.d.ts +3 -2
- package/core/services/context.service.d.ts +1 -0
- package/core/services/metric-calculation/metric-calculation.service.d.ts +5 -1
- package/core/services/quote-draft.service.d.ts +2 -2
- package/core/types/index.d.ts +0 -1
- package/core/types/ui-definition.types.d.ts +19 -4
- package/core/utils/index.d.ts +1 -0
- package/core/utils/line-item.utils.d.ts +2 -0
- package/core/utils/ui-definition.utils.d.ts +2 -0
- package/esm2015/cms/cms.actions.js +1 -6
- package/esm2015/cms/components/element-children/element-children.component.js +24 -8
- package/esm2015/cms/components/element-children/element-children.module.js +8 -6
- package/esm2015/cms/components/element-drop-handle/element-drop-handle.component.js +32 -0
- package/esm2015/cms/components/element-drop-handle/element-drop-handle.module.js +19 -0
- package/esm2015/cms/components/element-renderer/element-renderer.component.js +9 -9
- 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/index.js +2 -1
- package/esm2015/cms/components/preview/preview.component.js +21 -36
- package/esm2015/cms/components/preview/preview.module.js +7 -6
- package/esm2015/cms/components/preview/preview.types.js +2 -0
- package/esm2015/cms/directives/custom-template.directive.js +3 -3
- package/esm2015/cms/index.js +3 -1
- package/esm2015/cms/launcher.module.js +11 -10
- package/esm2015/cms/modules/federated/federated.component.js +3 -3
- package/esm2015/cms/modules/federated/federated.module.js +4 -4
- package/esm2015/cms/modules/migrations/index.js +3 -0
- package/esm2015/cms/modules/migrations/migrations.js +11 -0
- package/esm2015/cms/modules/migrations/migrations.module.js +15 -0
- package/esm2015/cms/modules/migrations/services/migrations.service.js +43 -0
- package/esm2015/cms/modules/migrations/types/migrations.types.js +2 -0
- package/esm2015/cms/modules/runtime/index.js +3 -0
- package/esm2015/cms/modules/runtime/runtime.module.js +32 -0
- package/esm2015/cms/modules/runtime/services/compilation.service.js +84 -0
- package/esm2015/cms/modules/runtime/services/runtime-editor.service.js +27 -0
- package/esm2015/cms/modules/runtime/services/runtime.service.js +74 -0
- package/esm2015/cms/modules/runtime/tokens.js +3 -0
- package/esm2015/cms/modules/runtime/types/compilation.types.js +2 -0
- package/esm2015/cms/modules/runtime/types/runtime.actions.js +2 -0
- package/esm2015/cms/plugins/configuration.plugin.js +12 -4
- package/esm2015/cms/plugins/io.plugin.js +3 -3
- package/esm2015/cms/plugins/script.plugin.js +3 -3
- package/esm2015/cms/services/element-context.service.js +3 -3
- package/esm2015/cms/services/index.js +2 -2
- package/esm2015/cms/services/integration.state.js +4 -4
- package/esm2015/cms/services/io-provider.service.js +9 -9
- package/esm2015/cms/services/resources.service.js +50 -0
- package/esm2015/cms/services/templates.service.js +3 -3
- package/esm2015/cms/types/common.types.js +1 -1
- package/esm2015/cms/types/configuration.types.js +1 -1
- package/esm2015/cms/types/index.js +2 -2
- package/esm2015/cms/types/integration.types.js +1 -1
- package/esm2015/cms/utils/elements-resolver.js +18 -8
- package/esm2015/cms/utils/index.js +2 -1
- package/esm2015/cms/utils/path.utils.js +2 -13
- package/esm2015/cms/utils/ui-definition.utils.js +82 -0
- package/esm2015/cms/vendor-map.js +26 -10
- package/esm2015/core/core.module.js +4 -4
- package/esm2015/core/modules/configuration/configuration.module.js +4 -4
- package/esm2015/core/modules/configuration/services/configuration-runtime.service.js +5 -10
- package/esm2015/core/modules/configuration/services/configuration.service.js +38 -34
- package/esm2015/core/modules/configuration/services/runtime-context.service.js +3 -3
- package/esm2015/core/modules/configuration/types/configuration-runtime.types.js +1 -1
- package/esm2015/core/modules/flow-configuration/flow-configuration.module.js +4 -4
- package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +11 -10
- package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +9 -9
- package/esm2015/core/services/context.service.js +7 -4
- package/esm2015/core/services/metric-calculation/metric-calculation.service.js +18 -9
- package/esm2015/core/services/product-images.service.js +3 -3
- package/esm2015/core/services/quote-draft.service.js +7 -7
- package/esm2015/core/types/index.js +1 -2
- package/esm2015/core/types/ui-definition.types.js +2 -2
- package/esm2015/core/utils/index.js +2 -1
- package/esm2015/core/utils/line-item.utils.js +27 -11
- package/esm2015/core/utils/ui-definition.utils.js +9 -0
- package/esm2015/runtime/components/component-preview/component-preview.component.js +4 -4
- package/esm2015/runtime/components/section-renderer/section-renderer.component.js +3 -3
- package/esm2015/runtime/components/ui-runtime/runtime.component.js +3 -3
- package/esm2015/runtime/components/ui-runtime-preview/runtime-preview.component.js +3 -3
- package/esm2015/runtime/execution/components/children-placeholder/children-placeholder.component.js +6 -6
- package/esm2015/runtime/execution/components/context-provider/context-provider.component.js +3 -3
- package/esm2015/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.js +3 -3
- package/esm2015/runtime/execution/components/federated/federated.component.js +3 -3
- 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 +3 -3
- package/esm2015/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-port-radio/velo-port-radio.component.js +3 -3
- package/esm2015/runtime/execution/components/velo-type/velo-type.component.js +3 -3
- package/esm2015/runtime/execution/directives/section-script.directive.js +3 -3
- package/esm2015/runtime/execution/directives/sf-query.directive.js +3 -3
- package/esm2015/runtime/execution/directives/velo-attribute.directive.js +3 -3
- package/esm2015/runtime/execution/directives/velo-port.directive.js +18 -18
- package/esm2015/runtime/execution/directives/vl-approval.directive.js +3 -3
- package/esm2015/runtime/execution/directives/vl-document-attachments.directive.js +3 -3
- package/esm2015/runtime/execution/directives/vl-document-templates.directive.js +3 -3
- package/esm2015/runtime/execution/directives/vl-quote.directive.js +4 -4
- package/esm2015/runtime/execution/directives/vl-ramp.directive.js +3 -3
- package/esm2015/runtime/execution/runtime-execution.module.js +4 -4
- package/esm2015/runtime/runtime.module.js +4 -4
- package/esm2015/runtime/services/cart.service.js +3 -3
- package/esm2015/runtime/services/collapsible-state.service.js +3 -3
- package/esm2015/runtime/services/configuration.service.js +11 -12
- package/esm2015/runtime/services/current-state.service.js +3 -3
- package/esm2015/runtime/services/form-scope.service.js +3 -3
- package/esm2015/runtime/services/product-model-cache.service.js +3 -3
- package/esm2015/runtime/services/runtime-context.service.js +3 -3
- package/esm2015/runtime/services/runtime-form.service.js +3 -3
- package/esm2015/runtime/services/runtime.service.js +4 -4
- package/esm2015/runtime/services/section-helper.service.js +3 -3
- package/esm2015/runtime/services/section-scope.service.js +3 -3
- package/esm2015/runtime/services/section-store.service.js +3 -3
- package/esm2015/runtime/services/section.service.js +6 -6
- package/esm2015/runtime/types/index.js +2 -1
- package/esm2015/runtime/types/quote-states.types.js +2 -0
- package/esm2015/src/components/dialog/dialog.component.js +16 -6
- package/esm2015/src/components/dialog/dialog.module.js +4 -4
- package/esm2015/src/components/dialog/dialog.types.js +1 -1
- package/esm2015/src/components/doc-gen/doc-gen.component.js +3 -3
- package/esm2015/src/components/doc-gen/doc-gen.module.js +4 -4
- package/esm2015/src/components/header/cart-overlay/cart-preview.component.js +3 -3
- package/esm2015/src/components/header/cart-overlay/cart-preview.module.js +4 -4
- package/esm2015/src/components/header/header.component.js +39 -13
- package/esm2015/src/components/header/header.module.js +4 -4
- package/esm2015/src/components/header/metrics/metrics.component.js +79 -67
- package/esm2015/src/components/header/metrics/metrics.definitions.js +1 -8
- package/esm2015/src/components/header/metrics/metrics.module.js +4 -4
- package/esm2015/src/flow-routing.module.js +18 -5
- package/esm2015/src/flow.component.js +3 -3
- package/esm2015/src/flow.module.js +4 -4
- package/esm2015/src/guards/context.guard.js +3 -3
- package/esm2015/src/guards/product-unload.guard.js +5 -5
- package/esm2015/src/guards/root.guard.js +3 -3
- package/esm2015/src/pages/assets/assets.component.js +117 -0
- package/esm2015/src/pages/assets/assets.module.js +20 -0
- package/esm2015/src/pages/catalog/catalog.component.js +6 -6
- package/esm2015/src/pages/catalog/catalog.module.js +4 -4
- package/esm2015/src/pages/debug/debug.component.js +3 -3
- package/esm2015/src/pages/debug/debug.module.js +4 -4
- package/esm2015/src/pages/empty-account/empty-account.component.js +3 -3
- package/esm2015/src/pages/empty-account/empty-account.module.js +4 -4
- package/esm2015/src/pages/legacy-product/legacy-product.component.js +4 -4
- package/esm2015/src/pages/legacy-product/legacy-product.module.js +4 -4
- package/esm2015/src/pages/product/product.component.js +5 -12
- package/esm2015/src/pages/product/product.module.js +4 -4
- 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 +5 -8
- package/esm2015/src/pages/remote/remote.module.js +4 -4
- package/esm2015/src/pages/shopping-cart/shopping-cart.component.js +6 -6
- package/esm2015/src/pages/shopping-cart/shopping-cart.module.js +4 -4
- package/esm2015/src/resolvers/flow.resolver.js +3 -3
- package/esm2015/src/resolvers/quote.resolver.js +17 -12
- package/esm2015/src/services/doc-gen.service.js +3 -3
- package/esm2015/src/services/flow-dialog.service.js +5 -4
- package/esm2015/src/services/flow-router.service.js +12 -4
- package/esm2015/src/services/flow.service.js +12 -5
- package/esm2015/src/types/flow-customization.types.js +1 -1
- package/esm2015/src/utils/flow.utils.js +3 -3
- package/fesm2015/veloceapps-sdk-cms.js +1073 -718
- package/fesm2015/veloceapps-sdk-cms.js.map +1 -1
- package/fesm2015/veloceapps-sdk-core.js +570 -533
- package/fesm2015/veloceapps-sdk-core.js.map +1 -1
- package/fesm2015/veloceapps-sdk-runtime.js +145 -146
- package/fesm2015/veloceapps-sdk-runtime.js.map +1 -1
- package/fesm2015/veloceapps-sdk.js +446 -262
- package/fesm2015/veloceapps-sdk.js.map +1 -1
- package/package.json +5 -3
- package/runtime/services/configuration.service.d.ts +2 -1
- package/runtime/services/runtime.service.d.ts +2 -1
- package/runtime/types/index.d.ts +1 -0
- package/src/components/dialog/dialog.types.d.ts +1 -0
- package/src/components/header/header.component.d.ts +10 -3
- package/src/components/header/metrics/metrics.component.d.ts +15 -6
- package/src/components/header/metrics/metrics.definitions.d.ts +0 -3
- package/src/flow-routing.module.d.ts +4 -3
- package/src/pages/assets/assets.component.d.ts +32 -0
- package/src/pages/assets/assets.module.d.ts +10 -0
- package/src/pages/product/product.component.d.ts +0 -1
- package/src/resolvers/quote.resolver.d.ts +1 -0
- package/src/services/flow-router.service.d.ts +2 -0
- package/src/services/flow.service.d.ts +1 -0
- package/src/types/flow-customization.types.d.ts +1 -0
- package/cms/services/dynamic-module.service.d.ts +0 -15
- package/cms/services/launcher.service.d.ts +0 -18
- package/esm2015/cms/services/dynamic-module.service.js +0 -33
- package/esm2015/cms/services/launcher.service.js +0 -58
- package/esm2015/cms/types/compilation.types.js +0 -2
- package/esm2015/core/types/quote-states.types.js +0 -2
- /package/{core → runtime}/types/quote-states.types.d.ts +0 -0
@@ -2,7 +2,7 @@
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@veloceapps/core'), require('rxjs'), require('rxjs/operators'), require('@veloceapps/api'), require('lodash'), require('@veloceapps/components'), require('primeng/api'), require('primeng/dynamicdialog'), require('moment')) :
|
3
3
|
typeof define === 'function' && define.amd ? define('@veloceapps/sdk/core', ['exports', '@angular/core', '@veloceapps/core', 'rxjs', 'rxjs/operators', '@veloceapps/api', 'lodash', '@veloceapps/components', 'primeng/api', 'primeng/dynamicdialog', 'moment'], factory) :
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.veloceapps = global.veloceapps || {}, global.veloceapps.sdk = global.veloceapps.sdk || {}, global.veloceapps.sdk.core = {}), global.ng.core, global["@veloceapps/core"], global.rxjs, global.rxjs.operators, global["@veloceapps/api"], global.lodash, global["@veloceapps/components"], global["primeng/api"], global["primeng/dynamicdialog"], global.moment));
|
5
|
-
})(this, (function (exports, i0, core, rxjs, operators, i1, lodash, components,
|
5
|
+
})(this, (function (exports, i0, core, rxjs, operators, i1, lodash, components, i5, i6, moment) { 'use strict';
|
6
6
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
8
8
|
|
@@ -26,8 +26,8 @@
|
|
26
26
|
|
27
27
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
28
28
|
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
29
|
-
var i4__namespace = /*#__PURE__*/_interopNamespace(i4);
|
30
29
|
var i5__namespace = /*#__PURE__*/_interopNamespace(i5);
|
30
|
+
var i6__namespace = /*#__PURE__*/_interopNamespace(i6);
|
31
31
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
32
32
|
|
33
33
|
var getDefaultLineItem = function (context, uiDefinitionProperties, qty) {
|
@@ -40,7 +40,7 @@
|
|
40
40
|
return lineItem;
|
41
41
|
};
|
42
42
|
|
43
|
-
|
43
|
+
/******************************************************************************
|
44
44
|
Copyright (c) Microsoft Corporation.
|
45
45
|
|
46
46
|
Permission to use, copy, modify, and/or distribute this software for any
|
@@ -107,6 +107,64 @@
|
|
107
107
|
function __param(paramIndex, decorator) {
|
108
108
|
return function (target, key) { decorator(target, key, paramIndex); };
|
109
109
|
}
|
110
|
+
function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
111
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function")
|
112
|
+
throw new TypeError("Function expected"); return f; }
|
113
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
114
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
115
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
116
|
+
var _, done = false;
|
117
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
118
|
+
var context = {};
|
119
|
+
for (var p in contextIn)
|
120
|
+
context[p] = p === "access" ? {} : contextIn[p];
|
121
|
+
for (var p in contextIn.access)
|
122
|
+
context.access[p] = contextIn.access[p];
|
123
|
+
context.addInitializer = function (f) { if (done)
|
124
|
+
throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
125
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
126
|
+
if (kind === "accessor") {
|
127
|
+
if (result === void 0)
|
128
|
+
continue;
|
129
|
+
if (result === null || typeof result !== "object")
|
130
|
+
throw new TypeError("Object expected");
|
131
|
+
if (_ = accept(result.get))
|
132
|
+
descriptor.get = _;
|
133
|
+
if (_ = accept(result.set))
|
134
|
+
descriptor.set = _;
|
135
|
+
if (_ = accept(result.init))
|
136
|
+
initializers.push(_);
|
137
|
+
}
|
138
|
+
else if (_ = accept(result)) {
|
139
|
+
if (kind === "field")
|
140
|
+
initializers.push(_);
|
141
|
+
else
|
142
|
+
descriptor[key] = _;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
if (target)
|
146
|
+
Object.defineProperty(target, contextIn.name, descriptor);
|
147
|
+
done = true;
|
148
|
+
}
|
149
|
+
;
|
150
|
+
function __runInitializers(thisArg, initializers, value) {
|
151
|
+
var useValue = arguments.length > 2;
|
152
|
+
for (var i = 0; i < initializers.length; i++) {
|
153
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
154
|
+
}
|
155
|
+
return useValue ? value : void 0;
|
156
|
+
}
|
157
|
+
;
|
158
|
+
function __propKey(x) {
|
159
|
+
return typeof x === "symbol" ? x : "".concat(x);
|
160
|
+
}
|
161
|
+
;
|
162
|
+
function __setFunctionName(f, name, prefix) {
|
163
|
+
if (typeof name === "symbol")
|
164
|
+
name = name.description ? "[".concat(name.description, "]") : "";
|
165
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
166
|
+
}
|
167
|
+
;
|
110
168
|
function __metadata(metadataKey, metadataValue) {
|
111
169
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
112
170
|
return Reflect.metadata(metadataKey, metadataValue);
|
@@ -138,7 +196,7 @@
|
|
138
196
|
function step(op) {
|
139
197
|
if (f)
|
140
198
|
throw new TypeError("Generator is already executing.");
|
141
|
-
while (_)
|
199
|
+
while (g && (g = 0, op[0] && (_ = 0)), _)
|
142
200
|
try {
|
143
201
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
144
202
|
return t;
|
@@ -202,7 +260,11 @@
|
|
202
260
|
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
203
261
|
if (k2 === undefined)
|
204
262
|
k2 = k;
|
205
|
-
Object.
|
263
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
264
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
265
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
266
|
+
}
|
267
|
+
Object.defineProperty(o, k2, desc);
|
206
268
|
}) : (function (o, m, k, k2) {
|
207
269
|
if (k2 === undefined)
|
208
270
|
k2 = k;
|
@@ -302,7 +364,7 @@
|
|
302
364
|
function __asyncDelegator(o) {
|
303
365
|
var i, p;
|
304
366
|
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
305
|
-
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done:
|
367
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
306
368
|
}
|
307
369
|
function __asyncValues(o) {
|
308
370
|
if (!Symbol.asyncIterator)
|
@@ -357,6 +419,11 @@
|
|
357
419
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
358
420
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
359
421
|
}
|
422
|
+
function __classPrivateFieldIn(state, receiver) {
|
423
|
+
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
|
424
|
+
throw new TypeError("Cannot use 'in' operator on non-object");
|
425
|
+
return typeof state === "function" ? receiver === state : state.has(receiver);
|
426
|
+
}
|
360
427
|
|
361
428
|
exports.RuntimeMode = void 0;
|
362
429
|
(function (RuntimeMode) {
|
@@ -374,6 +441,8 @@
|
|
374
441
|
RuntimeStep["UPDATE"] = "UPDATE";
|
375
442
|
})(exports.RuntimeStep || (exports.RuntimeStep = {}));
|
376
443
|
|
444
|
+
var UI_DEFINITION_VERSION = 3;
|
445
|
+
|
377
446
|
var ContextService = /** @class */ (function () {
|
378
447
|
function ContextService(contextApiService) {
|
379
448
|
this.contextApiService = contextApiService;
|
@@ -386,6 +455,13 @@
|
|
386
455
|
enumerable: false,
|
387
456
|
configurable: true
|
388
457
|
});
|
458
|
+
Object.defineProperty(ContextService.prototype, "mode", {
|
459
|
+
get: function () {
|
460
|
+
return this.resolve().properties.mode;
|
461
|
+
},
|
462
|
+
enumerable: false,
|
463
|
+
configurable: true
|
464
|
+
});
|
389
465
|
ContextService.prototype.resolve = function () {
|
390
466
|
if (!this.context.value) {
|
391
467
|
throw new Error('Context is not initialized yet!');
|
@@ -416,149 +492,434 @@
|
|
416
492
|
};
|
417
493
|
return ContextService;
|
418
494
|
}());
|
419
|
-
ContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
420
|
-
ContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
421
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
495
|
+
ContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ContextService, deps: [{ token: i1__namespace.ContextApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
496
|
+
ContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ContextService, providedIn: 'root' });
|
497
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ContextService, decorators: [{
|
422
498
|
type: i0.Injectable,
|
423
499
|
args: [{ providedIn: 'root' }]
|
424
500
|
}], ctorParameters: function () { return [{ type: i1__namespace.ContextApiService }]; } });
|
425
501
|
|
426
|
-
function
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
}
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
502
|
+
var RuntimeContextService = /** @class */ (function () {
|
503
|
+
function RuntimeContextService(configurationApiService) {
|
504
|
+
this.configurationApiService = configurationApiService;
|
505
|
+
}
|
506
|
+
RuntimeContextService.prototype.getRuntimeContext = function (productId, offeringId) {
|
507
|
+
var _this = this;
|
508
|
+
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(operators.map(function (runtimeData) {
|
509
|
+
var _a, _b, _c;
|
510
|
+
var uiDefinition = _this.getUIDefinition(runtimeData);
|
511
|
+
var runtimeModel = core.RuntimeModel.create(runtimeData.types, runtimeData.products);
|
512
|
+
var _d = (_a = Array.from(runtimeModel.components.values()).find(function (c) { return c.productId === productId; })) !== null && _a !== void 0 ? _a : {}, productName = _d.productName, properties = _d.properties;
|
513
|
+
return {
|
514
|
+
modelId: runtimeData.modelId,
|
515
|
+
uiDefinition: uiDefinition,
|
516
|
+
runtimeModel: runtimeModel,
|
517
|
+
runtimeMode: exports.RuntimeMode.PROD,
|
518
|
+
productId: productId,
|
519
|
+
productType: (properties === null || properties === void 0 ? void 0 : properties.displayName) || productName,
|
520
|
+
offeringId: offeringId,
|
521
|
+
properties: {
|
522
|
+
PricingEnabled: ((_b = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _b === void 0 ? void 0 : _b.pricingEnabled) ? 'true' : 'false',
|
523
|
+
PriceListId: (_c = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _c === void 0 ? void 0 : _c.priceList,
|
524
|
+
},
|
525
|
+
};
|
526
|
+
}));
|
527
|
+
};
|
528
|
+
RuntimeContextService.prototype.getUIDefinition = function (runtimeData) {
|
529
|
+
var _a;
|
530
|
+
var rawUiDefinitions;
|
531
|
+
try {
|
532
|
+
rawUiDefinitions = JSON.parse(runtimeData.uiDefinitionsSource);
|
457
533
|
}
|
458
|
-
|
459
|
-
return
|
534
|
+
catch (e) {
|
535
|
+
return;
|
460
536
|
}
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
537
|
+
var uiDefinitions = rawUiDefinitions.filter(function (uiDef) { return uiDef.version; });
|
538
|
+
var uiDefinition = (_a = uiDefinitions.find(function (uiDef) { return uiDef.primary; })) !== null && _a !== void 0 ? _a : uiDefinitions[0];
|
539
|
+
return uiDefinition;
|
540
|
+
};
|
541
|
+
return RuntimeContextService;
|
542
|
+
}());
|
543
|
+
RuntimeContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeContextService, deps: [{ token: i1__namespace.ConfigurationApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
544
|
+
RuntimeContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeContextService });
|
545
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeContextService, decorators: [{
|
546
|
+
type: i0.Injectable
|
547
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }]; } });
|
466
548
|
|
467
|
-
var
|
468
|
-
function
|
469
|
-
|
470
|
-
this.
|
471
|
-
this.
|
472
|
-
this.
|
473
|
-
this.
|
474
|
-
this.resetSubj$ = new rxjs.BehaviorSubject(true);
|
475
|
-
this.isInitializedSubj$ = new rxjs.BehaviorSubject(false);
|
476
|
-
this.initialCurrentState = [];
|
477
|
-
this._hasUnsavedChanges = false;
|
478
|
-
this.allPriceLists = [];
|
479
|
-
this.assetPriceLists = [];
|
480
|
-
this.reset$ = this.resetSubj$.asObservable();
|
481
|
-
this.activePriceList$ = this.context.resolve$().pipe(operators.map(function (ctx) { return _this.allPriceLists.find(function (priceList) { return priceList.id === ctx.properties.PriceListId; }); }), operators.map(function (priceList) { return priceList !== null && priceList !== void 0 ? priceList : null; }));
|
482
|
-
this.isInitializedSubj$
|
483
|
-
.pipe(operators.filter(function (isInitialized) { return isInitialized; }), operators.switchMap(function () { return _this.quoteSubj$.asObservable(); }), operators.skip(1), operators.tap(function (quote) { return _this.markAsUpdated(quote); }))
|
484
|
-
.subscribe();
|
549
|
+
var ConfigurationRuntimeService = /** @class */ (function () {
|
550
|
+
function ConfigurationRuntimeService(apiService, contextService, runtimeContextService) {
|
551
|
+
this.apiService = apiService;
|
552
|
+
this.contextService = contextService;
|
553
|
+
this.runtimeContextService = runtimeContextService;
|
554
|
+
this._isInitialized = false;
|
555
|
+
this.uiDefinitionProperties = {};
|
485
556
|
}
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
557
|
+
ConfigurationRuntimeService.prototype.reset = function () {
|
558
|
+
this._isInitialized = false;
|
559
|
+
this._runtimeContext = undefined;
|
560
|
+
this.initializationProps = undefined;
|
561
|
+
this.uiDefinitionProperties = {};
|
562
|
+
};
|
563
|
+
ConfigurationRuntimeService.prototype.initTestMode = function (modelId, uiDefinition) {
|
564
|
+
var _this = this;
|
565
|
+
var _a, _b;
|
566
|
+
this.uiDefinitionProperties = (_a = uiDefinition.properties) !== null && _a !== void 0 ? _a : {};
|
567
|
+
var uiDefinitionExternals = (_b = uiDefinition.externals) !== null && _b !== void 0 ? _b : {};
|
568
|
+
return rxjs.combineLatest([
|
569
|
+
this.apiService.getRuntimeDataByModelId(modelId),
|
570
|
+
this.contextService.create('TestId', core.ConfigurationContextMode.TEST),
|
571
|
+
]).pipe(operators.first(), operators.tap(function (_e) {
|
572
|
+
var _f = __read(_e, 2), runtimeData = _f[0], context = _f[1];
|
573
|
+
var _a;
|
574
|
+
_this._runtimeContext = {
|
575
|
+
modelId: modelId,
|
576
|
+
runtimeModel: core.RuntimeModel.create(runtimeData.types, runtimeData.products),
|
577
|
+
runtimeMode: exports.RuntimeMode.TEST,
|
578
|
+
};
|
579
|
+
_this.contextService.update({
|
580
|
+
properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = _this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: modelId, RuntimeMode: core.ConfigurationContextMode.TEST, PricingEnabled: _this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', StartDate: new Date().toISOString().substring(0, 10), PriceListId: _this.uiDefinitionProperties.priceList, standalone: 'true' }), uiDefinitionExternals),
|
581
|
+
});
|
582
|
+
_this._isInitialized = true;
|
583
|
+
}));
|
584
|
+
};
|
585
|
+
ConfigurationRuntimeService.prototype.init = function (props) {
|
586
|
+
var _this = this;
|
587
|
+
this.initializationProps = props;
|
588
|
+
var context = this.contextService.resolve();
|
589
|
+
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(operators.tap(function (runtimeContext) {
|
590
|
+
var _a, _b, _c, _d;
|
591
|
+
_this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {};
|
592
|
+
var PriceListId = ((_c = context.properties) !== null && _c !== void 0 ? _c : {}).PriceListId;
|
593
|
+
var mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
|
594
|
+
_this.id15to18('AccountId', mergeContext.properties);
|
595
|
+
_this._runtimeContext = mergeContext;
|
596
|
+
if (context.properties && ((_d = _this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
|
597
|
+
_this.contextService.update({
|
598
|
+
properties: Object.assign(Object.assign({}, _this._runtimeContext.properties), context.properties),
|
599
|
+
});
|
493
600
|
}
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
601
|
+
_this._isInitialized = true;
|
602
|
+
}));
|
603
|
+
};
|
604
|
+
ConfigurationRuntimeService.prototype.id15to18 = function (propertyName, source) {
|
605
|
+
if (!source) {
|
606
|
+
return;
|
607
|
+
}
|
608
|
+
var value = source[propertyName];
|
609
|
+
if (typeof value === 'string' && value.length === 15) {
|
610
|
+
source[propertyName] = core.SalesforceIdUtils.generateId18FromId15(value);
|
611
|
+
}
|
612
|
+
};
|
613
|
+
Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized", {
|
499
614
|
get: function () {
|
500
|
-
return this.
|
501
|
-
},
|
502
|
-
set: function (value) {
|
503
|
-
var _a, _b;
|
504
|
-
this._hasUnsavedChanges = value;
|
505
|
-
if (!this._hasUnsavedChanges) {
|
506
|
-
this.initialCurrentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
507
|
-
}
|
615
|
+
return this._isInitialized;
|
508
616
|
},
|
509
617
|
enumerable: false,
|
510
618
|
configurable: true
|
511
619
|
});
|
512
|
-
Object.defineProperty(
|
620
|
+
Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeModel", {
|
513
621
|
get: function () {
|
514
|
-
var
|
515
|
-
return this.
|
622
|
+
var _a;
|
623
|
+
return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
|
516
624
|
},
|
517
625
|
enumerable: false,
|
518
626
|
configurable: true
|
519
627
|
});
|
520
|
-
Object.defineProperty(
|
628
|
+
Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeContext", {
|
521
629
|
get: function () {
|
522
|
-
|
523
|
-
return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
|
630
|
+
return this._runtimeContext;
|
524
631
|
},
|
525
632
|
enumerable: false,
|
526
633
|
configurable: true
|
527
634
|
});
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
if (!quoteDraft) {
|
546
|
-
return;
|
547
|
-
}
|
548
|
-
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
|
549
|
-
};
|
550
|
-
QuoteDraftService.prototype.updateQuoteDraft = function (update) {
|
551
|
-
var quoteDraft = this.quoteSubj$.value;
|
552
|
-
if (!quoteDraft) {
|
553
|
-
return;
|
554
|
-
}
|
555
|
-
if (update.context) {
|
556
|
-
this.context.set(update.context);
|
635
|
+
return ConfigurationRuntimeService;
|
636
|
+
}());
|
637
|
+
ConfigurationRuntimeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService, deps: [{ token: i1__namespace.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
638
|
+
ConfigurationRuntimeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService });
|
639
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService, decorators: [{
|
640
|
+
type: i0.Injectable
|
641
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
|
642
|
+
|
643
|
+
var findLineItem = function (id, lineItems) {
|
644
|
+
return findLineItemWithComparator(lineItems, function (li) { return li.id === id; });
|
645
|
+
};
|
646
|
+
var findLineItemWithComparator = function (lineItems, comparator) {
|
647
|
+
var currentLevel = lineItems;
|
648
|
+
while (currentLevel.length) {
|
649
|
+
var found = currentLevel.find(comparator);
|
650
|
+
if (found) {
|
651
|
+
return found;
|
557
652
|
}
|
558
|
-
|
559
|
-
}
|
560
|
-
|
561
|
-
|
653
|
+
currentLevel = lodash.flatten(currentLevel.map(function (parent) { return parent.lineItems; }));
|
654
|
+
}
|
655
|
+
return;
|
656
|
+
};
|
657
|
+
var insertLineItem = function (lineItem, parentId, toInsert) {
|
658
|
+
var insertData = lineItem.id === parentId ? [toInsert] : [];
|
659
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: __spreadArray(__spreadArray([], __read(insertData)), __read(lineItem.lineItems.map(function (li) {
|
660
|
+
return insertLineItem(li, parentId, toInsert);
|
661
|
+
}))) });
|
662
|
+
};
|
663
|
+
var removeLineItem = function (lineItem, idToRemove) {
|
664
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems
|
665
|
+
.map(function (li) {
|
666
|
+
if (li.id === idToRemove) {
|
667
|
+
return;
|
668
|
+
}
|
669
|
+
else if (li.lineItems.length) {
|
670
|
+
return removeLineItem(li, idToRemove);
|
671
|
+
}
|
672
|
+
return li;
|
673
|
+
})
|
674
|
+
.filter(function (r) { return !!r; }) });
|
675
|
+
};
|
676
|
+
var replaceLineItem = function (lineItem, replaceTo) {
|
677
|
+
if (lineItem.id === replaceTo.id) {
|
678
|
+
return Object.assign({}, recalculateCardinalityVariables(lineItem, replaceTo));
|
679
|
+
}
|
680
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) { return replaceLineItem(li, replaceTo); }) });
|
681
|
+
};
|
682
|
+
var calculateCardinalityVariables = function (lineItems) {
|
683
|
+
var cardVars = new Map();
|
684
|
+
lineItems.forEach(function (li) {
|
685
|
+
var _a;
|
686
|
+
var cardinalityVariableName = "#CV-" + li.type + "@" + li.port;
|
687
|
+
cardVars.set(cardinalityVariableName, ((_a = cardVars.get(cardinalityVariableName)) !== null && _a !== void 0 ? _a : 0) + li.qty);
|
688
|
+
});
|
689
|
+
return cardVars;
|
690
|
+
};
|
691
|
+
var recalculateCardinalityVariables = function (original, updated) {
|
692
|
+
var cardinalityVariables = calculateCardinalityVariables(updated.lineItems);
|
693
|
+
var originalCardinalityVariables = calculateCardinalityVariables(original.lineItems);
|
694
|
+
originalCardinalityVariables.forEach(function (value, key) {
|
695
|
+
if (cardinalityVariables.get(key) === value) {
|
696
|
+
// no need to update cardinality if no changes
|
697
|
+
cardinalityVariables.delete(key);
|
698
|
+
}
|
699
|
+
else if (!cardinalityVariables.has(key)) {
|
700
|
+
// remove last item from port
|
701
|
+
cardinalityVariables.set(key, 0);
|
702
|
+
}
|
703
|
+
});
|
704
|
+
return Object.assign(Object.assign({}, updated), { attributes: upsertAttributes(updated.attributes, __spreadArray([], __read(cardinalityVariables)).map(function (_c) {
|
705
|
+
var _d = __read(_c, 2), name = _d[0], value = _d[1];
|
706
|
+
return ({ name: name, value: value });
|
707
|
+
})) });
|
708
|
+
};
|
709
|
+
var mapAttributes = function (attributes) {
|
710
|
+
return attributes.reduce(function (acc, _c) {
|
711
|
+
var _d;
|
712
|
+
var name = _c.name, value = _c.value;
|
713
|
+
return (Object.assign(Object.assign({}, acc), (_d = {}, _d[name] = value, _d)));
|
714
|
+
}, {});
|
715
|
+
};
|
716
|
+
var getAttributes = function (attributes, names) {
|
717
|
+
if (names === void 0) { names = []; }
|
718
|
+
var filtered = attributes.filter(function (_c) {
|
719
|
+
var name = _c.name;
|
720
|
+
return names.includes(name);
|
721
|
+
});
|
722
|
+
return lodash.sortBy(filtered, [function (_c) {
|
723
|
+
var name = _c.name;
|
724
|
+
return names.indexOf(name);
|
725
|
+
}]);
|
726
|
+
};
|
727
|
+
var upsertAttributes = function (originalAttributes, attributesToUpsert) {
|
728
|
+
return attributesToUpsert.reduce(function (acc, _c) {
|
729
|
+
var name = _c.name, value = _c.value;
|
730
|
+
var _d = __read(getAttributes(acc, [name]), 1), origAttr = _d[0];
|
731
|
+
return __spreadArray(__spreadArray([], __read(acc.filter(function (attr) { return attr.name !== name; }))), [
|
732
|
+
Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name: name })), { cfgStatus: 'User', value: value }),
|
733
|
+
]);
|
734
|
+
}, originalAttributes);
|
735
|
+
};
|
736
|
+
var patchAttributes = function (rootLineItem, id, attrs) {
|
737
|
+
var lineItem = findLineItem(id, [rootLineItem]);
|
738
|
+
if (!lineItem) {
|
739
|
+
return rootLineItem;
|
740
|
+
}
|
741
|
+
var attributes = upsertAttributes(lineItem.attributes, attrs);
|
742
|
+
return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes: attributes }));
|
743
|
+
};
|
744
|
+
var getAttributeValue = function (attributes, name) { var _a; return (_a = attributes.find(function (attr) { return attr.name === name; })) === null || _a === void 0 ? void 0 : _a.value; };
|
745
|
+
var generateLineItem = function (port, type, parentId, attributes, lineItems) {
|
746
|
+
if (attributes === void 0) { attributes = []; }
|
747
|
+
if (lineItems === void 0) { lineItems = []; }
|
748
|
+
return {
|
749
|
+
id: core.UUID.UUID(),
|
750
|
+
port: port,
|
751
|
+
type: type,
|
752
|
+
actionCode: 'ADD',
|
753
|
+
cfgStatus: 'New',
|
754
|
+
attributes: attributes.map(function (_c) {
|
755
|
+
var name = _c.name, value = _c.value;
|
756
|
+
return ({ cfgStatus: 'User', name: name, value: value });
|
757
|
+
}),
|
758
|
+
lineItems: lineItems,
|
759
|
+
parentId: parentId,
|
760
|
+
qty: 1,
|
761
|
+
};
|
762
|
+
};
|
763
|
+
var getRecommendedPrices = function (portDomain, type) {
|
764
|
+
var _a, _b;
|
765
|
+
var domainType = portDomain.domainTypes.find(function (_c) {
|
766
|
+
var name = _c.name;
|
767
|
+
return name === type;
|
768
|
+
});
|
769
|
+
var _c = __read((_b = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.recommendedPrices) === null || _a === void 0 ? void 0 : _a.filter(function (_c) {
|
770
|
+
var chargeMethod = _c.chargeMethod;
|
771
|
+
return chargeMethod === 'ONE_TIME';
|
772
|
+
}).reduce(function (acc, rp) {
|
773
|
+
var _c = __read(acc, 2), netPrice = _c[0], listPrice = _c[1];
|
774
|
+
return [netPrice + rp.netPrice, listPrice + rp.listPrice];
|
775
|
+
}, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0], 2), net = _c[0], list = _c[1];
|
776
|
+
return { net: net, list: list };
|
777
|
+
};
|
778
|
+
var multiplyLineItems = function (lineItem, qty, split) {
|
779
|
+
if (split) {
|
780
|
+
var unifyIds_1 = function (lineItem) { return (Object.assign(Object.assign({}, lineItem), { id: core.UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds_1) })); };
|
781
|
+
return lodash.map(new Array(qty), function () { return unifyIds_1(lineItem); });
|
782
|
+
}
|
783
|
+
else {
|
784
|
+
return [
|
785
|
+
Object.assign(Object.assign({}, lineItem), { qty: qty }),
|
786
|
+
];
|
787
|
+
}
|
788
|
+
};
|
789
|
+
|
790
|
+
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
791
|
+
__proto__: null,
|
792
|
+
findLineItem: findLineItem,
|
793
|
+
findLineItemWithComparator: findLineItemWithComparator,
|
794
|
+
insertLineItem: insertLineItem,
|
795
|
+
removeLineItem: removeLineItem,
|
796
|
+
replaceLineItem: replaceLineItem,
|
797
|
+
calculateCardinalityVariables: calculateCardinalityVariables,
|
798
|
+
recalculateCardinalityVariables: recalculateCardinalityVariables,
|
799
|
+
mapAttributes: mapAttributes,
|
800
|
+
getAttributes: getAttributes,
|
801
|
+
upsertAttributes: upsertAttributes,
|
802
|
+
patchAttributes: patchAttributes,
|
803
|
+
getAttributeValue: getAttributeValue,
|
804
|
+
generateLineItem: generateLineItem,
|
805
|
+
getRecommendedPrices: getRecommendedPrices,
|
806
|
+
multiplyLineItems: multiplyLineItems
|
807
|
+
});
|
808
|
+
|
809
|
+
var LineItemWorker = /** @class */ (function () {
|
810
|
+
function LineItemWorker(src) {
|
811
|
+
this.li = Object.assign({}, src);
|
812
|
+
}
|
813
|
+
LineItemWorker.prototype.insert = function (parentId, toInsert) {
|
814
|
+
return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
|
815
|
+
};
|
816
|
+
LineItemWorker.prototype.remove = function (id) {
|
817
|
+
return new LineItemWorker(removeLineItem(this.li, id));
|
818
|
+
};
|
819
|
+
LineItemWorker.prototype.replace = function (toReplace) {
|
820
|
+
return new LineItemWorker(replaceLineItem(this.li, toReplace));
|
821
|
+
};
|
822
|
+
LineItemWorker.prototype.patchAttribute = function (attrs, id) {
|
823
|
+
return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs));
|
824
|
+
};
|
825
|
+
return LineItemWorker;
|
826
|
+
}());
|
827
|
+
|
828
|
+
var QuoteDraftService = /** @class */ (function () {
|
829
|
+
function QuoteDraftService(context, quoteApiService, priceApiService) {
|
830
|
+
var _this = this;
|
831
|
+
this.context = context;
|
832
|
+
this.quoteApiService = quoteApiService;
|
833
|
+
this.priceApiService = priceApiService;
|
834
|
+
this.quoteSubj$ = new rxjs.BehaviorSubject(null);
|
835
|
+
this.resetSubj$ = new rxjs.BehaviorSubject(true);
|
836
|
+
this.isInitializedSubj$ = new rxjs.BehaviorSubject(false);
|
837
|
+
this.initialCurrentState = [];
|
838
|
+
this._hasUnsavedChanges = false;
|
839
|
+
this.allPriceLists = [];
|
840
|
+
this.assetPriceLists = [];
|
841
|
+
this.reset$ = this.resetSubj$.asObservable();
|
842
|
+
this.activePriceList$ = this.context.resolve$().pipe(operators.map(function (ctx) { return _this.allPriceLists.find(function (priceList) { return priceList.id === ctx.properties.PriceListId; }); }), operators.map(function (priceList) { return priceList !== null && priceList !== void 0 ? priceList : null; }));
|
843
|
+
this.isInitializedSubj$
|
844
|
+
.pipe(operators.filter(function (isInitialized) { return isInitialized; }), operators.switchMap(function () { return _this.quoteSubj$.asObservable(); }), operators.skip(1), operators.tap(function (quote) { return _this.markAsUpdated(quote); }))
|
845
|
+
.subscribe();
|
846
|
+
}
|
847
|
+
Object.defineProperty(QuoteDraftService.prototype, "isInitialized", {
|
848
|
+
get: function () {
|
849
|
+
return this.isInitializedSubj$.getValue();
|
850
|
+
},
|
851
|
+
set: function (value) {
|
852
|
+
if (this.isInitialized !== value) {
|
853
|
+
this.isInitializedSubj$.next(value);
|
854
|
+
}
|
855
|
+
},
|
856
|
+
enumerable: false,
|
857
|
+
configurable: true
|
858
|
+
});
|
859
|
+
Object.defineProperty(QuoteDraftService.prototype, "hasUnsavedChanges", {
|
860
|
+
get: function () {
|
861
|
+
return this._hasUnsavedChanges;
|
862
|
+
},
|
863
|
+
set: function (value) {
|
864
|
+
var _a, _b;
|
865
|
+
this._hasUnsavedChanges = value;
|
866
|
+
if (!this._hasUnsavedChanges) {
|
867
|
+
this.initialCurrentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
868
|
+
}
|
869
|
+
},
|
870
|
+
enumerable: false,
|
871
|
+
configurable: true
|
872
|
+
});
|
873
|
+
Object.defineProperty(QuoteDraftService.prototype, "hasProducts$", {
|
874
|
+
get: function () {
|
875
|
+
var _this = this;
|
876
|
+
return this.quoteSubj$.pipe(operators.map(function () { return _this.hasProducts; }));
|
877
|
+
},
|
878
|
+
enumerable: false,
|
879
|
+
configurable: true
|
880
|
+
});
|
881
|
+
Object.defineProperty(QuoteDraftService.prototype, "hasProducts", {
|
882
|
+
get: function () {
|
883
|
+
var quoteDraft = this.quoteSubj$.value;
|
884
|
+
return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
|
885
|
+
},
|
886
|
+
enumerable: false,
|
887
|
+
configurable: true
|
888
|
+
});
|
889
|
+
QuoteDraftService.prototype.reset = function () {
|
890
|
+
this.resetSubj$.next(true);
|
891
|
+
this.quoteSubj$.next(null);
|
892
|
+
this.hasUnsavedChanges = false;
|
893
|
+
};
|
894
|
+
QuoteDraftService.prototype.init = function (quoteId, params) {
|
895
|
+
var _this = this;
|
896
|
+
return rxjs.zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(operators.tap(function (_c) {
|
897
|
+
var _d = __read(_c, 2), quote = _d[0], allPriceLists = _d[1];
|
898
|
+
_this.allPriceLists = allPriceLists;
|
899
|
+
_this.quoteSubj$.next(quote);
|
900
|
+
_this.context.update(quote.context);
|
901
|
+
_this.populateActivePriceLists$();
|
902
|
+
}), operators.map(function () { return rxjs.noop(); }), operators.take(1));
|
903
|
+
};
|
904
|
+
QuoteDraftService.prototype.setCurrentLineItemState = function (lineItems) {
|
905
|
+
var quoteDraft = this.quoteSubj$.value;
|
906
|
+
if (!quoteDraft) {
|
907
|
+
return;
|
908
|
+
}
|
909
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
|
910
|
+
};
|
911
|
+
QuoteDraftService.prototype.updateQuoteDraft = function (update) {
|
912
|
+
var quoteDraft = this.quoteSubj$.value;
|
913
|
+
if (!quoteDraft) {
|
914
|
+
return;
|
915
|
+
}
|
916
|
+
if (update.context) {
|
917
|
+
this.context.set(update.context);
|
918
|
+
}
|
919
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
|
920
|
+
};
|
921
|
+
QuoteDraftService.prototype.updateByPriceSummary = function (priceSummary) {
|
922
|
+
var quoteDraft = this.quoteSubj$.value;
|
562
923
|
if (!quoteDraft) {
|
563
924
|
return;
|
564
925
|
}
|
@@ -689,485 +1050,62 @@
|
|
689
1050
|
QuoteDraftService.prototype.isEditMode = function () {
|
690
1051
|
var context = this.context.resolve();
|
691
1052
|
if (context.mode === core.ConfigurationContextMode.ACCOUNT) {
|
692
|
-
return true;
|
693
|
-
}
|
694
|
-
if (context.mode === core.ConfigurationContextMode.QUOTE) {
|
695
|
-
return context.properties.Status === 'Draft';
|
696
|
-
}
|
697
|
-
return false;
|
698
|
-
};
|
699
|
-
QuoteDraftService.prototype.updateActivePriceList = function (priceListId) {
|
700
|
-
this.context.update({ properties: { PriceListId: priceListId } });
|
701
|
-
};
|
702
|
-
QuoteDraftService.prototype.populateActivePriceLists$ = function () {
|
703
|
-
var _this = this;
|
704
|
-
var ctx = this.context.resolve();
|
705
|
-
var quoteDraft = this.quoteDraft;
|
706
|
-
if (!quoteDraft) {
|
707
|
-
return;
|
708
|
-
}
|
709
|
-
// In ACCOUNT mode populate price lists from related assets
|
710
|
-
if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
|
711
|
-
// Populate list of price lists
|
712
|
-
this.assetPriceLists = quoteDraft.currentState
|
713
|
-
.map(function (_c) {
|
714
|
-
var priceListId = _c.priceListId;
|
715
|
-
return priceListId;
|
716
|
-
})
|
717
|
-
.reduce(function (trunk, priceListId) {
|
718
|
-
var _a, _b;
|
719
|
-
if (!priceListId || trunk.some(function (item) { return item.id === priceListId; })) {
|
720
|
-
return trunk;
|
721
|
-
}
|
722
|
-
return __spreadArray(__spreadArray([], __read(trunk)), [
|
723
|
-
{ id: priceListId, name: (_b = (_a = _this.allPriceLists.find(function (item) { return item.id === priceListId; })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '' },
|
724
|
-
]);
|
725
|
-
}, []);
|
726
|
-
}
|
727
|
-
};
|
728
|
-
QuoteDraftService.prototype.filterByActivePriceList = function (lineItems) {
|
729
|
-
var ctx = this.context.resolve();
|
730
|
-
return lineItems.filter(function (li) { return !li.priceListId || li.priceListId === ctx.properties.PriceListId; });
|
731
|
-
};
|
732
|
-
QuoteDraftService.prototype.markAsUpdated = function (quote) {
|
733
|
-
if ((quote === null || quote === void 0 ? void 0 : quote.context.properties.mode) === core.ConfigurationContextMode.ACCOUNT) {
|
734
|
-
this.hasUnsavedChanges = !!quote && !quote.currentState.every(function (li) { return li.actionCode === 'EXIST'; });
|
735
|
-
}
|
736
|
-
else {
|
737
|
-
this.hasUnsavedChanges = !lodash.isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
|
738
|
-
}
|
739
|
-
};
|
740
|
-
return QuoteDraftService;
|
741
|
-
}());
|
742
|
-
QuoteDraftService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1__namespace.QuoteApiService }, { token: i1__namespace.PriceApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
743
|
-
QuoteDraftService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, providedIn: 'root' });
|
744
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: QuoteDraftService, decorators: [{
|
745
|
-
type: i0.Injectable,
|
746
|
-
args: [{ providedIn: 'root' }]
|
747
|
-
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }]; } });
|
748
|
-
|
749
|
-
var MetricsCalculationService = /** @class */ (function () {
|
750
|
-
function MetricsCalculationService(quoteDraftService, settingsService) {
|
751
|
-
var _this = this;
|
752
|
-
this.quoteDraftService = quoteDraftService;
|
753
|
-
this.settingsService = settingsService;
|
754
|
-
this.metricsUpdated$ = new rxjs.Subject();
|
755
|
-
this.quoteMetricsSettings = {};
|
756
|
-
this.metricsCalculationMethodMap = {};
|
757
|
-
this.metricsData = {};
|
758
|
-
rxjs.combineLatest([
|
759
|
-
this.quoteDraftService.currentState$,
|
760
|
-
this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(rxjs.take(1)),
|
761
|
-
]).subscribe(function (_a) {
|
762
|
-
var _b = __read(_a, 2), lineItems = _b[0], setting = _b[1];
|
763
|
-
var settingsData = {};
|
764
|
-
try {
|
765
|
-
settingsData = JSON.parse((setting === null || setting === void 0 ? void 0 : setting.value) || '{}');
|
766
|
-
}
|
767
|
-
catch (error) {
|
768
|
-
settingsData = {};
|
769
|
-
}
|
770
|
-
_this.quoteMetricsSettings = settingsData;
|
771
|
-
_this.updateMetrics(lineItems);
|
772
|
-
});
|
773
|
-
}
|
774
|
-
Object.defineProperty(MetricsCalculationService.prototype, "onMetricsUpdate$", {
|
775
|
-
get: function () {
|
776
|
-
return this.metricsUpdated$.asObservable();
|
777
|
-
},
|
778
|
-
enumerable: false,
|
779
|
-
configurable: true
|
780
|
-
});
|
781
|
-
MetricsCalculationService.prototype.getMetricValue = function (metric) {
|
782
|
-
return this.metricsData[metric] || 0;
|
783
|
-
};
|
784
|
-
MetricsCalculationService.prototype.updateMetrics = function (lineItems) {
|
785
|
-
var _this = this;
|
786
|
-
var metricKeys = this.collectMetricKeys(lineItems).filter(function (key) { return !key.includes('Effective_'); });
|
787
|
-
this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
|
788
|
-
this.metricsData = metricKeys.reduce(function (acc, key) {
|
789
|
-
var _a;
|
790
|
-
return (Object.assign(Object.assign({}, acc), (_a = {}, _a[key] = _this.calculateMetric(lineItems, key), _a)));
|
791
|
-
}, {});
|
792
|
-
this.metricsUpdated$.next();
|
793
|
-
};
|
794
|
-
MetricsCalculationService.prototype.calculateMetric = function (lineItems, metric) {
|
795
|
-
return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
|
796
|
-
};
|
797
|
-
MetricsCalculationService.prototype.buildMetricsCalculationMethods = function (metricKeys, initial) {
|
798
|
-
var _this = this;
|
799
|
-
return metricKeys.reduce(function (acc, name) {
|
800
|
-
var _a, _b;
|
801
|
-
if (acc[name]) {
|
802
|
-
return acc;
|
803
|
-
}
|
804
|
-
acc = Object.assign(Object.assign({}, acc), (_a = {}, _a[name] = 'sum', _a));
|
805
|
-
var settingKey = name.replace(/VDM_|Total_/g, '');
|
806
|
-
if (_this.quoteMetricsSettings[settingKey]) {
|
807
|
-
acc = Object.assign(Object.assign({}, acc), (_b = {}, _b[name] = _this.quoteMetricsSettings[settingKey], _b));
|
808
|
-
}
|
809
|
-
return acc;
|
810
|
-
}, initial);
|
811
|
-
};
|
812
|
-
MetricsCalculationService.prototype.collectMetricKeys = function (lineItems) {
|
813
|
-
var _this = this;
|
814
|
-
var keys = [];
|
815
|
-
lineItems.forEach(function (lineItem) {
|
816
|
-
keys.push.apply(keys, __spreadArray([], __read(Object.keys(lineItem.totalMetrics || {}))));
|
817
|
-
keys.push.apply(keys, __spreadArray([], __read(_this.collectMetricKeys(lineItem.lineItems))));
|
818
|
-
});
|
819
|
-
return lodash.uniq(keys);
|
820
|
-
};
|
821
|
-
return MetricsCalculationService;
|
822
|
-
}());
|
823
|
-
MetricsCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: i1__namespace.ConfigurationSettingsApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
824
|
-
MetricsCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: MetricsCalculationService, providedIn: 'root' });
|
825
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: MetricsCalculationService, decorators: [{
|
826
|
-
type: i0.Injectable,
|
827
|
-
args: [{ providedIn: 'root' }]
|
828
|
-
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: i1__namespace.ConfigurationSettingsApiService }]; } });
|
829
|
-
|
830
|
-
var ProductImagesService = /** @class */ (function () {
|
831
|
-
function ProductImagesService(productApiService) {
|
832
|
-
this.productApiService = productApiService;
|
833
|
-
this.imagesMap$ = new rxjs.BehaviorSubject({});
|
834
|
-
}
|
835
|
-
ProductImagesService.prototype.getImageUrl$ = function (productId) {
|
836
|
-
var _a;
|
837
|
-
if (this.imagesMap$.value[productId] == null) {
|
838
|
-
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), (_a = {}, _a[productId] = '', _a)));
|
839
|
-
this.fetchProductImage(productId);
|
840
|
-
}
|
841
|
-
return this.imagesMap$.pipe(rxjs.map(function (imagesMap) { return imagesMap[productId]; }), rxjs.distinctUntilChanged());
|
842
|
-
};
|
843
|
-
ProductImagesService.prototype.fetchProductImage = function (productId) {
|
844
|
-
var _this = this;
|
845
|
-
this.productApiService
|
846
|
-
.fetchImage$(productId)
|
847
|
-
.pipe(rxjs.map(function (file) { return URL.createObjectURL(file); }), rxjs.catchError(function () { return rxjs.of(''); }), rxjs.tap(function (url) {
|
848
|
-
var _a;
|
849
|
-
return _this.imagesMap$.next(Object.assign(Object.assign({}, _this.imagesMap$.value), (_a = {}, _a[productId] = url, _a)));
|
850
|
-
}))
|
851
|
-
.subscribe();
|
852
|
-
};
|
853
|
-
return ProductImagesService;
|
854
|
-
}());
|
855
|
-
ProductImagesService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ProductImagesService, deps: [{ token: i1__namespace.ProductApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
856
|
-
ProductImagesService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ProductImagesService, providedIn: 'root' });
|
857
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ProductImagesService, decorators: [{
|
858
|
-
type: i0.Injectable,
|
859
|
-
args: [{ providedIn: 'root' }]
|
860
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.ProductApiService }]; } });
|
861
|
-
|
862
|
-
var RuntimeContextService = /** @class */ (function () {
|
863
|
-
function RuntimeContextService(configurationApiService) {
|
864
|
-
this.configurationApiService = configurationApiService;
|
865
|
-
}
|
866
|
-
RuntimeContextService.prototype.getRuntimeContext = function (productId, offeringId) {
|
867
|
-
var _this = this;
|
868
|
-
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(operators.map(function (runtimeData) {
|
869
|
-
var _a, _b, _c;
|
870
|
-
var uiDefinition = _this.getUIDefinition(runtimeData);
|
871
|
-
var runtimeModel = core.RuntimeModel.create(runtimeData.types, runtimeData.products);
|
872
|
-
var _d = (_a = Array.from(runtimeModel.components.values()).find(function (c) { return c.productId === productId; })) !== null && _a !== void 0 ? _a : {}, productName = _d.productName, properties = _d.properties;
|
873
|
-
return {
|
874
|
-
modelId: runtimeData.modelId,
|
875
|
-
uiDefinition: uiDefinition,
|
876
|
-
runtimeModel: runtimeModel,
|
877
|
-
runtimeMode: exports.RuntimeMode.PROD,
|
878
|
-
productId: productId,
|
879
|
-
productType: (properties === null || properties === void 0 ? void 0 : properties.displayName) || productName,
|
880
|
-
offeringId: offeringId,
|
881
|
-
properties: {
|
882
|
-
PricingEnabled: ((_b = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _b === void 0 ? void 0 : _b.pricingEnabled) ? 'true' : 'false',
|
883
|
-
PriceListId: (_c = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _c === void 0 ? void 0 : _c.priceList,
|
884
|
-
},
|
885
|
-
};
|
886
|
-
}));
|
887
|
-
};
|
888
|
-
RuntimeContextService.prototype.getUIDefinition = function (runtimeData) {
|
889
|
-
var _a;
|
890
|
-
var rawUiDefinitions;
|
891
|
-
try {
|
892
|
-
rawUiDefinitions = JSON.parse(runtimeData.uiDefinitionsSource);
|
893
|
-
}
|
894
|
-
catch (e) {
|
895
|
-
return;
|
896
|
-
}
|
897
|
-
var uiDefinitions = rawUiDefinitions.filter(function (uiDef) { return uiDef.version; });
|
898
|
-
var uiDefinition = (_a = uiDefinitions.find(function (uiDef) { return uiDef.primary; })) !== null && _a !== void 0 ? _a : uiDefinitions[0];
|
899
|
-
return uiDefinition;
|
900
|
-
};
|
901
|
-
return RuntimeContextService;
|
902
|
-
}());
|
903
|
-
RuntimeContextService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RuntimeContextService, deps: [{ token: i1__namespace.ConfigurationApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
904
|
-
RuntimeContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RuntimeContextService });
|
905
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: RuntimeContextService, decorators: [{
|
906
|
-
type: i0.Injectable
|
907
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }]; } });
|
908
|
-
|
909
|
-
var ConfigurationRuntimeService = /** @class */ (function () {
|
910
|
-
function ConfigurationRuntimeService(apiService, contextService, runtimeContextService) {
|
911
|
-
this.apiService = apiService;
|
912
|
-
this.contextService = contextService;
|
913
|
-
this.runtimeContextService = runtimeContextService;
|
914
|
-
this._isInitialized = false;
|
915
|
-
this.uiDefinitionProperties = {};
|
916
|
-
}
|
917
|
-
ConfigurationRuntimeService.prototype.reset = function () {
|
918
|
-
this._isInitialized = false;
|
919
|
-
this._runtimeContext = undefined;
|
920
|
-
this._assets = undefined;
|
921
|
-
this.initializationProps = undefined;
|
922
|
-
this.uiDefinitionProperties = {};
|
923
|
-
};
|
924
|
-
ConfigurationRuntimeService.prototype.initTestMode = function (modelId, uiDefinition) {
|
925
|
-
var _this = this;
|
926
|
-
var _a, _b;
|
927
|
-
this.uiDefinitionProperties = (_a = uiDefinition.properties) !== null && _a !== void 0 ? _a : {};
|
928
|
-
var uiDefinitionExternals = (_b = uiDefinition.externals) !== null && _b !== void 0 ? _b : {};
|
929
|
-
return rxjs.combineLatest([
|
930
|
-
this.apiService.getRuntimeDataByModelId(modelId),
|
931
|
-
this.contextService.create('TestId', core.ConfigurationContextMode.TEST),
|
932
|
-
]).pipe(operators.first(), operators.tap(function (_e) {
|
933
|
-
var _f = __read(_e, 2), runtimeData = _f[0], context = _f[1];
|
934
|
-
var _a;
|
935
|
-
_this._runtimeContext = {
|
936
|
-
modelId: modelId,
|
937
|
-
runtimeModel: core.RuntimeModel.create(runtimeData.types, runtimeData.products),
|
938
|
-
runtimeMode: exports.RuntimeMode.TEST,
|
939
|
-
};
|
940
|
-
_this.contextService.update({
|
941
|
-
properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = _this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: modelId, RuntimeMode: core.ConfigurationContextMode.TEST, PricingEnabled: _this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', StartDate: new Date().toISOString().substring(0, 10), PriceListId: _this.uiDefinitionProperties.priceList, standalone: 'true' }), uiDefinitionExternals),
|
942
|
-
});
|
943
|
-
_this._isInitialized = true;
|
944
|
-
}));
|
945
|
-
};
|
946
|
-
ConfigurationRuntimeService.prototype.init = function (props) {
|
947
|
-
var _this = this;
|
948
|
-
this.initializationProps = props;
|
949
|
-
this._assets = props.assets;
|
950
|
-
var context = this.contextService.resolve();
|
951
|
-
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(operators.tap(function (runtimeContext) {
|
952
|
-
var _a, _b, _c, _d;
|
953
|
-
_this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {};
|
954
|
-
var PriceListId = ((_c = context.properties) !== null && _c !== void 0 ? _c : {}).PriceListId;
|
955
|
-
var mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
|
956
|
-
_this.id15to18('AccountId', mergeContext.properties);
|
957
|
-
_this._runtimeContext = mergeContext;
|
958
|
-
if (context.properties && ((_d = _this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
|
959
|
-
_this.contextService.update({
|
960
|
-
properties: Object.assign(Object.assign({}, _this._runtimeContext.properties), context.properties),
|
961
|
-
});
|
962
|
-
}
|
963
|
-
_this._isInitialized = true;
|
964
|
-
}));
|
965
|
-
};
|
966
|
-
ConfigurationRuntimeService.prototype.id15to18 = function (propertyName, source) {
|
967
|
-
if (!source) {
|
968
|
-
return;
|
969
|
-
}
|
970
|
-
var value = source[propertyName];
|
971
|
-
if (typeof value === 'string' && value.length === 15) {
|
972
|
-
source[propertyName] = core.SalesforceIdUtils.generateId18FromId15(value);
|
973
|
-
}
|
974
|
-
};
|
975
|
-
ConfigurationRuntimeService.prototype.getAsset = function (lineItem) {
|
976
|
-
return this._assets && this._assets.find(function (a) { return a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId; });
|
977
|
-
};
|
978
|
-
Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized", {
|
979
|
-
get: function () {
|
980
|
-
return this._isInitialized;
|
981
|
-
},
|
982
|
-
enumerable: false,
|
983
|
-
configurable: true
|
984
|
-
});
|
985
|
-
Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeModel", {
|
986
|
-
get: function () {
|
987
|
-
var _a;
|
988
|
-
return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
|
989
|
-
},
|
990
|
-
enumerable: false,
|
991
|
-
configurable: true
|
992
|
-
});
|
993
|
-
Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeContext", {
|
994
|
-
get: function () {
|
995
|
-
return this._runtimeContext;
|
996
|
-
},
|
997
|
-
enumerable: false,
|
998
|
-
configurable: true
|
999
|
-
});
|
1000
|
-
return ConfigurationRuntimeService;
|
1001
|
-
}());
|
1002
|
-
ConfigurationRuntimeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationRuntimeService, deps: [{ token: i1__namespace.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1003
|
-
ConfigurationRuntimeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationRuntimeService });
|
1004
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationRuntimeService, decorators: [{
|
1005
|
-
type: i0.Injectable
|
1006
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
|
1007
|
-
|
1008
|
-
var findLineItem = function (id, lineItems) {
|
1009
|
-
return findLineItemWithComparator(lineItems, function (li) { return li.id === id; });
|
1010
|
-
};
|
1011
|
-
var findLineItemWithComparator = function (lineItems, comparator) {
|
1012
|
-
var currentLevel = lineItems;
|
1013
|
-
while (currentLevel.length) {
|
1014
|
-
var found = currentLevel.find(comparator);
|
1015
|
-
if (found) {
|
1016
|
-
return found;
|
1017
|
-
}
|
1018
|
-
currentLevel = lodash.flatten(currentLevel.map(function (parent) { return parent.lineItems; }));
|
1019
|
-
}
|
1020
|
-
return;
|
1021
|
-
};
|
1022
|
-
var insertLineItem = function (lineItem, parentId, toInsert) {
|
1023
|
-
var insertData = lineItem.id === parentId ? [toInsert] : [];
|
1024
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: __spreadArray(__spreadArray([], __read(insertData)), __read(lineItem.lineItems.map(function (li) {
|
1025
|
-
return insertLineItem(li, parentId, toInsert);
|
1026
|
-
}))) });
|
1027
|
-
};
|
1028
|
-
var removeLineItem = function (lineItem, idToRemove) {
|
1029
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems
|
1030
|
-
.map(function (li) {
|
1031
|
-
if (li.id === idToRemove) {
|
1032
|
-
return;
|
1033
|
-
}
|
1034
|
-
else if (li.lineItems.length) {
|
1035
|
-
return removeLineItem(li, idToRemove);
|
1036
|
-
}
|
1037
|
-
return li;
|
1038
|
-
})
|
1039
|
-
.filter(function (r) { return !!r; }) });
|
1040
|
-
};
|
1041
|
-
var replaceLineItem = function (lineItem, replaceTo) {
|
1042
|
-
if (lineItem.id === replaceTo.id) {
|
1043
|
-
return Object.assign({}, replaceTo);
|
1044
|
-
}
|
1045
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) {
|
1046
|
-
if (li.id === replaceTo.id) {
|
1047
|
-
return replaceTo;
|
1048
|
-
}
|
1049
|
-
else if (li.lineItems.length) {
|
1050
|
-
return replaceLineItem(li, replaceTo);
|
1051
|
-
}
|
1052
|
-
return li;
|
1053
|
-
}) });
|
1054
|
-
};
|
1055
|
-
var mapAttributes = function (attributes) {
|
1056
|
-
return attributes.reduce(function (acc, _c) {
|
1057
|
-
var _d;
|
1058
|
-
var name = _c.name, value = _c.value;
|
1059
|
-
return (Object.assign(Object.assign({}, acc), (_d = {}, _d[name] = value, _d)));
|
1060
|
-
}, {});
|
1061
|
-
};
|
1062
|
-
var getAttributes = function (attributes, names) {
|
1063
|
-
if (names === void 0) { names = []; }
|
1064
|
-
var filtered = attributes.filter(function (_c) {
|
1065
|
-
var name = _c.name;
|
1066
|
-
return names.includes(name);
|
1067
|
-
});
|
1068
|
-
return lodash.sortBy(filtered, [function (_c) {
|
1069
|
-
var name = _c.name;
|
1070
|
-
return names.indexOf(name);
|
1071
|
-
}]);
|
1072
|
-
};
|
1073
|
-
var upsertAttributes = function (originalAttributes, attributesToUpsert) {
|
1074
|
-
return attributesToUpsert.reduce(function (acc, _c) {
|
1075
|
-
var name = _c.name, value = _c.value;
|
1076
|
-
var _d = __read(getAttributes(acc, [name]), 1), origAttr = _d[0];
|
1077
|
-
return __spreadArray(__spreadArray([], __read(acc.filter(function (attr) { return attr.name !== name; }))), [
|
1078
|
-
Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name: name })), { cfgStatus: 'User', value: value }),
|
1079
|
-
]);
|
1080
|
-
}, originalAttributes);
|
1081
|
-
};
|
1082
|
-
var patchAttributes = function (rootLineItem, id, attrs) {
|
1083
|
-
var lineItem = findLineItem(id, [rootLineItem]);
|
1084
|
-
if (!lineItem) {
|
1085
|
-
return rootLineItem;
|
1086
|
-
}
|
1087
|
-
var attributes = upsertAttributes(lineItem.attributes, attrs);
|
1088
|
-
return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes: attributes }));
|
1089
|
-
};
|
1090
|
-
var getAttributeValue = function (attributes, name) { var _a; return (_a = attributes.find(function (attr) { return attr.name === name; })) === null || _a === void 0 ? void 0 : _a.value; };
|
1091
|
-
var generateLineItem = function (port, type, parentId, attributes, lineItems) {
|
1092
|
-
if (attributes === void 0) { attributes = []; }
|
1093
|
-
if (lineItems === void 0) { lineItems = []; }
|
1094
|
-
return {
|
1095
|
-
id: core.UUID.UUID(),
|
1096
|
-
port: port,
|
1097
|
-
type: type,
|
1098
|
-
actionCode: 'ADD',
|
1099
|
-
cfgStatus: 'New',
|
1100
|
-
attributes: attributes.map(function (_c) {
|
1101
|
-
var name = _c.name, value = _c.value;
|
1102
|
-
return ({ cfgStatus: 'User', name: name, value: value });
|
1103
|
-
}),
|
1104
|
-
lineItems: lineItems,
|
1105
|
-
parentId: parentId,
|
1106
|
-
qty: 1,
|
1053
|
+
return true;
|
1054
|
+
}
|
1055
|
+
if (context.mode === core.ConfigurationContextMode.QUOTE) {
|
1056
|
+
return context.properties.Status === 'Draft';
|
1057
|
+
}
|
1058
|
+
return false;
|
1107
1059
|
};
|
1108
|
-
|
1109
|
-
|
1110
|
-
var _a, _b;
|
1111
|
-
var domainType = portDomain.domainTypes.find(function (_c) {
|
1112
|
-
var name = _c.name;
|
1113
|
-
return name === type;
|
1114
|
-
});
|
1115
|
-
var _c = __read((_b = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.recommendedPrices) === null || _a === void 0 ? void 0 : _a.filter(function (_c) {
|
1116
|
-
var chargeMethod = _c.chargeMethod;
|
1117
|
-
return chargeMethod === 'ONE_TIME';
|
1118
|
-
}).reduce(function (acc, rp) {
|
1119
|
-
var _c = __read(acc, 2), netPrice = _c[0], listPrice = _c[1];
|
1120
|
-
return [netPrice + rp.netPrice, listPrice + rp.listPrice];
|
1121
|
-
}, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0], 2), net = _c[0], list = _c[1];
|
1122
|
-
return { net: net, list: list };
|
1123
|
-
};
|
1124
|
-
var multiplyLineItems = function (lineItem, qty, split) {
|
1125
|
-
if (split) {
|
1126
|
-
var unifyIds_1 = function (lineItem) { return (Object.assign(Object.assign({}, lineItem), { id: core.UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds_1) })); };
|
1127
|
-
return lodash.map(new Array(qty), function () { return unifyIds_1(lineItem); });
|
1128
|
-
}
|
1129
|
-
else {
|
1130
|
-
return [
|
1131
|
-
Object.assign(Object.assign({}, lineItem), { qty: qty }),
|
1132
|
-
];
|
1133
|
-
}
|
1134
|
-
};
|
1135
|
-
|
1136
|
-
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
1137
|
-
__proto__: null,
|
1138
|
-
findLineItem: findLineItem,
|
1139
|
-
findLineItemWithComparator: findLineItemWithComparator,
|
1140
|
-
insertLineItem: insertLineItem,
|
1141
|
-
removeLineItem: removeLineItem,
|
1142
|
-
replaceLineItem: replaceLineItem,
|
1143
|
-
mapAttributes: mapAttributes,
|
1144
|
-
getAttributes: getAttributes,
|
1145
|
-
upsertAttributes: upsertAttributes,
|
1146
|
-
patchAttributes: patchAttributes,
|
1147
|
-
getAttributeValue: getAttributeValue,
|
1148
|
-
generateLineItem: generateLineItem,
|
1149
|
-
getRecommendedPrices: getRecommendedPrices,
|
1150
|
-
multiplyLineItems: multiplyLineItems
|
1151
|
-
});
|
1152
|
-
|
1153
|
-
var LineItemWorker = /** @class */ (function () {
|
1154
|
-
function LineItemWorker(src) {
|
1155
|
-
this.li = Object.assign({}, src);
|
1156
|
-
}
|
1157
|
-
LineItemWorker.prototype.insert = function (parentId, toInsert) {
|
1158
|
-
return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
|
1060
|
+
QuoteDraftService.prototype.updateActivePriceList = function (priceListId) {
|
1061
|
+
this.context.update({ properties: { PriceListId: priceListId } });
|
1159
1062
|
};
|
1160
|
-
|
1161
|
-
|
1063
|
+
QuoteDraftService.prototype.populateActivePriceLists$ = function () {
|
1064
|
+
var _this = this;
|
1065
|
+
var ctx = this.context.resolve();
|
1066
|
+
var quoteDraft = this.quoteDraft;
|
1067
|
+
if (!quoteDraft) {
|
1068
|
+
return;
|
1069
|
+
}
|
1070
|
+
// In ACCOUNT mode populate price lists from related assets
|
1071
|
+
if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
|
1072
|
+
// Populate list of price lists
|
1073
|
+
this.assetPriceLists = quoteDraft.currentState
|
1074
|
+
.map(function (_c) {
|
1075
|
+
var priceListId = _c.priceListId;
|
1076
|
+
return priceListId;
|
1077
|
+
})
|
1078
|
+
.reduce(function (trunk, priceListId) {
|
1079
|
+
var _a, _b;
|
1080
|
+
if (!priceListId || trunk.some(function (item) { return item.id === priceListId; })) {
|
1081
|
+
return trunk;
|
1082
|
+
}
|
1083
|
+
return __spreadArray(__spreadArray([], __read(trunk)), [
|
1084
|
+
{ id: priceListId, name: (_b = (_a = _this.allPriceLists.find(function (item) { return item.id === priceListId; })) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '' },
|
1085
|
+
]);
|
1086
|
+
}, []);
|
1087
|
+
}
|
1162
1088
|
};
|
1163
|
-
|
1164
|
-
|
1089
|
+
QuoteDraftService.prototype.filterByActivePriceList = function (lineItems) {
|
1090
|
+
var ctx = this.context.resolve();
|
1091
|
+
return lineItems.filter(function (li) { return !li.priceListId || li.priceListId === ctx.properties.PriceListId; });
|
1165
1092
|
};
|
1166
|
-
|
1167
|
-
|
1093
|
+
QuoteDraftService.prototype.markAsUpdated = function (quote) {
|
1094
|
+
if ((quote === null || quote === void 0 ? void 0 : quote.context.properties.mode) === core.ConfigurationContextMode.ACCOUNT) {
|
1095
|
+
this.hasUnsavedChanges = !!quote && !quote.currentState.every(function (li) { return li.actionCode === 'EXIST'; });
|
1096
|
+
}
|
1097
|
+
else {
|
1098
|
+
this.hasUnsavedChanges = !lodash.isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
|
1099
|
+
}
|
1168
1100
|
};
|
1169
|
-
return
|
1101
|
+
return QuoteDraftService;
|
1170
1102
|
}());
|
1103
|
+
QuoteDraftService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1__namespace.QuoteApiService }, { token: i1__namespace.PriceApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1104
|
+
QuoteDraftService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, providedIn: 'root' });
|
1105
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, decorators: [{
|
1106
|
+
type: i0.Injectable,
|
1107
|
+
args: [{ providedIn: 'root' }]
|
1108
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }]; } });
|
1171
1109
|
|
1172
1110
|
var ConfigurationService = /** @class */ (function () {
|
1173
1111
|
function ConfigurationService(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
|
@@ -1178,7 +1116,6 @@
|
|
1178
1116
|
this.messageService = messageService;
|
1179
1117
|
this.dialogService = dialogService;
|
1180
1118
|
this.mode = core.ConfigurationMode.SEARCH;
|
1181
|
-
this.states = {};
|
1182
1119
|
this.lineItem = new rxjs.BehaviorSubject(undefined);
|
1183
1120
|
this.charges = new rxjs.BehaviorSubject({});
|
1184
1121
|
this.pricePlans = new rxjs.BehaviorSubject({});
|
@@ -1187,7 +1124,7 @@
|
|
1187
1124
|
ConfigurationService.prototype.reset = function () {
|
1188
1125
|
this.hasUnsavedChanges = false;
|
1189
1126
|
this.runtimeService.reset();
|
1190
|
-
this.
|
1127
|
+
this.configurableRamp = undefined;
|
1191
1128
|
this.lineItem.next(undefined);
|
1192
1129
|
this.charges.next({});
|
1193
1130
|
this.pricePlans.next({});
|
@@ -1197,10 +1134,7 @@
|
|
1197
1134
|
if (!this.lineItem.value) {
|
1198
1135
|
return rxjs.throwError(function () { return new Error("Source LineItem not found"); });
|
1199
1136
|
}
|
1200
|
-
this.
|
1201
|
-
this.states.asset = this.states.configurableRamp
|
1202
|
-
? this.runtimeService.getAsset(this.states.configurableRamp)
|
1203
|
-
: undefined;
|
1137
|
+
this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem).li;
|
1204
1138
|
return this.configure().pipe(operators.catchError(function (error) {
|
1205
1139
|
console.error(error);
|
1206
1140
|
if (!_this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
@@ -1218,8 +1152,8 @@
|
|
1218
1152
|
ConfigurationService.prototype.patch = function (lineItem) {
|
1219
1153
|
this.patch$(lineItem).subscribe();
|
1220
1154
|
};
|
1221
|
-
ConfigurationService.prototype.
|
1222
|
-
this.
|
1155
|
+
ConfigurationService.prototype.setConfigurableRamp = function (lineItem) {
|
1156
|
+
this.configurableRamp = lineItem;
|
1223
1157
|
};
|
1224
1158
|
ConfigurationService.prototype.get = function () {
|
1225
1159
|
return this.lineItem.asObservable().pipe(rxjs.shareReplay());
|
@@ -1285,7 +1219,7 @@
|
|
1285
1219
|
}
|
1286
1220
|
var uiDefinitionProperties = Object.assign(Object.assign({}, ((_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {})), ((_c = this.runtimeService.uiDefinitionProperties) !== null && _c !== void 0 ? _c : {}));
|
1287
1221
|
var qty = (_d = this.runtimeService.initializationProps) === null || _d === void 0 ? void 0 : _d.defaultQty;
|
1288
|
-
var lineItem = (_e = this.
|
1222
|
+
var lineItem = (_e = this.configurableRamp) !== null && _e !== void 0 ? _e : getDefaultLineItem(runtimeContext, uiDefinitionProperties, qty);
|
1289
1223
|
var configurationRequest = this.createRequest(lineItem);
|
1290
1224
|
var mainPricingEnabled = (_f = runtimeContext.properties) === null || _f === void 0 ? void 0 : _f.PricingEnabled;
|
1291
1225
|
var pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
@@ -1305,27 +1239,33 @@
|
|
1305
1239
|
};
|
1306
1240
|
ConfigurationService.prototype.configureExternal$ = function (productId, qty) {
|
1307
1241
|
var _this = this;
|
1308
|
-
this.updateCurrentStates({
|
1309
|
-
currentState: this.quoteDraftService.currentState,
|
1310
|
-
});
|
1311
1242
|
return this.runtimeService.init({ productId: productId, defaultQty: qty }).pipe(operators.switchMap(function () { return _this.configure(); }), operators.first(), operators.catchError(function (error) {
|
1312
1243
|
_this.messageService.add({ severity: components.ToastType.error, summary: error });
|
1313
1244
|
throw error;
|
1314
1245
|
}), operators.finalize(function () { return _this.reset(); }));
|
1315
1246
|
};
|
1316
1247
|
ConfigurationService.prototype.createRequest = function (lineItem) {
|
1317
|
-
|
1248
|
+
var _a;
|
1249
|
+
var request = {
|
1318
1250
|
lineItem: lineItem,
|
1319
1251
|
mode: this.mode,
|
1320
1252
|
step: !this.lineItem.value ? exports.RuntimeStep.START : exports.RuntimeStep.UPDATE,
|
1321
1253
|
attributeDomainMode: 'ALL',
|
1322
1254
|
context: this.contextService.resolve(),
|
1323
|
-
lineItems: this.
|
1324
|
-
asset: this.
|
1255
|
+
lineItems: ((_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) || [],
|
1256
|
+
asset: this.getAsset(),
|
1325
1257
|
};
|
1258
|
+
request = core.ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
|
1259
|
+
return request;
|
1326
1260
|
};
|
1327
1261
|
ConfigurationService.prototype.showInactiveProductsConfirmation = function () {
|
1328
1262
|
var _this = this;
|
1263
|
+
var confirmationConfig = {
|
1264
|
+
title: ' ',
|
1265
|
+
description: 'This quote contains inactive products. Do you want to remove them?',
|
1266
|
+
primaryButtonLabel: 'Remove products',
|
1267
|
+
secondaryButtonLabel: 'Back to Quote',
|
1268
|
+
};
|
1329
1269
|
this.dialogService
|
1330
1270
|
.open(components.ConfirmationComponent, {
|
1331
1271
|
dismissableMask: false,
|
@@ -1334,14 +1274,7 @@
|
|
1334
1274
|
showHeader: true,
|
1335
1275
|
header: "Inactive Products in Quote",
|
1336
1276
|
width: '440px',
|
1337
|
-
data: {
|
1338
|
-
confirmationConfig: {
|
1339
|
-
title: ' ',
|
1340
|
-
description: 'This quote contains inactive products. Do you want to remove them?',
|
1341
|
-
submitBtn: 'Remove products',
|
1342
|
-
cancelBtn: 'Back to Quote',
|
1343
|
-
},
|
1344
|
-
},
|
1277
|
+
data: { confirmationConfig: confirmationConfig },
|
1345
1278
|
})
|
1346
1279
|
.onClose.subscribe(function (result) {
|
1347
1280
|
if (!result) {
|
@@ -1350,18 +1283,34 @@
|
|
1350
1283
|
}
|
1351
1284
|
});
|
1352
1285
|
};
|
1286
|
+
ConfigurationService.prototype.getAsset = function () {
|
1287
|
+
var _a;
|
1288
|
+
var lineItem = this.configurableRamp;
|
1289
|
+
if (!lineItem) {
|
1290
|
+
return;
|
1291
|
+
}
|
1292
|
+
return (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState.find(function (a) { return a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId; });
|
1293
|
+
};
|
1353
1294
|
return ConfigurationService;
|
1354
1295
|
}());
|
1355
|
-
ConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1356
|
-
ConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
1357
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1296
|
+
ConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1__namespace.ConfigurationApiService }, { token: i5__namespace.MessageService }, { token: i6__namespace.DialogService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1297
|
+
ConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService });
|
1298
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService, decorators: [{
|
1358
1299
|
type: i0.Injectable
|
1359
|
-
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type:
|
1300
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type: i5__namespace.MessageService }, { type: i6__namespace.DialogService }]; } });
|
1301
|
+
|
1302
|
+
function extractMetadata(uiDefinition) {
|
1303
|
+
return lodash.omit(uiDefinition, [
|
1304
|
+
'children',
|
1305
|
+
'pages',
|
1306
|
+
'components',
|
1307
|
+
]);
|
1308
|
+
}
|
1360
1309
|
|
1361
1310
|
var FlowUpdateService = /** @class */ (function () {
|
1362
1311
|
function FlowUpdateService() {
|
1363
1312
|
}
|
1364
|
-
FlowUpdateService.prototype.update = function (rootLineItems, updates) {
|
1313
|
+
FlowUpdateService.prototype.update = function (rootLineItems, updates, charges) {
|
1365
1314
|
var _this = this;
|
1366
1315
|
var remainingUpdates = __spreadArray([], __read(updates));
|
1367
1316
|
var currentLevel = rootLineItems;
|
@@ -1372,7 +1321,7 @@
|
|
1372
1321
|
var updated = false;
|
1373
1322
|
switch (update.dataType) {
|
1374
1323
|
case 'LINEITEM':
|
1375
|
-
updated = _this.applyLineItemUpdate(li, update);
|
1324
|
+
updated = _this.applyLineItemUpdate(li, update, charges);
|
1376
1325
|
break;
|
1377
1326
|
case 'CHARGE':
|
1378
1327
|
updated = _this.applyChargeUpdate(li, update);
|
@@ -1410,7 +1359,7 @@
|
|
1410
1359
|
var filtered = lineItems.filter(function (lineItem) { return !idsToRemove.includes(lineItem.id); });
|
1411
1360
|
return filtered.map(function (lineItem) { return new LineItemWorker(lineItem).remove(id).li; });
|
1412
1361
|
};
|
1413
|
-
FlowUpdateService.prototype.applyLineItemUpdate = function (lineItem, update) {
|
1362
|
+
FlowUpdateService.prototype.applyLineItemUpdate = function (lineItem, update, charges) {
|
1414
1363
|
if (lineItem.id !== update.id) {
|
1415
1364
|
return false;
|
1416
1365
|
}
|
@@ -1426,7 +1375,7 @@
|
|
1426
1375
|
break;
|
1427
1376
|
case 'PRICE_ADJUSTMENT':
|
1428
1377
|
{
|
1429
|
-
var
|
1378
|
+
var charge = lineItem.chargeItems.find(function (charge) { var _a; return (_a = (charges || {})[charge.chargeId]) === null || _a === void 0 ? void 0 : _a.main; });
|
1430
1379
|
if (charge) {
|
1431
1380
|
charge.priceAdjustment = update.newValue;
|
1432
1381
|
}
|
@@ -1434,7 +1383,7 @@
|
|
1434
1383
|
break;
|
1435
1384
|
case 'LIST_PRICE_ADJUSTMENT':
|
1436
1385
|
{
|
1437
|
-
var
|
1386
|
+
var charge = lineItem.chargeItems.find(function (charge) { var _a; return (_a = (charges || {})[charge.chargeId]) === null || _a === void 0 ? void 0 : _a.main; });
|
1438
1387
|
if (charge) {
|
1439
1388
|
charge.listPriceAdjustment = update.newValue;
|
1440
1389
|
}
|
@@ -1446,8 +1395,8 @@
|
|
1446
1395
|
return true;
|
1447
1396
|
};
|
1448
1397
|
FlowUpdateService.prototype.applyChargeUpdate = function (lineItem, update) {
|
1449
|
-
var foundCharge = lineItem.chargeItems.find(function (
|
1450
|
-
var id =
|
1398
|
+
var foundCharge = lineItem.chargeItems.find(function (_b) {
|
1399
|
+
var id = _b.id;
|
1451
1400
|
return id === update.id;
|
1452
1401
|
});
|
1453
1402
|
if (!foundCharge) {
|
@@ -1482,9 +1431,9 @@
|
|
1482
1431
|
};
|
1483
1432
|
return FlowUpdateService;
|
1484
1433
|
}());
|
1485
|
-
FlowUpdateService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1486
|
-
FlowUpdateService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
1487
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1434
|
+
FlowUpdateService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1435
|
+
FlowUpdateService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService });
|
1436
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService, decorators: [{
|
1488
1437
|
type: i0.Injectable
|
1489
1438
|
}] });
|
1490
1439
|
|
@@ -1518,7 +1467,7 @@
|
|
1518
1467
|
}
|
1519
1468
|
return rxjs.of([]).pipe(rxjs.map(function () {
|
1520
1469
|
var updatedState = lodash.cloneDeep(quoteDraft.currentState);
|
1521
|
-
_this.updateService.update(updatedState, updates);
|
1470
|
+
_this.updateService.update(updatedState, updates, quoteDraft.charges);
|
1522
1471
|
return updatedState;
|
1523
1472
|
}), rxjs.switchMap(function (updatedState) { return _this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState })); }), rxjs.map(function () { return _this.quoteDraftService.quoteDraft; }), this.handleErrorAndBounceBack());
|
1524
1473
|
};
|
@@ -1678,9 +1627,9 @@
|
|
1678
1627
|
};
|
1679
1628
|
return FlowConfigurationService;
|
1680
1629
|
}());
|
1681
|
-
FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1682
|
-
FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
1683
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1630
|
+
FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService, deps: [{ token: i1__namespace.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1631
|
+
FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService });
|
1632
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
|
1684
1633
|
type: i0.Injectable
|
1685
1634
|
}], ctorParameters: function () { return [{ type: i1__namespace.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
1686
1635
|
|
@@ -1689,10 +1638,10 @@
|
|
1689
1638
|
}
|
1690
1639
|
return FlowConfigurationModule;
|
1691
1640
|
}());
|
1692
|
-
FlowConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1693
|
-
FlowConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
1694
|
-
FlowConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
1695
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1641
|
+
FlowConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
1642
|
+
FlowConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule });
|
1643
|
+
FlowConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, i1.PriceApiService], imports: [[]] });
|
1644
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, decorators: [{
|
1696
1645
|
type: i0.NgModule,
|
1697
1646
|
args: [{
|
1698
1647
|
imports: [],
|
@@ -1705,9 +1654,9 @@
|
|
1705
1654
|
}
|
1706
1655
|
return ConfigurationModule;
|
1707
1656
|
}());
|
1708
|
-
ConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1709
|
-
ConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
1710
|
-
ConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
1657
|
+
ConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
1658
|
+
ConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, imports: [components.ConfirmationDialogModule] });
|
1659
|
+
ConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, providers: [
|
1711
1660
|
i1.ContextApiService,
|
1712
1661
|
i1.ProductModelApiService,
|
1713
1662
|
i1.ConfigurationApiService,
|
@@ -1715,7 +1664,7 @@
|
|
1715
1664
|
RuntimeContextService,
|
1716
1665
|
ConfigurationService,
|
1717
1666
|
], imports: [[components.ConfirmationDialogModule]] });
|
1718
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1667
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, decorators: [{
|
1719
1668
|
type: i0.NgModule,
|
1720
1669
|
args: [{
|
1721
1670
|
imports: [components.ConfirmationDialogModule],
|
@@ -1730,15 +1679,177 @@
|
|
1730
1679
|
}]
|
1731
1680
|
}] });
|
1732
1681
|
|
1682
|
+
function calculateMetricByMethod(lineItems, metric, method) {
|
1683
|
+
var items = getLineItemsByMethod(lineItems, method);
|
1684
|
+
return items.reduce(function (acc, li) {
|
1685
|
+
var value = li.reduce(function (accProduct, item) { return accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0); }, 0);
|
1686
|
+
if (method === 'avg' && li.length > 0) {
|
1687
|
+
value /= li.length;
|
1688
|
+
}
|
1689
|
+
return acc + value;
|
1690
|
+
}, 0);
|
1691
|
+
}
|
1692
|
+
function getLineItemsByMethod(lineItems, method) {
|
1693
|
+
switch (method) {
|
1694
|
+
case 'first': {
|
1695
|
+
return lineItems.filter(function (li) { return !li.rampInstanceId; }).map(function (item) { return [item]; });
|
1696
|
+
}
|
1697
|
+
case 'last': {
|
1698
|
+
var rootTermItems = lineItems.filter(function (li) { return !li.rampInstanceId; });
|
1699
|
+
var products = rootTermItems.map(function (lineItem) { return __spreadArray([
|
1700
|
+
lineItem
|
1701
|
+
], __read(lineItems.filter(function (li) { return li.rampInstanceId === lineItem.id; }))); });
|
1702
|
+
return products
|
1703
|
+
.map(function (items) { return __spreadArray([], __read(items)).sort(function (a, b) { return getDateValue(a.endDate || '') - getDateValue(b.endDate || ''); }).pop(); })
|
1704
|
+
.filter(function (li) { return Boolean(li); })
|
1705
|
+
.map(function (item) { return [item]; });
|
1706
|
+
}
|
1707
|
+
case 'avg': {
|
1708
|
+
var rootTermItems = lineItems.filter(function (li) { return !li.rampInstanceId; });
|
1709
|
+
return rootTermItems.map(function (lineItem) { return __spreadArray([lineItem], __read(lineItems.filter(function (li) { return li.rampInstanceId === lineItem.id; }))); });
|
1710
|
+
}
|
1711
|
+
case 'sum': {
|
1712
|
+
return lineItems.map(function (item) { return [item]; });
|
1713
|
+
}
|
1714
|
+
default: {
|
1715
|
+
return lineItems.map(function (item) { return [item]; });
|
1716
|
+
}
|
1717
|
+
}
|
1718
|
+
}
|
1719
|
+
function getDateValue(date) {
|
1720
|
+
return date ? new Date(date).getTime() : 0;
|
1721
|
+
}
|
1722
|
+
|
1723
|
+
var MetricsCalculationService = /** @class */ (function () {
|
1724
|
+
function MetricsCalculationService(quoteDraftService, flowConfiguration, settingsService) {
|
1725
|
+
var _this = this;
|
1726
|
+
this.quoteDraftService = quoteDraftService;
|
1727
|
+
this.flowConfiguration = flowConfiguration;
|
1728
|
+
this.settingsService = settingsService;
|
1729
|
+
this.metricsUpdated$ = new rxjs.Subject();
|
1730
|
+
this.quoteMetricsSettings = {};
|
1731
|
+
this.metricsCalculationMethodMap = {};
|
1732
|
+
this.metricsData = {};
|
1733
|
+
this.activeMetricRules = [];
|
1734
|
+
this.activeMetricRules = this.flowConfiguration.activeMetricsSnapshot.filter(function (metricRule) { return metricRule.metrics.some(function (metric) { return !!metric.totalName; }); });
|
1735
|
+
rxjs.combineLatest([
|
1736
|
+
this.quoteDraftService.currentState$,
|
1737
|
+
this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(rxjs.take(1)),
|
1738
|
+
]).subscribe(function (_c) {
|
1739
|
+
var _d = __read(_c, 2), lineItems = _d[0], setting = _d[1];
|
1740
|
+
var settingsData = {};
|
1741
|
+
try {
|
1742
|
+
settingsData = JSON.parse((setting === null || setting === void 0 ? void 0 : setting.value) || '{}');
|
1743
|
+
}
|
1744
|
+
catch (error) {
|
1745
|
+
settingsData = {};
|
1746
|
+
}
|
1747
|
+
_this.quoteMetricsSettings = settingsData;
|
1748
|
+
_this.updateMetrics(lineItems);
|
1749
|
+
});
|
1750
|
+
}
|
1751
|
+
Object.defineProperty(MetricsCalculationService.prototype, "onMetricsUpdate$", {
|
1752
|
+
get: function () {
|
1753
|
+
return this.metricsUpdated$.asObservable();
|
1754
|
+
},
|
1755
|
+
enumerable: false,
|
1756
|
+
configurable: true
|
1757
|
+
});
|
1758
|
+
MetricsCalculationService.prototype.getMetricValue = function (metric) {
|
1759
|
+
return this.metricsData[metric] || 0;
|
1760
|
+
};
|
1761
|
+
MetricsCalculationService.prototype.updateMetrics = function (lineItems) {
|
1762
|
+
var _this = this;
|
1763
|
+
var metricKeys = this.collectMetricKeys(lineItems).filter(function (key) { return !key.includes('Effective_'); });
|
1764
|
+
this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
|
1765
|
+
this.metricsData = metricKeys.reduce(function (acc, key) {
|
1766
|
+
var _c;
|
1767
|
+
return (Object.assign(Object.assign({}, acc), (_c = {}, _c[key] = _this.calculateMetric(lineItems, key), _c)));
|
1768
|
+
}, {});
|
1769
|
+
this.metricsUpdated$.next();
|
1770
|
+
};
|
1771
|
+
MetricsCalculationService.prototype.calculateMetric = function (lineItems, metric) {
|
1772
|
+
return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
|
1773
|
+
};
|
1774
|
+
MetricsCalculationService.prototype.buildMetricsCalculationMethods = function (metricKeys, initial) {
|
1775
|
+
var _this = this;
|
1776
|
+
return metricKeys.reduce(function (acc, name) {
|
1777
|
+
var _c, _d;
|
1778
|
+
var _a, _b;
|
1779
|
+
if (acc[name]) {
|
1780
|
+
return acc;
|
1781
|
+
}
|
1782
|
+
acc = Object.assign(Object.assign({}, acc), (_c = {}, _c[name] = 'sum', _c));
|
1783
|
+
var metricRule = _this.getMetricRuleByTotalMetricName(name);
|
1784
|
+
var settingKey = ((_b = (_a = metricRule === null || metricRule === void 0 ? void 0 : metricRule.metrics) === null || _a === void 0 ? void 0 : _a.find(function (metric) { return metric.totalName === name; })) === null || _b === void 0 ? void 0 : _b.name) || name;
|
1785
|
+
if (_this.quoteMetricsSettings[settingKey]) {
|
1786
|
+
acc = Object.assign(Object.assign({}, acc), (_d = {}, _d[name] = _this.quoteMetricsSettings[settingKey], _d));
|
1787
|
+
}
|
1788
|
+
return acc;
|
1789
|
+
}, initial);
|
1790
|
+
};
|
1791
|
+
MetricsCalculationService.prototype.collectMetricKeys = function (lineItems) {
|
1792
|
+
var _this = this;
|
1793
|
+
var keys = [];
|
1794
|
+
lineItems.forEach(function (lineItem) {
|
1795
|
+
keys.push.apply(keys, __spreadArray([], __read(Object.keys(lineItem.totalMetrics || {}))));
|
1796
|
+
keys.push.apply(keys, __spreadArray([], __read(_this.collectMetricKeys(lineItem.lineItems))));
|
1797
|
+
});
|
1798
|
+
return lodash.uniq(keys);
|
1799
|
+
};
|
1800
|
+
MetricsCalculationService.prototype.getMetricRuleByTotalMetricName = function (name) {
|
1801
|
+
return this.activeMetricRules.find(function (metricRule) { return metricRule.metrics.find(function (metric) { return metric.totalName === name; }); });
|
1802
|
+
};
|
1803
|
+
return MetricsCalculationService;
|
1804
|
+
}());
|
1805
|
+
MetricsCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: FlowConfigurationService }, { token: i1__namespace.ConfigurationSettingsApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1806
|
+
MetricsCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, providedIn: 'root' });
|
1807
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, decorators: [{
|
1808
|
+
type: i0.Injectable,
|
1809
|
+
args: [{ providedIn: 'root' }]
|
1810
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: FlowConfigurationService }, { type: i1__namespace.ConfigurationSettingsApiService }]; } });
|
1811
|
+
|
1812
|
+
var ProductImagesService = /** @class */ (function () {
|
1813
|
+
function ProductImagesService(productApiService) {
|
1814
|
+
this.productApiService = productApiService;
|
1815
|
+
this.imagesMap$ = new rxjs.BehaviorSubject({});
|
1816
|
+
}
|
1817
|
+
ProductImagesService.prototype.getImageUrl$ = function (productId) {
|
1818
|
+
var _a;
|
1819
|
+
if (this.imagesMap$.value[productId] == null) {
|
1820
|
+
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), (_a = {}, _a[productId] = '', _a)));
|
1821
|
+
this.fetchProductImage(productId);
|
1822
|
+
}
|
1823
|
+
return this.imagesMap$.pipe(rxjs.map(function (imagesMap) { return imagesMap[productId]; }), rxjs.distinctUntilChanged());
|
1824
|
+
};
|
1825
|
+
ProductImagesService.prototype.fetchProductImage = function (productId) {
|
1826
|
+
var _this = this;
|
1827
|
+
this.productApiService
|
1828
|
+
.fetchImage$(productId)
|
1829
|
+
.pipe(rxjs.map(function (file) { return URL.createObjectURL(file); }), rxjs.catchError(function () { return rxjs.of(''); }), rxjs.tap(function (url) {
|
1830
|
+
var _a;
|
1831
|
+
return _this.imagesMap$.next(Object.assign(Object.assign({}, _this.imagesMap$.value), (_a = {}, _a[productId] = url, _a)));
|
1832
|
+
}))
|
1833
|
+
.subscribe();
|
1834
|
+
};
|
1835
|
+
return ProductImagesService;
|
1836
|
+
}());
|
1837
|
+
ProductImagesService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, deps: [{ token: i1__namespace.ProductApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1838
|
+
ProductImagesService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, providedIn: 'root' });
|
1839
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, decorators: [{
|
1840
|
+
type: i0.Injectable,
|
1841
|
+
args: [{ providedIn: 'root' }]
|
1842
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.ProductApiService }]; } });
|
1843
|
+
|
1733
1844
|
var SdkCoreModule = /** @class */ (function () {
|
1734
1845
|
function SdkCoreModule() {
|
1735
1846
|
}
|
1736
1847
|
return SdkCoreModule;
|
1737
1848
|
}());
|
1738
|
-
SdkCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1739
|
-
SdkCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
1740
|
-
SdkCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
1741
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1849
|
+
SdkCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
1850
|
+
SdkCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
1851
|
+
SdkCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, providers: [ContextService, QuoteDraftService, ProductImagesService, MetricsCalculationService], imports: [[ConfigurationModule, FlowConfigurationModule]] });
|
1852
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, decorators: [{
|
1742
1853
|
type: i0.NgModule,
|
1743
1854
|
args: [{
|
1744
1855
|
imports: [ConfigurationModule, FlowConfigurationModule],
|
@@ -1761,6 +1872,9 @@
|
|
1761
1872
|
exports.ProductImagesService = ProductImagesService;
|
1762
1873
|
exports.QuoteDraftService = QuoteDraftService;
|
1763
1874
|
exports.SdkCoreModule = SdkCoreModule;
|
1875
|
+
exports.UI_DEFINITION_VERSION = UI_DEFINITION_VERSION;
|
1876
|
+
exports.calculateCardinalityVariables = calculateCardinalityVariables;
|
1877
|
+
exports.extractMetadata = extractMetadata;
|
1764
1878
|
exports.findLineItem = findLineItem;
|
1765
1879
|
exports.findLineItemWithComparator = findLineItemWithComparator;
|
1766
1880
|
exports.generateLineItem = generateLineItem;
|
@@ -1773,6 +1887,7 @@
|
|
1773
1887
|
exports.mapAttributes = mapAttributes;
|
1774
1888
|
exports.multiplyLineItems = multiplyLineItems;
|
1775
1889
|
exports.patchAttributes = patchAttributes;
|
1890
|
+
exports.recalculateCardinalityVariables = recalculateCardinalityVariables;
|
1776
1891
|
exports.removeLineItem = removeLineItem;
|
1777
1892
|
exports.replaceLineItem = replaceLineItem;
|
1778
1893
|
exports.upsertAttributes = upsertAttributes;
|