@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.
@@ -9623,13 +9623,7 @@ var SmartGridType;
9623
9623
  SmartGridType["CARD1"] = "CARD1";
9624
9624
  SmartGridType["CARD2"] = "CARD2";
9625
9625
  SmartGridType["CUSTOM"] = "CUSTOM";
9626
- })(SmartGridType || (SmartGridType = {}));
9627
- // export type SmartGridTreeNode = {
9628
- // item: string;
9629
- // level: number;
9630
- // expandable: boolean;
9631
- // row: SmartGrid;
9632
- // };
9626
+ })(SmartGridType || (SmartGridType = {}));
9633
9627
 
9634
9628
  class SmartGridCardComponent {
9635
9629
  constructor(cfService) {
@@ -10308,9 +10302,8 @@ class SmartGridService {
10308
10302
  this.gridModelChanged = new Subject();
10309
10303
  }
10310
10304
  async load(uuid, gridIdentifier) {
10311
- // let gridModelResult = await lastValueFrom(this.api.load(uuid, gridIdentifier));
10312
- // this.updateGrid(gridModelResult, 'load');
10313
- this.updateGrid(this.gridModel, 'load');
10305
+ let gridModelResult = await lastValueFrom(this.api.load(uuid, gridIdentifier));
10306
+ this.updateGrid(gridModelResult, 'load');
10314
10307
  }
10315
10308
  async setPage(uuid, gridIdentifier, offset, limit) {
10316
10309
  await lastValueFrom(this.api.setPage(uuid, gridIdentifier, offset, limit));
@@ -10329,14 +10322,9 @@ class SmartGridService {
10329
10322
  }
10330
10323
  async select(smartGrid, gridRow) {
10331
10324
  gridRow.selected = !gridRow.selected;
10332
- // return await this.api
10333
- // .select(
10334
- // smartGrid.gridModel.viewUuid!,
10335
- // smartGrid.gridIdentifier,
10336
- // gridRow.id!,
10337
- // gridRow.selected
10338
- // )
10339
- // .toPromise();
10325
+ return await this.api
10326
+ .select(smartGrid.gridModel.viewUuid, smartGrid.gridIdentifier, gridRow.id, gridRow.selected)
10327
+ .toPromise();
10340
10328
  }
10341
10329
  async selectAll(smartGrid, selected) {
10342
10330
  return await this.api
@@ -11229,23 +11217,43 @@ class SmartGridComponent {
11229
11217
  renderCards() {
11230
11218
  // TODO
11231
11219
  }
11220
+ isMultipleSelection() {
11221
+ const selectionMode = this.service.gridModel.view?.descriptor?.selectionMode;
11222
+ return selectionMode === GridSelectionMode.Multiple;
11223
+ }
11232
11224
  renderTree() {
11233
11225
  if (!this.treeDataSource) {
11234
11226
  this.treeFlattener = new MatTreeFlattener(this.transformer, this.getLevel, this.isExpandable, this.getChildren);
11235
11227
  this.treeControl = new FlatTreeControl(this.getLevel, this.isExpandable);
11236
11228
  this.treeDataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
11237
- const selectionMode = this.service.gridModel.view?.descriptor?.selectionMode;
11238
- const isMultiple = selectionMode === GridSelectionMode.Multiple;
11239
- this.treeChecklistSelection = new SelectionModel(isMultiple);
11229
+ this.treeChecklistSelection = new SelectionModel(this.isMultipleSelection());
11230
+ }
11231
+ let nodes = this.treeControl?.dataNodes;
11232
+ let expandedNodes;
11233
+ if (nodes) {
11234
+ expandedNodes = nodes
11235
+ .filter((node) => this.treeControl?.isExpandable(node))
11236
+ .filter((node) => this.treeControl?.isExpanded(node))
11237
+ .map((node) => node.id);
11238
+ }
11239
+ else {
11240
+ expandedNodes = [];
11240
11241
  }
11242
+ this.smartGrid.gridModel.page.rows.forEach((row) => (row.level = undefined));
11241
11243
  this.treeDataSource.data = this.smartGrid.gridModel.page.rows.filter((row) => !row.parent);
11242
- // TODO handle and set selection..
11243
11244
  this.treeChecklistSelection?.clear();
11244
11245
  this.treeControl?.dataNodes.forEach((node) => {
11245
11246
  if (node.selected) {
11246
11247
  this.treeChecklistSelection?.select(node);
11247
11248
  }
11248
11249
  });
11250
+ this.treeControl?.collapseAll();
11251
+ expandedNodes.forEach((rowId) => {
11252
+ let row = this.treeControl?.dataNodes.find((row) => rowId === row.id);
11253
+ if (row) {
11254
+ this.treeControl?.expand(row);
11255
+ }
11256
+ });
11249
11257
  }
11250
11258
  getTreeItem(row) {
11251
11259
  let columns = this.smartGrid?.gridModel.view?.orderedColumnNames;
@@ -11262,20 +11270,25 @@ class SmartGridComponent {
11262
11270
  }
11263
11271
  let selectionBefore = this.treeChecklistSelection.selected.map((row) => row.id);
11264
11272
  this.treeChecklistSelection.toggle(node);
11265
- const descendants = this.treeControl.getDescendants(node);
11266
- this.treeChecklistSelection.isSelected(node)
11267
- ? this.treeChecklistSelection.select(...descendants)
11268
- : this.treeChecklistSelection.deselect(...descendants);
11269
- this.checkAllParentsSelection(node);
11273
+ if (this.isMultipleSelection()) {
11274
+ const descendants = this.treeControl.getDescendants(node);
11275
+ this.treeChecklistSelection.isSelected(node)
11276
+ ? this.treeChecklistSelection.select(...descendants)
11277
+ : this.treeChecklistSelection.deselect(...descendants);
11278
+ this.checkAllParentsSelection(node);
11279
+ }
11270
11280
  let selectionAfter = this.treeChecklistSelection.selected.map((row) => row.id);
11271
11281
  let selectedIds = selectionAfter.filter((s) => !selectionBefore.includes(s));
11272
11282
  let unselectedIds = selectionBefore.filter((s) => !selectionAfter.includes(s));
11273
- this.service.gridModel.page.rows
11274
- ?.filter((row) => selectedIds.includes(row.id))
11275
- .forEach((row) => (row.selected = false)); // onSelect will toggle!
11276
- this.service.gridModel.page.rows
11277
- ?.filter((row) => unselectedIds.includes(row.id))
11278
- .forEach((row) => (row.selected = true)); // onSelect will toggle!
11283
+ if (this.dev) {
11284
+ // when service call is active (!dev), onSelect will toggle row.selected
11285
+ this.service.gridModel.page.rows
11286
+ ?.filter((row) => selectedIds.includes(row.id))
11287
+ .forEach((row) => (row.selected = true));
11288
+ this.service.gridModel.page.rows
11289
+ ?.filter((row) => unselectedIds.includes(row.id))
11290
+ .forEach((row) => (row.selected = false));
11291
+ }
11279
11292
  let union = selectedIds.concat(unselectedIds);
11280
11293
  this.onSelectList(union);
11281
11294
  }
@@ -11510,22 +11523,23 @@ class SmartGridComponent {
11510
11523
  }
11511
11524
  async onSelect(rowId) {
11512
11525
  this.isBlocked = true;
11513
- this.onSelectInternal(rowId);
11526
+ this.selectRowInternal(rowId);
11514
11527
  this.refresh();
11515
11528
  }
11516
- async onSelectInternal(rowId) {
11529
+ async selectRowInternal(rowId) {
11517
11530
  const row = this.service.gridModel.page.rows?.find((gridRow) => gridRow.id === rowId);
11518
11531
  const viewContextChange = await this.service.select(this.smartGrid, row);
11519
- // this.smartGrid!.viewContextService.handleChanges(viewContextChange.changes);
11532
+ this.smartGrid.viewContextService.handleChanges(viewContextChange.changes);
11520
11533
  }
11521
11534
  async onSelectList(rowIds) {
11522
- // remove
11523
- this.isBlocked = true;
11524
- this.refresh();
11525
- //
11526
11535
  this.isBlocked = true;
11527
- rowIds.forEach((rowId) => this.onSelectInternal(rowId));
11528
- this.refresh();
11536
+ if (this.dev) {
11537
+ this.render();
11538
+ }
11539
+ else {
11540
+ rowIds.forEach((rowId) => this.selectRowInternal(rowId));
11541
+ this.refresh();
11542
+ }
11529
11543
  }
11530
11544
  async onSelectAll(selected) {
11531
11545
  this.isBlocked = true;