@veloceapps/sdk 6.0.0-3 → 6.0.0-30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/veloceapps-sdk-cms.umd.js +144 -72
- package/bundles/veloceapps-sdk-cms.umd.js.map +1 -1
- package/bundles/veloceapps-sdk-core.umd.js +724 -611
- package/bundles/veloceapps-sdk-core.umd.js.map +1 -1
- package/bundles/veloceapps-sdk-runtime.umd.js +209 -142
- package/bundles/veloceapps-sdk-runtime.umd.js.map +1 -1
- package/bundles/veloceapps-sdk.umd.js +360 -296
- package/bundles/veloceapps-sdk.umd.js.map +1 -1
- package/cms/vendor-map.d.ts +26 -14
- 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 +6 -3
- 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/utils/line-item.utils.d.ts +2 -0
- package/esm2015/cms/components/element-children/element-children.component.js +3 -3
- package/esm2015/cms/components/element-children/element-children.module.js +4 -4
- package/esm2015/cms/components/element-renderer/element-renderer.component.js +3 -3
- package/esm2015/cms/components/element-renderer/element-renderer.module.js +4 -4
- package/esm2015/cms/components/plugin.component.js +3 -3
- package/esm2015/cms/components/preview/preview.component.js +3 -3
- package/esm2015/cms/components/preview/preview.module.js +4 -4
- package/esm2015/cms/directives/custom-template.directive.js +3 -3
- package/esm2015/cms/launcher.module.js +4 -4
- package/esm2015/cms/modules/federated/federated.component.js +3 -3
- package/esm2015/cms/modules/federated/federated.module.js +4 -4
- package/esm2015/cms/plugins/configuration.plugin.js +3 -3
- package/esm2015/cms/plugins/io.plugin.js +3 -3
- package/esm2015/cms/plugins/script.plugin.js +3 -3
- package/esm2015/cms/services/dynamic-module.service.js +3 -3
- package/esm2015/cms/services/element-context.service.js +3 -3
- package/esm2015/cms/services/integration.state.js +3 -3
- package/esm2015/cms/services/io-provider.service.js +3 -3
- package/esm2015/cms/services/launcher.service.js +6 -5
- package/esm2015/cms/services/templates.service.js +3 -3
- package/esm2015/cms/vendor-map.js +11 -4
- 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 +27 -24
- 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 +17 -9
- package/esm2015/core/modules/flow-configuration/services/flow-update.service.js +3 -3
- package/esm2015/core/services/context.service.js +3 -3
- 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/utils/line-item.utils.js +27 -11
- 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 +4 -4
- 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 +3 -3
- package/esm2015/src/components/dialog/dialog.module.js +4 -4
- 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 +6 -6
- 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 +4 -4
- 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 +3 -3
- package/esm2015/src/guards/root.guard.js +3 -3
- package/esm2015/src/pages/catalog/catalog.component.js +3 -3
- 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 +3 -3
- 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 +8 -8
- package/esm2015/src/services/doc-gen.service.js +3 -3
- package/esm2015/src/services/flow-dialog.service.js +3 -3
- package/esm2015/src/services/flow-router.service.js +3 -3
- package/esm2015/src/services/flow.service.js +3 -3
- package/esm2015/src/utils/flow.utils.js +3 -3
- package/fesm2015/veloceapps-sdk-cms.js +74 -67
- package/fesm2015/veloceapps-sdk-cms.js.map +1 -1
- package/fesm2015/veloceapps-sdk-core.js +520 -490
- package/fesm2015/veloceapps-sdk-core.js.map +1 -1
- package/fesm2015/veloceapps-sdk-runtime.js +138 -138
- package/fesm2015/veloceapps-sdk-runtime.js.map +1 -1
- package/fesm2015/veloceapps-sdk.js +238 -242
- package/fesm2015/veloceapps-sdk.js.map +1 -1
- package/package.json +1 -1
- 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/{core → runtime}/types/quote-states.types.d.ts +0 -0
- package/src/components/header/metrics/metrics.component.d.ts +15 -6
- package/src/components/header/metrics/metrics.definitions.d.ts +0 -3
- package/src/pages/product/product.component.d.ts +0 -1
- package/esm2015/core/types/quote-states.types.js +0 -2
@@ -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) {
|
@@ -416,581 +483,140 @@
|
|
416
483
|
};
|
417
484
|
return ContextService;
|
418
485
|
}());
|
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.
|
486
|
+
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 });
|
487
|
+
ContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ContextService, providedIn: 'root' });
|
488
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ContextService, decorators: [{
|
422
489
|
type: i0.Injectable,
|
423
490
|
args: [{ providedIn: 'root' }]
|
424
491
|
}], ctorParameters: function () { return [{ type: i1__namespace.ContextApiService }]; } });
|
425
492
|
|
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
|
-
|
493
|
+
var RuntimeContextService = /** @class */ (function () {
|
494
|
+
function RuntimeContextService(configurationApiService) {
|
495
|
+
this.configurationApiService = configurationApiService;
|
496
|
+
}
|
497
|
+
RuntimeContextService.prototype.getRuntimeContext = function (productId, offeringId) {
|
498
|
+
var _this = this;
|
499
|
+
return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(operators.map(function (runtimeData) {
|
500
|
+
var _a, _b, _c;
|
501
|
+
var uiDefinition = _this.getUIDefinition(runtimeData);
|
502
|
+
var runtimeModel = core.RuntimeModel.create(runtimeData.types, runtimeData.products);
|
503
|
+
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;
|
504
|
+
return {
|
505
|
+
modelId: runtimeData.modelId,
|
506
|
+
uiDefinition: uiDefinition,
|
507
|
+
runtimeModel: runtimeModel,
|
508
|
+
runtimeMode: exports.RuntimeMode.PROD,
|
509
|
+
productId: productId,
|
510
|
+
productType: (properties === null || properties === void 0 ? void 0 : properties.displayName) || productName,
|
511
|
+
offeringId: offeringId,
|
512
|
+
properties: {
|
513
|
+
PricingEnabled: ((_b = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _b === void 0 ? void 0 : _b.pricingEnabled) ? 'true' : 'false',
|
514
|
+
PriceListId: (_c = uiDefinition === null || uiDefinition === void 0 ? void 0 : uiDefinition.properties) === null || _c === void 0 ? void 0 : _c.priceList,
|
515
|
+
},
|
516
|
+
};
|
517
|
+
}));
|
518
|
+
};
|
519
|
+
RuntimeContextService.prototype.getUIDefinition = function (runtimeData) {
|
520
|
+
var _a;
|
521
|
+
var rawUiDefinitions;
|
522
|
+
try {
|
523
|
+
rawUiDefinitions = JSON.parse(runtimeData.uiDefinitionsSource);
|
457
524
|
}
|
458
|
-
|
459
|
-
return
|
525
|
+
catch (e) {
|
526
|
+
return;
|
460
527
|
}
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
528
|
+
var uiDefinitions = rawUiDefinitions.filter(function (uiDef) { return uiDef.version; });
|
529
|
+
var uiDefinition = (_a = uiDefinitions.find(function (uiDef) { return uiDef.primary; })) !== null && _a !== void 0 ? _a : uiDefinitions[0];
|
530
|
+
return uiDefinition;
|
531
|
+
};
|
532
|
+
return RuntimeContextService;
|
533
|
+
}());
|
534
|
+
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 });
|
535
|
+
RuntimeContextService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeContextService });
|
536
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: RuntimeContextService, decorators: [{
|
537
|
+
type: i0.Injectable
|
538
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }]; } });
|
466
539
|
|
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();
|
540
|
+
var ConfigurationRuntimeService = /** @class */ (function () {
|
541
|
+
function ConfigurationRuntimeService(apiService, contextService, runtimeContextService) {
|
542
|
+
this.apiService = apiService;
|
543
|
+
this.contextService = contextService;
|
544
|
+
this.runtimeContextService = runtimeContextService;
|
545
|
+
this._isInitialized = false;
|
546
|
+
this.uiDefinitionProperties = {};
|
485
547
|
}
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
if (this.isInitialized !== value) {
|
492
|
-
this.isInitializedSubj$.next(value);
|
493
|
-
}
|
494
|
-
},
|
495
|
-
enumerable: false,
|
496
|
-
configurable: true
|
497
|
-
});
|
498
|
-
Object.defineProperty(QuoteDraftService.prototype, "hasUnsavedChanges", {
|
499
|
-
get: function () {
|
500
|
-
return this._hasUnsavedChanges;
|
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
|
-
}
|
508
|
-
},
|
509
|
-
enumerable: false,
|
510
|
-
configurable: true
|
511
|
-
});
|
512
|
-
Object.defineProperty(QuoteDraftService.prototype, "hasAssets$", {
|
513
|
-
get: function () {
|
514
|
-
var _this = this;
|
515
|
-
return this.quoteSubj$.pipe(operators.map(function () { return _this.hasAssets; }));
|
516
|
-
},
|
517
|
-
enumerable: false,
|
518
|
-
configurable: true
|
519
|
-
});
|
520
|
-
Object.defineProperty(QuoteDraftService.prototype, "hasAssets", {
|
521
|
-
get: function () {
|
522
|
-
var quoteDraft = this.quoteSubj$.value;
|
523
|
-
return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
|
524
|
-
},
|
525
|
-
enumerable: false,
|
526
|
-
configurable: true
|
527
|
-
});
|
528
|
-
QuoteDraftService.prototype.reset = function () {
|
529
|
-
this.resetSubj$.next(true);
|
530
|
-
this.quoteSubj$.next(null);
|
531
|
-
this.hasUnsavedChanges = false;
|
548
|
+
ConfigurationRuntimeService.prototype.reset = function () {
|
549
|
+
this._isInitialized = false;
|
550
|
+
this._runtimeContext = undefined;
|
551
|
+
this.initializationProps = undefined;
|
552
|
+
this.uiDefinitionProperties = {};
|
532
553
|
};
|
533
|
-
|
554
|
+
ConfigurationRuntimeService.prototype.initTestMode = function (modelId, uiDefinition) {
|
534
555
|
var _this = this;
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
556
|
+
var _a, _b;
|
557
|
+
this.uiDefinitionProperties = (_a = uiDefinition.properties) !== null && _a !== void 0 ? _a : {};
|
558
|
+
var uiDefinitionExternals = (_b = uiDefinition.externals) !== null && _b !== void 0 ? _b : {};
|
559
|
+
return rxjs.combineLatest([
|
560
|
+
this.apiService.getRuntimeDataByModelId(modelId),
|
561
|
+
this.contextService.create('TestId', core.ConfigurationContextMode.TEST),
|
562
|
+
]).pipe(operators.first(), operators.tap(function (_e) {
|
563
|
+
var _f = __read(_e, 2), runtimeData = _f[0], context = _f[1];
|
564
|
+
var _a;
|
565
|
+
_this._runtimeContext = {
|
566
|
+
modelId: modelId,
|
567
|
+
runtimeModel: core.RuntimeModel.create(runtimeData.types, runtimeData.products),
|
568
|
+
runtimeMode: exports.RuntimeMode.TEST,
|
569
|
+
};
|
570
|
+
_this.contextService.update({
|
571
|
+
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),
|
572
|
+
});
|
573
|
+
_this._isInitialized = true;
|
574
|
+
}));
|
542
575
|
};
|
543
|
-
|
544
|
-
var
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
576
|
+
ConfigurationRuntimeService.prototype.init = function (props) {
|
577
|
+
var _this = this;
|
578
|
+
this.initializationProps = props;
|
579
|
+
var context = this.contextService.resolve();
|
580
|
+
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(operators.tap(function (runtimeContext) {
|
581
|
+
var _a, _b, _c, _d;
|
582
|
+
_this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {};
|
583
|
+
var PriceListId = ((_c = context.properties) !== null && _c !== void 0 ? _c : {}).PriceListId;
|
584
|
+
var mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
|
585
|
+
_this.id15to18('AccountId', mergeContext.properties);
|
586
|
+
_this._runtimeContext = mergeContext;
|
587
|
+
if (context.properties && ((_d = _this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
|
588
|
+
_this.contextService.update({
|
589
|
+
properties: Object.assign(Object.assign({}, _this._runtimeContext.properties), context.properties),
|
590
|
+
});
|
591
|
+
}
|
592
|
+
_this._isInitialized = true;
|
593
|
+
}));
|
549
594
|
};
|
550
|
-
|
551
|
-
|
552
|
-
if (!quoteDraft) {
|
595
|
+
ConfigurationRuntimeService.prototype.id15to18 = function (propertyName, source) {
|
596
|
+
if (!source) {
|
553
597
|
return;
|
554
598
|
}
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
|
559
|
-
};
|
560
|
-
QuoteDraftService.prototype.updateByPriceSummary = function (priceSummary) {
|
561
|
-
var quoteDraft = this.quoteSubj$.value;
|
562
|
-
if (!quoteDraft) {
|
563
|
-
return;
|
599
|
+
var value = source[propertyName];
|
600
|
+
if (typeof value === 'string' && value.length === 15) {
|
601
|
+
source[propertyName] = core.SalesforceIdUtils.generateId18FromId15(value);
|
564
602
|
}
|
565
|
-
var updatedCurrentState = this.currentState.map(function (lineItem) {
|
566
|
-
var updated = priceSummary.lineItems.find(function (li) { return li.id === lineItem.id; });
|
567
|
-
return updated !== null && updated !== void 0 ? updated : lineItem;
|
568
|
-
});
|
569
|
-
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
|
570
603
|
};
|
571
|
-
Object.defineProperty(
|
604
|
+
Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized", {
|
572
605
|
get: function () {
|
573
|
-
|
574
|
-
return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.quoteDraft; }), operators.filter(function (quote) { return Boolean(quote); }), operators.shareReplay());
|
606
|
+
return this._isInitialized;
|
575
607
|
},
|
576
608
|
enumerable: false,
|
577
609
|
configurable: true
|
578
610
|
});
|
579
|
-
Object.defineProperty(
|
611
|
+
Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeModel", {
|
580
612
|
get: function () {
|
581
|
-
var
|
582
|
-
|
583
|
-
return null;
|
584
|
-
}
|
585
|
-
return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
|
613
|
+
var _a;
|
614
|
+
return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
|
586
615
|
},
|
587
616
|
enumerable: false,
|
588
617
|
configurable: true
|
589
618
|
});
|
590
|
-
Object.defineProperty(
|
591
|
-
get: function () {
|
592
|
-
var quoteDraft = this.quoteDraft;
|
593
|
-
if (!quoteDraft) {
|
594
|
-
return null;
|
595
|
-
}
|
596
|
-
return Object.assign(Object.assign({}, quoteDraft), { initialState: this.filterByActivePriceList(quoteDraft.initialState), currentState: this.filterByActivePriceList(quoteDraft.currentState) });
|
597
|
-
},
|
598
|
-
enumerable: false,
|
599
|
-
configurable: true
|
600
|
-
});
|
601
|
-
Object.defineProperty(QuoteDraftService.prototype, "currentState$", {
|
602
|
-
get: function () {
|
603
|
-
return this.quoteDraft$.pipe(operators.map(function (quote) { return quote.currentState; }));
|
604
|
-
},
|
605
|
-
enumerable: false,
|
606
|
-
configurable: true
|
607
|
-
});
|
608
|
-
Object.defineProperty(QuoteDraftService.prototype, "currentState", {
|
609
|
-
get: function () {
|
610
|
-
var _a, _b;
|
611
|
-
return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
612
|
-
},
|
613
|
-
enumerable: false,
|
614
|
-
configurable: true
|
615
|
-
});
|
616
|
-
Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState$", {
|
617
|
-
/**
|
618
|
-
* Stream of activeCurrentState
|
619
|
-
*/
|
620
|
-
get: function () {
|
621
|
-
var _this = this;
|
622
|
-
return this.quoteDraft$.pipe(operators.map(function () { return _this.activeCurrentState; }));
|
623
|
-
},
|
624
|
-
enumerable: false,
|
625
|
-
configurable: true
|
626
|
-
});
|
627
|
-
Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState", {
|
628
|
-
/**
|
629
|
-
* activeCurrentState is currentState passed through additional filters
|
630
|
-
*/
|
631
|
-
get: function () {
|
632
|
-
var _a, _b;
|
633
|
-
var currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
634
|
-
currentState = this.filterByActivePriceList(currentState);
|
635
|
-
return currentState;
|
636
|
-
},
|
637
|
-
enumerable: false,
|
638
|
-
configurable: true
|
639
|
-
});
|
640
|
-
Object.defineProperty(QuoteDraftService.prototype, "activeInitialState$", {
|
641
|
-
/**
|
642
|
-
* Stream of activeInitialState
|
643
|
-
*/
|
644
|
-
get: function () {
|
645
|
-
var _this = this;
|
646
|
-
return this.quoteDraft$.pipe(operators.map(function () { return _this.activeInitialState; }));
|
647
|
-
},
|
648
|
-
enumerable: false,
|
649
|
-
configurable: true
|
650
|
-
});
|
651
|
-
Object.defineProperty(QuoteDraftService.prototype, "activeInitialState", {
|
652
|
-
/**
|
653
|
-
* activeInitialState is initialState passed through additional filters
|
654
|
-
*/
|
655
|
-
get: function () {
|
656
|
-
var _a, _b;
|
657
|
-
var ctx = this.context.resolve();
|
658
|
-
var initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
|
659
|
-
if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
|
660
|
-
initialState = this.filterByActivePriceList(initialState);
|
661
|
-
}
|
662
|
-
return initialState;
|
663
|
-
},
|
664
|
-
enumerable: false,
|
665
|
-
configurable: true
|
666
|
-
});
|
667
|
-
Object.defineProperty(QuoteDraftService.prototype, "isStandalone", {
|
668
|
-
get: function () {
|
669
|
-
return this.context.resolve().properties.standalone === 'true';
|
670
|
-
},
|
671
|
-
enumerable: false,
|
672
|
-
configurable: true
|
673
|
-
});
|
674
|
-
Object.defineProperty(QuoteDraftService.prototype, "isStandalone$", {
|
675
|
-
get: function () {
|
676
|
-
var _this = this;
|
677
|
-
return this.context.resolve$().pipe(operators.map(function () { return _this.isStandalone; }));
|
678
|
-
},
|
679
|
-
enumerable: false,
|
680
|
-
configurable: true
|
681
|
-
});
|
682
|
-
QuoteDraftService.prototype.getInitialCurrentState = function () {
|
683
|
-
return this.initialCurrentState;
|
684
|
-
};
|
685
|
-
QuoteDraftService.prototype.isEditMode$ = function () {
|
686
|
-
var _this = this;
|
687
|
-
return this.context.resolve$().pipe(operators.map(function () { return _this.isEditMode(); }));
|
688
|
-
};
|
689
|
-
QuoteDraftService.prototype.isEditMode = function () {
|
690
|
-
var context = this.context.resolve();
|
691
|
-
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", {
|
619
|
+
Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeContext", {
|
994
620
|
get: function () {
|
995
621
|
return this._runtimeContext;
|
996
622
|
},
|
@@ -999,9 +625,9 @@
|
|
999
625
|
});
|
1000
626
|
return ConfigurationRuntimeService;
|
1001
627
|
}());
|
1002
|
-
ConfigurationRuntimeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1003
|
-
ConfigurationRuntimeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
1004
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
628
|
+
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 });
|
629
|
+
ConfigurationRuntimeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService });
|
630
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService, decorators: [{
|
1005
631
|
type: i0.Injectable
|
1006
632
|
}], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
|
1007
633
|
|
@@ -1040,17 +666,36 @@
|
|
1040
666
|
};
|
1041
667
|
var replaceLineItem = function (lineItem, replaceTo) {
|
1042
668
|
if (lineItem.id === replaceTo.id) {
|
1043
|
-
return Object.assign({}, replaceTo);
|
669
|
+
return Object.assign({}, recalculateCardinalityVariables(lineItem, replaceTo));
|
1044
670
|
}
|
1045
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) {
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
671
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) { return replaceLineItem(li, replaceTo); }) });
|
672
|
+
};
|
673
|
+
var calculateCardinalityVariables = function (lineItems) {
|
674
|
+
var cardVars = new Map();
|
675
|
+
lineItems.forEach(function (li) {
|
676
|
+
var _a;
|
677
|
+
var cardinalityVariableName = "#CV-" + li.type + "@" + li.port;
|
678
|
+
cardVars.set(cardinalityVariableName, ((_a = cardVars.get(cardinalityVariableName)) !== null && _a !== void 0 ? _a : 0) + li.qty);
|
679
|
+
});
|
680
|
+
return cardVars;
|
681
|
+
};
|
682
|
+
var recalculateCardinalityVariables = function (original, updated) {
|
683
|
+
var cardinalityVariables = calculateCardinalityVariables(updated.lineItems);
|
684
|
+
var originalCardinalityVariables = calculateCardinalityVariables(original.lineItems);
|
685
|
+
originalCardinalityVariables.forEach(function (value, key) {
|
686
|
+
if (cardinalityVariables.get(key) === value) {
|
687
|
+
// no need to update cardinality if no changes
|
688
|
+
cardinalityVariables.delete(key);
|
689
|
+
}
|
690
|
+
else if (!cardinalityVariables.has(key)) {
|
691
|
+
// remove last item from port
|
692
|
+
cardinalityVariables.set(key, 0);
|
693
|
+
}
|
694
|
+
});
|
695
|
+
return Object.assign(Object.assign({}, updated), { attributes: upsertAttributes(updated.attributes, __spreadArray([], __read(cardinalityVariables)).map(function (_c) {
|
696
|
+
var _d = __read(_c, 2), name = _d[0], value = _d[1];
|
697
|
+
return ({ name: name, value: value });
|
698
|
+
})) });
|
1054
699
|
};
|
1055
700
|
var mapAttributes = function (attributes) {
|
1056
701
|
return attributes.reduce(function (acc, _c) {
|
@@ -1140,6 +785,8 @@
|
|
1140
785
|
insertLineItem: insertLineItem,
|
1141
786
|
removeLineItem: removeLineItem,
|
1142
787
|
replaceLineItem: replaceLineItem,
|
788
|
+
calculateCardinalityVariables: calculateCardinalityVariables,
|
789
|
+
recalculateCardinalityVariables: recalculateCardinalityVariables,
|
1143
790
|
mapAttributes: mapAttributes,
|
1144
791
|
getAttributes: getAttributes,
|
1145
792
|
upsertAttributes: upsertAttributes,
|
@@ -1157,17 +804,299 @@
|
|
1157
804
|
LineItemWorker.prototype.insert = function (parentId, toInsert) {
|
1158
805
|
return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
|
1159
806
|
};
|
1160
|
-
LineItemWorker.prototype.remove = function (id) {
|
1161
|
-
return new LineItemWorker(removeLineItem(this.li, id));
|
807
|
+
LineItemWorker.prototype.remove = function (id) {
|
808
|
+
return new LineItemWorker(removeLineItem(this.li, id));
|
809
|
+
};
|
810
|
+
LineItemWorker.prototype.replace = function (toReplace) {
|
811
|
+
return new LineItemWorker(replaceLineItem(this.li, toReplace));
|
812
|
+
};
|
813
|
+
LineItemWorker.prototype.patchAttribute = function (attrs, id) {
|
814
|
+
return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs));
|
815
|
+
};
|
816
|
+
return LineItemWorker;
|
817
|
+
}());
|
818
|
+
|
819
|
+
var QuoteDraftService = /** @class */ (function () {
|
820
|
+
function QuoteDraftService(context, quoteApiService, priceApiService) {
|
821
|
+
var _this = this;
|
822
|
+
this.context = context;
|
823
|
+
this.quoteApiService = quoteApiService;
|
824
|
+
this.priceApiService = priceApiService;
|
825
|
+
this.quoteSubj$ = new rxjs.BehaviorSubject(null);
|
826
|
+
this.resetSubj$ = new rxjs.BehaviorSubject(true);
|
827
|
+
this.isInitializedSubj$ = new rxjs.BehaviorSubject(false);
|
828
|
+
this.initialCurrentState = [];
|
829
|
+
this._hasUnsavedChanges = false;
|
830
|
+
this.allPriceLists = [];
|
831
|
+
this.assetPriceLists = [];
|
832
|
+
this.reset$ = this.resetSubj$.asObservable();
|
833
|
+
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; }));
|
834
|
+
this.isInitializedSubj$
|
835
|
+
.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); }))
|
836
|
+
.subscribe();
|
837
|
+
}
|
838
|
+
Object.defineProperty(QuoteDraftService.prototype, "isInitialized", {
|
839
|
+
get: function () {
|
840
|
+
return this.isInitializedSubj$.getValue();
|
841
|
+
},
|
842
|
+
set: function (value) {
|
843
|
+
if (this.isInitialized !== value) {
|
844
|
+
this.isInitializedSubj$.next(value);
|
845
|
+
}
|
846
|
+
},
|
847
|
+
enumerable: false,
|
848
|
+
configurable: true
|
849
|
+
});
|
850
|
+
Object.defineProperty(QuoteDraftService.prototype, "hasUnsavedChanges", {
|
851
|
+
get: function () {
|
852
|
+
return this._hasUnsavedChanges;
|
853
|
+
},
|
854
|
+
set: function (value) {
|
855
|
+
var _a, _b;
|
856
|
+
this._hasUnsavedChanges = value;
|
857
|
+
if (!this._hasUnsavedChanges) {
|
858
|
+
this.initialCurrentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
859
|
+
}
|
860
|
+
},
|
861
|
+
enumerable: false,
|
862
|
+
configurable: true
|
863
|
+
});
|
864
|
+
Object.defineProperty(QuoteDraftService.prototype, "hasProducts$", {
|
865
|
+
get: function () {
|
866
|
+
var _this = this;
|
867
|
+
return this.quoteSubj$.pipe(operators.map(function () { return _this.hasProducts; }));
|
868
|
+
},
|
869
|
+
enumerable: false,
|
870
|
+
configurable: true
|
871
|
+
});
|
872
|
+
Object.defineProperty(QuoteDraftService.prototype, "hasProducts", {
|
873
|
+
get: function () {
|
874
|
+
var quoteDraft = this.quoteSubj$.value;
|
875
|
+
return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
|
876
|
+
},
|
877
|
+
enumerable: false,
|
878
|
+
configurable: true
|
879
|
+
});
|
880
|
+
QuoteDraftService.prototype.reset = function () {
|
881
|
+
this.resetSubj$.next(true);
|
882
|
+
this.quoteSubj$.next(null);
|
883
|
+
this.hasUnsavedChanges = false;
|
884
|
+
};
|
885
|
+
QuoteDraftService.prototype.init = function (quoteId, params) {
|
886
|
+
var _this = this;
|
887
|
+
return rxjs.zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(operators.tap(function (_c) {
|
888
|
+
var _d = __read(_c, 2), quote = _d[0], allPriceLists = _d[1];
|
889
|
+
_this.allPriceLists = allPriceLists;
|
890
|
+
_this.quoteSubj$.next(quote);
|
891
|
+
_this.context.update(quote.context);
|
892
|
+
_this.populateActivePriceLists$();
|
893
|
+
}), operators.map(function () { return rxjs.noop(); }), operators.take(1));
|
894
|
+
};
|
895
|
+
QuoteDraftService.prototype.setCurrentLineItemState = function (lineItems) {
|
896
|
+
var quoteDraft = this.quoteSubj$.value;
|
897
|
+
if (!quoteDraft) {
|
898
|
+
return;
|
899
|
+
}
|
900
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
|
901
|
+
};
|
902
|
+
QuoteDraftService.prototype.updateQuoteDraft = function (update) {
|
903
|
+
var quoteDraft = this.quoteSubj$.value;
|
904
|
+
if (!quoteDraft) {
|
905
|
+
return;
|
906
|
+
}
|
907
|
+
if (update.context) {
|
908
|
+
this.context.set(update.context);
|
909
|
+
}
|
910
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
|
911
|
+
};
|
912
|
+
QuoteDraftService.prototype.updateByPriceSummary = function (priceSummary) {
|
913
|
+
var quoteDraft = this.quoteSubj$.value;
|
914
|
+
if (!quoteDraft) {
|
915
|
+
return;
|
916
|
+
}
|
917
|
+
var updatedCurrentState = this.currentState.map(function (lineItem) {
|
918
|
+
var updated = priceSummary.lineItems.find(function (li) { return li.id === lineItem.id; });
|
919
|
+
return updated !== null && updated !== void 0 ? updated : lineItem;
|
920
|
+
});
|
921
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedCurrentState, totalPrices: priceSummary.totalPrices, approvalItems: priceSummary.approvalItems }));
|
922
|
+
};
|
923
|
+
Object.defineProperty(QuoteDraftService.prototype, "quoteDraft$", {
|
924
|
+
get: function () {
|
925
|
+
var _this = this;
|
926
|
+
return rxjs.combineLatest([this.quoteSubj$, this.context.resolve$()]).pipe(operators.map(function () { return _this.quoteDraft; }), operators.filter(function (quote) { return Boolean(quote); }), operators.shareReplay());
|
927
|
+
},
|
928
|
+
enumerable: false,
|
929
|
+
configurable: true
|
930
|
+
});
|
931
|
+
Object.defineProperty(QuoteDraftService.prototype, "quoteDraft", {
|
932
|
+
get: function () {
|
933
|
+
var quote = this.quoteSubj$.value;
|
934
|
+
if (!quote) {
|
935
|
+
return null;
|
936
|
+
}
|
937
|
+
return Object.assign(Object.assign({}, quote), { context: this.context.resolve() });
|
938
|
+
},
|
939
|
+
enumerable: false,
|
940
|
+
configurable: true
|
941
|
+
});
|
942
|
+
Object.defineProperty(QuoteDraftService.prototype, "quoteDraftForActivePriceList", {
|
943
|
+
get: function () {
|
944
|
+
var quoteDraft = this.quoteDraft;
|
945
|
+
if (!quoteDraft) {
|
946
|
+
return null;
|
947
|
+
}
|
948
|
+
return Object.assign(Object.assign({}, quoteDraft), { initialState: this.filterByActivePriceList(quoteDraft.initialState), currentState: this.filterByActivePriceList(quoteDraft.currentState) });
|
949
|
+
},
|
950
|
+
enumerable: false,
|
951
|
+
configurable: true
|
952
|
+
});
|
953
|
+
Object.defineProperty(QuoteDraftService.prototype, "currentState$", {
|
954
|
+
get: function () {
|
955
|
+
return this.quoteDraft$.pipe(operators.map(function (quote) { return quote.currentState; }));
|
956
|
+
},
|
957
|
+
enumerable: false,
|
958
|
+
configurable: true
|
959
|
+
});
|
960
|
+
Object.defineProperty(QuoteDraftService.prototype, "currentState", {
|
961
|
+
get: function () {
|
962
|
+
var _a, _b;
|
963
|
+
return (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
964
|
+
},
|
965
|
+
enumerable: false,
|
966
|
+
configurable: true
|
967
|
+
});
|
968
|
+
Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState$", {
|
969
|
+
/**
|
970
|
+
* Stream of activeCurrentState
|
971
|
+
*/
|
972
|
+
get: function () {
|
973
|
+
var _this = this;
|
974
|
+
return this.quoteDraft$.pipe(operators.map(function () { return _this.activeCurrentState; }));
|
975
|
+
},
|
976
|
+
enumerable: false,
|
977
|
+
configurable: true
|
978
|
+
});
|
979
|
+
Object.defineProperty(QuoteDraftService.prototype, "activeCurrentState", {
|
980
|
+
/**
|
981
|
+
* activeCurrentState is currentState passed through additional filters
|
982
|
+
*/
|
983
|
+
get: function () {
|
984
|
+
var _a, _b;
|
985
|
+
var currentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
986
|
+
currentState = this.filterByActivePriceList(currentState);
|
987
|
+
return currentState;
|
988
|
+
},
|
989
|
+
enumerable: false,
|
990
|
+
configurable: true
|
991
|
+
});
|
992
|
+
Object.defineProperty(QuoteDraftService.prototype, "activeInitialState$", {
|
993
|
+
/**
|
994
|
+
* Stream of activeInitialState
|
995
|
+
*/
|
996
|
+
get: function () {
|
997
|
+
var _this = this;
|
998
|
+
return this.quoteDraft$.pipe(operators.map(function () { return _this.activeInitialState; }));
|
999
|
+
},
|
1000
|
+
enumerable: false,
|
1001
|
+
configurable: true
|
1002
|
+
});
|
1003
|
+
Object.defineProperty(QuoteDraftService.prototype, "activeInitialState", {
|
1004
|
+
/**
|
1005
|
+
* activeInitialState is initialState passed through additional filters
|
1006
|
+
*/
|
1007
|
+
get: function () {
|
1008
|
+
var _a, _b;
|
1009
|
+
var ctx = this.context.resolve();
|
1010
|
+
var initialState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState) !== null && _b !== void 0 ? _b : [];
|
1011
|
+
if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
|
1012
|
+
initialState = this.filterByActivePriceList(initialState);
|
1013
|
+
}
|
1014
|
+
return initialState;
|
1015
|
+
},
|
1016
|
+
enumerable: false,
|
1017
|
+
configurable: true
|
1018
|
+
});
|
1019
|
+
Object.defineProperty(QuoteDraftService.prototype, "isStandalone", {
|
1020
|
+
get: function () {
|
1021
|
+
return this.context.resolve().properties.standalone === 'true';
|
1022
|
+
},
|
1023
|
+
enumerable: false,
|
1024
|
+
configurable: true
|
1025
|
+
});
|
1026
|
+
Object.defineProperty(QuoteDraftService.prototype, "isStandalone$", {
|
1027
|
+
get: function () {
|
1028
|
+
var _this = this;
|
1029
|
+
return this.context.resolve$().pipe(operators.map(function () { return _this.isStandalone; }));
|
1030
|
+
},
|
1031
|
+
enumerable: false,
|
1032
|
+
configurable: true
|
1033
|
+
});
|
1034
|
+
QuoteDraftService.prototype.getInitialCurrentState = function () {
|
1035
|
+
return this.initialCurrentState;
|
1036
|
+
};
|
1037
|
+
QuoteDraftService.prototype.isEditMode$ = function () {
|
1038
|
+
var _this = this;
|
1039
|
+
return this.context.resolve$().pipe(operators.map(function () { return _this.isEditMode(); }));
|
1162
1040
|
};
|
1163
|
-
|
1164
|
-
|
1041
|
+
QuoteDraftService.prototype.isEditMode = function () {
|
1042
|
+
var context = this.context.resolve();
|
1043
|
+
if (context.mode === core.ConfigurationContextMode.ACCOUNT) {
|
1044
|
+
return true;
|
1045
|
+
}
|
1046
|
+
if (context.mode === core.ConfigurationContextMode.QUOTE) {
|
1047
|
+
return context.properties.Status === 'Draft';
|
1048
|
+
}
|
1049
|
+
return false;
|
1165
1050
|
};
|
1166
|
-
|
1167
|
-
|
1051
|
+
QuoteDraftService.prototype.updateActivePriceList = function (priceListId) {
|
1052
|
+
this.context.update({ properties: { PriceListId: priceListId } });
|
1168
1053
|
};
|
1169
|
-
|
1054
|
+
QuoteDraftService.prototype.populateActivePriceLists$ = function () {
|
1055
|
+
var _this = this;
|
1056
|
+
var ctx = this.context.resolve();
|
1057
|
+
var quoteDraft = this.quoteDraft;
|
1058
|
+
if (!quoteDraft) {
|
1059
|
+
return;
|
1060
|
+
}
|
1061
|
+
// In ACCOUNT mode populate price lists from related assets
|
1062
|
+
if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
|
1063
|
+
// Populate list of price lists
|
1064
|
+
this.assetPriceLists = quoteDraft.currentState
|
1065
|
+
.map(function (_c) {
|
1066
|
+
var priceListId = _c.priceListId;
|
1067
|
+
return priceListId;
|
1068
|
+
})
|
1069
|
+
.reduce(function (trunk, priceListId) {
|
1070
|
+
var _a, _b;
|
1071
|
+
if (!priceListId || trunk.some(function (item) { return item.id === priceListId; })) {
|
1072
|
+
return trunk;
|
1073
|
+
}
|
1074
|
+
return __spreadArray(__spreadArray([], __read(trunk)), [
|
1075
|
+
{ 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 : '' },
|
1076
|
+
]);
|
1077
|
+
}, []);
|
1078
|
+
}
|
1079
|
+
};
|
1080
|
+
QuoteDraftService.prototype.filterByActivePriceList = function (lineItems) {
|
1081
|
+
var ctx = this.context.resolve();
|
1082
|
+
return lineItems.filter(function (li) { return !li.priceListId || li.priceListId === ctx.properties.PriceListId; });
|
1083
|
+
};
|
1084
|
+
QuoteDraftService.prototype.markAsUpdated = function (quote) {
|
1085
|
+
if ((quote === null || quote === void 0 ? void 0 : quote.context.properties.mode) === core.ConfigurationContextMode.ACCOUNT) {
|
1086
|
+
this.hasUnsavedChanges = !!quote && !quote.currentState.every(function (li) { return li.actionCode === 'EXIST'; });
|
1087
|
+
}
|
1088
|
+
else {
|
1089
|
+
this.hasUnsavedChanges = !lodash.isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
|
1090
|
+
}
|
1091
|
+
};
|
1092
|
+
return QuoteDraftService;
|
1170
1093
|
}());
|
1094
|
+
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 });
|
1095
|
+
QuoteDraftService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, providedIn: 'root' });
|
1096
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, decorators: [{
|
1097
|
+
type: i0.Injectable,
|
1098
|
+
args: [{ providedIn: 'root' }]
|
1099
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }]; } });
|
1171
1100
|
|
1172
1101
|
var ConfigurationService = /** @class */ (function () {
|
1173
1102
|
function ConfigurationService(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
|
@@ -1178,7 +1107,6 @@
|
|
1178
1107
|
this.messageService = messageService;
|
1179
1108
|
this.dialogService = dialogService;
|
1180
1109
|
this.mode = core.ConfigurationMode.SEARCH;
|
1181
|
-
this.states = {};
|
1182
1110
|
this.lineItem = new rxjs.BehaviorSubject(undefined);
|
1183
1111
|
this.charges = new rxjs.BehaviorSubject({});
|
1184
1112
|
this.pricePlans = new rxjs.BehaviorSubject({});
|
@@ -1187,7 +1115,7 @@
|
|
1187
1115
|
ConfigurationService.prototype.reset = function () {
|
1188
1116
|
this.hasUnsavedChanges = false;
|
1189
1117
|
this.runtimeService.reset();
|
1190
|
-
this.
|
1118
|
+
this.configurableRamp = undefined;
|
1191
1119
|
this.lineItem.next(undefined);
|
1192
1120
|
this.charges.next({});
|
1193
1121
|
this.pricePlans.next({});
|
@@ -1197,10 +1125,7 @@
|
|
1197
1125
|
if (!this.lineItem.value) {
|
1198
1126
|
return rxjs.throwError(function () { return new Error("Source LineItem not found"); });
|
1199
1127
|
}
|
1200
|
-
this.
|
1201
|
-
this.states.asset = this.states.configurableRamp
|
1202
|
-
? this.runtimeService.getAsset(this.states.configurableRamp)
|
1203
|
-
: undefined;
|
1128
|
+
this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem).li;
|
1204
1129
|
return this.configure().pipe(operators.catchError(function (error) {
|
1205
1130
|
console.error(error);
|
1206
1131
|
if (!_this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
|
@@ -1218,8 +1143,8 @@
|
|
1218
1143
|
ConfigurationService.prototype.patch = function (lineItem) {
|
1219
1144
|
this.patch$(lineItem).subscribe();
|
1220
1145
|
};
|
1221
|
-
ConfigurationService.prototype.
|
1222
|
-
this.
|
1146
|
+
ConfigurationService.prototype.setConfigurableRamp = function (lineItem) {
|
1147
|
+
this.configurableRamp = lineItem;
|
1223
1148
|
};
|
1224
1149
|
ConfigurationService.prototype.get = function () {
|
1225
1150
|
return this.lineItem.asObservable().pipe(rxjs.shareReplay());
|
@@ -1285,7 +1210,7 @@
|
|
1285
1210
|
}
|
1286
1211
|
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
1212
|
var qty = (_d = this.runtimeService.initializationProps) === null || _d === void 0 ? void 0 : _d.defaultQty;
|
1288
|
-
var lineItem = (_e = this.
|
1213
|
+
var lineItem = (_e = this.configurableRamp) !== null && _e !== void 0 ? _e : getDefaultLineItem(runtimeContext, uiDefinitionProperties, qty);
|
1289
1214
|
var configurationRequest = this.createRequest(lineItem);
|
1290
1215
|
var mainPricingEnabled = (_f = runtimeContext.properties) === null || _f === void 0 ? void 0 : _f.PricingEnabled;
|
1291
1216
|
var pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
|
@@ -1305,23 +1230,21 @@
|
|
1305
1230
|
};
|
1306
1231
|
ConfigurationService.prototype.configureExternal$ = function (productId, qty) {
|
1307
1232
|
var _this = this;
|
1308
|
-
this.updateCurrentStates({
|
1309
|
-
currentState: this.quoteDraftService.currentState,
|
1310
|
-
});
|
1311
1233
|
return this.runtimeService.init({ productId: productId, defaultQty: qty }).pipe(operators.switchMap(function () { return _this.configure(); }), operators.first(), operators.catchError(function (error) {
|
1312
1234
|
_this.messageService.add({ severity: components.ToastType.error, summary: error });
|
1313
1235
|
throw error;
|
1314
1236
|
}), operators.finalize(function () { return _this.reset(); }));
|
1315
1237
|
};
|
1316
1238
|
ConfigurationService.prototype.createRequest = function (lineItem) {
|
1239
|
+
var _a;
|
1317
1240
|
return {
|
1318
1241
|
lineItem: lineItem,
|
1319
1242
|
mode: this.mode,
|
1320
1243
|
step: !this.lineItem.value ? exports.RuntimeStep.START : exports.RuntimeStep.UPDATE,
|
1321
1244
|
attributeDomainMode: 'ALL',
|
1322
1245
|
context: this.contextService.resolve(),
|
1323
|
-
lineItems: this.
|
1324
|
-
asset: this.
|
1246
|
+
lineItems: ((_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) || [],
|
1247
|
+
asset: this.getAsset(),
|
1325
1248
|
};
|
1326
1249
|
};
|
1327
1250
|
ConfigurationService.prototype.showInactiveProductsConfirmation = function () {
|
@@ -1350,13 +1273,21 @@
|
|
1350
1273
|
}
|
1351
1274
|
});
|
1352
1275
|
};
|
1276
|
+
ConfigurationService.prototype.getAsset = function () {
|
1277
|
+
var _a;
|
1278
|
+
var lineItem = this.configurableRamp;
|
1279
|
+
if (!lineItem) {
|
1280
|
+
return;
|
1281
|
+
}
|
1282
|
+
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; });
|
1283
|
+
};
|
1353
1284
|
return ConfigurationService;
|
1354
1285
|
}());
|
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.
|
1286
|
+
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 });
|
1287
|
+
ConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService });
|
1288
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService, decorators: [{
|
1358
1289
|
type: i0.Injectable
|
1359
|
-
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type:
|
1290
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type: i5__namespace.MessageService }, { type: i6__namespace.DialogService }]; } });
|
1360
1291
|
|
1361
1292
|
var FlowUpdateService = /** @class */ (function () {
|
1362
1293
|
function FlowUpdateService() {
|
@@ -1482,9 +1413,9 @@
|
|
1482
1413
|
};
|
1483
1414
|
return FlowUpdateService;
|
1484
1415
|
}());
|
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.
|
1416
|
+
FlowUpdateService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1417
|
+
FlowUpdateService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService });
|
1418
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService, decorators: [{
|
1488
1419
|
type: i0.Injectable
|
1489
1420
|
}] });
|
1490
1421
|
|
@@ -1614,6 +1545,16 @@
|
|
1614
1545
|
enumerable: false,
|
1615
1546
|
configurable: true
|
1616
1547
|
});
|
1548
|
+
Object.defineProperty(FlowConfigurationService.prototype, "activeMetrics$", {
|
1549
|
+
get: function () {
|
1550
|
+
return this.quoteDraftService.quoteDraft$.pipe(rxjs.map(function (_c) {
|
1551
|
+
var activeMetrics = _c.activeMetrics;
|
1552
|
+
return activeMetrics;
|
1553
|
+
}));
|
1554
|
+
},
|
1555
|
+
enumerable: false,
|
1556
|
+
configurable: true
|
1557
|
+
});
|
1617
1558
|
Object.defineProperty(FlowConfigurationService.prototype, "chargesSnapshot", {
|
1618
1559
|
get: function () {
|
1619
1560
|
var _a, _b;
|
@@ -1630,6 +1571,14 @@
|
|
1630
1571
|
enumerable: false,
|
1631
1572
|
configurable: true
|
1632
1573
|
});
|
1574
|
+
Object.defineProperty(FlowConfigurationService.prototype, "activeMetricsSnapshot", {
|
1575
|
+
get: function () {
|
1576
|
+
var _a, _b;
|
1577
|
+
return (_b = (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.activeMetrics) !== null && _b !== void 0 ? _b : [];
|
1578
|
+
},
|
1579
|
+
enumerable: false,
|
1580
|
+
configurable: true
|
1581
|
+
});
|
1633
1582
|
Object.defineProperty(FlowConfigurationService.prototype, "contextSnapshot", {
|
1634
1583
|
get: function () {
|
1635
1584
|
return this.contextService.resolve();
|
@@ -1660,9 +1609,9 @@
|
|
1660
1609
|
};
|
1661
1610
|
return FlowConfigurationService;
|
1662
1611
|
}());
|
1663
|
-
FlowConfigurationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1664
|
-
FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
1665
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1612
|
+
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 });
|
1613
|
+
FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService });
|
1614
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
|
1666
1615
|
type: i0.Injectable
|
1667
1616
|
}], ctorParameters: function () { return [{ type: i1__namespace.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
1668
1617
|
|
@@ -1671,10 +1620,10 @@
|
|
1671
1620
|
}
|
1672
1621
|
return FlowConfigurationModule;
|
1673
1622
|
}());
|
1674
|
-
FlowConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1675
|
-
FlowConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
1676
|
-
FlowConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
1677
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1623
|
+
FlowConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
1624
|
+
FlowConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule });
|
1625
|
+
FlowConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, i1.PriceApiService], imports: [[]] });
|
1626
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, decorators: [{
|
1678
1627
|
type: i0.NgModule,
|
1679
1628
|
args: [{
|
1680
1629
|
imports: [],
|
@@ -1687,9 +1636,9 @@
|
|
1687
1636
|
}
|
1688
1637
|
return ConfigurationModule;
|
1689
1638
|
}());
|
1690
|
-
ConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1691
|
-
ConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
1692
|
-
ConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
1639
|
+
ConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
1640
|
+
ConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, imports: [components.ConfirmationDialogModule] });
|
1641
|
+
ConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, providers: [
|
1693
1642
|
i1.ContextApiService,
|
1694
1643
|
i1.ProductModelApiService,
|
1695
1644
|
i1.ConfigurationApiService,
|
@@ -1697,7 +1646,7 @@
|
|
1697
1646
|
RuntimeContextService,
|
1698
1647
|
ConfigurationService,
|
1699
1648
|
], imports: [[components.ConfirmationDialogModule]] });
|
1700
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1649
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, decorators: [{
|
1701
1650
|
type: i0.NgModule,
|
1702
1651
|
args: [{
|
1703
1652
|
imports: [components.ConfirmationDialogModule],
|
@@ -1712,15 +1661,177 @@
|
|
1712
1661
|
}]
|
1713
1662
|
}] });
|
1714
1663
|
|
1664
|
+
function calculateMetricByMethod(lineItems, metric, method) {
|
1665
|
+
var items = getLineItemsByMethod(lineItems, method);
|
1666
|
+
return items.reduce(function (acc, li) {
|
1667
|
+
var value = li.reduce(function (accProduct, item) { return accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0); }, 0);
|
1668
|
+
if (method === 'avg' && li.length > 0) {
|
1669
|
+
value /= li.length;
|
1670
|
+
}
|
1671
|
+
return acc + value;
|
1672
|
+
}, 0);
|
1673
|
+
}
|
1674
|
+
function getLineItemsByMethod(lineItems, method) {
|
1675
|
+
switch (method) {
|
1676
|
+
case 'first': {
|
1677
|
+
return lineItems.filter(function (li) { return !li.rampInstanceId; }).map(function (item) { return [item]; });
|
1678
|
+
}
|
1679
|
+
case 'last': {
|
1680
|
+
var rootTermItems = lineItems.filter(function (li) { return !li.rampInstanceId; });
|
1681
|
+
var products = rootTermItems.map(function (lineItem) { return __spreadArray([
|
1682
|
+
lineItem
|
1683
|
+
], __read(lineItems.filter(function (li) { return li.rampInstanceId === lineItem.id; }))); });
|
1684
|
+
return products
|
1685
|
+
.map(function (items) { return __spreadArray([], __read(items)).sort(function (a, b) { return getDateValue(a.endDate || '') - getDateValue(b.endDate || ''); }).pop(); })
|
1686
|
+
.filter(function (li) { return Boolean(li); })
|
1687
|
+
.map(function (item) { return [item]; });
|
1688
|
+
}
|
1689
|
+
case 'avg': {
|
1690
|
+
var rootTermItems = lineItems.filter(function (li) { return !li.rampInstanceId; });
|
1691
|
+
return rootTermItems.map(function (lineItem) { return __spreadArray([lineItem], __read(lineItems.filter(function (li) { return li.rampInstanceId === lineItem.id; }))); });
|
1692
|
+
}
|
1693
|
+
case 'sum': {
|
1694
|
+
return lineItems.map(function (item) { return [item]; });
|
1695
|
+
}
|
1696
|
+
default: {
|
1697
|
+
return lineItems.map(function (item) { return [item]; });
|
1698
|
+
}
|
1699
|
+
}
|
1700
|
+
}
|
1701
|
+
function getDateValue(date) {
|
1702
|
+
return date ? new Date(date).getTime() : 0;
|
1703
|
+
}
|
1704
|
+
|
1705
|
+
var MetricsCalculationService = /** @class */ (function () {
|
1706
|
+
function MetricsCalculationService(quoteDraftService, flowConfiguration, settingsService) {
|
1707
|
+
var _this = this;
|
1708
|
+
this.quoteDraftService = quoteDraftService;
|
1709
|
+
this.flowConfiguration = flowConfiguration;
|
1710
|
+
this.settingsService = settingsService;
|
1711
|
+
this.metricsUpdated$ = new rxjs.Subject();
|
1712
|
+
this.quoteMetricsSettings = {};
|
1713
|
+
this.metricsCalculationMethodMap = {};
|
1714
|
+
this.metricsData = {};
|
1715
|
+
this.activeMetricRules = [];
|
1716
|
+
this.activeMetricRules = this.flowConfiguration.activeMetricsSnapshot.filter(function (metricRule) { return metricRule.metrics.some(function (metric) { return !!metric.totalName; }); });
|
1717
|
+
rxjs.combineLatest([
|
1718
|
+
this.quoteDraftService.currentState$,
|
1719
|
+
this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(rxjs.take(1)),
|
1720
|
+
]).subscribe(function (_c) {
|
1721
|
+
var _d = __read(_c, 2), lineItems = _d[0], setting = _d[1];
|
1722
|
+
var settingsData = {};
|
1723
|
+
try {
|
1724
|
+
settingsData = JSON.parse((setting === null || setting === void 0 ? void 0 : setting.value) || '{}');
|
1725
|
+
}
|
1726
|
+
catch (error) {
|
1727
|
+
settingsData = {};
|
1728
|
+
}
|
1729
|
+
_this.quoteMetricsSettings = settingsData;
|
1730
|
+
_this.updateMetrics(lineItems);
|
1731
|
+
});
|
1732
|
+
}
|
1733
|
+
Object.defineProperty(MetricsCalculationService.prototype, "onMetricsUpdate$", {
|
1734
|
+
get: function () {
|
1735
|
+
return this.metricsUpdated$.asObservable();
|
1736
|
+
},
|
1737
|
+
enumerable: false,
|
1738
|
+
configurable: true
|
1739
|
+
});
|
1740
|
+
MetricsCalculationService.prototype.getMetricValue = function (metric) {
|
1741
|
+
return this.metricsData[metric] || 0;
|
1742
|
+
};
|
1743
|
+
MetricsCalculationService.prototype.updateMetrics = function (lineItems) {
|
1744
|
+
var _this = this;
|
1745
|
+
var metricKeys = this.collectMetricKeys(lineItems).filter(function (key) { return !key.includes('Effective_'); });
|
1746
|
+
this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
|
1747
|
+
this.metricsData = metricKeys.reduce(function (acc, key) {
|
1748
|
+
var _c;
|
1749
|
+
return (Object.assign(Object.assign({}, acc), (_c = {}, _c[key] = _this.calculateMetric(lineItems, key), _c)));
|
1750
|
+
}, {});
|
1751
|
+
this.metricsUpdated$.next();
|
1752
|
+
};
|
1753
|
+
MetricsCalculationService.prototype.calculateMetric = function (lineItems, metric) {
|
1754
|
+
return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
|
1755
|
+
};
|
1756
|
+
MetricsCalculationService.prototype.buildMetricsCalculationMethods = function (metricKeys, initial) {
|
1757
|
+
var _this = this;
|
1758
|
+
return metricKeys.reduce(function (acc, name) {
|
1759
|
+
var _c, _d;
|
1760
|
+
var _a, _b;
|
1761
|
+
if (acc[name]) {
|
1762
|
+
return acc;
|
1763
|
+
}
|
1764
|
+
acc = Object.assign(Object.assign({}, acc), (_c = {}, _c[name] = 'sum', _c));
|
1765
|
+
var metricRule = _this.getMetricRuleByTotalMetricName(name);
|
1766
|
+
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;
|
1767
|
+
if (_this.quoteMetricsSettings[settingKey]) {
|
1768
|
+
acc = Object.assign(Object.assign({}, acc), (_d = {}, _d[name] = _this.quoteMetricsSettings[settingKey], _d));
|
1769
|
+
}
|
1770
|
+
return acc;
|
1771
|
+
}, initial);
|
1772
|
+
};
|
1773
|
+
MetricsCalculationService.prototype.collectMetricKeys = function (lineItems) {
|
1774
|
+
var _this = this;
|
1775
|
+
var keys = [];
|
1776
|
+
lineItems.forEach(function (lineItem) {
|
1777
|
+
keys.push.apply(keys, __spreadArray([], __read(Object.keys(lineItem.totalMetrics || {}))));
|
1778
|
+
keys.push.apply(keys, __spreadArray([], __read(_this.collectMetricKeys(lineItem.lineItems))));
|
1779
|
+
});
|
1780
|
+
return lodash.uniq(keys);
|
1781
|
+
};
|
1782
|
+
MetricsCalculationService.prototype.getMetricRuleByTotalMetricName = function (name) {
|
1783
|
+
return this.activeMetricRules.find(function (metricRule) { return metricRule.metrics.find(function (metric) { return metric.totalName === name; }); });
|
1784
|
+
};
|
1785
|
+
return MetricsCalculationService;
|
1786
|
+
}());
|
1787
|
+
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 });
|
1788
|
+
MetricsCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, providedIn: 'root' });
|
1789
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, decorators: [{
|
1790
|
+
type: i0.Injectable,
|
1791
|
+
args: [{ providedIn: 'root' }]
|
1792
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: FlowConfigurationService }, { type: i1__namespace.ConfigurationSettingsApiService }]; } });
|
1793
|
+
|
1794
|
+
var ProductImagesService = /** @class */ (function () {
|
1795
|
+
function ProductImagesService(productApiService) {
|
1796
|
+
this.productApiService = productApiService;
|
1797
|
+
this.imagesMap$ = new rxjs.BehaviorSubject({});
|
1798
|
+
}
|
1799
|
+
ProductImagesService.prototype.getImageUrl$ = function (productId) {
|
1800
|
+
var _a;
|
1801
|
+
if (this.imagesMap$.value[productId] == null) {
|
1802
|
+
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), (_a = {}, _a[productId] = '', _a)));
|
1803
|
+
this.fetchProductImage(productId);
|
1804
|
+
}
|
1805
|
+
return this.imagesMap$.pipe(rxjs.map(function (imagesMap) { return imagesMap[productId]; }), rxjs.distinctUntilChanged());
|
1806
|
+
};
|
1807
|
+
ProductImagesService.prototype.fetchProductImage = function (productId) {
|
1808
|
+
var _this = this;
|
1809
|
+
this.productApiService
|
1810
|
+
.fetchImage$(productId)
|
1811
|
+
.pipe(rxjs.map(function (file) { return URL.createObjectURL(file); }), rxjs.catchError(function () { return rxjs.of(''); }), rxjs.tap(function (url) {
|
1812
|
+
var _a;
|
1813
|
+
return _this.imagesMap$.next(Object.assign(Object.assign({}, _this.imagesMap$.value), (_a = {}, _a[productId] = url, _a)));
|
1814
|
+
}))
|
1815
|
+
.subscribe();
|
1816
|
+
};
|
1817
|
+
return ProductImagesService;
|
1818
|
+
}());
|
1819
|
+
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 });
|
1820
|
+
ProductImagesService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, providedIn: 'root' });
|
1821
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, decorators: [{
|
1822
|
+
type: i0.Injectable,
|
1823
|
+
args: [{ providedIn: 'root' }]
|
1824
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.ProductApiService }]; } });
|
1825
|
+
|
1715
1826
|
var SdkCoreModule = /** @class */ (function () {
|
1716
1827
|
function SdkCoreModule() {
|
1717
1828
|
}
|
1718
1829
|
return SdkCoreModule;
|
1719
1830
|
}());
|
1720
|
-
SdkCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
1721
|
-
SdkCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
1722
|
-
SdkCoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
1723
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1831
|
+
SdkCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
1832
|
+
SdkCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
1833
|
+
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]] });
|
1834
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, decorators: [{
|
1724
1835
|
type: i0.NgModule,
|
1725
1836
|
args: [{
|
1726
1837
|
imports: [ConfigurationModule, FlowConfigurationModule],
|
@@ -1743,6 +1854,7 @@
|
|
1743
1854
|
exports.ProductImagesService = ProductImagesService;
|
1744
1855
|
exports.QuoteDraftService = QuoteDraftService;
|
1745
1856
|
exports.SdkCoreModule = SdkCoreModule;
|
1857
|
+
exports.calculateCardinalityVariables = calculateCardinalityVariables;
|
1746
1858
|
exports.findLineItem = findLineItem;
|
1747
1859
|
exports.findLineItemWithComparator = findLineItemWithComparator;
|
1748
1860
|
exports.generateLineItem = generateLineItem;
|
@@ -1755,6 +1867,7 @@
|
|
1755
1867
|
exports.mapAttributes = mapAttributes;
|
1756
1868
|
exports.multiplyLineItems = multiplyLineItems;
|
1757
1869
|
exports.patchAttributes = patchAttributes;
|
1870
|
+
exports.recalculateCardinalityVariables = recalculateCardinalityVariables;
|
1758
1871
|
exports.removeLineItem = removeLineItem;
|
1759
1872
|
exports.replaceLineItem = replaceLineItem;
|
1760
1873
|
exports.upsertAttributes = upsertAttributes;
|