@smartbit4all/ng-client 1.1.1 → 1.1.3

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.
@@ -2075,11 +2075,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
2075
2075
  }], ctorParameters: function () { return [{ type: SmartViewContextService }]; } });
2076
2076
 
2077
2077
  class SmartViewContextService {
2078
- constructor(view, session, navigation, dialog) {
2078
+ constructor(view, session, navigation, dialog, apiQueueService) {
2079
2079
  this.view = view;
2080
2080
  this.session = session;
2081
2081
  this.navigation = navigation;
2082
2082
  this.dialog = dialog;
2083
+ this.apiQueueService = apiQueueService;
2083
2084
  this.tabIdName = 'viewContextUuid';
2084
2085
  this.tabIdhttpHeaderName = 'viewContextUuid';
2085
2086
  this.viewHandlers = new Array();
@@ -2376,13 +2377,71 @@ class SmartViewContextService {
2376
2377
  return await this.view.downloadItem(uuid, item).toPromise();
2377
2378
  }
2378
2379
  async performAction(uuid, uiActionRequest) {
2379
- return await this.handlePerformActionResponse(await this.view.performAction(uuid, uiActionRequest).toPromise());
2380
+ const isCompleted = new Subject();
2381
+ this.apiQueueService.addToQueue({
2382
+ callback: this._performAction.bind(this),
2383
+ config: {
2384
+ uuid,
2385
+ uiActionRequest,
2386
+ },
2387
+ isCompleted,
2388
+ });
2389
+ return await isCompleted.toPromise();
2380
2390
  }
2381
2391
  async performWidgetAction(uuid, widgetId, nodeId, uiActionRequest) {
2382
- return await this.handlePerformActionResponse(await this.view.performWidgetAction(uuid, widgetId, nodeId, uiActionRequest).toPromise());
2392
+ const isCompleted = new Subject();
2393
+ this.apiQueueService.addToQueue({
2394
+ callback: this._performWidgetAction.bind(this),
2395
+ config: {
2396
+ uuid,
2397
+ widgetId,
2398
+ nodeId,
2399
+ uiActionRequest,
2400
+ },
2401
+ isCompleted,
2402
+ });
2403
+ return await isCompleted.toPromise();
2383
2404
  }
2384
2405
  async performWidgetMainAction(uuid, widgetId, uiActionRequest) {
2385
- return await this.handlePerformActionResponse(await this.view.performWidgetMainAction(uuid, widgetId, uiActionRequest).toPromise());
2406
+ const isCompleted = new Subject();
2407
+ this.apiQueueService.addToQueue({
2408
+ callback: this._performWidgetMainAction.bind(this),
2409
+ config: {
2410
+ uuid,
2411
+ widgetId,
2412
+ uiActionRequest,
2413
+ },
2414
+ isCompleted,
2415
+ });
2416
+ return await isCompleted.toPromise();
2417
+ }
2418
+ async dataChanged(uuid, dataChange) {
2419
+ const isCompleted = new Subject();
2420
+ this.apiQueueService.addToQueue({
2421
+ callback: this._dataChanged.bind(this),
2422
+ config: {
2423
+ uuid,
2424
+ dataChange,
2425
+ },
2426
+ isCompleted,
2427
+ });
2428
+ return await isCompleted.toPromise();
2429
+ }
2430
+ async _performAction(config) {
2431
+ return await this.handlePerformActionResponse(await this.view.performAction(config.uuid, config.uiActionRequest).toPromise());
2432
+ }
2433
+ async _performWidgetAction(config) {
2434
+ return await this.handlePerformActionResponse(await this.view
2435
+ .performWidgetAction(config.uuid, config.widgetId, config.nodeId, config.uiActionRequest)
2436
+ .toPromise());
2437
+ }
2438
+ async _performWidgetMainAction(config) {
2439
+ return await this.handlePerformActionResponse(await this.view
2440
+ .performWidgetMainAction(config.uuid, config.widgetId, config.uiActionRequest)
2441
+ .toPromise());
2442
+ }
2443
+ async _dataChanged(config) {
2444
+ return await this.handlePerformActionResponse(await this.view.dataChanged(config.uuid, config.dataChange).toPromise());
2386
2445
  }
2387
2446
  async handlePerformActionResponse(viewContextChange) {
2388
2447
  this.viewContext = viewContextChange?.viewContext;
@@ -2403,15 +2462,56 @@ class SmartViewContextService {
2403
2462
  return await this.view.getComponentModel(uuid).toPromise();
2404
2463
  }
2405
2464
  }
2406
- SmartViewContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextService, deps: [{ token: ViewService }, { token: SmartSessionService }, { token: i3$1.SmartNavigationService }, { token: i4.SmartdialogService }], target: i0.ɵɵFactoryTarget.Injectable });
2465
+ SmartViewContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextService, deps: [{ token: ViewService }, { token: SmartSessionService }, { token: i3$1.SmartNavigationService }, { token: i4.SmartdialogService }, { token: ApiQueueService }], target: i0.ɵɵFactoryTarget.Injectable });
2407
2466
  SmartViewContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextService, providedIn: 'root' });
