@colijnit/product 257.1.10 → 257.1.11

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.
@@ -0,0 +1,14 @@
1
+ export declare class RootStorageObject {
2
+ id: string;
3
+ }
4
+ export declare class LocalStorageService {
5
+ readonly storage: Storage;
6
+ protected _appRoot: string;
7
+ protected _storageObj: RootStorageObject;
8
+ constructor();
9
+ save(): void;
10
+ clear(): void;
11
+ set id(id: string);
12
+ get id(): string;
13
+ protected _initLocalStorageObj(): void;
14
+ }
@@ -1,19 +1,24 @@
1
1
  import { EventEmitter, OnDestroy, OnInit } from '@angular/core';
2
+ import { ProductConnectorService } from './service/product-connector.service';
2
3
  import { ProductEventService } from './service/product-event.service';
3
4
  import { ArticleListObject } from '@colijnit/articleapi/build/model/article-list-object';
4
5
  import { ProductSettingsService } from './service/product-settings.service';
5
6
  import { Selection } from '@colijnit/articleapi/build/model/selection';
6
7
  import { ArticleQuickSel } from '@colijnit/articleapi/build/model/article-quick-sel';
7
8
  import { ArticleListObjectExtended } from '@colijnit/articleapi/build/model/article-list-object-extended.bo';
9
+ import { LocalStorageService } from "./bundle/service/local-storage.service";
8
10
  export declare class IoneProductComponent implements OnInit, OnDestroy {
9
11
  private _appEventService;
10
12
  private _settingsService;
13
+ private _productConnectorService;
14
+ private _localStorageService;
11
15
  sku: string;
12
16
  isReturn: boolean;
13
17
  showRelatedProductsPopup: boolean;
14
18
  set settings(value: any);
15
19
  get settings(): any;
16
20
  handleAddArticleInternally: boolean;
21
+ handleAddToCartInternally: boolean;
17
22
  onAddToCart: EventEmitter<{
18
23
  article: string | ArticleListObjectExtended;
19
24
  quantity: number;
@@ -30,7 +35,7 @@ export declare class IoneProductComponent implements OnInit, OnDestroy {
30
35
  showHD: boolean;
31
36
  private _settings;
32
37
  private _subs;
33
- constructor(_appEventService: ProductEventService, _settingsService: ProductSettingsService);
38
+ constructor(_appEventService: ProductEventService, _settingsService: ProductSettingsService, _productConnectorService: ProductConnectorService, _localStorageService: LocalStorageService);
34
39
  ngOnInit(): Promise<void>;
35
40
  ngOnDestroy(): void;
36
41
  private _handleAnswerInfoReceived;
@@ -31,8 +31,8 @@
31
31
  function Version() {
32
32
  this.name = "@colijnit/product";
33
33
  this.description = "Product detail page project for iOne";
34
- this.symVer = "257.1.10";
35
- this.publishDate = "20-6-2025 15:30:05";
34
+ this.symVer = "257.1.11";
35
+ this.publishDate = "2-7-2025 11:03:13";
36
36
  }
37
37
  return Version;
38
38
  }());
@@ -1340,8 +1340,51 @@
1340
1340
  { type: ProductSettingsService }
1341
1341
  ]; };
1342
1342
 
