@colijnit/catalog 12.1.43 → 12.1.45

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.
@@ -28,6 +28,7 @@ import { Preset } from '@colijnit/mainapi/build/model/preset.bo';
28
28
  import { UserGroup } from '@colijnit/mainapi/build/model/user-group.bo';
29
29
  import { PriceList } from '@colijnit/transactionapi/build/model/price-list';
30
30
  import { Transaction } from '@colijnit/transactionapi/build/transaction';
31
+ import { ExternalCatalogStartupInfo } from '@colijnit/articleapi/build/model/external-catalog-startup-info';
31
32
  import { ObjectUtils } from '@colijnit/ioneconnector/build/utils/object-utils';
32
33
  import { FileUtils } from '@colijnit/ioneconnector/build/utils/file-utils';
33
34
  import { FilterViewmodel, FilterItemViewmodel, FilterItemModule, InputTextModule, ButtonModule, IconModule, FilterItemMode as FilterItemMode$1, InputDatePickerModule, IconCollapseHandleModule, CoDialogModule, ListOfValuesModule, CheckmarkOverlayModule, ImageModule, OverlayModule, OverlayService, InputSearchModule, PaginationBarModule } from '@colijnit/corecomponents_v12';
@@ -45,8 +46,8 @@ class Version {
45
46
  constructor() {
46
47
  this.name = "@colijnit/catalog";
47
48
  this.description = "iOne Catalog module based on Angular 12";
48
- this.symVer = "12.1.43";
49
- this.publishDate = "15-9-2023 17:25:36";
49
+ this.symVer = "12.1.45";
50
+ this.publishDate = "2-10-2023 19:34:19";
50
51
  }
51
52
  }
52
53
 
@@ -615,6 +616,17 @@ class CatalogConnectorAdapterService {
615
616
  }
616
617
  });
617
618
  }
619
+ getWebViewStartupInfo(request) {
620
+ return __awaiter(this, void 0, void 0, function* () {
621
+ const response = yield this.connector.getWebviewStartupInfo(request);
622
+ if (response && response.validationResult && response.validationResult.success) {
623
+ return this._boFactory.makeWithRawBackendData(ExternalCatalogStartupInfo, response.resultObject);
624
+ }
625
+ else {
626
+ console.error(response.validationMessagesAsString);
627
+ }
628
+ });
629
+ }
618
630
  // will be called in future
619
631
  // public getArticleGroupImages(): Promise<ArticleGroupImage[]> {
620
632
  // return this.connector.getArticleGroupImages();
@@ -1278,6 +1290,11 @@ class CatalogConnectorService {
1278
1290
  return this._adapterService.updatePreset(presetName);
1279
1291
  });
1280
1292
  }
