@smartbit4all/ng-client 3.1.62 → 3.1.64

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.
@@ -9690,13 +9690,7 @@ var SmartGridType;
9690
9690
  SmartGridType["CARD1"] = "CARD1";
9691
9691
  SmartGridType["CARD2"] = "CARD2";
9692
9692
  SmartGridType["CUSTOM"] = "CUSTOM";
9693
- })(SmartGridType || (SmartGridType = {}));
9694
- // export type SmartGridTreeNode = {
9695
- // item: string;
9696
- // level: number;
9697
- // expandable: boolean;
9698
- // row: SmartGrid;
9699
- // };
9693
+ })(SmartGridType || (SmartGridType = {}));
9700
9694
 
9701
9695
  class SmartGridCardComponent {
9702
9696
  constructor(cfService) {
@@ -10379,9 +10373,8 @@ class SmartGridService {
10379
10373
  }
10380
10374
  load(uuid, gridIdentifier) {
10381
10375
  return __awaiter(this, void 0, void 0, function* () {
10382
- // let gridModelResult = await lastValueFrom(this.api.load(uuid, gridIdentifier));
10383
- // this.updateGrid(gridModelResult, 'load');
10384
- this.updateGrid(this.gridModel, 'load');
10376
+ let gridModelResult = yield lastValueFrom(this.api.load(uuid, gridIdentifier));
10377
+ this.updateGrid(gridModelResult, 'load');
10385
10378
  });
10386
10379
  }
10387
10380
  setPage(uuid, gridIdentifier, offset, limit) {
@@ -10408,14 +10401,9 @@ class SmartGridService {
10408
10401
  select(smartGrid, gridRow) {
10409
10402
  return __awaiter(this, void 0, void 0, function* () {
10410
10403
  gridRow.selected = !gridRow.selected;
10411
- // return await this.api
10412
- // .select(
10413
- // smartGrid.gridModel.viewUuid!,
10414
- // smartGrid.gridIdentifier,
10415
- // gridRow.id!,
10416
- // gridRow.selected
10417
- // )
10418
- // .toPromise();
10404
+ return yield this.api
10405
+ .select(smartGrid.gridModel.viewUuid, smartGrid.gridIdentifier, gridRow.id, gridRow.selected)
10406
+ .toPromise();
10419
10407
  });
10420
10408
  }
10421
10409
  selectAll(smartGrid, selected) {
@@ -11318,25 +11306,47 @@ class SmartGridComponent {
11318
11306
  renderCards() {
11319
11307
  // TODO
11320
11308
  }
11309
+ isMultipleSelection() {
11310
+ var _a, _b;
11311
+ const selectionMode = (_b = (_a = this.service.gridModel.view) === null || _a === void 0 ? void 0 : _a.descriptor) === null || _b === void 0 ? void 0 : _b.selectionMode;
11312
+ return selectionMode === GridSelectionMode.Multiple;
11313
+ }
11321
11314
  renderTree() {
11322
11315
  var _a, _b, _c, _d;
11323
11316
  if (!this.treeDataSource) {
11324
11317
  this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel, this.isExpandable, this.getChildren);
11325
11318
  this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
11326
11319
  this.treeDataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
11327
- const selectionMode = (_b = (_a = this.service.gridModel.view) === null || _a === void 0 ? void 0 : _a.descriptor) === null || _b === void 0 ? void 0 : _b.selectionMode;
11328
- const isMultiple = selectionMode === GridSelectionMode.Multiple;
11329
- this.treeChecklistSelection = new SelectionModel(isMultiple);
11320
+ this.treeChecklistSelection = new SelectionModel(this.isMultipleSelection());
11321
+ }
11322
+ let nodes = (_a = this.treeControl) === null || _a === void 0 ? void 0 : _a.dataNodes;
11323
+ let expandedNodes;
11324
+ if (nodes) {
11325
+ expandedNodes = nodes
11326
+ .filter((node) => { var _a; return (_a = this.treeControl) === null || _a === void 0 ? void 0 : _a.isExpandable(node); })
11327
+ .filter((node) => { var _a; return (_a = this.treeControl) === null || _a === void 0 ? void 0 : _a.isExpanded(node); })
11328
+ .map((node) => node.id);
11330
11329
  }
11330
+ else {
11331
+ expandedNodes = [];
11332
+ }
11333
+ this.smartGrid.gridModel.page.rows.forEach((row) => (row.level = undefined));
11331
11334
  this.treeDataSource.data = this.smartGrid.gridModel.page.rows.filter((row) => !row.parent);
11332
- // TODO handle and set selection..
11333
- (_c = this.treeChecklistSelection) === null || _c === void 0 ? void 0 : _c.clear();
11334
- (_d = this.treeControl) === null || _d === void 0 ? void 0 : _d.dataNodes.forEach((node) => {
11335
+ (_b = this.treeChecklistSelection) === null || _b === void 0 ? void 0 : _b.clear();
11336
+ (_c = this.treeControl) === null || _c === void 0 ? void 0 : _c.dataNodes.forEach((node) => {
11335
11337
  var _a;
11336
11338
  if (node.selected) {
11337
11339
  (_a = this.treeChecklistSelection) === null || _a === void 0 ? void 0 : _a.select(node);
11338
11340
  }
11339
11341
  });
11342
+ (_d = this.treeControl) === null || _d === void 0 ? void 0 : _d.collapseAll();
11343
+ expandedNodes.forEach((rowId) => {
11344
+ var _a, _b;
11345
+ let row = (_a = this.treeControl) === null || _a === void 0 ? void 0 : _a.dataNodes.find((row) => rowId === row.id);
11346
+ if (row) {
11347
+ (_b = this.treeControl) === null || _b === void 0 ? void 0 : _b.expand(row);
11348
+ }
11349
+ });
11340
11350
  }
11341
11351
  getTreeItem(row) {
11342
11352
  var _a, _b;
@@ -11355,16 +11365,21 @@ class SmartGridComponent {
11355
11365
  }
11356
11366
  let selectionBefore = this.treeChecklistSelection.selected.map((row) => row.id);
11357
11367
  this.treeChecklistSelection.toggle(node);
11358
- const descendants = this.treeControl.getDescendants(node);
11359
- this.treeChecklistSelection.isSelected(node)
11360
- ? this.treeChecklistSelection.select(...descendants)
11361
- : this.treeChecklistSelection.deselect(...descendants);
11362
- this.checkAllParentsSelection(node);
11368
+ if (this.isMultipleSelection()) {
11369
+ const descendants = this.treeControl.getDescendants(node);
11370
+ this.treeChecklistSelection.isSelected(node)
11371
+ ? this.treeChecklistSelection.select(...descendants)
11372
+ : this.treeChecklistSelection.deselect(...descendants);
11373
+ this.checkAllParentsSelection(node);
11374
+ }
11363
11375
  let selectionAfter = this.treeChecklistSelection.selected.map((row) => row.id);
11364
11376
  let selectedIds = selectionAfter.filter((s) => !selectionBefore.includes(s));
11365
11377
  let unselectedIds = selectionBefore.filter((s) => !selectionAfter.includes(s));
11366
- (_a = this.service.gridModel.page.rows) === null || _a === void 0 ? void 0 : _a.filter((row) => selectedIds.includes(row.id)).forEach((row) => (row.selected = false)); // onSelect will toggle!
11367
- (_b = this.service.gridModel.page.rows) === null || _b === void 0 ? void 0 : _b.filter((row) => unselectedIds.includes(row.id)).forEach((row) => (row.selected = true)); // onSelect will toggle!
11378
+ if (this.dev) {
11379
+ // when service call is active (!dev), onSelect will toggle row.selected
11380
+ (_a = this.service.gridModel.page.rows) === null || _a === void 0 ? void 0 : _a.filter((row) => selectedIds.includes(row.id)).forEach((row) => (row.selected = true));
11381
+ (_b = this.service.gridModel.page.rows) === null || _b === void 0 ? void 0 : _b.filter((row) => unselectedIds.includes(row.id)).forEach((row) => (row.selected = false));
11382
+ }
11368
11383
  let union = selectedIds.concat(unselectedIds);
11369
11384
  this.onSelectList(union);
11370
11385
  }
@@ -11604,26 +11619,28 @@ class SmartGridComponent {
11604
11619
  onSelect(rowId) {
11605
11620
  return __awaiter(this, void 0, void 0, function* () {
11606
11621
  this.isBlocked = true;
11607
- this.onSelectInternal(rowId);
11622
+ this.selectRowInternal(rowId);
11608
11623
  this.refresh();
11609
11624
  });
11610
11625
  }
11611
- onSelectInternal(rowId) {
11626
+ selectRowInternal(rowId) {
11612
11627
  var _a;
11613
11628
  return __awaiter(this, void 0, void 0, function* () {
11614
11629
  const row = (_a = this.service.gridModel.page.rows) === null || _a === void 0 ? void 0 : _a.find((gridRow) => gridRow.id === rowId);
11615
11630
  const viewContextChange = yield this.service.select(this.smartGrid, row);
11631
+ this.smartGrid.viewContextService.handleChanges(viewContextChange.changes);
11616
11632
  });
11617
11633
  }
11618
11634
  onSelectList(rowIds) {
11619
11635
  return __awaiter(this, void 0, void 0, function* () {
11620
- // remove
11621
- this.isBlocked = true;
11622
- this.refresh();
11623
- //
11624
11636
  this.isBlocked = true;
11625
- rowIds.forEach((rowId) => this.onSelectInternal(rowId));
11626
- this.refresh();
11637
+ if (this.dev) {
11638
+ this.render();
11639
+ }
11640
+ else {
11641
+ rowIds.forEach((rowId) => this.selectRowInternal(rowId));
11642
+ this.refresh();
11643
+ }
11627
11644
  });
11628
11645
  }
11629
11646
  onSelectAll(selected) {