2408
2467
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextService, decorators: [{
2409
2468
  type: Injectable,
2410
2469
  args: [{
2411
2470
  providedIn: 'root',
2412
2471
  }]
2413
- }], ctorParameters: function () { return [{ type: ViewService }, { type: SmartSessionService }, { type: i3$1.SmartNavigationService }, { type: i4.SmartdialogService }]; } });
2472
+ }], ctorParameters: function () { return [{ type: ViewService }, { type: SmartSessionService }, { type: i3$1.SmartNavigationService }, { type: i4.SmartdialogService }, { type: ApiQueueService }]; } });
2414
2473
  const IS_ASYNC_PARAM_NAME = 'isAsync';
2474
+ class ApiQueueService {
2475
+ constructor() {
2476
+ this._destroy$ = new Subject();
2477
+ this.queue = [];
2478
+ this.isProcessing = false;
2479
+ this.queueSubject = new Subject();
2480
+ this.queueSubject.pipe(takeUntil(this._destroy$)).subscribe(() => this.processQueue());
2481
+ }
2482
+ ngOnDestroy() {
2483
+ this._destroy$.next();
2484
+ this._destroy$.complete();
2485
+ }
2486
+ addToQueue(call, priority = false) {
2487
+ if (priority) {
2488
+ this.queue.unshift(call); // Add at the beginning of the queue if it has higher priority
2489
+ }
2490
+ else {
2491
+ this.queue.push(call); // Add at the end of the queue if it has lower priority
2492
+ }
2493
+ if (!this.isProcessing) {
2494
+ this.processQueue();
2495
+ }
2496
+ }
2497
+ async processQueue() {
2498
+ if (this.queue.length === 0) {
2499
+ this.isProcessing = false;
2500
+ return;
2501
+ }
2502
+ const apiQueueCall = this.queue.shift();
2503
+ if (apiQueueCall) {
2504
+ await apiQueueCall.callback(apiQueueCall.config);
2505
+ apiQueueCall.isCompleted.complete();
2506
+ this.queueSubject.next();
2507
+ }
2508
+ }
2509
+ }
2510
+ ApiQueueService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiQueueService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2511
+ ApiQueueService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiQueueService });
2512
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiQueueService, decorators: [{
2513
+ type: Injectable
2514
+ }], ctorParameters: function () { return []; } });
2415
2515
 
