@sumaris-net/ngx-components 1.5.5 → 1.5.6

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.
@@ -543,26 +543,31 @@
543
543
  if (target === items)
544
544
  target = target.slice();
545
545
  target.sort(propertiesPathComparator(keys));
546
- var total = items.length || 0;
547
- // Truncate if need
546
+ var res = {
547
+ total: target.length || 0,
548
+ data: undefined // will be below
549
+ };
550
+ // Page (truncate if need)
548
551
  if (opts) {
549
552
  if (isNil(opts.offset) && opts.offset > 0) {
550
- target = target.slice(opts.offset);
553
+ res.data = target.slice(opts.offset);
551
554
  }
552
555
  if (isNotNil(opts.size) && target.length > opts.size) {
553
- target = target.slice(0, opts.size);
556
+ res.data = target.slice(0, opts.size);
554
557
  }
555
558
  }
556
- var res = {
557
- data: target,
558
- total: total
559
- };
559
+ else {
560
+ res.data = target;
561
+ }
560
562
  // Add fetch more capability, if total was fetched
561
- var nextOffset = (opts && opts.offset || 0) + items.length;
562
- if (nextOffset < total) {
563
- res.fetchMore = function (_) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
564
- return [2 /*return*/, suggestFromArray(items, value, Object.assign({ offset: nextOffset }, opts))];
565
- }); }); };
563
+ var nextOffset = (opts && opts.offset || 0) + target.length;
564
+ if (nextOffset < res.total) {
565
+ res.fetchMore = function (_) { return __awaiter(_this, void 0, void 0, function () {
566
+ return __generator(this, function (_a) {
567
+ return [2 /*return*/, suggestFromArray(target, undefined /*already applied*/, Object.assign(Object.assign({}, opts), { offset: nextOffset, excludedIds: undefined // not need (already applied)
568
+ }))];
569
+ });
570
+ }); };
566
571
  }
567
572
  return res;
568
573
  }