@smartbit4all/ng-client 1.1.2 → 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.
@@ -1996,11 +1996,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
1996
1996
  }], ctorParameters: function () { return [{ type: SmartViewContextService }]; } });
1997
1997
 
1998
1998
  class SmartViewContextService {
1999
- constructor(view, session, navigation, dialog) {
1999
+ constructor(view, session, navigation, dialog, apiQueueService) {
2000
2000
  this.view = view;
2001
2001
  this.session = session;
2002
2002
  this.navigation = navigation;
2003
2003
  this.dialog = dialog;
2004
+ this.apiQueueService = apiQueueService;
2004
2005
  this.tabIdName = 'viewContextUuid';
2005
2006
  this.tabIdhttpHeaderName = 'viewContextUuid';
2006
2007
  this.viewHandlers = new Array();
@@ -2325,17 +2326,85 @@ class SmartViewContextService {
2325
2326
  }
2326
2327
  performAction(uuid, uiActionRequest) {
2327
2328
  return __awaiter(this, void 0, void 0, function* () {
2328
- return yield this.handlePerformActionResponse(yield this.view.performAction(uuid, uiActionRequest).toPromise());
2329
+ const isCompleted = new Subject();
2330
+ this.apiQueueService.addToQueue({
2331
+ callback: this._performAction.bind(this),
2332
+ config: {
2333
+ uuid,
2334
+ uiActionRequest,
2335
+ },
2336
+ isCompleted,
2337
+ });
2338
+ return yield isCompleted.toPromise();
2329
2339
  });
2330
2340
  }
2331
2341
  performWidgetAction(uuid, widgetId, nodeId, uiActionRequest) {
2332
2342
  return __awaiter(this, void 0, void 0, function* () {
2333
- return yield this.handlePerformActionResponse(yield this.view.performWidgetAction(uuid, widgetId, nodeId, uiActionRequest).toPromise());
2343
+ const isCompleted = new Subject();
2344
+ this.apiQueueService.addToQueue({
2345
+ callback: this._performWidgetAction.bind(this),
2346
+ config: {
2347
+ uuid,
2348
+ widgetId,
2349
+ nodeId,
2350
+ uiActionRequest,
2351
+ },
2352
+ isCompleted,
2353
+ });
2354
+ return yield isCompleted.toPromise();
2334
2355
  });
2335
2356
  }
2336
2357
  performWidgetMainAction(uuid, widgetId, uiActionRequest) {
2337
2358
  return __awaiter(this, void 0, void 0, function* () {
2338
- return yield this.handlePerformActionResponse(yield this.view.performWidgetMainAction(uuid, widgetId, uiActionRequest).toPromise());
2359
+ const isCompleted = new Subject();
2360
+ this.apiQueueService.addToQueue({
2361
+ callback: this._performWidgetMainAction.bind(this),
2362
+ config: {
2363
+ uuid,
2364
+ widgetId,
2365
+ uiActionRequest,
2366
+ },
2367
+ isCompleted,
2368
+ });
2369
+ return yield isCompleted.toPromise();
2370
+ });
2371
+ }
2372
+ dataChanged(uuid, dataChange) {
2373
+ return __awaiter(this, void 0, void 0, function* () {
2374
+ const isCompleted = new Subject();
2375
+ this.apiQueueService.addToQueue({
2376
+ callback: this._dataChanged.bind(this),
2377
+ config: {
2378
+ uuid,
2379
+ dataChange,
2380
+ },
2381
+ isCompleted,
2382
+ });
2383
+ return yield isCompleted.toPromise();
2384
+ });
2385
+ }
2386
+ _performAction(config) {
2387
+ return __awaiter(this, void 0, void 0, function* () {
2388
+ return yield this.handlePerformActionResponse(yield this.view.performAction(config.uuid, config.uiActionRequest).toPromise());
2389
+ });
2390
+ }
2391
+ _performWidgetAction(config) {
2392
+ return __awaiter(this, void 0, void 0, function* () {
2393
+ return yield this.handlePerformActionResponse(yield this.view
2394
+ .performWidgetAction(config.uuid, config.widgetId, config.nodeId, config.uiActionRequest)
2395
+ .toPromise());
2396
+ });
2397
+ }
2398
+ _performWidgetMainAction(config) {
2399
+ return __awaiter(this, void 0, void 0, function* () {
2400
+ return yield this.handlePerformActionResponse(yield this.view
2401
+ .performWidgetMainAction(config.uuid, config.widgetId, config.uiActionRequest)
2402
+ .toPromise());
2403
+ });
2404
+ }
2405
+ _dataChanged(config) {
2406
+ return __awaiter(this, void 0, void 0, function* () {
2407
+ return yield this.handlePerformActionResponse(yield this.view.dataChanged(config.uuid, config.dataChange).toPromise());
2339
2408
  });
2340
2409
  }
2341
2410
  handlePerformActionResponse(viewContextChange) {
@@ -2361,15 +2430,58 @@ class SmartViewContextService {
2361
2430
  });
2362
2431
  }
2363
2432
  }
2364
- 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 });
2433
+ 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 });
2365
2434
  SmartViewContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextService, providedIn: 'root' });