2416
2516
  class SmartNgClientService {
2417
2517
  constructor(session, viewContext) {
@@ -3873,6 +3973,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
3873
3973
  this.auth = auth;
3874
3974
  this.pageName = pageName;
3875
3975
  this._destroy$ = new Subject();
3976
+ this.sendDataChanges = false;
3876
3977
  this.detectChange = new SmartSubject(this._destroy$);
3877
3978
  this.uiActionModels = [];
3878
3979
  this.dataChanged = new SmartSubject(this._destroy$);
@@ -3996,16 +4097,23 @@ let SmartComponentApiClient = class SmartComponentApiClient {
3996
4097
  smartGrid.uiActionDescriptorService = this.uiActionDescriptorService;
3997
4098
  smartGrid.serviceToUse = this;
3998
4099
  smartGrid.viewContextService = this.viewContext;
4100
+ this.widgets.addWidget(smartGrid.gridIdentifier, componentReference);
3999
4101
  if (useAsDefaultGrid) {
4000
4102
  this.smartGrid = smartGrid;
4001
4103
  return this.smartGrid;
4002
4104
  }
4003
- this.widgets.addWidget(smartGrid.gridIdentifier, componentReference);
4004
4105
  return smartGrid;
4005
4106
  }
4006
4107
  addForm(smartFormId, smartForm, componentReference) {
4007
4108
  this.formWidgets.addWidget(smartFormId, componentReference);
4008
- // TODO form value changes
4109
+ if (this.sendDataChanges && componentReference) {
4110
+ smartForm.useOnValueChangeEvent = true;
4111
+ componentReference.sophisticatedValueChange
4112
+ .pipe(takeUntil(this._destroy$))
4113
+ .subscribe((valueChange) => {
4114
+ this.handleValueChanges(valueChange);
4115
+ });
4116
+ }
4009
4117
  return smartForm;
4010
4118
  }
4011
4119
  setUpDefaultTree(treeId) {
@@ -4018,6 +4126,26 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4018
4126
  return treeService;
4019
4127
  }
4020
4128
  // #region handle changes
4129
+ handleValueChanges(valueChange) {
4130
+ let dataChange;
4131
+ if (valueChange.key.includes('.')) {
4132
+ const source = valueChange.key.split('.')[0];
4133
+ const valueKey = valueChange.key.split('.')[1];
4134
+ dataChange = {
4135
+ kind: valueChange.kind === 'basic' ? DataChangeKind.Widget : DataChangeKind.Selection,
4136
+ source,
4137
+ values: [[valueKey, valueChange.value]],
4138
+ };
4139
+ }
4140
+ else {
4141
+ dataChange = {
4142
+ kind: valueChange.kind === 'basic' ? DataChangeKind.Widget : DataChangeKind.Selection,
4143
+ source: valueChange.key,
4144
+ values: [[valueChange.key, valueChange.value]],
4145
+ };
4146
+ }
4147
+ this.viewContext.dataChanged(this.uuid, dataChange);
4148
+ }
4021
4149
  handleChanges(change) {
4022
4150
  if (change.changedWidgets) {
4023
4151
  this.handleChangeWidgets(change.changedWidgets);
@@ -4080,7 +4208,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4080
4208
  return model;
4081
4209
  }
4082
4210
  handleDataChange(changes, changeKey) {
4083
- this.setValueDeeply(this.data, changeKey, changes[changeKey]);
4211
+ this.setValueDeeply(this.model, changeKey, changes[changeKey]);
4084
4212
  this.formWidgets.widgets.forEach((formComponent, key) => {
4085
4213
  if (formComponent === undefined) {
4086
4214
  console.error(`Provided form reference for ${key} is undefined.`);
@@ -4193,5 +4321,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
4193
4321
  * Generated bundle index. Do not edit.
4194
4322
  */
4195
4323
 
4196
- export { APIS, ApiModule, BASE_PATH, COLLECTION_FORMATS, CloseResult, Configuration, DataChangeKind, IS_ASYNC_PARAM_NAME, MessageOptionType, MessageType, SessionAPIS, SessionErrorBehaviour, SessionService, SmartAuthService, SmartComponent, SmartComponentApiClient, SmartDevToolDatePipe, SmartDevToolFloatingButtonComponent, SmartDevToolService, SmartLinkChannelVariableInPath, SmartLinkUuidVariableInPath, SmartNgClientModule, SmartNgClientService, SmartService, SmartSessionModule, SmartSessionService, SmartSessionTimerComponent, SmartSessionTimerService, SmartSubject, SmartViewContextModule, SmartViewContextService, SmartViewRedirect, UiActionButtonIconPos, UiActionButtonType, UiActionConfirmDialogComponent, UiActionConfirmDialogService, UiActionDescriptorService, UiActionDialogType, UiActionFeedbackType, UiActionInputDialogComponent, UiActionInputDialogService, UiActionInputType, UiActionService, UiActionToolbarComponent, ViewEventHandler, ViewService, ViewState, ViewType, WidgetMap };
4324
+ export { APIS, ApiModule, ApiQueueService, BASE_PATH, COLLECTION_FORMATS, CloseResult, Configuration, DataChangeKind, IS_ASYNC_PARAM_NAME, MessageOptionType, MessageType, SessionAPIS, SessionErrorBehaviour, SessionService, SmartAuthService, SmartComponent, SmartComponentApiClient, SmartDevToolDatePipe, SmartDevToolFloatingButtonComponent, SmartDevToolService, SmartLinkChannelVariableInPath, SmartLinkUuidVariableInPath, SmartNgClientModule, SmartNgClientService, SmartService, SmartSessionModule, SmartSessionService, SmartSessionTimerComponent, SmartSessionTimerService, SmartSubject, SmartViewContextModule, SmartViewContextService, SmartViewRedirect, UiActionButtonIconPos, UiActionButtonType, UiActionConfirmDialogComponent, UiActionConfirmDialogService, UiActionDescriptorService, UiActionDialogType, UiActionFeedbackType, UiActionInputDialogComponent, UiActionInputDialogService, UiActionInputType, UiActionService, UiActionToolbarComponent, ViewEventHandler, ViewService, ViewState, ViewType, WidgetMap };
4197
4325
  //# sourceMappingURL=smartbit4all-ng-client.mjs.map