@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.
@@ -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
+ }, true);
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,61 @@ 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, providedIn: 'root' });
2482
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: ApiQueueService, decorators: [{
2483
+ type: Injectable,
2484
+ args: [{
2485
+ providedIn: 'root',
2486
+ }]
2487
+ }], ctorParameters: function () { return []; } });
2373
2488
 
2374
2489
  class SmartNgClientService {
2375
2490
  constructor(session, viewContext) {
@@ -3868,6 +3983,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
3868
3983
  this.auth = auth;
3869
3984
  this.pageName = pageName;
3870
3985
  this._destroy$ = new Subject();
3986
+ this.sendDataChanges = false;
3871
3987
  this.detectChange = new SmartSubject(this._destroy$);
3872
3988
  this.uiActionModels = [];
3873
3989
  this.dataChanged = new SmartSubject(this._destroy$);
@@ -4006,7 +4122,14 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4006
4122
  }
4007
4123
  addForm(smartFormId, smartForm, componentReference) {
4008
4124
  this.formWidgets.addWidget(smartFormId, componentReference);
4009
- // TODO form value changes
4125
+ if (this.sendDataChanges && componentReference) {
4126
+ smartForm.useOnValueChangeEvent = true;
4127
+ componentReference.sophisticatedValueChange
4128
+ .pipe(takeUntil(this._destroy$))
4129
+ .subscribe((valueChange) => {
4130
+ this.handleValueChanges(valueChange);
4131
+ });
4132
+ }
4010
4133
  return smartForm;
4011
4134
  }
4012
4135
  setUpDefaultTree(treeId) {
@@ -4019,6 +4142,26 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4019
4142
  return treeService;
4020
4143
  }
4021
4144
  // #region handle changes
4145
+ handleValueChanges(valueChange) {
4146
+ let dataChange;
4147
+ if (valueChange.key.includes('.')) {
4148
+ const source = valueChange.key.split('.')[0];
4149
+ const valueKey = valueChange.key.split('.')[1];
4150
+ dataChange = {
4151
+ kind: valueChange.kind === 'basic' ? DataChangeKind.Widget : DataChangeKind.Selection,
4152
+ source,
4153
+ values: [[valueKey, valueChange.value]],
4154
+ };
4155
+ }
4156
+ else {
4157
+ dataChange = {
4158
+ kind: valueChange.kind === 'basic' ? DataChangeKind.Widget : DataChangeKind.Selection,
4159
+ source: valueChange.key,
4160
+ values: [[valueChange.key, valueChange.value]],
4161
+ };
4162
+ }
4163
+ this.viewContext.dataChanged(this.uuid, dataChange);
4164
+ }
4022
4165
  handleChanges(change) {
4023
4166
  if (change.changedWidgets) {
4024
4167
  this.handleChangeWidgets(change.changedWidgets);
@@ -4082,7 +4225,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
4082
4225
  return model;
4083
4226
  }
4084
4227
  handleDataChange(changes, changeKey) {
4085
- this.setValueDeeply(this.data, changeKey, changes[changeKey]);
4228
+ this.setValueDeeply(this.model, changeKey, changes[changeKey]);
4086
4229
  this.formWidgets.widgets.forEach((formComponent, key) => {
4087
4230
  if (formComponent === undefined) {
4088
4231
  console.error(`Provided form reference for ${key} is undefined.`);
@@ -4199,5 +4342,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImpo
4199
4342
  * Generated bundle index. Do not edit.
4200
4343
  */
4201
4344
 
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 };
4345
+ 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
4346
  //# sourceMappingURL=smartbit4all-ng-client.mjs.map