2366
2435
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: SmartViewContextService, decorators: [{
2367
2436
  type: Injectable,
2368
2437
  args: [{
2369
2438
  providedIn: 'root',
2370
2439
  }]
2371
- }], ctorParameters: function () { return [{ type: ViewService }, { type: SmartSessionService }, { type: i3$1.SmartNavigationService }, { type: i4.SmartdialogService }]; } });
2440
+ }], ctorParameters: function () { return [{ type: ViewService }, { type: SmartSessionService }, { type: i3$1.SmartNavigationService }, { type: i4.SmartdialogService }, { type: ApiQueueService }]; } });
2372
2441
  const IS_ASYNC_PARAM_NAME = 'isAsync';
2442
+ class ApiQueueService {
2443
+ constructor() {
2444
+ this._destroy$ = new Subject();
2445
+ this.queue = [];
2446
+ this.isProcessing = false;
2447
+ this.queueSubject = new Subject();
2448
+ this.queueSubject.pipe(takeUntil(this._destroy$)).subscribe(() => this.processQueue());
2449
+ }
2450
+ ngOnDestroy() {
2451
+ this._destroy$.next();
2452
+ this._destroy$.complete();
2453
+ }
2454
+ addToQueue(call, priority = false) {
2455
+ if (priority) {
2456
+ this.queue.unshift(call); // Add at the beginning of the queue if it has higher priority
2457
+ }
2458
+ else {
2459
+ this.queue.push(call); // Add at the end of the queue if it has lower priority
2460
+ }
2461
+ if (!this.isProcessing) {
2462
+ this.processQueue();
2463
+ }
2464
+ }
2465
+ processQueue() {
2466
+ return __awaiter(this, void 0, void 0, function* () {
2467
+ if (this.queue.length === 0) {
2468
+ this.isProcessing = false;
2469
+ return;
2470
+ }
2471
+ const apiQueueCall = this.queue.shift();
2472
+ if (apiQueueCall) {
2473
+ yield apiQueueCall.callback(apiQueueCall.config);
2474
+ apiQueueCall.isCompleted.complete();
2475
+ this.queueSubject.next();
2476
+ }
2477
+ });
2478
+ }
2479
+ }
2480
+ ApiQueueService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiQueueService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
2481
+ ApiQueueService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiQueueService });
2482
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiQueueService, decorators: [{
2483
+ type: Injectable
2484
+ }], ctorParameters: function () { return []; } });
2373
2485
 
2374
2486
  class SmartNgClientService {
2375
2487
  constructor(session, viewContext) {
@@ -3868,6 +3980,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
3868
3980
  this.auth = auth;
3869
3981
  this.pageName = pageName;
3870
3982
  this._destroy$ = new Subject();
3983
+ this.sendDataChanges = false;
3871
3984
  this.detectChange = new SmartSubject(this._destroy$);
3872
3985
  this.uiActionModels = [];
3873
3986
  this.dataChanged = new SmartSubject(this._destroy$);
@@ -4006,7 +4119,14 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4006
4119
  }
4007
4120
  addForm(smartFormId, smartForm, componentReference) {
4008
4121
  this.formWidgets.addWidget(smartFormId, componentReference);
4009
- // TODO form value changes
4122
+ if (this.sendDataChanges && componentReference) {
4123
+ smartForm.useOnValueChangeEvent = true;
4124
+ componentReference.sophisticatedValueChange
4125
+ .pipe(takeUntil(this._destroy$))
4126
+ .subscribe((valueChange) => {
4127
+ this.handleValueChanges(valueChange);
4128
+ });
4129
+ }
4010
4130
  return smartForm;
4011
4131
  }
4012
4132
  setUpDefaultTree(treeId) {
@@ -4019,6 +4139,26 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4019
4139
  return treeService;
4020
4140
  }
4021
4141
  // #region handle changes
4142
+ handleValueChanges(valueChange) {
4143
+ let dataChange;
4144
+ if (valueChange.key.includes('.')) {
4145
+ const source = valueChange.key.split('.')[0];
4146
+ const valueKey = valueChange.key.split('.')[1];
4147
+ dataChange = {
4148
+ kind: valueChange.kind === 'basic' ? DataChangeKind.Widget : DataChangeKind.Selection,
4149
+ source,
4150
+ values: [[valueKey, valueChange.value]],
4151
+ };
4152
+ }
4153
+ else {
4154
+ dataChange = {
4155
+ kind: valueChange.kind === 'basic' ? DataChangeKind.Widget : DataChangeKind.Selection,
4156
+ source: valueChange.key,
4157
+ values: [[valueChange.key, valueChange.value]],
4158
+ };
4159
+ }
4160
+ this.viewContext.dataChanged(this.uuid, dataChange);
4161
+ }
4022
4162
  handleChanges(change) {
4023
4163
  if (change.changedWidgets) {
4024
4164
  this.handleChangeWidgets(change.changedWidgets);
@@ -4082,7 +4222,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4082
4222
  return model;
4083
4223
  }
4084
4224
  handleDataChange(changes, changeKey) {
4085
- this.setValueDeeply(this.data, changeKey, changes[changeKey]);
4225
+ this.setValueDeeply(this.model, changeKey, changes[changeKey]);
4086
4226
  this.formWidgets.widgets.forEach((formComponent, key) => {
4087
4227
  if (formComponent === undefined) {
4088
4228
  console.error(`Provided form reference for ${key} is undefined.`);
@@ -4199,5 +4339,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
4199
4339
  * Generated bundle index. Do not edit.
4200
4340
  */
4201
4341
 
4202
- 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 };
4342
+ 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 };
4203
4343
  //# sourceMappingURL=smartbit4all-ng-client.mjs.map