@sd-angular/core 1.0.0 → 1.0.4

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.
@@ -1243,11 +1243,13 @@ class SdGridMaterial {
1243
1243
  });
1244
1244
  _filterLocal.set(this, (localItems, filterInfo) => {
1245
1245
  const { columns } = this.gridOption;
1246
+ const { rawColumnFilter, orderBy, orderDirection, pageSize, pageNumber } = filterInfo;
1246
1247
  const items = localItems.filter(item => {
1247
1248
  var _a, _b;
1248
1249
  for (const column of columns) {
1249
- const filterValue = (filterInfo.rawColumnFilter[column.field] || '').toString().trim().toLowerCase();
1250
- const columnValue = (item[column.field] || '').toString().trim().toLowerCase();
1250
+ const { field } = column;
1251
+ const filterValue = (rawColumnFilter[field] || '').toString().trim().toLowerCase();
1252
+ const columnValue = (item[field] || '').toString().trim().toLowerCase();
1251
1253
  if (filterValue) {
1252
1254
  if (!columnValue) {
1253
1255
  return false;
@@ -1310,8 +1312,8 @@ class SdGridMaterial {
1310
1312
  return true;
1311
1313
  });
1312
1314
  // Sort
1313
- if (filterInfo.orderBy && filterInfo.orderDirection) {
1314
- const column = columns.find(e => e.field === filterInfo.orderBy);
1315
+ if (orderBy && orderDirection) {
1316
+ const column = columns.find(e => e.field === orderBy);
1315
1317
  if (column) {
1316
1318
  const { type, field } = column;
1317
1319
  items.sort((current, next) => {
@@ -1333,18 +1335,16 @@ class SdGridMaterial {
1333
1335
  }
1334
1336
  return 0;
1335
1337
  });
1336
- if (filterInfo.orderDirection === 'desc') {
1338
+ if (orderDirection === 'desc') {
1337
1339
  items.reverse();
1338
1340
  }
1339
1341
  }
1340
1342
  }
1343
+ console.log(localItems, items, rawColumnFilter);
1341
1344
  return {
1342
1345
  items: items.filter((item, index) => {
1343
- var _a, _b, _c, _d;
1344
- const pageIndex = ((_a = __classPrivateFieldGet(this, _paginator)) === null || _a === void 0 ? void 0 : _a.pageIndex) || 0;
1345
- const pageSize = ((_b = __classPrivateFieldGet(this, _paginator)) === null || _b === void 0 ? void 0 : _b.pageSize) || ((_d = (_c = this.gridOption) === null || _c === void 0 ? void 0 : _c.paginate) === null || _d === void 0 ? void 0 : _d.pageSize) || 50;
1346
- return index >= pageIndex * pageSize
1347
- && index < (pageIndex + 1) * pageSize;
1346
+ return index >= pageNumber * pageSize
1347
+ && index < (pageNumber + 1) * pageSize;
1348
1348
  }),
1349
1349
  total: items.length
1350
1350
  };
@@ -1361,7 +1361,7 @@ class SdGridMaterial {
1361
1361
  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
1362
1362
  });
1363
1363
  });
1364
- _load$1.set(this, (filterReq) => __awaiter(this, void 0, void 0, function* () {
1364
+ _load$1.set(this, (filterReq, force = true) => __awaiter(this, void 0, void 0, function* () {
1365
1365
  this.isLoading = true;
1366
1366
  try {
1367
1367
  if (this.gridOption.type === 'server') {
@@ -1372,12 +1372,14 @@ class SdGridMaterial {
1372
1372
  return yield result;
1373
1373
  }
1374
1374
  else {
1375
- const results = this.gridOption.items();
1376
- if (results instanceof Promise) {
1377
- this.localItems = yield results;
1378
- }
1379
- else {
1380
- this.localItems = results;
1375
+ if (force) {
1376
+ const results = this.gridOption.items();
1377
+ if (results instanceof Promise) {
1378
+ this.localItems = yield results;
1379
+ }
1380
+ else {
1381
+ this.localItems = results;
1382
+ }
1381
1383
  }
1382
1384
  return __classPrivateFieldGet(this, _filterLocal).call(this, this.localItems, filterReq);
1383
1385
  }
@@ -1402,8 +1404,8 @@ class SdGridMaterial {
1402
1404
  this.isSelectAll = this.items.every(e => e.isSelected);
1403
1405
  __classPrivateFieldGet(this, _updateSelectedItems).call(this);
1404
1406
  }));
1405
- this.reload = () => __awaiter(this, void 0, void 0, function* () {
1406
- const data = yield __classPrivateFieldGet(this, _load$1).call(this, __classPrivateFieldGet(this, _getFilter).call(this));
1407
+ this.reload = (force = true) => __awaiter(this, void 0, void 0, function* () {
1408
+ const data = yield __classPrivateFieldGet(this, _load$1).call(this, __classPrivateFieldGet(this, _getFilter).call(this), force);
1407
1409
  __classPrivateFieldGet(this, _render).call(this, data);
1408
1410
  });
1409
1411
  _exportedItems.set(this, (pageNumber = 0, pageSize = 10000) => __awaiter(this, void 0, void 0, function* () {
@@ -1655,7 +1657,7 @@ class SdGridMaterial {
1655
1657
  });
1656
1658
  this.onFilterChange = () => {
1657
1659
  __classPrivateFieldGet(this, _paginator).pageIndex = 0;
1658
- this.reload();
1660
+ this.reload(false);
1659
1661
  };
1660
1662
  this.onExpand = (rowData) => __awaiter(this, void 0, void 0, function* () {
1661
1663
  var _q, _r, _s;
@@ -1901,7 +1903,7 @@ class SdGridMaterial {
1901
1903
  __classPrivateFieldGet(this, _subscription$1).add(gridFilter.filterChange.pipe(debounceTime(200), map(() => {
1902
1904
  __classPrivateFieldGet(this, _paginator).pageIndex = 0;
1903
1905
  return __classPrivateFieldGet(this, _getFilter).call(this);
1904
- }), switchMap(__classPrivateFieldGet(this, _load$1))).subscribe(__classPrivateFieldGet(this, _render)));
1906
+ }), switchMap(filterInfo => __classPrivateFieldGet(this, _load$1).call(this, filterInfo, false))).subscribe(__classPrivateFieldGet(this, _render)));
1905
1907
  }
1906
1908
  }
1907
1909
  set option(option) {
@@ -1924,13 +1926,13 @@ class SdGridMaterial {
1924
1926
  set paginator(paginator) {
1925
1927
  if (paginator && __classPrivateFieldGet(this, _paginator) !== paginator) {
1926
1928
  __classPrivateFieldSet(this, _paginator, paginator);
1927
- __classPrivateFieldGet(this, _subscription$1).add(paginator.page.pipe(debounceTime(200), map(__classPrivateFieldGet(this, _getFilter)), switchMap(__classPrivateFieldGet(this, _load$1))).subscribe(__classPrivateFieldGet(this, _render)));
1929
+ __classPrivateFieldGet(this, _subscription$1).add(paginator.page.pipe(debounceTime(200), map(__classPrivateFieldGet(this, _getFilter)), switchMap(filterInfo => __classPrivateFieldGet(this, _load$1).call(this, filterInfo, false))).subscribe(__classPrivateFieldGet(this, _render)));
1928
1930
  }
1929
1931
  }
1930
1932
  set sort(sort) {
1931
1933
  if (sort && __classPrivateFieldGet(this, _sort) !== sort) {
1932
1934
  __classPrivateFieldSet(this, _sort, sort);
1933
- __classPrivateFieldGet(this, _subscription$1).add(sort.sortChange.pipe(debounceTime(200), map(__classPrivateFieldGet(this, _getFilter)), switchMap(__classPrivateFieldGet(this, _load$1))).subscribe(__classPrivateFieldGet(this, _render)));
1935
+ __classPrivateFieldGet(this, _subscription$1).add(sort.sortChange.pipe(debounceTime(200), map(__classPrivateFieldGet(this, _getFilter)), switchMap(filterInfo => __classPrivateFieldGet(this, _load$1).call(this, filterInfo, false))).subscribe(__classPrivateFieldGet(this, _render)));
1934
1936
  }
1935
1937
  }
1936
1938
  ngOnInit() {
@@ -1940,7 +1942,7 @@ class SdGridMaterial {
1940
1942
  __classPrivateFieldGet(this, _subscription$1).add(this.sdCellDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initCellDef)));
1941
1943
  __classPrivateFieldGet(this, _subscription$1).add(this.sdFooterDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initFooterDef)));
1942
1944
  __classPrivateFieldGet(this, _subscription$1).add(this.sdFilterDefs.changes.pipe(startWith([])).subscribe(__classPrivateFieldGet(this, _initFilterDef)));
1943
- __classPrivateFieldGet(this, _subscription$1).add(__classPrivateFieldGet(this, _optionChanges).pipe(startWith({}), debounceTime(200), map(__classPrivateFieldGet(this, _getFilter)), switchMap(__classPrivateFieldGet(this, _load$1))).subscribe(__classPrivateFieldGet(this, _render)));
1945
+ __classPrivateFieldGet(this, _subscription$1).add(__classPrivateFieldGet(this, _optionChanges).pipe(startWith({}), debounceTime(200), map(__classPrivateFieldGet(this, _getFilter)), switchMap(filterInfo => __classPrivateFieldGet(this, _load$1).call(this, filterInfo, true))).subscribe(__classPrivateFieldGet(this, _render)));
1944
1946
  this.ref.detectChanges();
1945
1947
  }
1946
1948
  ngOnDestroy() {