1293
+ getWebViewStartupInfo(request) {
1294
+ return __awaiter(this, void 0, void 0, function* () {
1295
+ return this._adapterService.getWebViewStartupInfo(request);
1296
+ });
1297
+ }
1281
1298
  getDocumentContent(docId, thumbnail = true) {
1282
1299
  return __awaiter(this, void 0, void 0, function* () {
1283
1300
  return this._selectSingleParameterizedCacheService.requestCache(String, (docId, thumbnail) => {
@@ -4294,19 +4311,34 @@ class CatalogExternalSourceComponent {
4294
4311
  this.showNavigation = true;
4295
4312
  this.articleClick = new EventEmitter();
4296
4313
  this.addArticleClick = new EventEmitter();
4314
+ this.iFrameFeedbackReceived = new EventEmitter();
4297
4315
  this.showClass = true;
4298
4316
  this.showCatalog = false;
4299
4317
  this.loaded = false;
4300
4318
  this.externalSettings = {};
4301
4319
  this._subs = [];
4302
4320
  }
4303
- set externalSource(value) {
4304
- this._externalSource = value;
4321
+ set container(content) {
4322
+ if (content) {
4323
+ this.catalogFrame = content;
4324
+ this.catalogFrame.nativeElement.setAttribute('data-password', this.password);
4325
+ this.catalogFrame.nativeElement.setAttribute('data-username', this.username);
4326
+ }
4327
+ }
4328
+ set catalogDefinitionId(value) {
4329
+ this._catalogDefinitionId = value;
4330
+ }
4331
+ get catalogDefinitionId() {
4332
+ return this._catalogDefinitionId;
4333
+ }
4334
+ set externalCatalogStartupInfo(value) {
4335
+ this._externalCatalogStartupInfo = value;
4336
+ this._externalSource = value.externalSource;
4305
4337
  this.loaded = false;
4306
4338
  this._prepareExternalSource();
4307
4339
  }
4308
- get externalSource() {
4309
- return this._externalSource;
4340
+ get externalCatalogStartupInfo() {
4341
+ return this._externalCatalogStartupInfo;
4310
4342
  }
4311
4343
  ngOnInit() {
4312
4344
  this._subs.push(this._appEventService.addArticleButtonClick.subscribe((json) => {
@@ -4318,6 +4350,22 @@ class CatalogExternalSourceComponent {
4318
4350
  this.articleClick.emit({ article: article, settings: { name: this.name, settings: this.externalSettings } });
4319
4351
  }
4320
4352
  }
4353
+ receiveMessage(event) {
4354
+ //if(event.origin === this.externalSource.url) {
4355
+ if (typeof event.data === 'string') {
4356
+ this.iFrameFeedbackReceived.emit(event.data);
4357
+ }
4358
+ else {
4359
+ this.iFrameFeedbackReceived.emit(JSON.stringify(event.data));
4360
+ }
4361
+ //}
4362
+ }
4363
+ iframeLoaded(event) {
4364
+ event.target.contentWindow.postMessage({
4365
+ 'USERNAME': this.username,
4366
+ 'PASSWORD': this.password
4367
+ }, '*');
4368
+ }
4321
4369
  _prepareExternalSource() {
4322
4370
  return __awaiter(this, void 0, void 0, function* () {
4323
4371
  if (!this._externalSource) {
@@ -4325,24 +4373,32 @@ class CatalogExternalSourceComponent {
4325
4373
  }
4326
4374
  this.externalUrl = undefined;
4327
4375
  this.externalSettings = {};
4328
- if (this.externalSource.type === 'CATF') {
4376
+ if (this._externalSource.type === 'CATF') {
4329
4377
  // get bundle settings from external source
4330
- const bundleSettings = yield this._catalogConnectorService.getCatalogBundleSettings(this.externalSource.url, parseInt(this.externalSource.schema));
4378
+ const bundleSettings = yield this._catalogConnectorService.getCatalogBundleSettings(this._externalSource.url, parseInt(this._externalSource.schema));
4331
4379
  this.externalSettings = JSON.parse(bundleSettings);
4332
4380
  if (this.options) {
4333
4381
  this.externalSettings.options = this.options;
4334
4382
  }
4335
- if (this.externalSource.username && this.externalSource.password) {
4336
- this.externalSettings.username = this.externalSource.username;
4337
- this.externalSettings.password = this.externalSource.password;
4383
+ if (this._externalSource.username && this._externalSource.password) {
4384
+ this.externalSettings.username = this._externalSource.username;
4385
+ this.externalSettings.password = this._externalSource.password;
4338
4386
  }
4339
4387
  // finally show the catalog
4340
4388
  this.showCatalog = true;
4341
4389
  }
4342
4390
  else {
4343
- this.externalUrl = this.externalSource.url;
4391
+ if (this._externalSource.type !== 'WEBS') {
4392
+ this.externalUrl = this._externalCatalogStartupInfo.apiUrl;
4393
+ this.username = this._externalCatalogStartupInfo.username;
4394
+ this.password = this._externalCatalogStartupInfo.password;
4395
+ }
4396
+ else {
4397
+ this.externalUrl = this._externalSource.url;
4398
+ }
4344
4399
  this.safeUrl = this._sanitizer.bypassSecurityTrustResourceUrl(this.externalUrl);
4345
4400
  this.showCatalog = false;
4401
+ window.addEventListener("message", (event) => { this.receiveMessage(event); });
4346
4402
  }
4347
4403
  this.loaded = true;
4348
4404
  });
@@ -4365,7 +4421,7 @@ CatalogExternalSourceComponent.decorators = [
4365
4421
  ></co-catalog-search>
4366
4422
  </ng-container>
4367
4423
  <ng-container *ngIf="!showCatalog">
4368
- <iframe width="100%" height="100%" [src]="safeUrl" frameborder="0" allowfullscreen></iframe>
4424
+ <iframe #catalogFrame width="100%" height="100%" [src]="safeUrl" frameborder="0" allowfullscreen (load)="iframeLoaded($event)"></iframe>
4369
4425
  </ng-container>
4370
4426
  </ng-container>
4371
4427
  `,
@@ -4378,7 +4434,10 @@ CatalogExternalSourceComponent.ctorParameters = () => [
4378
4434
  { type: CatalogEventService }
4379
4435
  ];
4380
4436
  CatalogExternalSourceComponent.propDecorators = {
4381
- externalSource: [{ type: Input }],
4437
+ container: [{ type: ViewChild, args: ['catalogFrame', { read: ElementRef },] }],
4438
+ catalogDefinitionId: [{ type: Input }],
4439
+ user: [{ type: Input }],
4440
+ externalCatalogStartupInfo: [{ type: Input }],
4382
4441
  title: [{ type: Input }],
4383
4442
  subTitle: [{ type: Input }],
4384
4443
  searchPlaceholder: [{ type: Input }],
@@ -4388,6 +4447,7 @@ CatalogExternalSourceComponent.propDecorators = {
4388
4447
  name: [{ type: Input }],
4389
4448
  articleClick: [{ type: Output }],
4390
4449
  addArticleClick: [{ type: Output }],
4450
+ iFrameFeedbackReceived: [{ type: Output }],
4391
4451
  showClass: [{ type: HostBinding, args: ['class.co-catalog-external-source',] }]
4392
4452
  };
4393
4453