@smartbit4all/ng-client 3.0.11 → 3.0.12

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.
@@ -3083,6 +3083,7 @@ class SmartFormService {
3083
3083
  widget.type === SmartFormWidgetType.SELECT_MULTIPLE ||
3084
3084
  widget.type === SmartFormWidgetType.RADIO_BUTTON ||
3085
3085
  widget.type === SmartFormWidgetType.CHECK_BOX ||
3086
+ widget.type === SmartFormWidgetType.CHECK_BOX_2 ||
3086
3087
  widget.type === SmartFormWidgetType.TEXT_FIELD) {
3087
3088
  if (widget.selection && valueSets) {
3088
3089
  if (widget.selection.type === SelectionDefinition.TypeEnum.Property &&
@@ -10337,12 +10338,12 @@ class SmartGridService extends SmartdialogService {
10337
10338
  this.gridModelChanged.next();
10338
10339
  }
10339
10340
  updateGrid(gridModel, method) {
10341
+ this.gridModel = gridModel;
10340
10342
  if (gridModel) {
10341
- this.gridModel = gridModel;
10342
10343
  this.gridModelChanged.next();
10343
10344
  }
10344
10345
  else {
10345
- console.error(`GridModel is undefined in service after ${method}!`);
10346
+ console.warn(`GridModel is undefined in service after ${method}!`);
10346
10347
  }
10347
10348
  }
10348
10349
  }
@@ -10950,7 +10951,9 @@ class SmartGridComponent {
10950
10951
  this.isBlocked = true;
10951
10952
  this.service.gridModelChanged.subscribe(() => {
10952
10953
  // called after every service call (load, save, refresh, etc.)
10953
- this.smartGrid.gridModel = this.service.gridModel;
10954
+ if (this.service.gridModel) {
10955
+ this.smartGrid.gridModel = this.service.gridModel;
10956
+ }
10954
10957
  this.render();
10955
10958
  });
10956
10959
  }
@@ -10962,7 +10965,29 @@ class SmartGridComponent {
10962
10965
  this.uuid = changes['uuid'].currentValue;
10963
10966
  }
10964
10967
  if (this.afterViewInitExecuted && this.uuid && this.smartGrid) {
10965
- this.refresh();
10968
+ if (changes['smartGrid']) {
10969
+ let prev = changes['smartGrid'].previousValue;
10970
+ let curr = changes['smartGrid'].currentValue;
10971
+ if (!prev.pageLoaded && curr.pageLoaded) {
10972
+ if (!this.service.gridModel) {
10973
+ // page just loaded, gridModel was empty
10974
+ this.refresh();
10975
+ } // otherwise gridModel already loaded
10976
+ }
10977
+ else if (prev.pageLoaded && !curr.pageLoaded) {
10978
+ // page change in progress
10979
+ // TODO a bit awkard to clear service.model from here..
10980
+ this.service.gridModel = undefined;
10981
+ // TODO call render to show grid placeholder?
10982
+ }
10983
+ else {
10984
+ // something else changed in smartGrid -> refresh
10985
+ this.refresh();
10986
+ }
10987
+ }
10988
+ else {
10989
+ this.refresh();
10990
+ }
10966
10991
  }
10967
10992
  }
10968
10993
  ngOnDestroy() {
@@ -10975,7 +11000,7 @@ class SmartGridComponent {
10975
11000
  this.service.gridModel = this.smartGrid.gridModel;
10976
11001
  this.render();
10977
11002
  }
10978
- if (this.uuid && this.smartGrid && !this.dev) {
11003
+ else if (this.uuid && this.smartGrid && !this.service.gridModel) {
10979
11004
  this.refresh();
10980
11005
  }
10981
11006
  this.afterViewInitExecuted = true;
@@ -11081,15 +11106,13 @@ class SmartGridComponent {
11081
11106
  if (tableConfig.asyncOnExpand) {
11082
11107
  tableConfig.rowExpander = this;
11083
11108
  }
11084
- const selectionMode = this.service.gridModel.view?.descriptor?.selectionMode;
11109
+ const selectionMode = this.smartGrid.gridModel.view?.descriptor?.selectionMode;
11085
11110
  if (!tableConfig.selection &&
11086
11111
  !tableConfig.selectionProperty &&
11087
11112
  selectionMode !== GridSelectionMode.None) {
11088
11113
  const isMultiple = selectionMode === GridSelectionMode.Multiple;
11089
11114
  tableConfig.selectionProperty = 'id';
11090
- const selectedIds = this.service.gridModel.page
11091
- .rows.filter((gridRow) => gridRow.selected)
11092
- .map((gridRow) => gridRow.id);
11115
+ const selectedIds = this.smartGrid.gridModel.page.rows.filter((gridRow) => gridRow.selected).map((gridRow) => gridRow.id);
11093
11116
  tableConfig.selection = new SelectionModel(isMultiple, selectedIds);
11094
11117
  }
11095
11118
  this.smartTable = new SmartTable(tableConfig);
@@ -11196,8 +11219,8 @@ class SmartGridComponent {
11196
11219
  filterExpressionOrderByItem.order === FilterExpressionOrderBy.OrderEnum.Asc
11197
11220
  ? SmartTableOrder.ASC
11198
11221
  : SmartTableOrder.DESC;
11199
- if (this.service.gridModel.view.orderByList.length > 1) {
11200
- orderNumber = this.service.gridModel.view.orderByList.findIndex((filter) => filter.propertyName === descColumn.propertyName);
11222
+ if (this.smartGrid.gridModel.view.orderByList.length > 1) {
11223
+ orderNumber = this.smartGrid.gridModel.view.orderByList.findIndex((filter) => filter.propertyName === descColumn.propertyName);
11201
11224
  orderNumber++;
11202
11225
  }
11203
11226
  }
@@ -11339,10 +11362,12 @@ class SmartGridComponent {
11339
11362
  }
11340
11363
  async onSelect(rowId) {
11341
11364
  this.isBlocked = true;
11342
- const row = this.service.gridModel.page.rows?.find((gridRow) => gridRow.id === rowId);
11343
- const viewContextChange = await this.service.select(this.smartGrid, row);
11344
- this.smartGrid.viewContextService.handleChanges(viewContextChange.changes);
11345
- this.refresh();
11365
+ if (this.service.gridModel) {
11366
+ const row = this.service.gridModel.page.rows?.find((gridRow) => gridRow.id === rowId);
11367
+ const viewContextChange = await this.service.select(this.smartGrid, row);
11368
+ this.smartGrid.viewContextService.handleChanges(viewContextChange.changes);
11369
+ this.refresh();
11370
+ }
11346
11371
  }
11347
11372
  async onSelectAll(selected) {
11348
11373
  this.isBlocked = true;
@@ -11361,7 +11386,7 @@ class SmartGridComponent {
11361
11386
  config: {
11362
11387
  uuid: this.uuid,
11363
11388
  identifier: this.smartGrid.gridIdentifier,
11364
- view: this.service.gridModel.view,
11389
+ view: this.smartGrid.gridModel.view,
11365
11390
  },
11366
11391
  },
11367
11392
  };
@@ -12337,6 +12362,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
12337
12362
  this.dataChanged = new SmartSubject(this._destroy$);
12338
12363
  // Contained Widgets
12339
12364
  this.widgets = new WidgetMap();
12365
+ this.smartGrids = new WidgetMap();
12340
12366
  this.formWidgets = new WidgetMap();
12341
12367
  this.detectChange.subscribe((change) => {
12342
12368
  this.handleChanges(change);
@@ -12357,6 +12383,10 @@ let SmartComponentApiClient = class SmartComponentApiClient {
12357
12383
  this._uuid = uuid;
12358
12384
  if (uuid) {
12359
12385
  this.widgets.widgets.forEach((ref, key) => {
12386
+ let smartGrid = this.smartGrids.get(key);
12387
+ if (smartGrid) {
12388
+ smartGrid.pageLoaded = false;
12389
+ }
12360
12390
  if (ref instanceof SmartGridComponent) {
12361
12391
  ref.uuid = uuid;
12362
12392
  }
@@ -12405,6 +12435,8 @@ let SmartComponentApiClient = class SmartComponentApiClient {
12405
12435
  _ngOnDestroy() {
12406
12436
  this.viewContext.unfollow(this.uuid);
12407
12437
  this.widgets.clearWidgets();
12438
+ this.smartGrids.clearWidgets();
12439
+ this.formWidgets.clearWidgets();
12408
12440
  this._destroy$.next();
12409
12441
  this._destroy$.complete();
12410
12442
  }
@@ -12412,6 +12444,9 @@ let SmartComponentApiClient = class SmartComponentApiClient {
12412
12444
  this.initData();
12413
12445
  this.initActions();
12414
12446
  // TODO: layout, valueSet, widgets
12447
+ this.smartGrids.widgets.forEach((smartGrid) => {
12448
+ smartGrid.pageLoaded = true;
12449
+ });
12415
12450
  }
12416
12451
  initData() {
12417
12452
  if (this.model?.data) {
@@ -12500,6 +12535,7 @@ let SmartComponentApiClient = class SmartComponentApiClient {
12500
12535
  smartGrid.serviceToUse = this;
12501
12536
  smartGrid.viewContextService = this.viewContext;
12502
12537
  this.widgets.addWidget(smartGrid.gridIdentifier, componentReference);
12538
+ this.smartGrids.addWidget(smartGrid.gridIdentifier, smartGrid);
12503
12539
  if (useAsDefaultGrid) {
12504
12540
  this.smartGrid = smartGrid;
12505
12541
  return this.smartGrid;