@sd-angular/core 1.3.1 → 1.3.2

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.
@@ -5,10 +5,10 @@ import { MatPaginator, MatPaginatorIntl, MatPaginatorModule } from '@angular/mat
5
5
  import { MatSort, MatSortModule } from '@angular/material/sort';
6
6
  import { trigger, state, style, transition, animate } from '@angular/animations';
7
7
  import { v4 } from 'uuid';
8
- import { Subject, Subscription, isObservable, defer, from } from 'rxjs';
8
+ import { Subject, Subscription, isObservable } from 'rxjs';
9
9
  import { SdNotifyService } from '@sd-angular/core/notify';
10
10
  import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
11
- import { startWith, debounceTime, map, switchMap } from 'rxjs/operators';
11
+ import { startWith, map, debounceTime, switchMap } from 'rxjs/operators';
12
12
  import hash from 'object-hash';
13
13
  import { SdSettingService } from '@sd-angular/core/setting';
14
14
  import { DeviceDetectorService } from 'ngx-device-detector';
@@ -1483,41 +1483,37 @@ class SdGridMaterial {
1483
1483
  pageSize: ((_j = __classPrivateFieldGet(this, _paginator)) === null || _j === void 0 ? void 0 : _j.pageSize) || ((_l = (_k = this.gridOption) === null || _k === void 0 ? void 0 : _k.paginate) === null || _l === void 0 ? void 0 : _l.pageSize) || 50
1484
1484
  });
1485
1485
  });
