@smartbit4all/ng-client 7.3.27 → 7.3.28

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.
@@ -4355,8 +4355,8 @@ function isSameKey(key1, key2) {
4355
4355
 
4356
4356
  /**
4357
4357
  * The Global Value Set Store: the value sets of the browser tab shared by every open view,
4358
- * explicit sets by backend module, namespace and name, implicit sets by view uuid and key. It
4359
- * fetches the versions a view context change names and it lacks, keeps what the open views read
4358
+ * explicit sets by backend module, namespace, name and branch, implicit sets by view uuid and key.
4359
+ * It fetches the versions a view context change names and it lacks, keeps what the open views read
4360
4360
  * and empties at a change of the session locale.
4361
4361
  */
4362
4362
  class SmartValueSetStore {
@@ -4391,8 +4391,8 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4391
4391
  this.readExplicitKeys = new Map();
4392
4392
  /** The number of subscribers of {@link get} to each explicit set. */
4393
4393
  this.subscriberCounts = new Map();
4394
- /** The version of each branch item of the version maps, by its explicit key. */
4395
- this.branchVersions = new Map();
4394
+ /** The explicit keys of the branch items of the last version map of each module. */
4395
+ this.branchKeys = new Set();
4396
4396
  /** The fetches of each entry, by its explicit or implicit key. */
4397
4397
  this.fetchRecords = new Map();
4398
4398
  /** Numbers the fetches in the order they start. */
@@ -4414,8 +4414,8 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4414
4414
  }
4415
4415
  });
4416
4416
  }
