@ngrdt/forms 0.0.41 → 0.0.42

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.
@@ -576,6 +576,7 @@ class RdtOfflineSelectDatasource extends RdtSelectDatasource {
576
576
  }
577
577
 
578
578
  const rdtSelectInitialState = {
579
+ initialized: false,
579
580
  query: null,
580
581
  nextPageIndex: 0,
581
582
  pageSize: 20,
@@ -642,6 +643,10 @@ function getRdtSelectStore(initialState = rdtSelectInitialState) {
642
643
  return selected;
643
644
  }),
644
645
  })), withMethods((store) => ({
646
+ init(initialValue) {
647
+ this.setSelected(initialValue ?? []);
648
+ patchState(store, { initialized: true });
649
+ },
645
650
  fetch() {
646
651
  const datasource = untracked(store.datasource);
647
652
  const index = untracked(store.nextPageIndex);
@@ -813,9 +818,12 @@ function getRdtSelectStore(initialState = rdtSelectInitialState) {
813
818
  return newMissing;
814
819
  },
815
820
  _loadMissingSelected() {
821
+ const datasource = store.datasource();
816
822
  const reallyMissing = this._setAndGetMissing();
817
- if (!untracked(store.loading) && reallyMissing.length > 0) {
818
- this._fetchMissing(reallyMissing);
823
+ if (!untracked(store.loading) &&
824
+ reallyMissing.length > 0 &&
825
+ datasource) {
826
+ this._fetchMissing(reallyMissing, datasource);
819
827
  }
820
828
  },
821
829
  _cancelFetchMissingIfNeeded() {
@@ -829,9 +837,8 @@ function getRdtSelectStore(initialState = rdtSelectInitialState) {
829
837
  });
830
838
  }
831
839
  },
832
- _fetchMissing(ids) {
833
- const datasource = untracked(store.datasource);
834
- if (!datasource || ids.length === 0) {
840
+ _fetchMissing(ids, datasource) {
841
+ if (ids.length === 0) {
835
842
  return;
836
843
  }
837
844
  const sub = datasource.getItemsByIds(ids).subscribe((map) => {
@@ -1054,6 +1061,16 @@ class RdtBaseSelectCommonComponent extends RdtBaseFormInputComponent {
1054
1061
  });
1055
1062
  ngOnInit() {
1056
1063
  super.ngOnInit();
1064
+ const control = this.control();
1065
+ if (control && control.value !== null) {
1066
+ const arr = Array.isArray(control.value)
1067
+ ? control.value
1068
+ : [control.value];
1069
+ this.store.init(arr);
1070
+ }
1071
+ else {
1072
+ this.store.init(null);
1073
+ }
1057
1074
  this.debouncedInput$
1058
1075
  .pipe(takeUntilDestroyed(this.destroyRef))
1059
1076
  .subscribe((value) => this.handleInput(value));