@colijnit/product 2.9.0 → 2.9.1

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.
@@ -1,4 +1,4 @@
1
- import { ChangeDetectorRef, EventEmitter, OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
1
+ import { ChangeDetectorRef, EventEmitter, OnChanges, OnDestroy, OnInit, SimpleChanges } from '@angular/core';
2
2
  import { JsonUtilsService } from './utils/json-utils.service';
3
3
  import { ProductConnectorService } from './service/product-connector.service';
4
4
  import { DictionaryService } from './service/dictionary.service';
@@ -7,7 +7,7 @@ import { ArticleListObject } from '@colijnit/articleapi/build/model/article-list
7
7
  import { ProductSettingsService } from './service/product-settings.service';
8
8
  import { Selection } from '@colijnit/articleapi/build/model/selection';
9
9
  import { ArticleQuickSel } from '@colijnit/articleapi/build/model/article-quick-sel';
10
- export declare class IoneProductComponent implements OnChanges, OnDestroy {
10
+ export declare class IoneProductComponent implements OnInit, OnChanges, OnDestroy {
11
11
  private _dictionary;
12
12
  private _jsonUtils;
13
13
  private _ione;
@@ -24,9 +24,11 @@ export declare class IoneProductComponent implements OnChanges, OnDestroy {
24
24
  onArticleReceived: EventEmitter<ArticleQuickSel>;
25
25
  onSelectionsReceived: EventEmitter<Selection[]>;
26
26
  onAddToQuote: EventEmitter<string>;
27
+ settingsLoaded: boolean;
27
28
  private _settings;
28
29
  private _subs;
29
30
  constructor(_dictionary: DictionaryService, _jsonUtils: JsonUtilsService, _ione: ProductConnectorService, _changeDetector: ChangeDetectorRef, _appEventService: ProductEventService, _settingsService: ProductSettingsService);
31
+ ngOnInit(): Promise<void>;
30
32
  ngOnChanges(changes: SimpleChanges): void;
31
33
  ngOnDestroy(): void;
32
34
  private _handleAnswerInfoReceived;
@@ -1,4 +1,2 @@
1
- import { ProductInitializerService } from './service/product-initializer.service';
2
- export declare function initializeApp(context: ProductInitializerService): () => Promise<void>;
3
1
  export declare class IoneProductModule {
4
2
  }
@@ -228,8 +228,8 @@
228
228
  function Version() {
229
229
  this.name = "@colijnit/product";
230
230
  this.description = "Product detail page project for iOne";
231
- this.symVer = "2.9.0";
232
- this.publishDate = "7-9-2023 15:18:44";
231
+ this.symVer = "2.9.1";
232
+ this.publishDate = "14-9-2023 16:32:35";
233
233
  }
234
234
  return Version;
235
235
  }());
@@ -1004,13 +1004,16 @@
1004
1004
  this.onArticleReceived = new core.EventEmitter();
1005
1005
  this.onSelectionsReceived = new core.EventEmitter();
1006
1006
  this.onAddToQuote = new core.EventEmitter();
1007
+ this.settingsLoaded = false;
1007
1008
  this._subs = [];
1008
1009
  // this.sku = "70000107";
1009
1010
  this._subs.push(
1010
1011
  // this._dictionary.dictionaryLoaded.subscribe(d => this.upAndLoaded = true),
1011
1012
  this._appEventService.onAddToCart.subscribe(function (json) {
1012
1013
  _this._handleAddToCart(json);
1013
- }), this._appEventService.onAddToQuote.subscribe(function (json) { return _this.onAddToQuote.emit(json); }), this._appEventService.onAlternativeClick.subscribe(function (article) { return _this.onAlternativeClick.emit(article); }), this._appEventService.onArticleInfoReceived.subscribe(function (info) { return _this._handleAnswerInfoReceived(info); }), this._appEventService.onArticleReceived.subscribe(function (article) { return _this.onArticleReceived.emit(article); }), this._appEventService.onSelectionsReceived.subscribe(function (selections) { return _this.onSelectionsReceived.emit(selections); }));
1014
+ }), this._appEventService.onAddToQuote.subscribe(function (json) { return _this.onAddToQuote.emit(json); }), this._appEventService.onAlternativeClick.subscribe(function (article) { return _this.onAlternativeClick.emit(article); }), this._appEventService.onArticleInfoReceived.subscribe(function (info) { return _this._handleAnswerInfoReceived(info); }), this._appEventService.onArticleReceived.subscribe(function (article) { return _this.onArticleReceived.emit(article); }), this._appEventService.onSelectionsReceived.subscribe(function (selections) { return _this.onSelectionsReceived.emit(selections); }), this._settingsService.settingsLoaded.subscribe(function (loaded) {
1015
+ _this.settingsLoaded = loaded;
1016
+ }));
1014
1017
  }
