@smartbit4all/ng-client 2.1.2 → 2.2.0

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.
@@ -4120,18 +4120,28 @@ class UiActionService {
4120
4120
  identifier: uiAction.identifier,
4121
4121
  params: (_a = uiAction.params) !== null && _a !== void 0 ? _a : {},
4122
4122
  };
4123
- if (uiAction.submit) {
4124
- this.uiActionModel.serviceToUse.submit.next();
4125
- try {
4126
- yield this.uiActionModel.serviceToUse.submit.toPromise();
4127
- this.uiActionModel.serviceToUse.submit = new SmartSubject(this._destroy$);
4128
- this.uiActionModel.serviceToUse.reSubscribeToChange.next();
4123
+ if (uiAction.submit || uiAction.model) {
4124
+ // submit: with validation, model: without validation. both can be undefined
4125
+ const validate = !uiAction.model;
4126
+ if ('reSubscribeToChange' in this.uiActionModel.serviceToUse) {
4127
+ if (!validate) {
4128
+ console.error(`Validate = false, but UseUiAction doesn't support it`);
4129
+ }
4130
+ this.uiActionModel.serviceToUse.submit.next();
4131
+ try {
4132
+ yield this.uiActionModel.serviceToUse.submit.toPromise();
4133
+ this.uiActionModel.serviceToUse.submit = new SmartSubject(this._destroy$);
4134
+ this.uiActionModel.serviceToUse.reSubscribeToChange.next();
4135
+ }
4136
+ catch (error) {
4137
+ console.error(error);
4138
+ this.uiActionModel.serviceToUse.submit = new SmartSubject(this._destroy$);
4139
+ this.uiActionModel.serviceToUse.reSubscribeToChange.next();
4140
+ return;
4141
+ }
4129
4142
  }
4130
- catch (error) {
4131
- console.error(error);
4132
- this.uiActionModel.serviceToUse.submit = new SmartSubject(this._destroy$);
4133
- this.uiActionModel.serviceToUse.reSubscribeToChange.next();
4134
- return;
4143
+ else {
4144
+ this.uiActionModel.serviceToUse.submitForm(validate);
4135
4145
  }
4136
4146
  }
4137
4147
  if (uiAction.confirm) {
@@ -5912,14 +5922,31 @@ let SmartComponentApiClient = class SmartComponentApiClient {
5912
5922
  this.pageName = pageName;
5913
5923
  this._destroy$ = new Subject();
5914
5924
  this.sendDataChanges = false;
5915
- this._useAutoSubmit = false;
5916
- this._useAutoSubmitTurnedOff = new SmartSubject(this._destroy$);
5925
+ // private _useAutoSubmit: boolean = false;
5926
+ // private _useAutoSubmitTurnedOff: Subject<void> = new SmartSubject(this._destroy$);
5927
+ // protected get useAutoSubmit(): boolean {
5928
+ // return this._useAutoSubmit;
5929
+ // }
5930
+ // protected set useAutoSubmit(useAutoSubmit: boolean) {
5931
+ // this._useAutoSubmit = useAutoSubmit;
5932
+ // if (this._useAutoSubmit) {
5933
+ // this.subscribeToAutoSubmit();
5934
+ // this.reSubscribeToChange.pipe(takeUntil(this._useAutoSubmitTurnedOff)).subscribe(() => {
5935
+ // this.subscribeToAutoSubmit();
5936
+ // });
5937
+ // } else {
5938
+ // this._useAutoSubmitTurnedOff.next();
5939
+ // }
5940
+ // }
5941
+ // private subscribeToAutoSubmit(): void {
5942
+ // this.submit.pipe(takeUntil(this._useAutoSubmitTurnedOff)).subscribe(() => {
5943
+ // this.submitForms();
5944
+ // this.submit.complete();
5945
+ // });
5946
+ // }
5917
5947
  this.detectChange = new SmartSubject(this._destroy$);
5918
5948
  this.uiActionModels = [];
5919
5949
  this.dataChanged = new SmartSubject(this._destroy$);
5920
- // UseUiAction
5921
- this.submit = new SmartSubject(this._destroy$);
5922
- this.reSubscribeToChange = new SmartSubject(this._destroy$);
5923
5950
  // Contained Widgets
5924
5951
  this.widgets = new WidgetMap();
5925
5952
  this.formWidgets = new WidgetMap();
@@ -5930,27 +5957,6 @@ let SmartComponentApiClient = class SmartComponentApiClient {
5930
5957
  this.uiActionService = inject.get(UiActionService);
5931
5958
  this.uiActionDescriptorService = inject.get(UiActionDescriptorService);
5932
5959
  }
5933
- get useAutoSubmit() {
5934
- return this._useAutoSubmit;
5935
- }
5936
- set useAutoSubmit(useAutoSubmit) {
5937
- this._useAutoSubmit = useAutoSubmit;
5938
- if (this._useAutoSubmit) {
5939
- this.subscribeToAutoSubmit();
5940
- this.reSubscribeToChange.pipe(takeUntil(this._useAutoSubmitTurnedOff)).subscribe(() => {
5941
- this.subscribeToAutoSubmit();
5942
- });
5943
- }
5944
- else {
5945
- this._useAutoSubmitTurnedOff.next();
5946
- }
5947
- }
5948
- subscribeToAutoSubmit() {
5949
- this.submit.pipe(takeUntil(this._useAutoSubmitTurnedOff)).subscribe(() => {
5950
- this.submitForms();
5951
- this.submit.complete();
5952
- });
5953
- }
5954
5960
  get uuid() {
5955
5961
  return this._uuid;
5956
5962
  }
@@ -6063,6 +6069,9 @@ let SmartComponentApiClient = class SmartComponentApiClient {
6063
6069
  getModel() {
6064
6070
  return this.data;
6065
6071
  }
6072
+ submitForm(validate) {
6073
+ this.submitForms(validate);
6074
+ }
6066
6075
  performUiActionRequest(uiActionRequest, widgetId, nodeId) {
6067
6076
  return __awaiter(this, void 0, void 0, function* () {
6068
6077
  if (uiActionRequest.params['_files']) {
@@ -6097,10 +6106,10 @@ let SmartComponentApiClient = class SmartComponentApiClient {
6097
6106
  /**
6098
6107
  * Submits all the registered forms in the SmartComponent
6099
6108
  */
6100
- submitForms() {
6109
+ submitForms(validate) {
6101
6110
  Object.keys(this.formWidgets.widgets).map((key) => {
6102
6111
  var _a;
6103
- (_a = this.formWidgets.widgets.get(key)) === null || _a === void 0 ? void 0 : _a.submitForm();
6112
+ (_a = this.formWidgets.widgets.get(key)) === null || _a === void 0 ? void 0 : _a.submitForm(validate);
6104
6113
  });
6105
6114
  }
6106
6115
  addGrid(smartGrid, options, useAsDefaultGrid, componentReference) {
@@ -6176,14 +6185,17 @@ let SmartComponentApiClient = class SmartComponentApiClient {
6176
6185
  if (change.changes) {
6177
6186
  const changes = change.changes;
6178
6187
  Object.keys(changes).map((changeKey) => {
6179
- var _a, _b;
6188
+ var _a, _b, _c;
6180
6189
  if (changeKey.startsWith('data.')) {
6181
6190
  this.handleDataChange(changes, changeKey);
6182
6191
  }
6183
6192
  else if (changeKey.startsWith('layouts.') && ((_a = this.model) === null || _a === void 0 ? void 0 : _a.layouts)) {
6184
6193
  this.handleLayoutChange(changes, changeKey);
6185
6194
  }
6186
- else if (changeKey.startsWith('valueSets.') && ((_b = this.model) === null || _b === void 0 ? void 0 : _b.valueSets)) {
6195
+ else if (changeKey.startsWith('componentLayouts.') && ((_b = this.model) === null || _b === void 0 ? void 0 : _b.layouts)) {
6196
+ this.handleComponentLayoutChange(changes, changeKey);
6197
+ }
6198
+ else if (changeKey.startsWith('valueSets.') && ((_c = this.model) === null || _c === void 0 ? void 0 : _c.valueSets)) {
6187
6199
  this.handleValueSetChange(changes, changeKey);
6188
6200
  }
6189
6201
  else if (changeKey === 'actions') {
@@ -6258,6 +6270,11 @@ let SmartComponentApiClient = class SmartComponentApiClient {
6258
6270
  let layoutKey = changeKey.split('.')[1];
6259
6271
  this.model.layouts[layoutKey] = changes[changeKey];
6260
6272
  }
6273
+ handleComponentLayoutChange(changes, changeKey) {
6274
+ let layoutKey = changeKey.split('.')[1];
6275
+ let componentLayouts = this.model.componentLayouts;
6276
+ componentLayouts[layoutKey] = changes[changeKey];
6277
+ }
6261
6278
  handleValueSetChange(changes, changeKey) {
6262
6279
  let valueSetKey = changeKey.split('.')[1];
6263
6280
  this.model.valueSets[valueSetKey] = changes[changeKey];