@acorex/platform 21.0.0-next.17 → 21.0.0-next.18

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.
@@ -10882,6 +10882,8 @@ class AXPEntityListWidgetViewComponent extends AXPValueWidgetComponent {
10882
10882
  this.list = viewChild('list', ...(ngDevMode ? [{ debugName: "list" }] : []));
10883
10883
  this.allWidgets = viewChildren(AXPWidgetRendererDirective, ...(ngDevMode ? [{ debugName: "allWidgets" }] : []));
10884
10884
  this.listWidget = linkedSignal(() => this.allWidgets().find((widget) => widget.node()?.type === AXPWidgetsCatalog.dataList), ...(ngDevMode ? [{ debugName: "listWidget" }] : []));
10885
+ // Cached instance reference to ensure consistency with the first created instance
10886
+ this.listWidgetInstance = signal(null, ...(ngDevMode ? [{ debugName: "listWidgetInstance" }] : []));
10885
10887
  this.toolbarWidget = computed(() => this.allWidgets().find((widget) => widget.node()?.type === AXPWidgetsCatalog.listToolbar), ...(ngDevMode ? [{ debugName: "toolbarWidget" }] : []));
10886
10888
  this.selectedItems = signal([], ...(ngDevMode ? [{ debugName: "selectedItems" }] : []));
10887
10889
  this.toolbarNode = signal(null, ...(ngDevMode ? [{ debugName: "toolbarNode" }] : []));
@@ -10963,17 +10965,18 @@ class AXPEntityListWidgetViewComponent extends AXPValueWidgetComponent {
10963
10965
  //TODO: this is a temporary solution to handle the query changes; this should be removed when the query changes are handled in the widget core;
10964
10966
  if (this.getValue()?.toolbar) {
10965
10967
  this.queries = this.getValue()?.toolbar;
10968
+ // Use cached instance or get from listWidget
10969
+ const listInstance = this.listWidgetInstance() || this.listWidget()?.instance;
10970
+ // const dataSource = this.listWidget()?.options()['dataSource'] as AXDataSource;
10971
+ const dataSource = listInstance?.options()?.['dataSource'];
10972
+ const isMounted = this.isMounted();
10973
+ if (!this.hasRequiredDependencies(dataSource, this.queries, listInstance)) {
10974
+ return;
10975
+ }
10976
+ untracked(() => {
10977
+ this.handleQueryChanges(this.queries, dataSource, listInstance, isMounted);
10978
+ });
10966
10979
  }
10967
- const listInstance = this.listWidget()?.instance;
10968
- // const dataSource = this.listWidget()?.options()['dataSource'] as AXDataSource;
10969
- const dataSource = listInstance?.options()?.['dataSource'];
10970
- const isMounted = this.isMounted();
10971
- if (!this.hasRequiredDependencies(dataSource, this.queries, listInstance)) {
10972
- return;
10973
- }
10974
- untracked(() => {
10975
- this.handleQueryChanges(this.queries, dataSource, listInstance, isMounted);
10976
- });
10977
10980
  }, ...(ngDevMode ? [{ debugName: "#effect" }] : []));
10978
10981
  //#endregion
10979
10982
  this.context = {};
@@ -11105,7 +11108,8 @@ class AXPEntityListWidgetViewComponent extends AXPValueWidgetComponent {
11105
11108
  if (!changeTracker.isColumnsChanged) {
11106
11109
  return;
11107
11110
  }
11108
- const listInstance = this.listWidget()?.instance;
11111
+ // Use cached instance or get from listWidget
11112
+ const listInstance = this.listWidgetInstance() || this.listWidget()?.instance;
11109
11113
  const toolbarState = this.getValue()?.toolbar;
11110
11114
  if (!listInstance || !toolbarState?.columns) {
11111
11115
  return;
@@ -11171,7 +11175,8 @@ class AXPEntityListWidgetViewComponent extends AXPValueWidgetComponent {
11171
11175
  .pipe(takeUntil(this.destroyed))
11172
11176
  .subscribe((event) => {
11173
11177
  if (event.payload.entity == this.entitySource()) {
11174
- this.listWidget()?.instance.call('refresh');
11178
+ const instance = this.listWidgetInstance() || this.listWidget()?.instance;
11179
+ instance?.call('refresh');
11175
11180
  }
11176
11181
  });
11177
11182
  this.eventService
@@ -11179,21 +11184,36 @@ class AXPEntityListWidgetViewComponent extends AXPValueWidgetComponent {
11179
11184
  .pipe(takeUntil(this.destroyed))
11180
11185
  .subscribe((e) => {
11181
11186
  if (e.data.name == `${this.entity()?.module}.${this.entity()?.name}`) {
11182
- this.listWidget()?.instance.call('refresh');
11187
+ const instance = this.listWidgetInstance() || this.listWidget()?.instance;
11188
+ instance?.call('refresh');
11183
11189
  }
11184
11190
  });
11185
- const listWidget = (await this.layoutService.waitForWidget(`${this.entitySource()}-tab-list_table`, 500));
11186
- if (listWidget?.api && typeof listWidget.api === 'function') {
11187
- const onSelectionChange = listWidget.api()['onSelectionChange'];
11188
- if (onSelectionChange) {
11189
- onSelectionChange.pipe(takeUntil(this.destroyed)).subscribe((e) => {
11190
- this.selectedItems.set(e);
11191
- });
11191
+ // Wait for the widget to be available using listWidget signal
11192
+ // Poll until the widget instance is ready to ensure we use the first created instance
11193
+ let attempts = 0;
11194
+ const maxAttempts = 50; // 5 seconds max wait (50 * 100ms)
11195
+ while (attempts < maxAttempts) {
11196
+ const widgetDirective = this.listWidget();
11197
+ if (widgetDirective?.instance) {
11198
+ const listWidgetInstance = widgetDirective.instance;
11199
+ // Cache the instance for consistent usage across all methods
11200
+ this.listWidgetInstance.set(listWidgetInstance);
11201
+ if (listWidgetInstance?.api && typeof listWidgetInstance.api === 'function') {
11202
+ const onSelectionChange = listWidgetInstance.api()['onSelectionChange'];
11203
+ if (onSelectionChange) {
11204
+ onSelectionChange.pipe(takeUntil(this.destroyed)).subscribe((e) => {
11205
+ this.selectedItems.set(e);
11206
+ });
11207
+ }
11208
+ }
11209
+ break;
11192
11210
  }
11211
+ await new Promise((resolve) => setTimeout(resolve, 100));
11212
+ attempts++;
11193
11213
  }
11194
11214
  }
11195
11215
  ngOnDestroy() {
11196
- this.listWidget.set(undefined);
11216
+ this.listWidgetInstance.set(null);
11197
11217
  this.destroyed.next();
11198
11218
  this.destroyed.complete();
11199
11219
  }