@veloceapps/sdk 5.0.14-9 → 5.0.15-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/veloceapps-sdk-cms.umd.js +133 -66
- package/bundles/veloceapps-sdk-cms.umd.js.map +1 -1
- package/bundles/veloceapps-sdk-core.umd.js +687 -620
- 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 +200 -133
- package/bundles/veloceapps-sdk.umd.js.map +1 -1
- package/cms/vendor-map.d.ts +15 -12
- package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
- package/core/modules/configuration/services/configuration.service.d.ts +2 -1
- package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +3 -2
- 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 +3 -3
- package/esm2015/cms/services/templates.service.js +3 -3
- 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 -5
- package/esm2015/core/modules/configuration/services/configuration.service.js +11 -10
- package/esm2015/core/modules/configuration/services/runtime-context.service.js +3 -3
- package/esm2015/core/modules/flow-configuration/flow-configuration.module.js +4 -4
- package/esm2015/core/modules/flow-configuration/services/flow-configuration.service.js +10 -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 +3 -3
- package/esm2015/core/services/product-images.service.js +3 -3
- package/esm2015/core/services/quote-draft.service.js +3 -3
- 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 +3 -3
- 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 +3 -3
- 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 +3 -3
- 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/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 +3 -3
- package/esm2015/src/components/header/header.module.js +4 -4
- package/esm2015/src/components/header/metrics/metrics.component.js +3 -3
- 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 +3 -3
- package/esm2015/src/pages/legacy-product/legacy-product.module.js +4 -4
- package/esm2015/src/pages/product/product.component.js +3 -3
- 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 +3 -3
- 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 +3 -3
- 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/fesm2015/veloceapps-sdk-cms.js +62 -62
- package/fesm2015/veloceapps-sdk-cms.js.map +1 -1
- package/fesm2015/veloceapps-sdk-core.js +460 -460
- 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 +129 -129
- package/fesm2015/veloceapps-sdk.js.map +1 -1
- package/package.json +1 -1
@@ -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,147 +483,416 @@
|
|
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
|
-
|
492
|
-
|
548
|
+
ConfigurationRuntimeService.prototype.reset = function () {
|
549
|
+
this._isInitialized = false;
|
550
|
+
this._runtimeContext = undefined;
|
551
|
+
this._assets = undefined;
|
552
|
+
this.initializationProps = undefined;
|
553
|
+
this.uiDefinitionProperties = {};
|
554
|
+
};
|
555
|
+
ConfigurationRuntimeService.prototype.initTestMode = function (modelId, uiDefinition) {
|
556
|
+
var _this = this;
|
557
|
+
var _a, _b;
|
558
|
+
this.uiDefinitionProperties = (_a = uiDefinition.properties) !== null && _a !== void 0 ? _a : {};
|
559
|
+
var uiDefinitionExternals = (_b = uiDefinition.externals) !== null && _b !== void 0 ? _b : {};
|
560
|
+
return rxjs.combineLatest([
|
561
|
+
this.apiService.getRuntimeDataByModelId(modelId),
|
562
|
+
this.contextService.create('TestId', core.ConfigurationContextMode.TEST),
|
563
|
+
]).pipe(operators.first(), operators.tap(function (_e) {
|
564
|
+
var _f = __read(_e, 2), runtimeData = _f[0], context = _f[1];
|
565
|
+
var _a;
|
566
|
+
_this._runtimeContext = {
|
567
|
+
modelId: modelId,
|
568
|
+
runtimeModel: core.RuntimeModel.create(runtimeData.types, runtimeData.products),
|
569
|
+
runtimeMode: exports.RuntimeMode.TEST,
|
570
|
+
};
|
571
|
+
_this.contextService.update({
|
572
|
+
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),
|
573
|
+
});
|
574
|
+
_this._isInitialized = true;
|
575
|
+
}));
|
576
|
+
};
|
577
|
+
ConfigurationRuntimeService.prototype.init = function (props) {
|
578
|
+
var _this = this;
|
579
|
+
this.initializationProps = props;
|
580
|
+
this._assets = props.assets;
|
581
|
+
var context = this.contextService.resolve();
|
582
|
+
return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(operators.tap(function (runtimeContext) {
|
583
|
+
var _a, _b, _c, _d;
|
584
|
+
_this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinition) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {};
|
585
|
+
var PriceListId = ((_c = context.properties) !== null && _c !== void 0 ? _c : {}).PriceListId;
|
586
|
+
var mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
|
587
|
+
_this.id15to18('AccountId', mergeContext.properties);
|
588
|
+
_this._runtimeContext = mergeContext;
|
589
|
+
if (context.properties && ((_d = _this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
|
590
|
+
_this.contextService.update({
|
591
|
+
properties: Object.assign(Object.assign({}, _this._runtimeContext.properties), context.properties),
|
592
|
+
});
|
493
593
|
}
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
594
|
+
_this._isInitialized = true;
|
595
|
+
}));
|
596
|
+
};
|
597
|
+
ConfigurationRuntimeService.prototype.id15to18 = function (propertyName, source) {
|
598
|
+
if (!source) {
|
599
|
+
return;
|
600
|
+
}
|
601
|
+
var value = source[propertyName];
|
602
|
+
if (typeof value === 'string' && value.length === 15) {
|
603
|
+
source[propertyName] = core.SalesforceIdUtils.generateId18FromId15(value);
|
604
|
+
}
|
605
|
+
};
|
606
|
+
ConfigurationRuntimeService.prototype.getAsset = function (lineItem) {
|
607
|
+
return this._assets && this._assets.find(function (a) { return a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId; });
|
608
|
+
};
|
609
|
+
Object.defineProperty(ConfigurationRuntimeService.prototype, "isInitialized", {
|
499
610
|
get: function () {
|
500
|
-
return this.
|
501
|
-
},
|
502
|
-
set: function (value) {
|
503
|
-
var _a, _b;
|
504
|
-
this._hasUnsavedChanges = value;
|
505
|
-
if (!this._hasUnsavedChanges) {
|
506
|
-
this.initialCurrentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
507
|
-
}
|
611
|
+
return this._isInitialized;
|
508
612
|
},
|
509
613
|
enumerable: false,
|
510
614
|
configurable: true
|
511
615
|
});
|
512
|
-
Object.defineProperty(
|
616
|
+
Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeModel", {
|
513
617
|
get: function () {
|
514
|
-
var
|
515
|
-
return this.
|
618
|
+
var _a;
|
619
|
+
return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
|
516
620
|
},
|
517
621
|
enumerable: false,
|
518
622
|
configurable: true
|
519
623
|
});
|
520
|
-
Object.defineProperty(
|
624
|
+
Object.defineProperty(ConfigurationRuntimeService.prototype, "runtimeContext", {
|
521
625
|
get: function () {
|
522
|
-
|
523
|
-
return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
|
626
|
+
return this._runtimeContext;
|
524
627
|
},
|
525
628
|
enumerable: false,
|
526
629
|
configurable: true
|
527
630
|
});
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
if (!quoteDraft) {
|
546
|
-
return;
|
547
|
-
}
|
548
|
-
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
|
549
|
-
};
|
550
|
-
QuoteDraftService.prototype.updateQuoteDraft = function (update) {
|
551
|
-
var quoteDraft = this.quoteSubj$.value;
|
552
|
-
if (!quoteDraft) {
|
553
|
-
return;
|
554
|
-
}
|
555
|
-
if (update.context) {
|
556
|
-
this.context.set(update.context);
|
631
|
+
return ConfigurationRuntimeService;
|
632
|
+
}());
|
633
|
+
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 });
|
634
|
+
ConfigurationRuntimeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService });
|
635
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationRuntimeService, decorators: [{
|
636
|
+
type: i0.Injectable
|
637
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
|
638
|
+
|
639
|
+
var findLineItem = function (id, lineItems) {
|
640
|
+
return findLineItemWithComparator(lineItems, function (li) { return li.id === id; });
|
641
|
+
};
|
642
|
+
var findLineItemWithComparator = function (lineItems, comparator) {
|
643
|
+
var currentLevel = lineItems;
|
644
|
+
while (currentLevel.length) {
|
645
|
+
var found = currentLevel.find(comparator);
|
646
|
+
if (found) {
|
647
|
+
return found;
|
557
648
|
}
|
558
|
-
|
559
|
-
}
|
649
|
+
currentLevel = lodash.flatten(currentLevel.map(function (parent) { return parent.lineItems; }));
|
650
|
+
}
|
651
|
+
return;
|
652
|
+
};
|
653
|
+
var insertLineItem = function (lineItem, parentId, toInsert) {
|
654
|
+
var insertData = lineItem.id === parentId ? [toInsert] : [];
|
655
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: __spreadArray(__spreadArray([], __read(insertData)), __read(lineItem.lineItems.map(function (li) {
|
656
|
+
return insertLineItem(li, parentId, toInsert);
|
657
|
+
}))) });
|
658
|
+
};
|
659
|
+
var removeLineItem = function (lineItem, idToRemove) {
|
660
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems
|
661
|
+
.map(function (li) {
|
662
|
+
if (li.id === idToRemove) {
|
663
|
+
return;
|
664
|
+
}
|
665
|
+
else if (li.lineItems.length) {
|
666
|
+
return removeLineItem(li, idToRemove);
|
667
|
+
}
|
668
|
+
return li;
|
669
|
+
})
|
670
|
+
.filter(function (r) { return !!r; }) });
|
671
|
+
};
|
672
|
+
var replaceLineItem = function (lineItem, replaceTo) {
|
673
|
+
if (lineItem.id === replaceTo.id) {
|
674
|
+
return Object.assign({}, replaceTo);
|
675
|
+
}
|
676
|
+
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) {
|
677
|
+
if (li.id === replaceTo.id) {
|
678
|
+
return replaceTo;
|
679
|
+
}
|
680
|
+
else if (li.lineItems.length) {
|
681
|
+
return replaceLineItem(li, replaceTo);
|
682
|
+
}
|
683
|
+
return li;
|
684
|
+
}) });
|
685
|
+
};
|
686
|
+
var mapAttributes = function (attributes) {
|
687
|
+
return attributes.reduce(function (acc, _c) {
|
688
|
+
var _d;
|
689
|
+
var name = _c.name, value = _c.value;
|
690
|
+
return (Object.assign(Object.assign({}, acc), (_d = {}, _d[name] = value, _d)));
|
691
|
+
}, {});
|
692
|
+
};
|
693
|
+
var getAttributes = function (attributes, names) {
|
694
|
+
if (names === void 0) { names = []; }
|
695
|
+
var filtered = attributes.filter(function (_c) {
|
696
|
+
var name = _c.name;
|
697
|
+
return names.includes(name);
|
698
|
+
});
|
699
|
+
return lodash.sortBy(filtered, [function (_c) {
|
700
|
+
var name = _c.name;
|
701
|
+
return names.indexOf(name);
|
702
|
+
}]);
|
703
|
+
};
|
704
|
+
var upsertAttributes = function (originalAttributes, attributesToUpsert) {
|
705
|
+
return attributesToUpsert.reduce(function (acc, _c) {
|
706
|
+
var name = _c.name, value = _c.value;
|
707
|
+
var _d = __read(getAttributes(acc, [name]), 1), origAttr = _d[0];
|
708
|
+
return __spreadArray(__spreadArray([], __read(acc.filter(function (attr) { return attr.name !== name; }))), [
|
709
|
+
Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name: name })), { cfgStatus: 'User', value: value }),
|
710
|
+
]);
|
711
|
+
}, originalAttributes);
|
712
|
+
};
|
713
|
+
var patchAttributes = function (rootLineItem, id, attrs) {
|
714
|
+
var lineItem = findLineItem(id, [rootLineItem]);
|
715
|
+
if (!lineItem) {
|
716
|
+
return rootLineItem;
|
717
|
+
}
|
718
|
+
var attributes = upsertAttributes(lineItem.attributes, attrs);
|
719
|
+
return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes: attributes }));
|
720
|
+
};
|
721
|
+
var getAttributeValue = function (attributes, name) { var _a; return (_a = attributes.find(function (attr) { return attr.name === name; })) === null || _a === void 0 ? void 0 : _a.value; };
|
722
|
+
var generateLineItem = function (port, type, parentId, attributes, lineItems) {
|
723
|
+
if (attributes === void 0) { attributes = []; }
|
724
|
+
if (lineItems === void 0) { lineItems = []; }
|
725
|
+
return {
|
726
|
+
id: core.UUID.UUID(),
|
727
|
+
port: port,
|
728
|
+
type: type,
|
729
|
+
actionCode: 'ADD',
|
730
|
+
cfgStatus: 'New',
|
731
|
+
attributes: attributes.map(function (_c) {
|
732
|
+
var name = _c.name, value = _c.value;
|
733
|
+
return ({ cfgStatus: 'User', name: name, value: value });
|
734
|
+
}),
|
735
|
+
lineItems: lineItems,
|
736
|
+
parentId: parentId,
|
737
|
+
qty: 1,
|
738
|
+
};
|
739
|
+
};
|
740
|
+
var getRecommendedPrices = function (portDomain, type) {
|
741
|
+
var _a, _b;
|
742
|
+
var domainType = portDomain.domainTypes.find(function (_c) {
|
743
|
+
var name = _c.name;
|
744
|
+
return name === type;
|
745
|
+
});
|
746
|
+
var _c = __read((_b = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.recommendedPrices) === null || _a === void 0 ? void 0 : _a.filter(function (_c) {
|
747
|
+
var chargeMethod = _c.chargeMethod;
|
748
|
+
return chargeMethod === 'ONE_TIME';
|
749
|
+
}).reduce(function (acc, rp) {
|
750
|
+
var _c = __read(acc, 2), netPrice = _c[0], listPrice = _c[1];
|
751
|
+
return [netPrice + rp.netPrice, listPrice + rp.listPrice];
|
752
|
+
}, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0], 2), net = _c[0], list = _c[1];
|
753
|
+
return { net: net, list: list };
|
754
|
+
};
|
755
|
+
var multiplyLineItems = function (lineItem, qty, split) {
|
756
|
+
if (split) {
|
757
|
+
var unifyIds_1 = function (lineItem) { return (Object.assign(Object.assign({}, lineItem), { id: core.UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds_1) })); };
|
758
|
+
return lodash.map(new Array(qty), function () { return unifyIds_1(lineItem); });
|
759
|
+
}
|
760
|
+
else {
|
761
|
+
return [
|
762
|
+
Object.assign(Object.assign({}, lineItem), { qty: qty }),
|
763
|
+
];
|
764
|
+
}
|
765
|
+
};
|
766
|
+
|
767
|
+
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
768
|
+
__proto__: null,
|
769
|
+
findLineItem: findLineItem,
|
770
|
+
findLineItemWithComparator: findLineItemWithComparator,
|
771
|
+
insertLineItem: insertLineItem,
|
772
|
+
removeLineItem: removeLineItem,
|
773
|
+
replaceLineItem: replaceLineItem,
|
774
|
+
mapAttributes: mapAttributes,
|
775
|
+
getAttributes: getAttributes,
|
776
|
+
upsertAttributes: upsertAttributes,
|
777
|
+
patchAttributes: patchAttributes,
|
778
|
+
getAttributeValue: getAttributeValue,
|
779
|
+
generateLineItem: generateLineItem,
|
780
|
+
getRecommendedPrices: getRecommendedPrices,
|
781
|
+
multiplyLineItems: multiplyLineItems
|
782
|
+
});
|
783
|
+
|
784
|
+
var LineItemWorker = /** @class */ (function () {
|
785
|
+
function LineItemWorker(src) {
|
786
|
+
this.li = Object.assign({}, src);
|
787
|
+
}
|
788
|
+
LineItemWorker.prototype.insert = function (parentId, toInsert) {
|
789
|
+
return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
|
790
|
+
};
|
791
|
+
LineItemWorker.prototype.remove = function (id) {
|
792
|
+
return new LineItemWorker(removeLineItem(this.li, id));
|
793
|
+
};
|
794
|
+
LineItemWorker.prototype.replace = function (toReplace) {
|
795
|
+
return new LineItemWorker(replaceLineItem(this.li, toReplace));
|
796
|
+
};
|
797
|
+
LineItemWorker.prototype.patchAttribute = function (attrs, id) {
|
798
|
+
return new LineItemWorker(patchAttributes(this.li, id !== null && id !== void 0 ? id : this.li.id, attrs));
|
799
|
+
};
|
800
|
+
return LineItemWorker;
|
801
|
+
}());
|
802
|
+
|
803
|
+
var QuoteDraftService = /** @class */ (function () {
|
804
|
+
function QuoteDraftService(context, quoteApiService, priceApiService) {
|
805
|
+
var _this = this;
|
806
|
+
this.context = context;
|
807
|
+
this.quoteApiService = quoteApiService;
|
808
|
+
this.priceApiService = priceApiService;
|
809
|
+
this.quoteSubj$ = new rxjs.BehaviorSubject(null);
|
810
|
+
this.resetSubj$ = new rxjs.BehaviorSubject(true);
|
811
|
+
this.isInitializedSubj$ = new rxjs.BehaviorSubject(false);
|
812
|
+
this.initialCurrentState = [];
|
813
|
+
this._hasUnsavedChanges = false;
|
814
|
+
this.allPriceLists = [];
|
815
|
+
this.assetPriceLists = [];
|
816
|
+
this.reset$ = this.resetSubj$.asObservable();
|
817
|
+
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; }));
|
818
|
+
this.isInitializedSubj$
|
819
|
+
.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); }))
|
820
|
+
.subscribe();
|
821
|
+
}
|
822
|
+
Object.defineProperty(QuoteDraftService.prototype, "isInitialized", {
|
823
|
+
get: function () {
|
824
|
+
return this.isInitializedSubj$.getValue();
|
825
|
+
},
|
826
|
+
set: function (value) {
|
827
|
+
if (this.isInitialized !== value) {
|
828
|
+
this.isInitializedSubj$.next(value);
|
829
|
+
}
|
830
|
+
},
|
831
|
+
enumerable: false,
|
832
|
+
configurable: true
|
833
|
+
});
|
834
|
+
Object.defineProperty(QuoteDraftService.prototype, "hasUnsavedChanges", {
|
835
|
+
get: function () {
|
836
|
+
return this._hasUnsavedChanges;
|
837
|
+
},
|
838
|
+
set: function (value) {
|
839
|
+
var _a, _b;
|
840
|
+
this._hasUnsavedChanges = value;
|
841
|
+
if (!this._hasUnsavedChanges) {
|
842
|
+
this.initialCurrentState = (_b = (_a = this.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) !== null && _b !== void 0 ? _b : [];
|
843
|
+
}
|
844
|
+
},
|
845
|
+
enumerable: false,
|
846
|
+
configurable: true
|
847
|
+
});
|
848
|
+
Object.defineProperty(QuoteDraftService.prototype, "hasAssets$", {
|
849
|
+
get: function () {
|
850
|
+
var _this = this;
|
851
|
+
return this.quoteSubj$.pipe(operators.map(function () { return _this.hasAssets; }));
|
852
|
+
},
|
853
|
+
enumerable: false,
|
854
|
+
configurable: true
|
855
|
+
});
|
856
|
+
Object.defineProperty(QuoteDraftService.prototype, "hasAssets", {
|
857
|
+
get: function () {
|
858
|
+
var quoteDraft = this.quoteSubj$.value;
|
859
|
+
return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
|
860
|
+
},
|
861
|
+
enumerable: false,
|
862
|
+
configurable: true
|
863
|
+
});
|
864
|
+
QuoteDraftService.prototype.reset = function () {
|
865
|
+
this.resetSubj$.next(true);
|
866
|
+
this.quoteSubj$.next(null);
|
867
|
+
this.hasUnsavedChanges = false;
|
868
|
+
};
|
869
|
+
QuoteDraftService.prototype.init = function (quoteId, params) {
|
870
|
+
var _this = this;
|
871
|
+
return rxjs.zip(this.quoteApiService.getQuoteDraft(quoteId, params), this.priceApiService.getPriceLists()).pipe(operators.tap(function (_c) {
|
872
|
+
var _d = __read(_c, 2), quote = _d[0], allPriceLists = _d[1];
|
873
|
+
_this.allPriceLists = allPriceLists;
|
874
|
+
_this.quoteSubj$.next(quote);
|
875
|
+
_this.context.update(quote.context);
|
876
|
+
_this.populateActivePriceLists$();
|
877
|
+
}), operators.map(function () { return rxjs.noop(); }), operators.take(1));
|
878
|
+
};
|
879
|
+
QuoteDraftService.prototype.setCurrentLineItemState = function (lineItems) {
|
880
|
+
var quoteDraft = this.quoteSubj$.value;
|
881
|
+
if (!quoteDraft) {
|
882
|
+
return;
|
883
|
+
}
|
884
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), { currentState: lineItems }));
|
885
|
+
};
|
886
|
+
QuoteDraftService.prototype.updateQuoteDraft = function (update) {
|
887
|
+
var quoteDraft = this.quoteSubj$.value;
|
888
|
+
if (!quoteDraft) {
|
889
|
+
return;
|
890
|
+
}
|
891
|
+
if (update.context) {
|
892
|
+
this.context.set(update.context);
|
893
|
+
}
|
894
|
+
this.quoteSubj$.next(Object.assign(Object.assign({}, quoteDraft), update));
|
895
|
+
};
|
560
896
|
QuoteDraftService.prototype.updateByPriceSummary = function (priceSummary) {
|
561
897
|
var quoteDraft = this.quoteSubj$.value;
|
562
898
|
if (!quoteDraft) {
|
@@ -686,488 +1022,65 @@
|
|
686
1022
|
var _this = this;
|
687
1023
|
return this.context.resolve$().pipe(operators.map(function () { return _this.isEditMode(); }));
|
688
1024
|
};
|
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", {
|
994
|
-
get: function () {
|
995
|
-
return this._runtimeContext;
|
996
|
-
},
|
997
|
-
enumerable: false,
|
998
|
-
configurable: true
|
999
|
-
});
|
1000
|
-
return ConfigurationRuntimeService;
|
1001
|
-
}());
|
1002
|
-
ConfigurationRuntimeService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationRuntimeService, deps: [{ token: i1__namespace.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1003
|
-
ConfigurationRuntimeService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationRuntimeService });
|
1004
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.15", ngImport: i0__namespace, type: ConfigurationRuntimeService, decorators: [{
|
1005
|
-
type: i0.Injectable
|
1006
|
-
}], ctorParameters: function () { return [{ type: i1__namespace.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
|
1007
|
-
|
1008
|
-
var findLineItem = function (id, lineItems) {
|
1009
|
-
return findLineItemWithComparator(lineItems, function (li) { return li.id === id; });
|
1010
|
-
};
|
1011
|
-
var findLineItemWithComparator = function (lineItems, comparator) {
|
1012
|
-
var currentLevel = lineItems;
|
1013
|
-
while (currentLevel.length) {
|
1014
|
-
var found = currentLevel.find(comparator);
|
1015
|
-
if (found) {
|
1016
|
-
return found;
|
1017
|
-
}
|
1018
|
-
currentLevel = lodash.flatten(currentLevel.map(function (parent) { return parent.lineItems; }));
|
1019
|
-
}
|
1020
|
-
return;
|
1021
|
-
};
|
1022
|
-
var insertLineItem = function (lineItem, parentId, toInsert) {
|
1023
|
-
var insertData = lineItem.id === parentId ? [toInsert] : [];
|
1024
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: __spreadArray(__spreadArray([], __read(insertData)), __read(lineItem.lineItems.map(function (li) {
|
1025
|
-
return insertLineItem(li, parentId, toInsert);
|
1026
|
-
}))) });
|
1027
|
-
};
|
1028
|
-
var removeLineItem = function (lineItem, idToRemove) {
|
1029
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems
|
1030
|
-
.map(function (li) {
|
1031
|
-
if (li.id === idToRemove) {
|
1032
|
-
return;
|
1033
|
-
}
|
1034
|
-
else if (li.lineItems.length) {
|
1035
|
-
return removeLineItem(li, idToRemove);
|
1036
|
-
}
|
1037
|
-
return li;
|
1038
|
-
})
|
1039
|
-
.filter(function (r) { return !!r; }) });
|
1040
|
-
};
|
1041
|
-
var replaceLineItem = function (lineItem, replaceTo) {
|
1042
|
-
if (lineItem.id === replaceTo.id) {
|
1043
|
-
return Object.assign({}, replaceTo);
|
1044
|
-
}
|
1045
|
-
return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(function (li) {
|
1046
|
-
if (li.id === replaceTo.id) {
|
1047
|
-
return replaceTo;
|
1048
|
-
}
|
1049
|
-
else if (li.lineItems.length) {
|
1050
|
-
return replaceLineItem(li, replaceTo);
|
1051
|
-
}
|
1052
|
-
return li;
|
1053
|
-
}) });
|
1054
|
-
};
|
1055
|
-
var mapAttributes = function (attributes) {
|
1056
|
-
return attributes.reduce(function (acc, _c) {
|
1057
|
-
var _d;
|
1058
|
-
var name = _c.name, value = _c.value;
|
1059
|
-
return (Object.assign(Object.assign({}, acc), (_d = {}, _d[name] = value, _d)));
|
1060
|
-
}, {});
|
1061
|
-
};
|
1062
|
-
var getAttributes = function (attributes, names) {
|
1063
|
-
if (names === void 0) { names = []; }
|
1064
|
-
var filtered = attributes.filter(function (_c) {
|
1065
|
-
var name = _c.name;
|
1066
|
-
return names.includes(name);
|
1067
|
-
});
|
1068
|
-
return lodash.sortBy(filtered, [function (_c) {
|
1069
|
-
var name = _c.name;
|
1070
|
-
return names.indexOf(name);
|
1071
|
-
}]);
|
1072
|
-
};
|
1073
|
-
var upsertAttributes = function (originalAttributes, attributesToUpsert) {
|
1074
|
-
return attributesToUpsert.reduce(function (acc, _c) {
|
1075
|
-
var name = _c.name, value = _c.value;
|
1076
|
-
var _d = __read(getAttributes(acc, [name]), 1), origAttr = _d[0];
|
1077
|
-
return __spreadArray(__spreadArray([], __read(acc.filter(function (attr) { return attr.name !== name; }))), [
|
1078
|
-
Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name: name })), { cfgStatus: 'User', value: value }),
|
1079
|
-
]);
|
1080
|
-
}, originalAttributes);
|
1081
|
-
};
|
1082
|
-
var patchAttributes = function (rootLineItem, id, attrs) {
|
1083
|
-
var lineItem = findLineItem(id, [rootLineItem]);
|
1084
|
-
if (!lineItem) {
|
1085
|
-
return rootLineItem;
|
1086
|
-
}
|
1087
|
-
var attributes = upsertAttributes(lineItem.attributes, attrs);
|
1088
|
-
return replaceLineItem(rootLineItem, Object.assign(Object.assign({}, lineItem), { attributes: attributes }));
|
1089
|
-
};
|
1090
|
-
var getAttributeValue = function (attributes, name) { var _a; return (_a = attributes.find(function (attr) { return attr.name === name; })) === null || _a === void 0 ? void 0 : _a.value; };
|
1091
|
-
var generateLineItem = function (port, type, parentId, attributes, lineItems) {
|
1092
|
-
if (attributes === void 0) { attributes = []; }
|
1093
|
-
if (lineItems === void 0) { lineItems = []; }
|
1094
|
-
return {
|
1095
|
-
id: core.UUID.UUID(),
|
1096
|
-
port: port,
|
1097
|
-
type: type,
|
1098
|
-
actionCode: 'ADD',
|
1099
|
-
cfgStatus: 'New',
|
1100
|
-
attributes: attributes.map(function (_c) {
|
1101
|
-
var name = _c.name, value = _c.value;
|
1102
|
-
return ({ cfgStatus: 'User', name: name, value: value });
|
1103
|
-
}),
|
1104
|
-
lineItems: lineItems,
|
1105
|
-
parentId: parentId,
|
1106
|
-
qty: 1,
|
1025
|
+
QuoteDraftService.prototype.isEditMode = function () {
|
1026
|
+
var context = this.context.resolve();
|
1027
|
+
if (context.mode === core.ConfigurationContextMode.ACCOUNT) {
|
1028
|
+
return true;
|
1029
|
+
}
|
1030
|
+
if (context.mode === core.ConfigurationContextMode.QUOTE) {
|
1031
|
+
return context.properties.Status === 'Draft';
|
1032
|
+
}
|
1033
|
+
return false;
|
1107
1034
|
};
|
1108
|
-
|
1109
|
-
|
1110
|
-
var _a, _b;
|
1111
|
-
var domainType = portDomain.domainTypes.find(function (_c) {
|
1112
|
-
var name = _c.name;
|
1113
|
-
return name === type;
|
1114
|
-
});
|
1115
|
-
var _c = __read((_b = (_a = domainType === null || domainType === void 0 ? void 0 : domainType.recommendedPrices) === null || _a === void 0 ? void 0 : _a.filter(function (_c) {
|
1116
|
-
var chargeMethod = _c.chargeMethod;
|
1117
|
-
return chargeMethod === 'ONE_TIME';
|
1118
|
-
}).reduce(function (acc, rp) {
|
1119
|
-
var _c = __read(acc, 2), netPrice = _c[0], listPrice = _c[1];
|
1120
|
-
return [netPrice + rp.netPrice, listPrice + rp.listPrice];
|
1121
|
-
}, [0, 0])) !== null && _b !== void 0 ? _b : [0, 0], 2), net = _c[0], list = _c[1];
|
1122
|
-
return { net: net, list: list };
|
1123
|
-
};
|
1124
|
-
var multiplyLineItems = function (lineItem, qty, split) {
|
1125
|
-
if (split) {
|
1126
|
-
var unifyIds_1 = function (lineItem) { return (Object.assign(Object.assign({}, lineItem), { id: core.UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds_1) })); };
|
1127
|
-
return lodash.map(new Array(qty), function () { return unifyIds_1(lineItem); });
|
1128
|
-
}
|
1129
|
-
else {
|
1130
|
-
return [
|
1131
|
-
Object.assign(Object.assign({}, lineItem), { qty: qty }),
|
1132
|
-
];
|
1133
|
-
}
|
1134
|
-
};
|
1135
|
-
|
1136
|
-
var lineItem_utils = /*#__PURE__*/Object.freeze({
|
1137
|
-
__proto__: null,
|
1138
|
-
findLineItem: findLineItem,
|
1139
|
-
findLineItemWithComparator: findLineItemWithComparator,
|
1140
|
-
insertLineItem: insertLineItem,
|
1141
|
-
removeLineItem: removeLineItem,
|
1142
|
-
replaceLineItem: replaceLineItem,
|
1143
|
-
mapAttributes: mapAttributes,
|
1144
|
-
getAttributes: getAttributes,
|
1145
|
-
upsertAttributes: upsertAttributes,
|
1146
|
-
patchAttributes: patchAttributes,
|
1147
|
-
getAttributeValue: getAttributeValue,
|
1148
|
-
generateLineItem: generateLineItem,
|
1149
|
-
getRecommendedPrices: getRecommendedPrices,
|
1150
|
-
multiplyLineItems: multiplyLineItems
|
1151
|
-
});
|
1152
|
-
|
1153
|
-
var LineItemWorker = /** @class */ (function () {
|
1154
|
-
function LineItemWorker(src) {
|
1155
|
-
this.li = Object.assign({}, src);
|
1156
|
-
}
|
1157
|
-
LineItemWorker.prototype.insert = function (parentId, toInsert) {
|
1158
|
-
return new LineItemWorker(insertLineItem(this.li, parentId, toInsert));
|
1035
|
+
QuoteDraftService.prototype.updateActivePriceList = function (priceListId) {
|
1036
|
+
this.context.update({ properties: { PriceListId: priceListId } });
|
1159
1037
|
};
|
1160
|
-
|
1161
|
-
|
1038
|
+
QuoteDraftService.prototype.populateActivePriceLists$ = function () {
|
1039
|
+
var _this = this;
|
1040
|
+
var ctx = this.context.resolve();
|
1041
|
+
var quoteDraft = this.quoteDraft;
|
1042
|
+
if (!quoteDraft) {
|
1043
|
+
return;
|
1044
|
+
}
|
1045
|
+
// In ACCOUNT mode populate price lists from related assets
|
1046
|
+
if (ctx.mode === core.ConfigurationContextMode.ACCOUNT) {
|
1047
|
+
// Populate list of price lists
|
1048
|
+
this.assetPriceLists = quoteDraft.currentState
|
1049
|
+
.map(function (_c) {
|
1050
|
+
var priceListId = _c.priceListId;
|
1051
|
+
return priceListId;
|
1052
|
+
})
|
1053
|
+
.reduce(function (trunk, priceListId) {
|
1054
|
+
var _a, _b;
|
1055
|
+
if (!priceListId || trunk.some(function (item) { return item.id === priceListId; })) {
|
1056
|
+
return trunk;
|
1057
|
+
}
|
1058
|
+
return __spreadArray(__spreadArray([], __read(trunk)), [
|
1059
|
+
{ 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 : '' },
|
1060
|
+
]);
|
1061
|
+
}, []);
|
1062
|
+
}
|
1162
1063
|
};
|
1163
|
-
|
1164
|
-
|
1064
|
+
QuoteDraftService.prototype.filterByActivePriceList = function (lineItems) {
|
1065
|
+
var ctx = this.context.resolve();
|
1066
|
+
return lineItems.filter(function (li) { return !li.priceListId || li.priceListId === ctx.properties.PriceListId; });
|
1165
1067
|
};
|
1166
|
-
|
1167
|
-
|
1068
|
+
QuoteDraftService.prototype.markAsUpdated = function (quote) {
|
1069
|
+
if ((quote === null || quote === void 0 ? void 0 : quote.context.properties.mode) === core.ConfigurationContextMode.ACCOUNT) {
|
1070
|
+
this.hasUnsavedChanges = !!quote && !quote.currentState.every(function (li) { return li.actionCode === 'EXIST'; });
|
1071
|
+
}
|
1072
|
+
else {
|
1073
|
+
this.hasUnsavedChanges = !lodash.isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
|
1074
|
+
}
|
1168
1075
|
};
|
1169
|
-
return
|
1076
|
+
return QuoteDraftService;
|
1170
1077
|
}());
|
1078
|
+
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 });
|
1079
|
+
QuoteDraftService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, providedIn: 'root' });
|
1080
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: QuoteDraftService, decorators: [{
|
1081
|
+
type: i0.Injectable,
|
1082
|
+
args: [{ providedIn: 'root' }]
|
1083
|
+
}], ctorParameters: function () { return [{ type: ContextService }, { type: i1__namespace.QuoteApiService }, { type: i1__namespace.PriceApiService }]; } });
|
1171
1084
|
|
1172
1085
|
var ConfigurationService = /** @class */ (function () {
|
1173
1086
|
function ConfigurationService(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
|
@@ -1352,11 +1265,11 @@
|
|
1352
1265
|
};
|
1353
1266
|
return ConfigurationService;
|
1354
1267
|
}());
|
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.
|
1268
|
+
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 });
|
1269
|
+
ConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService });
|
1270
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationService, decorators: [{
|
1358
1271
|
type: i0.Injectable
|
1359
|
-
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type:
|
1272
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1__namespace.ConfigurationApiService }, { type: i5__namespace.MessageService }, { type: i6__namespace.DialogService }]; } });
|
1360
1273
|
|
1361
1274
|
var FlowUpdateService = /** @class */ (function () {
|
1362
1275
|
function FlowUpdateService() {
|
@@ -1482,9 +1395,9 @@
|
|
1482
1395
|
};
|
1483
1396
|
return FlowUpdateService;
|
1484
1397
|
}());
|
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.
|
1398
|
+
FlowUpdateService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1399
|
+
FlowUpdateService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService });
|
1400
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowUpdateService, decorators: [{
|
1488
1401
|
type: i0.Injectable
|
1489
1402
|
}] });
|
1490
1403
|
|
@@ -1660,9 +1573,9 @@
|
|
1660
1573
|
};
|
1661
1574
|
return FlowConfigurationService;
|
1662
1575
|
}());
|
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.
|
1576
|
+
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 });
|
1577
|
+
FlowConfigurationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService });
|
1578
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationService, decorators: [{
|
1666
1579
|
type: i0.Injectable
|
1667
1580
|
}], ctorParameters: function () { return [{ type: i1__namespace.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
|
1668
1581
|
|
@@ -1671,10 +1584,10 @@
|
|
1671
1584
|
}
|
1672
1585
|
return FlowConfigurationModule;
|
1673
1586
|
}());
|
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.
|
1587
|
+
FlowConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
1588
|
+
FlowConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule });
|
1589
|
+
FlowConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, i1.PriceApiService], imports: [[]] });
|
1590
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FlowConfigurationModule, decorators: [{
|
1678
1591
|
type: i0.NgModule,
|
1679
1592
|
args: [{
|
1680
1593
|
imports: [],
|
@@ -1687,9 +1600,9 @@
|
|
1687
1600
|
}
|
1688
1601
|
return ConfigurationModule;
|
1689
1602
|
}());
|
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.
|
1603
|
+
ConfigurationModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
1604
|
+
ConfigurationModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, imports: [components.ConfirmationDialogModule] });
|
1605
|
+
ConfigurationModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, providers: [
|
1693
1606
|
i1.ContextApiService,
|
1694
1607
|
i1.ProductModelApiService,
|
1695
1608
|
i1.ConfigurationApiService,
|
@@ -1697,7 +1610,7 @@
|
|
1697
1610
|
RuntimeContextService,
|
1698
1611
|
ConfigurationService,
|
1699
1612
|
], imports: [[components.ConfirmationDialogModule]] });
|
1700
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
1613
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ConfigurationModule, decorators: [{
|
1701
1614
|
type: i0.NgModule,
|
1702
1615
|
args: [{
|
1703
1616
|
imports: [components.ConfirmationDialogModule],
|
@@ -1712,15 +1625,169 @@
|
|
1712
1625
|
}]
|
1713
1626
|
}] });
|
1714
1627
|
|
1628
|
+
function calculateMetricByMethod(lineItems, metric, method) {
|
1629
|
+
var items = getLineItemsByMethod(lineItems, method);
|
1630
|
+
return items.reduce(function (acc, li) {
|
1631
|
+
var value = li.reduce(function (accProduct, item) { return accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0); }, 0);
|
1632
|
+
if (method === 'avg' && li.length > 0) {
|
1633
|
+
value /= li.length;
|
1634
|
+
}
|
1635
|
+
return acc + value;
|
1636
|
+
}, 0);
|
1637
|
+
}
|
1638
|
+
function getLineItemsByMethod(lineItems, method) {
|
1639
|
+
switch (method) {
|
1640
|
+
case 'first': {
|
1641
|
+
return lineItems.filter(function (li) { return !li.rampInstanceId; }).map(function (item) { return [item]; });
|
1642
|
+
}
|
1643
|
+
case 'last': {
|
1644
|
+
var rootTermItems = lineItems.filter(function (li) { return !li.rampInstanceId; });
|
1645
|
+
var products = rootTermItems.map(function (lineItem) { return __spreadArray([
|
1646
|
+
lineItem
|
1647
|
+
], __read(lineItems.filter(function (li) { return li.rampInstanceId === lineItem.id; }))); });
|
1648
|
+
return products
|
1649
|
+
.map(function (items) { return __spreadArray([], __read(items)).sort(function (a, b) { return getDateValue(a.endDate || '') - getDateValue(b.endDate || ''); }).pop(); })
|
1650
|
+
.filter(function (li) { return Boolean(li); })
|
1651
|
+
.map(function (item) { return [item]; });
|
1652
|
+
}
|
1653
|
+
case 'avg': {
|
1654
|
+
var rootTermItems = lineItems.filter(function (li) { return !li.rampInstanceId; });
|
1655
|
+
return rootTermItems.map(function (lineItem) { return __spreadArray([lineItem], __read(lineItems.filter(function (li) { return li.rampInstanceId === lineItem.id; }))); });
|
1656
|
+
}
|
1657
|
+
case 'sum': {
|
1658
|
+
return lineItems.map(function (item) { return [item]; });
|
1659
|
+
}
|
1660
|
+
default: {
|
1661
|
+
return lineItems.map(function (item) { return [item]; });
|
1662
|
+
}
|
1663
|
+
}
|
1664
|
+
}
|
1665
|
+
function getDateValue(date) {
|
1666
|
+
return date ? new Date(date).getTime() : 0;
|
1667
|
+
}
|
1668
|
+
|
1669
|
+
var MetricsCalculationService = /** @class */ (function () {
|
1670
|
+
function MetricsCalculationService(quoteDraftService, settingsService) {
|
1671
|
+
var _this = this;
|
1672
|
+
this.quoteDraftService = quoteDraftService;
|
1673
|
+
this.settingsService = settingsService;
|
1674
|
+
this.metricsUpdated$ = new rxjs.Subject();
|
1675
|
+
this.quoteMetricsSettings = {};
|
1676
|
+
this.metricsCalculationMethodMap = {};
|
1677
|
+
this.metricsData = {};
|
1678
|
+
rxjs.combineLatest([
|
1679
|
+
this.quoteDraftService.currentState$,
|
1680
|
+
this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(rxjs.take(1)),
|
1681
|
+
]).subscribe(function (_a) {
|
1682
|
+
var _b = __read(_a, 2), lineItems = _b[0], setting = _b[1];
|
1683
|
+
var settingsData = {};
|
1684
|
+
try {
|
1685
|
+
settingsData = JSON.parse((setting === null || setting === void 0 ? void 0 : setting.value) || '{}');
|
1686
|
+
}
|
1687
|
+
catch (error) {
|
1688
|
+
settingsData = {};
|
1689
|
+
}
|
1690
|
+
_this.quoteMetricsSettings = settingsData;
|
1691
|
+
_this.updateMetrics(lineItems);
|
1692
|
+
});
|
1693
|
+
}
|
1694
|
+
Object.defineProperty(MetricsCalculationService.prototype, "onMetricsUpdate$", {
|
1695
|
+
get: function () {
|
1696
|
+
return this.metricsUpdated$.asObservable();
|
1697
|
+
},
|
1698
|
+
enumerable: false,
|
1699
|
+
configurable: true
|
1700
|
+
});
|
1701
|
+
MetricsCalculationService.prototype.getMetricValue = function (metric) {
|
1702
|
+
return this.metricsData[metric] || 0;
|
1703
|
+
};
|
1704
|
+
MetricsCalculationService.prototype.updateMetrics = function (lineItems) {
|
1705
|
+
var _this = this;
|
1706
|
+
var metricKeys = this.collectMetricKeys(lineItems).filter(function (key) { return !key.includes('Effective_'); });
|
1707
|
+
this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
|
1708
|
+
this.metricsData = metricKeys.reduce(function (acc, key) {
|
1709
|
+
var _a;
|
1710
|
+
return (Object.assign(Object.assign({}, acc), (_a = {}, _a[key] = _this.calculateMetric(lineItems, key), _a)));
|
1711
|
+
}, {});
|
1712
|
+
this.metricsUpdated$.next();
|
1713
|
+
};
|
1714
|
+
MetricsCalculationService.prototype.calculateMetric = function (lineItems, metric) {
|
1715
|
+
return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
|
1716
|
+
};
|
1717
|
+
MetricsCalculationService.prototype.buildMetricsCalculationMethods = function (metricKeys, initial) {
|
1718
|
+
var _this = this;
|
1719
|
+
return metricKeys.reduce(function (acc, name) {
|
1720
|
+
var _a, _b;
|
1721
|
+
if (acc[name]) {
|
1722
|
+
return acc;
|
1723
|
+
}
|
1724
|
+
acc = Object.assign(Object.assign({}, acc), (_a = {}, _a[name] = 'sum', _a));
|
1725
|
+
var settingKey = name.replace(/VDM_|Total_/g, '');
|
1726
|
+
if (_this.quoteMetricsSettings[settingKey]) {
|
1727
|
+
acc = Object.assign(Object.assign({}, acc), (_b = {}, _b[name] = _this.quoteMetricsSettings[settingKey], _b));
|
1728
|
+
}
|
1729
|
+
return acc;
|
1730
|
+
}, initial);
|
1731
|
+
};
|
1732
|
+
MetricsCalculationService.prototype.collectMetricKeys = function (lineItems) {
|
1733
|
+
var _this = this;
|
1734
|
+
var keys = [];
|
1735
|
+
lineItems.forEach(function (lineItem) {
|
1736
|
+
keys.push.apply(keys, __spreadArray([], __read(Object.keys(lineItem.totalMetrics || {}))));
|
1737
|
+
keys.push.apply(keys, __spreadArray([], __read(_this.collectMetricKeys(lineItem.lineItems))));
|
1738
|
+
});
|
1739
|
+
return lodash.uniq(keys);
|
1740
|
+
};
|
1741
|
+
return MetricsCalculationService;
|
1742
|
+
}());
|
1743
|
+
MetricsCalculationService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: i1__namespace.ConfigurationSettingsApiService }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
1744
|
+
MetricsCalculationService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, providedIn: 'root' });
|
1745
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: MetricsCalculationService, decorators: [{
|
1746
|
+
type: i0.Injectable,
|
1747
|
+
args: [{ providedIn: 'root' }]
|
1748
|
+
}], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: i1__namespace.ConfigurationSettingsApiService }]; } });
|
1749
|
+
|
1750
|
+
var ProductImagesService = /** @class */ (function () {
|
1751
|
+
function ProductImagesService(productApiService) {
|
1752
|
+
this.productApiService = productApiService;
|
1753
|
+
this.imagesMap$ = new rxjs.BehaviorSubject({});
|
1754
|
+
}
|
1755
|
+
ProductImagesService.prototype.getImageUrl$ = function (productId) {
|
1756
|
+
var _a;
|
1757
|
+
if (this.imagesMap$.value[productId] == null) {
|
1758
|
+
this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), (_a = {}, _a[productId] = '', _a)));
|
1759
|
+
this.fetchProductImage(productId);
|
1760
|
+
}
|
1761
|
+
return this.imagesMap$.pipe(rxjs.map(function (imagesMap) { return imagesMap[productId]; }), rxjs.distinctUntilChanged());
|
1762
|
+
};
|
1763
|
+
ProductImagesService.prototype.fetchProductImage = function (productId) {
|
1764
|
+
var _this = this;
|
1765
|
+
this.productApiService
|
1766
|
+
.fetchImage$(productId)
|
1767
|
+
.pipe(rxjs.map(function (file) { return URL.createObjectURL(file); }), rxjs.catchError(function () { return rxjs.of(''); }), rxjs.tap(function (url) {
|
1768
|
+
var _a;
|
1769
|
+
return _this.imagesMap$.next(Object.assign(Object.assign({}, _this.imagesMap$.value), (_a = {}, _a[productId] = url, _a)));
|
1770
|
+
}))
|
1771
|
+
.subscribe();
|
1772
|
+
};
|
1773
|
+
return ProductImagesService;
|
1774
|
+
}());
|
1775
|
+
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 });
|
1776
|
+
ProductImagesService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, providedIn: 'root' });
|
1777
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: ProductImagesService, decorators: [{
|
1778
|
+
type: i0.Injectable,
|
1779
|
+
args: [{ providedIn: 'root' }]
|
1780
|
+
}], ctorParameters: function () { return [{ type: i1__namespace.ProductApiService }]; } });
|
1781
|
+
|
1715
1782
|
var SdkCoreModule = /** @class */ (function () {
|
1716
1783
|
function SdkCoreModule() {
|
1717
1784
|
}
|
1718
1785
|
return SdkCoreModule;
|
1719
1786
|
}());
|
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.
|
1787
|
+
SdkCoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
1788
|
+
SdkCoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
|
1789
|
+
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]] });
|
1790
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: SdkCoreModule, decorators: [{
|
1724
1791
|
type: i0.NgModule,
|
1725
1792
|
args: [{
|
1726
1793
|
imports: [ConfigurationModule, FlowConfigurationModule],
|