@colijnit/catalog 255.1.6 → 255.1.8

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.
@@ -30,8 +30,8 @@
30
30
  function Version() {
31
31
  this.name = "@colijnit/catalog";
32
32
  this.description = "iOne Catalog module based on Angular 12";
33
- this.symVer = "255.1.6";
34
- this.publishDate = "2-9-2024 16:25:22";
33
+ this.symVer = "255.1.8";
34
+ this.publishDate = "16-9-2024 17:31:10";
35
35
  }
36
36
  return Version;
37
37
  }());
@@ -5815,16 +5815,6 @@
5815
5815
  enumerable: false,
5816
5816
  configurable: true
5817
5817
  });
5818
- Object.defineProperty(CatalogExternalSourceComponent.prototype, "catalogDefinitionId", {
5819
- get: function () {
5820
- return this._catalogDefinitionId;
5821
- },
5822
- set: function (value) {
5823
- this._catalogDefinitionId = value;
5824
- },
5825
- enumerable: false,
5826
- configurable: true
5827
- });
5828
5818
  Object.defineProperty(CatalogExternalSourceComponent.prototype, "externalCatalogStartupInfo", {
5829
5819
  get: function () {
5830
5820
  return this._externalCatalogStartupInfo;
@@ -5842,24 +5832,102 @@
5842
5832
  var _this = this;
5843
5833
  this._subs.push(this._appEventService.addArticleButtonClick.subscribe(function (article) {
5844
5834
  if (!(article instanceof articleExtended_bo.ArticleExtended)) {
5845
- _this.addArticleClick.next({ quantity: 1, article: article });
5835
+ _this.addArticleClick.next({
5836
+ quantity: 1,
5837
+ article: article,
5838
+ catalogDefinition: _this.catalogDefinition,
5839
+ externalSource: _this._externalSource
5840
+ });
5846
5841
  }
5847
5842
  }));
5848
5843
  };
5849
5844
  CatalogExternalSourceComponent.prototype.handleArticleClick = function (article) {
5850
5845
  if (article && this.externalSettings) {
5851
- this.articleClick.emit({ article: article, settings: { name: this.name, settings: this.externalSettings } });
5846
+ this.articleClick.emit({
5847
+ article: article,
5848
+ settings: { name: this.name, settings: this.externalSettings },
5849
+ catalogDefinition: this.catalogDefinition,
5850
+ externalSource: this._externalSource
5851
+ });
5852
5852
  }
5853
5853
  };
5854
5854
  CatalogExternalSourceComponent.prototype.receiveMessage = function (event) {
5855
- //if(event.origin === this.externalSource.url) {
5856
- if (typeof event.data === 'string') {
5857
- this.iFrameFeedbackReceived.emit(event.data);
5858
- }
5855
+ if (this._externalSource.type !== '3DIMERCE')
5856
+ if (typeof event.data === 'string') {
5857
+ this.iFrameFeedbackReceived.emit(event.data);
5858
+ }
5859
+ else {
5860
+ this.iFrameFeedbackReceived.emit(JSON.stringify(event.data));
5861
+ }
5859
5862
  else {
5860
- this.iFrameFeedbackReceived.emit(JSON.stringify(event.data));
5863
+ if (typeof event.data && event.data['hash'] !== undefined) {
5864
+ this.fetchAndCombineThreeDimerseData(event.data['hash']);
5865
+ }
5861
5866
  }
5862
- //}
5867
+ };
5868
+ CatalogExternalSourceComponent.prototype.fetchAndCombineThreeDimerseData = function (hash) {
5869
+ return __awaiter(this, void 0, void 0, function () {
5870
+ var customerName, configurationUrl, priceDataUrl, apiResponses, configurationResponse, priceDataResponse, configurationData_1, priceData_1, resultObject, error_1;
5871
+ return __generator(this, function (_a) {
5872
+ switch (_a.label) {
5873
+ case 0:
5874
+ customerName = 'Linteloo';
5875
+ configurationUrl = this._externalSource.domain + '/configurationData/' + hash;
5876
+ console.log('configurationUrl');
5877
+ priceDataUrl = this._externalSource.domain + '/rules/api/' + customerName.toLowerCase() + '/' + hash;
5878
+ console.log('priceDataUrl');
5879
+ _a.label = 1;
5880
+ case 1:
5881
+ _a.trys.push([1, 3, , 4]);
5882
+ return [4 /*yield*/, Promise.all([
5883
+ this.fetchJsonFile(configurationUrl),
5884
+ this.fetchJsonFile(priceDataUrl)
5885
+ ])];
5886
+ case 2:
5887
+ apiResponses = _a.sent();
5888
+ configurationResponse = apiResponses[0];
5889
+ priceDataResponse = apiResponses[1];
5890
+ if (configurationResponse && configurationResponse.ok) {
5891
+ configurationResponse.json().then(function (result) {
5892
+ console.log(result);
5893
+ configurationData_1 = result;
5894
+ }).catch(function (e) {
5895
+ console.log(e);
5896
+ configurationData_1 = {};
5897
+ });
5898
+ }
5899
+ if (priceDataResponse && priceDataResponse.ok) {
5900
+ priceDataResponse.json().then(function (result) {
5901
+ console.log(result);
5902
+ priceData_1 = result;
5903
+ }).catch(function (e) {
5904
+ console.log(e);
5905
+ priceData_1 = {};
5906
+ });
5907
+ }
5908
+ resultObject = {};
5909
+ resultObject['configuratie-data'] = configurationData_1;
5910
+ resultObject['prijs-data'] = priceData_1;
5911
+ this.iFrameFeedbackReceived.emit(JSON.stringify(resultObject));
5912
+ return [3 /*break*/, 4];
5913
+ case 3:
5914
+ error_1 = _a.sent();
5915
+ console.error('Error fetching data:', error_1);
5916
+ return [3 /*break*/, 4];
5917
+ case 4: return [2 /*return*/];
5918
+ }
5919
+ });
5920
+ });
5921
+ };
5922
+ CatalogExternalSourceComponent.prototype.fetchJsonFile = function (url) {
5923
+ return __awaiter(this, void 0, void 0, function () {
5924
+ return __generator(this, function (_a) {
5925
+ switch (_a.label) {
5926
+ case 0: return [4 /*yield*/, fetch(url)];
5927
+ case 1: return [2 /*return*/, _a.sent()];
5928
+ }
5929
+ });
5930
+ });
5863
5931
  };
5864
5932
  CatalogExternalSourceComponent.prototype.iframeLoaded = function (event) {
5865
5933
  if (this.username && this.password) {
@@ -5905,7 +5973,7 @@
5905
5973
  this.showCatalog = true;
5906
5974
  return [3 /*break*/, 3];
5907
5975
  case 2:
5908
- if (this._externalSource.type !== externalCatalogTypes_enum.ExternalCatalogTypes.Webshop) {
5976
+ if (this._externalSource.type !== externalCatalogTypes_enum.ExternalCatalogTypes.Webshop && this._externalSource.type !== externalCatalogTypes_enum.ExternalCatalogTypes.ThreeDimerse) {
5909
5977
  this.externalUrl = this._externalCatalogStartupInfo.apiUrl;
5910
5978
  if (this._externalSource.type === externalCatalogTypes_enum.ExternalCatalogTypes.Vadain) {
5911
5979
  this.username = this._externalCatalogStartupInfo.username;
@@ -5918,7 +5986,9 @@
5918
5986
  }
5919
5987
  this.safeUrl = this._sanitizer.bypassSecurityTrustResourceUrl(this.externalUrl);
5920
5988
  this.showCatalog = false;
5921
- window.addEventListener("message", function (event) { _this.receiveMessage(event); });
5989
+ window.addEventListener('message', function (event) {
5990
+ _this.receiveMessage(event);
5991
+ });
5922
5992
  _a.label = 3;
5923
5993
  case 3:
5924
5994
  this.loaded = true;
@@ -5932,7 +6002,7 @@
5932
6002
  CatalogExternalSourceComponent.decorators = [
5933
6003
  { type: i0.Component, args: [{
5934
6004
  selector: 'co-catalog-external-source',
5935
- template: "\n <ng-container *ngIf=\"loaded\">\n <ng-container *ngIf=\"showCatalog\">\n <co-catalog-search\n [(settings)]=\"externalSettings\"\n [title]=\"title\"\n [subTitle]=\"subTitle\"\n [searchPlaceholder]=\"searchPlaceholder\"\n [showFilter]=\"showFilter\"\n [showNavigation]=\"showNavigation\"\n (onArticleClick)=\"handleArticleClick($event)\"\n ></co-catalog-search>\n </ng-container>\n <ng-container *ngIf=\"!showCatalog\">\n <iframe #catalogFrame width=\"100%\" height=\"100%\" [src]=\"safeUrl\" frameborder=\"0\" allowfullscreen (load)=\"iframeLoaded($event)\"></iframe>\n </ng-container>\n </ng-container>\n ",
6005
+ template: "\n <ng-container *ngIf=\"loaded\">\n <ng-container *ngIf=\"showCatalog\">\n <co-catalog-search\n [(settings)]=\"externalSettings\"\n [title]=\"title\"\n [subTitle]=\"subTitle\"\n [searchPlaceholder]=\"searchPlaceholder\"\n [showFilter]=\"showFilter\"\n [showNavigation]=\"showNavigation\"\n (onArticleClick)=\"handleArticleClick($event)\"\n ></co-catalog-search>\n </ng-container>\n <ng-container *ngIf=\"!showCatalog\">\n <iframe #catalogFrame width=\"100%\" height=\"100%\" [src]=\"safeUrl\" frameborder=\"0\" allowfullscreen\n (load)=\"iframeLoaded($event)\"></iframe>\n </ng-container>\n </ng-container>\n ",
5936
6006
  encapsulation: i0.ViewEncapsulation.None
5937
6007
  },] }
5938
6008
  ];
@@ -5943,7 +6013,7 @@
5943
6013
  ]; };
5944
6014
  CatalogExternalSourceComponent.propDecorators = {
5945
6015
  container: [{ type: i0.ViewChild, args: ['catalogFrame', { read: i0.ElementRef },] }],
5946
- catalogDefinitionId: [{ type: i0.Input }],
6016
+ catalogDefinition: [{ type: i0.Input }],
5947
6017
  user: [{ type: i0.Input }],
5948
6018
  externalCatalogStartupInfo: [{ type: i0.Input }],
5949
6019
  title: [{ type: i0.Input }],