1486
- _load$1.set(this, (filterReq, force = true) => {
1487
- const func = () => __awaiter(this, void 0, void 0, function* () {
1488
- this.isLoading = true;
1489
- try {
1490
- if (this.gridOption.type === 'server') {
1491
- let result = this.gridOption.items(filterReq);
1492
- if (isObservable(result)) {
1493
- result = result.toPromise();
1494
- }
1495
- return yield result;
1486
+ _load$1.set(this, (filterReq, force = true) => __awaiter(this, void 0, void 0, function* () {
1487
+ this.isLoading = true;
1488
+ try {
1489
+ if (this.gridOption.type === 'server') {
1490
+ let result = this.gridOption.items(filterReq);
1491
+ if (isObservable(result)) {
1492
+ result = result.toPromise();
1496
1493
  }
1497
- else {
1498
- if (force) {
1499
- const results = this.gridOption.items();
1500
- if (results instanceof Promise) {
1501
- this.localItems = yield results;
1502
- }
1503
- else {
1504
- this.localItems = results;
1505
- }
1494
+ return yield result;
1495
+ }
1496
+ else {
1497
+ if (force) {
1498
+ const results = this.gridOption.items();
1499
+ if (results instanceof Promise) {
1500
+ this.localItems = yield results;
1501
+ }
1502
+ else {
1503
+ this.localItems = results;
1506
1504
  }
1507
- return __classPrivateFieldGet(this, _filterLocal).call(this, this.localItems, filterReq);
1508
1505
  }
1506
+ return __classPrivateFieldGet(this, _filterLocal).call(this, this.localItems, filterReq);
1509
1507
  }
1510
- catch (error) {
1511
- this.notifyService.handle.error(error);
1512
- }
1513
- finally {
1514
- this.isLoading = false;
1515
- this.ref.detectChanges();
1516
- }
1517
- });
1518
- const obs = defer(() => from(func()));
1519
- return obs.pipe(debounceTime(200));
1520
- });
1508
+ }
1509
+ catch (error) {
1510
+ this.notifyService.handle.error(error);
1511
+ }
1512
+ finally {
1513
+ this.isLoading = false;
1514
+ this.ref.detectChanges();
1515
+ }
1516
+ }));
1521
1517
  _render.set(this, (args) => __awaiter(this, void 0, void 0, function* () {
1522
1518
  var _a, _b, _c, _d;
1523
1519
  (_a = this.sdScroll) === null || _a === void 0 ? void 0 : _a.scrollTop();
@@ -1532,7 +1528,7 @@ class SdGridMaterial {
1532
1528
  __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1533
1529
  }));
1534
1530
  this.reload = (force = true) => __awaiter(this, void 0, void 0, function* () {
1535
- const data = yield __classPrivateFieldGet(this, _load$1).call(this, __classPrivateFieldGet(this, _getFilter).call(this), force).toPromise();
1531
+ const data = yield __classPrivateFieldGet(this, _load$1).call(this, __classPrivateFieldGet(this, _getFilter).call(this), force);
1536
1532
  __classPrivateFieldGet(this, _render).call(this, data);
1537
1533
  });
1538
1534
  _exportedItems.set(this, (pageNumber = 0, pageSize = 10000) => __awaiter(this, void 0, void 0, function* () {
@@ -2100,10 +2096,11 @@ class SdGridMaterial {
2100
2096
  set _gridFilter(gridFilter) {
2101
2097
  if (gridFilter && this.gridFilter !== gridFilter) {
2102
2098
  this.gridFilter = gridFilter;
2099
+ __classPrivateFieldGet(this, _reload).next(false);
2103
2100
  __classPrivateFieldGet(this, _subscription$1).add(gridFilter.filterChange.pipe(map(() => {
2104
2101
  __classPrivateFieldGet(this, _paginator).pageIndex = 0;
2105
- return __classPrivateFieldGet(this, _getFilter).call(this);
2106
- }), switchMap(filterInfo => __classPrivateFieldGet(this, _load$1).call(this, filterInfo, false))).subscribe(__classPrivateFieldGet(this, _render)));
2102
+ __classPrivateFieldGet(this, _reload).next(false);
2103
+ })).subscribe());
2107
2104
  }
2108
2105
  }
2109
2106
  set option(option) {
@@ -2111,7 +2108,7 @@ class SdGridMaterial {
2111
2108
  if (option) {
2112
2109
  option = __classPrivateFieldGet(this, _initConfiguration).call(this, option);
2113
2110
  this.gridOption = option;
2114
- __classPrivateFieldGet(this, _optionChanges).emit();
2111
+ __classPrivateFieldGet(this, _reload).next(true);
2115
2112
  (_a = option === null || option === void 0 ? void 0 : option.columns) === null || _a === void 0 ? void 0 : _a.forEach(col => {
2116
2113
  var _a;
2117
2114
  if ((_a = col.filter) === null || _a === void 0 ? void 0 : _a.default) {
@@ -2126,23 +2123,36 @@ class SdGridMaterial {
2126
2123
  set paginator(paginator) {
2127
2124
  if (paginator && __classPrivateFieldGet(this, _paginator) !== paginator) {
2128
2125
  __classPrivateFieldSet(this, _paginator, paginator);
2129
- __classPrivateFieldGet(this, _subscription$1).add(paginator.page.pipe(map(__classPrivateFieldGet(this, _getFilter)), switchMap(filterInfo => __classPrivateFieldGet(this, _load$1).call(this, filterInfo, false))).subscribe(__classPrivateFieldGet(this, _render)));
2126
+ __classPrivateFieldGet(this, _subscription$1).add(paginator.page.pipe(map(() => {
2127
+ __classPrivateFieldGet(this, _reload).next(false);
2128
+ })).subscribe());
2130
2129
  }
2131
2130
  }
2132
2131
  set sort(sort) {
2133
2132
  if (sort && __classPrivateFieldGet(this, _sort) !== sort) {
2134
2133
  __classPrivateFieldSet(this, _sort, sort);
2135
- __classPrivateFieldGet(this, _subscription$1).add(sort.sortChange.pipe(map(__classPrivateFieldGet(this, _getFilter)), switchMap(filterInfo => __classPrivateFieldGet(this, _load$1).call(this, filterInfo, false))).subscribe(__classPrivateFieldGet(this, _render)));
2134
+ __classPrivateFieldGet(this, _subscription$1).add(sort.sortChange.pipe(map(() => {
2135
+ __classPrivateFieldGet(this, _reload).next(false);
2136
+ })).subscribe());
2136
2137
  }
2137
2138
  }
2138
2139
  ngOnInit() {
2139
2140
  __classPrivateFieldGet(this, _initCellDef).call(this);
2140
2141
  }
2141
2142
  ngAfterViewInit() {
2143
+ __classPrivateFieldGet(this, _subscription$1).add(__classPrivateFieldGet(this, _reload).pipe(startWith(true), debounceTime(200), switchMap(force => {
2144
+ const filterInfo = __classPrivateFieldGet(this, _getFilter).call(this);
2145
+ return __classPrivateFieldGet(this, _load$1).call(this, filterInfo, force);
2146
+ })).subscribe(__classPrivateFieldGet(this, _render)));
2142
2147
  __classPrivateFieldGet(this, _subscription$1).add(this.sdCellDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initCellDef)));
2143
2148
  __classPrivateFieldGet(this, _subscription$1).add(this.sdFooterDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initFooterDef)));
2144
2149
  __classPrivateFieldGet(this, _subscription$1).add(this.sdFilterDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initFilterDef)));
2145
- __classPrivateFieldGet(this, _subscription$1).add(__classPrivateFieldGet(this, _optionChanges).pipe(startWith({}), map(__classPrivateFieldGet(this, _getFilter)), switchMap(filterInfo => __classPrivateFieldGet(this, _load$1).call(this, filterInfo, true))).subscribe(__classPrivateFieldGet(this, _render)));
2150
+ // this.#subscription.add(this.#optionChanges.pipe(
2151
+ // debounceTime(200),
2152
+ // startWith({}),
2153
+ // map(this.#getFilter),
2154
+ // switchMap(filterInfo => this.#load(filterInfo, true))
2155
+ // ).subscribe(this.#render));
2146
2156
  this.ref.detectChanges();
2147
2157
  }
2148
2158
  ngOnDestroy() {