1015
1018
  Object.defineProperty(IoneProductComponent.prototype, "settings", {
1016
1019
  get: function () {
@@ -1032,6 +1035,18 @@
1032
1035
  enumerable: true,
1033
1036
  configurable: true
1034
1037
  });
1038
+ IoneProductComponent.prototype.ngOnInit = function () {
1039
+ return __awaiter(this, void 0, void 0, function () {
1040
+ return __generator(this, function (_a) {
1041
+ switch (_a.label) {
1042
+ case 0: return [4 /*yield*/, this._settingsService.initializeSettings()];
1043
+ case 1:
1044
+ _a.sent();
1045
+ return [2 /*return*/];
1046
+ }
1047
+ });
1048
+ });
1049
+ };
1035
1050
  IoneProductComponent.prototype.ngOnChanges = function (changes) {
1036
1051
  this._changeDetector.detectChanges();
1037
1052
  };
@@ -1043,7 +1058,7 @@
1043
1058
  };
1044
1059
  IoneProductComponent.prototype._handleAddToCart = function (json) {
1045
1060
  return __awaiter(this, void 0, void 0, function () {
1046
- var articleTreeData, i, good, subArticle;
1061
+ var articleTreeData, compositeGoods, _loop_1, this_1, i;
1047
1062
  return __generator(this, function (_a) {
1048
1063
  switch (_a.label) {
1049
1064
  case 0:
@@ -1052,14 +1067,32 @@
1052
1067
  articleTreeData = JSON.parse(json);
1053
1068
  if (!(articleTreeData.articleTree && articleTreeData.articleTree.article)) return [3 /*break*/, 7];
1054
1069
  if (!(articleTreeData.articleTree.compositeGoods && Array.isArray(articleTreeData.articleTree.compositeGoods) &&
1055
- articleTreeData.articleTree.compositeGoods.length > 0 && articleTreeData.articleTree.subArticles && Array.isArray(articleTreeData.articleTree.subArticles))) return [3 /*break*/, 5];
1070
+ articleTreeData.articleTree.compositeGoods.length > 0 &&
1071
+ articleTreeData.articleTree.subArticles && Array.isArray(articleTreeData.articleTree.subArticles))) return [3 /*break*/, 5];
1072
+ compositeGoods = articleTreeData.articleTree.compositeGoods;
1073
+ compositeGoods.sort(function (a, b) { return a.versionNumber < b.versionNumber ? -1 : 1; });
1074
+ _loop_1 = function (i) {
1075
+ var good, subArticle;
1076
+ return __generator(this, function (_a) {
1077
+ switch (_a.label) {
1078
+ case 0:
1079
+ good = compositeGoods[i];
1080
+ subArticle = articleTreeData.articleTree.subArticles.find(function (s) { return s.goodId === good.memberGoodId; });
1081
+ if (!subArticle) return [3 /*break*/, 2];
1082
+ return [4 /*yield*/, this_1._ione.addWebSessionTransactionLine(subArticle.articleNumber, good.quantity)];
1083
+ case 1:
1084
+ _a.sent();
1085
+ _a.label = 2;
1086
+ case 2: return [2 /*return*/];
1087
+ }
1088
+ });
1089
+ };
1090
+ this_1 = this;
1056
1091
  i = 0;
1057
1092
  _a.label = 1;
1058
1093
  case 1:
1059
- if (!(i < articleTreeData.articleTree.compositeGoods.length - 1)) return [3 /*break*/, 4];
1060
- good = articleTreeData.articleTree.compositeGoods[i];
1061
- subArticle = articleTreeData.articleTree.subArticles[i];
1062
- return [4 /*yield*/, this._ione.addWebSessionTransactionLine(subArticle.articleNumber, good.quantity)];
1094
+ if (!(i < compositeGoods.length)) return [3 /*break*/, 4];
1095
+ return [5 /*yield**/, _loop_1(i)];
1063
1096
  case 2:
1064
1097
  _a.sent();
1065
1098
  _a.label = 3;
@@ -1116,7 +1149,7 @@
1116
1149
  IoneProductComponent = __decorate([
1117
1150
  core.Component({
1118
1151
  selector: 'app-ione-product',
1119
- template: "\n <app-product-page [sku]=\"sku\"\n ></app-product-page>\n ",
1152
+ template: "\n <app-product-page *ngIf=\"settingsLoaded\"\n [sku]=\"sku\"\n ></app-product-page>\n ",
1120
1153
  providers: [
1121
1154
  ProductEventService,
1122
1155
  ProductSettingsService,
@@ -1130,29 +1163,6 @@
1130
1163
  return IoneProductComponent;
1131
1164
  }());
1132
1165
 
1133
- var ProductInitializerService = /** @class */ (function () {
1134
- function ProductInitializerService(_settingsService) {
1135
- this._settingsService = _settingsService;
1136
- }
1137
- ProductInitializerService.prototype.initializeApp = function () {
1138
- return __awaiter(this, void 0, void 0, function () {
1139
- return __generator(this, function (_a) {
1140
- return [2 /*return*/, this._settingsService.initializeSettings()];
1141
- });
1142
- });
1143
- };
1144
- ProductInitializerService.ctorParameters = function () { return [
1145
- { type: ProductSettingsService }
1146
- ]; };
1147
- ProductInitializerService.ɵprov = core.ɵɵdefineInjectable({ factory: function ProductInitializerService_Factory() { return new ProductInitializerService(core.ɵɵinject(ProductSettingsService)); }, token: ProductInitializerService, providedIn: "root" });
1148
- ProductInitializerService = __decorate([
1149
- core.Injectable({
1150
- providedIn: 'root',
1151
- })
1152
- ], ProductInitializerService);
1153
- return ProductInitializerService;
1154
- }());
1155
-
1156
1166
  var ProductExternalSourceComponent = /** @class */ (function () {
1157
1167
  function ProductExternalSourceComponent(_sanitizer, _productConnectorService, _appEventService) {
1158
1168
  this._sanitizer = _sanitizer;
@@ -2740,10 +2750,6 @@
2740
2750
  return ProductExternalSourceModule;
2741
2751
  }());
2742
2752
 
2743
- function initializeApp(context) {
2744
- var x = function () { return context.initializeApp(); };
2745
- return x;
2746
- }
2747
2753
  var IoneProductModule = /** @class */ (function () {
2748
2754
  function IoneProductModule() {
2749
2755
  }
@@ -2761,14 +2767,7 @@
2761
2767
  entryComponents: [
2762
2768
  IoneProductComponent
2763
2769
  ],
2764
- providers: [
2765
- {
2766
- provide: core.APP_INITIALIZER,
2767
- useFactory: initializeApp,
2768
- deps: [ProductInitializerService],
2769
- multi: true
2770
- }
2771
- ],
2770
+ providers: [],
2772
2771
  exports: [IoneProductComponent],
2773
2772
  bootstrap: [
2774
2773
  IoneProductComponent
@@ -2782,12 +2781,10 @@
2782
2781
  exports.ProductExternalSourceComponent = ProductExternalSourceComponent;
2783
2782
  exports.ProductExternalSourceModule = ProductExternalSourceModule;
2784
2783
  exports.Version = Version;
2785
- exports.initializeApp = initializeApp;
2786
2784
  exports.ɵa = ProductPageModule;
2787
2785
  exports.ɵb = PipeModule;
2788
2786
  exports.ɵba = ProductSymbolsComponent;
2789
2787
  exports.ɵbb = IoneProductComponent;
2790
- exports.ɵbc = ProductInitializerService;
2791
2788
  exports.ɵc = LocalizePipe;
2792
2789
  exports.ɵd = DictionaryService;
2793
2790
  exports.ɵe = JsonUtilsService;