@smartbit4all/ng-client 1.1.2 → 1.1.5

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
+ }, true);
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,59 @@ 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, providedIn: 'root' });
2512
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiQueueService, decorators: [{
2513
+ type: Injectable,
2514
+ args: [{
2515
+ providedIn: 'root',
2516
+ }]
2517
+ }], ctorParameters: function () { return []; } });
2415
2518
 
2416
2519
  class SmartNgClientService {
2417
2520
  constructor(session, viewContext) {
@@ -3873,6 +3976,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
3873
3976
  this.auth = auth;
3874
3977
  this.pageName = pageName;
3875
3978
  this._destroy$ = new Subject();
3979
+ this.sendDataChanges = false;
3876
3980
  this.detectChange = new SmartSubject(this._destroy$);
3877
3981
  this.uiActionModels = [];
3878
3982
  this.dataChanged = new SmartSubject(this._destroy$);
@@ -4005,7 +4109,14 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4005
4109
  }
4006
4110
  addForm(smartFormId, smartForm, componentReference) {
4007
4111
  this.formWidgets.addWidget(smartFormId, componentReference);
4008
- // TODO form value changes
4112
+ if (this.sendDataChanges && componentReference) {
4113
+ smartForm.useOnValueChangeEvent = true;
4114
+ componentReference.sophisticatedValueChange
4115
+ .pipe(takeUntil(this._destroy$))
4116
+ .subscribe((valueChange) => {
4117
+ this.handleValueChanges(valueChange);
4118
+ });
4119
+ }
4009
4120
  return smartForm;
4010
4121
  }
4011
4122
  setUpDefaultTree(treeId) {
@@ -4018,6 +4129,26 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4018
4129
  return treeService;
4019
4130
  }
4020
4131
  // #region handle changes
4132
+ handleValueChanges(valueChange) {
4133
+ let dataChange;
4134
+ if (valueChange.key.includes('.')) {
4135
+ const source = valueChange.key.split('.')[0];
4136
+ const valueKey = valueChange.key.split('.')[1];
4137
+ dataChange = {
4138
+ kind: valueChange.kind === 'basic' ? DataChangeKind.Widget : DataChangeKind.Selection,
4139
+ source,
4140
+ values: [[valueKey, valueChange.value]],
4141
+ };
4142
+ }
4143
+ else {
4144
+ dataChange = {
4145
+ kind: valueChange.kind === 'basic' ? DataChangeKind.Widget : DataChangeKind.Selection,
4146
+ source: valueChange.key,
4147
+ values: [[valueChange.key, valueChange.value]],
4148
+ };
4149
+ }
4150
+ this.viewContext.dataChanged(this.uuid, dataChange);
4151
+ }
4021
4152
  handleChanges(change) {
4022
4153
  if (change.changedWidgets) {
4023
4154
  this.handleChangeWidgets(change.changedWidgets);
@@ -4080,7 +4211,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4080
4211
  return model;
4081
4212
  }
4082
4213
  handleDataChange(changes, changeKey) {
4083
- this.setValueDeeply(this.data, changeKey, changes[changeKey]);
4214
+ this.setValueDeeply(this.model, changeKey, changes[changeKey]);
4084
4215
  this.formWidgets.widgets.forEach((formComponent, key) => {
4085
4216
  if (formComponent === undefined) {
4086
4217
  console.error(`Provided form reference for ${key} is undefined.`);
@@ -4193,5 +4324,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
4193
4324
  * Generated bundle index. Do not edit.
4194
4325
  */
4195
4326
 
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 };
4327
+ 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
4328
  //# sourceMappingURL=smartbit4all-ng-client.mjs.map