@acorex/platform 20.4.2 → 20.5.0-next.0

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { computed, signal, Injectable, InjectionToken, inject, ElementRef, effect, Injector, ChangeDetectorRef, ViewChild, Input, ChangeDetectionStrategy, Component, EventEmitter, Output, input, output, ViewContainerRef, Directive, Optional, Inject, NgModule, createComponent } from '@angular/core';
2
+ import { computed, signal, Injectable, InjectionToken, inject, ElementRef, effect, untracked, Injector, ChangeDetectorRef, ViewChild, Input, ChangeDetectionStrategy, Component, EventEmitter, Output, input, output, ViewContainerRef, Directive, Optional, Inject, NgModule, createComponent } from '@angular/core';
3
3
  import { convertArrayToDataSource, AXDataSource } from '@acorex/cdk/common';
4
4
  import { setSmart, AXPDataSourceDefinitionProviderService, extractValue, getSmart, AXPExpressionEvaluatorService } from '@acorex/platform/core';
5
5
  import { cloneDeep, isEqual, get, set, merge, isNil, isUndefined, isObjectLike, sum, isEmpty, isString } from 'lodash-es';
@@ -666,60 +666,64 @@ class AXPDataListWidgetComponent extends AXPValueWidgetComponent {
666
666
  this.rf = effect(async () => {
667
667
  const rawValue = this.options()['dataSource'];
668
668
  // static datasource class
669
- if (rawValue instanceof AXDataSource) {
670
- this.dataSource.set(rawValue);
671
- }
672
- // static array datasource
673
- else if (Array.isArray(rawValue)) {
674
- const ds = new AXDataSource({
675
- key: this.valueField(),
676
- pageSize: 10,
677
- load: async (e) => {
678
- const raw = this.options()['dataSource'];
679
- const skip = e.skip ?? 0;
680
- const take = e.take ?? raw.length;
681
- return {
682
- items: raw.slice(skip, skip + take),
683
- total: raw.length,
684
- };
685
- },
686
- byKey: (key) => {
687
- const raw = this.options()['dataSource'];
688
- const item = raw.filter((c) => c[this.valueField()] == key);
689
- return Promise.resolve(item[0]);
690
- },
691
- });
692
- this.dataSource.set(ds);
693
- }
694
- // resolve data source by name
695
- else if (rawValue && (typeof rawValue == 'string' || typeof rawValue == 'object')) {
696
- const id = typeof rawValue == 'object' ? rawValue['id'] : rawValue;
697
- const c = await this.dataService.get(id);
698
- if (this.mode == 'designer' && c?.samples?.length) {
699
- this.dataSource.set(convertArrayToDataSource(c.samples, {
700
- key: this.valueField(),
701
- pageSize: 500,
702
- }));
703
- }
704
- else {
705
- const ds = c?.source();
706
- if (ds && ds instanceof Promise) {
707
- const d = await ds;
708
- this.dataSource.set(d);
669
+ untracked(async () => {
670
+ if (!isEqual(this.options()['dataSource'].config, this.dataSource().config)) {
671
+ if (rawValue instanceof AXDataSource) {
672
+ this.dataSource.set(rawValue);
709
673
  }
710
- else if (ds) {
674
+ // static array datasource
675
+ else if (Array.isArray(rawValue)) {
676
+ const ds = new AXDataSource({
677
+ key: this.valueField(),
678
+ pageSize: 10,
679
+ load: async (e) => {
680
+ const raw = this.options()['dataSource'];
681
+ const skip = e.skip ?? 0;
682
+ const take = e.take ?? raw.length;
683
+ return {
684
+ items: raw.slice(skip, skip + take),
685
+ total: raw.length,
686
+ };
687
+ },
688
+ byKey: (key) => {
689
+ const raw = this.options()['dataSource'];
690
+ const item = raw.filter((c) => c[this.valueField()] == key);
691
+ return Promise.resolve(item[0]);
692
+ },
693
+ });
711
694
  this.dataSource.set(ds);
712
695
  }
696
+ // resolve data source by name
697
+ else if (rawValue && (typeof rawValue == 'string' || typeof rawValue == 'object')) {
698
+ const id = typeof rawValue == 'object' ? rawValue['id'] : rawValue;
699
+ const c = await this.dataService.get(id);
700
+ if (this.mode == 'designer' && c?.samples?.length) {
701
+ this.dataSource.set(convertArrayToDataSource(c.samples, {
702
+ key: this.valueField(),
703
+ pageSize: 500,
704
+ }));
705
+ }
706
+ else {
707
+ const ds = c?.source();
708
+ if (ds && ds instanceof Promise) {
709
+ const d = await ds;
710
+ this.dataSource.set(d);
711
+ }
712
+ else if (ds) {
713
+ this.dataSource.set(ds);
714
+ }
715
+ // empty datasource
716
+ else {
717
+ this.dataSource.set(convertArrayToDataSource([]));
718
+ }
719
+ }
720
+ }
713
721
  // empty datasource
714
722
  else {
715
723
  this.dataSource.set(convertArrayToDataSource([]));
716
724
  }
717
725
  }
718
- }
719
- // empty datasource
720
- else {
721
- this.dataSource.set(convertArrayToDataSource([]));
722
- }
726
+ });
723
727
  }, ...(ngDevMode ? [{ debugName: "rf" }] : []));
724
728
  this.effect2 = effect(async () => {
725
729
  const value = this.getValue();