4417
- get(module, namespace, name) {
4418
- const key = createExplicitKey(module, namespace, name);
4417
+ get(module, namespace, name, branchUri) {
4418
+ const key = createExplicitKey(module, namespace, name, branchUri);
4419
4419
  return defer(() => {
4420
4420
  this.subscriberCounts.set(key, (this.subscriberCounts.get(key) ?? 0) + 1);
4421
4421
  return this.followChanges(name, () => this.explicitEntries.get(key)?.data);
@@ -4441,7 +4441,7 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4441
4441
  };
4442
4442
  const data = this.findForSelection(viewUuid, selection);
4443
4443
  if (data && !this.viewEntries.get(viewUuid)?.get(name)?.implicit) {
4444
- this.registerExplicitRead(viewUuid, createExplicitKey(module, selection.valueSetNamespace, name));
4444
+ this.registerExplicitRead(viewUuid, this.createLineKey(viewUuid, selection.valueSetNamespace, name));
4445
4445
  }
4446
4446
  return data;
4447
4447
  }
@@ -4534,32 +4534,17 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4534
4534
  }
4535
4535
  applyVersions(viewContextChange, viewUuid) {
4536
4536
  const versions = viewContextChange?.valueSetVersions;
4537
- const requestViewUuid = viewUuid ?? viewContextChange?.changes?.[0]?.uuid;
4538
- if (!versions?.length || !requestViewUuid) {
4537
+ if (!versions) {
4539
4538
  return Promise.resolve();
4540
4539
  }
4541
- const module = this.findViewModule(requestViewUuid);
4540
+ const module = this.findViewModule(viewUuid);
4541
+ this.writeBranchKeys(module, versions
4542
+ .filter((version) => version.branchUri)
4543
+ .map((version) => createExplicitKey(module, version.namespace, version.name, version.branchUri)));
4542
4544
  const readKeys = this.collectReadExplicitKeys();
4543
4545
  let isFetchPending = false;
4544
- /** The version noted before and the one noted now of each branch item queued for a fetch. */
4545
- const notedBranchVersions = new Map();
4546
4546
  versions.forEach((version) => {
4547
4547
  const key = createExplicitKey(module, version.namespace, version.name, version.branchUri);
4548
- if (version.branchUri) {
4549
- const previous = this.branchVersions.get(key);
4550
- this.branchVersions.set(key, version.version);
4551
- if (previous === undefined || previous === version.version) {
4552
- return;
4553
- }
4554
- const holders = this.findViewsHoldingImplicitly(module, version.name);
4555
- if (!holders.length) {
4556
- return;
4557
- }
4558
- holders.forEach((holder) => this.queueImplicitItem(holder, version.name));
4559
- notedBranchVersions.set(key, [previous, version.version]);
4560
- isFetchPending = true;
4561
- return;
4562
- }
4563
4548
  const held = this.explicitEntries.get(key)?.version;
4564
4549
  if (held === version.version ||
4565
4550
  this.isFetching(key, version.version) ||
@@ -4567,7 +4552,7 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4567
4552
  return;
4568
4553
  }
4569
4554
  this.markFetching(key, version.version);
4570
- this.queueItem(module, requestViewUuid, {
4555
+ this.queueItem(module, viewUuid, {
4571
4556
  namespace: version.namespace,
4572
4557
  name: version.name,
4573
4558
  branchUri: version.branchUri,
@@ -4575,17 +4560,7 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4575
4560
  });
4576
4561
  isFetchPending = true;
4577
4562
  });
4578
- if (!isFetchPending) {
4579
- return Promise.resolve();
4580
- }
4581
- const flush = this.scheduleFlush();
4582
- // A branch version whose fetch failed is taken back, so the next map fetches again.
4583
- flush.catch(() => notedBranchVersions.forEach(([previous, noted], key) => {
4584
- if (this.branchVersions.get(key) === noted) {
4585
- this.branchVersions.set(key, previous);
4586
- }
4587
- }));
4588
- return flush;
4563
+ return isFetchPending ? this.scheduleFlush() : Promise.resolve();
4589
4564
  }
4590
4565
  fetch(module, viewUuid, items) {
4591
4566
  if (!items.length) {
@@ -4755,7 +4730,7 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4755
4730
  return (!readKeys.has(key) &&
4756
4731
  this.findViewsHoldingImplicitly(module, name).some((viewUuid) => {
4757
4732
  const selection = this.viewSelections.get(viewUuid)?.get(name);
4758
- return (!!selection && createExplicitKey(module, selection.valueSetNamespace, name) === key);
4733
+ return (!!selection && this.createLineKey(viewUuid, selection.valueSetNamespace, name) === key);
4759
4734
  }));
4760
4735
  }
4761
4736
  /** The views of the module holding an implicit set under the name. */
@@ -4772,10 +4747,9 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4772
4747
  const keys = new Set(this.subscriberCounts.keys());
4773
4748
  this.readExplicitKeys.forEach((viewKeys) => viewKeys.forEach((key) => keys.add(key)));
4774
4749
  this.viewSelections.forEach((selections, viewUuid) => {
4775
- const module = this.findViewModule(viewUuid);
4776
4750
  selections.forEach((selection, name) => {
4777
4751
  if (!this.viewEntries.get(viewUuid)?.get(name)?.implicit) {
4778
- keys.add(createExplicitKey(module, selection.valueSetNamespace, name));
4752
+ keys.add(this.createLineKey(viewUuid, selection.valueSetNamespace, name));
4779
4753
  }
4780
4754
  });
4781
4755
  });
@@ -4860,9 +4834,51 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4860
4834
  // An implicit set of the view wins: the explicit one is not read.
4861
4835
  const data = viewEntry?.implicit
4862
4836
  ? viewEntry.data
4863
- : this.explicitEntries.get(createExplicitKey(this.findViewModule(viewUuid), selection.valueSetNamespace, selection.valueSetName))?.data;
4837
+ : this.findExplicitEntry(viewUuid, selection.valueSetNamespace, selection.valueSetName)
4838
+ ?.data;
4864
4839
  return data && this.mergeViewExtras(data, viewEntry, selection);
4865
4840
  }
4841
+ /**
4842
+ * The explicit entry of the set on the line the view reads it on; until the entry of a branch is
4843
+ * written, the main-line one, so a widget keeps its values while the branch fetch runs.
4844
+ */
4845
+ findExplicitEntry(viewUuid, namespace, name) {
4846
+ return (this.explicitEntries.get(this.createLineKey(viewUuid, namespace, name)) ??
4847
+ this.explicitEntries.get(createExplicitKey(this.findViewModule(viewUuid), namespace, name)));
4848
+ }
4849
+ /**
4850
+ * The explicit key of the set on the line the view reads it on: the view's branch when the last
4851
+ * version map of its module listed the set on that branch, else the main line.
4852
+ */
4853
+ createLineKey(viewUuid, namespace, name) {
4854
+ const view = this.findView(viewUuid);
4855
+ const module = view?.module ?? "";
4856
+ const branchKey = view?.branchUri && createExplicitKey(module, namespace, name, view.branchUri);
4857
+ return branchKey && this.branchKeys.has(branchKey)
4858
+ ? branchKey
4859
+ : createExplicitKey(module, namespace, name);
4860
+ }
4861
+ /**
4862
+ * Replaces the branch keys of the module; a reader of a set whose line changed reads again.
4863
+ */
4864
+ writeBranchKeys(module, keys) {
4865
+ const next = new Set(keys);
4866
+ const changedNames = new Set();
4867
+ this.branchKeys.forEach((key) => {
4868
+ const parsed = parseExplicitKey(key);
4869
+ if (parsed.module === module && !next.has(key)) {
4870
+ this.branchKeys.delete(key);
4871
+ changedNames.add(parsed.name);
4872
+ }
4873
+ });
4874
+ next.forEach((key) => {
4875
+ if (!this.branchKeys.has(key)) {
4876
+ this.branchKeys.add(key);
4877
+ changedNames.add(parseExplicitKey(key).name);
4878
+ }
4879
+ });
4880
+ changedNames.forEach((name) => this.changeSource.next(name));
4881
+ }
4866
4882
  mergeViewExtras(data, viewEntry, selection) {
4867
4883
  return viewEntry?.extras?.length || viewEntry?.excludedKeys?.length
4868
4884
  ? mergeExtraValues(data, viewEntry, selection)
@@ -4874,10 +4890,13 @@ class SmartValueSetMemoryStore extends SmartValueSetStore {
4874
4890
  }
4875
4891
  /** The module a view is served by; the empty string stands for the session's own backend. */
4876
4892
  findViewModule(viewUuid) {
4877
- return (this.injector
4893
+ return this.findView(viewUuid)?.module ?? "";
4894
+ }
4895
+ findView(viewUuid) {
4896
+ return this.injector
4878
4897
  .get(SmartViewContextService)
4879
4898
  .getCurrentViewContext()
4880
- ?.views?.find((view) => view.uuid === viewUuid)?.module ?? "");
4899
+ ?.views?.find((view) => view.uuid === viewUuid);
4881
4900
  }
4882
4901
  /** Writes the explicit entry as the most recently written one. */
4883
4902
  writeExplicitEntry(key, name, entry) {
@@ -14171,7 +14190,7 @@ class SmartViewContextService {
14171
14190
  async message(messageData, messageResult) {
14172
14191
  return await this.handlePerformActionResponse(await this.view
14173
14192
  .message(messageData.viewUuid ?? "", messageData.uuid, messageResult)
14174
- .toPromise(), messageData.viewUuid);
14193
+ .toPromise(), messageData.viewUuid ?? "");
14175
14194
  // in future use this.apiQueueService.addToQueue
14176
14195
  }
14177
14196
  getSmartViewContextApiErrorByCode(code) {
@@ -14342,9 +14361,10 @@ class SmartViewContextService {
14342
14361
  * report of the client reached the server after the close. So a view to be closed in the view
14343
14362
  * context not applied is closed all the same.
14344
14363
  *
14345
- * The Value Set Version Map of the change goes to the value set store, whose fetches are held
14346
- * until the change is applied, so one request carries the implicit sets the changed models name.
14347
- * The fetch is not awaited: the widgets follow the store.
14364
+ * The Value Set Version Map of the change goes to the value set store under the module of
14365
+ * `viewUuid`, the view the request was sent for, as the server built it. The store's fetches are
14366
+ * held until the change is applied, so one request carries the implicit sets the changed models
14367
+ * name. The fetch is not awaited: the widgets follow the store.
14348
14368
  */
14349
14369
  async handlePerformActionResponse(viewContextChange, viewUuid) {
14350
14370
  // The implicit sets the changed models name go in the Value Set Fetch of the version map.
@@ -22849,13 +22869,13 @@ class SmartGridComponent {
22849
22869
  this.isBlocked = true;
22850
22870
  const row = this.service.gridModel.page.rows?.find((gridRow) => gridRow.id === rowId);
22851
22871
  const viewContextChange = await this.service.select(this.smartGrid, row);
22852
- this.smartGrid.viewContextService.handlePerformActionResponse(viewContextChange, this.smartGrid.gridModel.viewUuid);
22872
+ this.smartGrid.viewContextService.handlePerformActionResponse(viewContextChange, this.smartGrid.gridModel.viewUuid ?? "");
22853
22873
  this.refresh();
22854
22874
  }
22855
22875
  async onSelectAll(selected) {
22856
22876
  this.isBlocked = true;
22857
22877
  const viewContextChange = await this.service.selectAll(this.smartGrid, selected);
22858
- this.smartGrid.viewContextService.handlePerformActionResponse(viewContextChange, this.smartGrid.gridModel.viewUuid);
22878
+ this.smartGrid.viewContextService.handlePerformActionResponse(viewContextChange, this.smartGrid.gridModel.viewUuid ?? "");
22859
22879
  this.refresh();
22860
22880
  }
22861
22881
  async onSelectRows(selectedIds, unselectedIds) {
@@ -22863,7 +22883,7 @@ class SmartGridComponent {
22863
22883
  let selected = selectedIds.filter((item) => item !== undefined);
22864
22884
  let unselected = unselectedIds.filter((item) => item !== undefined);
22865
22885
  const viewContextChange = await this.service.selectRows(this.smartGrid, selected, unselected);
22866
- this.smartGrid.viewContextService.handlePerformActionResponse(viewContextChange, this.smartGrid.gridModel.viewUuid);
22886
+ this.smartGrid.viewContextService.handlePerformActionResponse(viewContextChange, this.smartGrid.gridModel.viewUuid ?? "");
22867
22887
  this.refresh();
22868
22888
  }
22869
22889
  editColumns() {