1343
+ var RootStorageObject = /** @class */ (function () {
1344
+ function RootStorageObject() {
1345
+ }
1346
+ return RootStorageObject;
1347
+ }());
1348
+ var LocalStorageService = /** @class */ (function () {
1349
+ function LocalStorageService() {
1350
+ this.storage = localStorage;
1351
+ this._appRoot = "web-order";
1352
+ this._storageObj = new RootStorageObject();
1353
+ this._initLocalStorageObj();
1354
+ }
1355
+ LocalStorageService.prototype.save = function () {
1356
+ this.storage.setItem(this._appRoot, JSON.stringify(this._storageObj));
1357
+ };
1358
+ LocalStorageService.prototype.clear = function () {
1359
+ this.storage.clear();
1360
+ };
1361
+ Object.defineProperty(LocalStorageService.prototype, "id", {
1362
+ get: function () {
1363
+ return this._storageObj ? this._storageObj.id : "";
1364
+ },
1365
+ set: function (id) {
1366
+ this._storageObj.id = id;
1367
+ this.save();
1368
+ },
1369
+ enumerable: false,
1370
+ configurable: true
1371
+ });
1372
+ LocalStorageService.prototype._initLocalStorageObj = function () {
1373
+ this._storageObj = JSON.parse(this.storage.getItem(this._appRoot)) || this._storageObj;
1374
+ this.save();
1375
+ };
1376
+ return LocalStorageService;
1377
+ }());
1378
+ LocalStorageService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function LocalStorageService_Factory() { return new LocalStorageService(); }, token: LocalStorageService, providedIn: "root" });
1379
+ LocalStorageService.decorators = [
1380
+ { type: i0.Injectable, args: [{
1381
+ providedIn: 'root'
1382
+ },] }
1383
+ ];
1384
+ LocalStorageService.ctorParameters = function () { return []; };
1385
+
1343
1386
  var IoneProductComponent = /** @class */ (function () {
1344
- function IoneProductComponent(_appEventService, _settingsService) {
1387
+ function IoneProductComponent(_appEventService, _settingsService, _productConnectorService, _localStorageService) {
1345
1388
  var _this = this;
1346
1389
  // this.sku = 'CF-HILL';
1347
1390
  // this.sku = 'CF-ALMADA';
@@ -1357,7 +1400,10 @@
1357
1400
  // this.sku = "grover";
1358
1401
  this._appEventService = _appEventService;
1359
1402
  this._settingsService = _settingsService;
1403
+ this._productConnectorService = _productConnectorService;
1404
+ this._localStorageService = _localStorageService;
1360
1405
  this.handleAddArticleInternally = true;
1406
+ this.handleAddToCartInternally = false;
1361
1407
  this.onAddToCart = new i0.EventEmitter();
1362
1408
  this.forceRenderImage = new i0.EventEmitter();
1363
1409
  this.onAlternativeClick = new i0.EventEmitter();
@@ -1419,9 +1465,41 @@
1419
1465
  };
1420
1466
  IoneProductComponent.prototype._handleAddToCart = function (data) {
1421
1467
  return __awaiter(this, void 0, void 0, function () {
1468
+ var article, transactionId, transactionId;
1422
1469
  return __generator(this, function (_a) {
1423
- this.onAddToCart.emit(data);
1424
- return [2 /*return*/];
1470
+ switch (_a.label) {
1471
+ case 0:
1472
+ if (!this.handleAddToCartInternally) return [3 /*break*/, 7];
1473
+ if (!(data && data.article)) return [3 /*break*/, 6];
1474
+ if (!(typeof data.article === 'string')) return [3 /*break*/, 3];
1475
+ article = JSON.parse(data.article);
1476
+ if (!(article.selectorData && article.selectorData.compositions)) return [3 /*break*/, 2];
1477
+ return [4 /*yield*/, this._productConnectorService.addWebSessionTransactionLine(this._localStorageService.id, article.selectorData.compositions[0].compositionArticleNo, data.quantity)];
1478
+ case 1:
1479
+ transactionId = _a.sent();
1480
+ if (transactionId) {
1481
+ this._localStorageService.id = transactionId;
1482
+ }
1483
+ _a.label = 2;
1484
+ case 2: return [3 /*break*/, 5];
1485
+ case 3:
1486
+ if (!data.article.hasOwnProperty('articleNr')) return [3 /*break*/, 5];
1487
+ return [4 /*yield*/, this._productConnectorService.addWebSessionTransactionLine(this._localStorageService.id, data.article['articleNr'], data.quantity)];
1488
+ case 4:
1489
+ transactionId = _a.sent();
1490
+ if (transactionId) {
1491
+ this._localStorageService.id = transactionId;
1492
+ }
1493
+ _a.label = 5;
1494
+ case 5:
1495
+ this.onAddToCart.next(data);
1496
+ _a.label = 6;
1497
+ case 6: return [3 /*break*/, 8];
1498
+ case 7:
1499
+ this.onAddToCart.emit(data);
1500
+ _a.label = 8;
1501
+ case 8: return [2 /*return*/];
1502
+ }
1425
1503
  });
1426
1504
  });
1427
1505
  };
@@ -1446,7 +1524,9 @@
1446
1524
  ];
1447
1525
  IoneProductComponent.ctorParameters = function () { return [
1448
1526
  { type: ProductEventService },
1449
- { type: ProductSettingsService }
1527
+ { type: ProductSettingsService },
1528
+ { type: ProductConnectorService },
1529
+ { type: LocalStorageService }
1450
1530
  ]; };
1451
1531
  IoneProductComponent.propDecorators = {
1452
1532
  sku: [{ type: i0.Input }],
@@ -1454,6 +1534,7 @@
1454
1534
  showRelatedProductsPopup: [{ type: i0.Input }],
1455
1535
  settings: [{ type: i0.Input }],
1456
1536
  handleAddArticleInternally: [{ type: i0.Input }],
1537
+ handleAddToCartInternally: [{ type: i0.Input }],
1457
1538
  onAddToCart: [{ type: i0.Output }],
1458
1539
  forceRenderImage: [{ type: i0.Output }],
1459
1540
  onAlternativeClick: [{ type: i0.Output }],
@@ -1725,7 +1806,7 @@
1725
1806
  this._ione.getFullArticle(this._sku).then(function (article) {
1726
1807
  _this.article = article;
1727
1808
  if (_this.article) {
1728
- _this.configurable = !(_this.article.goodType === 'B' && !_this.article.isConfigurable);
1809
+ _this.configurable = _this.article.goodType === 'B' && (_this.article.isConfigurable || _this.article.isConfigurable === undefined);
1729
1810
  if (_this.configurable) {
1730
1811
  _this.showAddToCart = false;
1731
1812
  _this.currentView = SelectorType.TwoD;
@@ -3952,6 +4033,7 @@
3952
4033
  exports["ɵbn"] = ProductHdModule;
3953
4034
  exports["ɵbo"] = ProductHdComponent;
3954
4035
  exports["ɵbp"] = ProductScriptLoaderService;
4036
+ exports["ɵbq"] = LocalStorageService;
3955
4037
  exports["ɵc"] = PipeModule;
3956
4038
  exports["ɵd"] = LocalizePipe;
3957
4039
  exports["ɵe"] = DictionaryService;