@firestitch/list 12.19.0 → 12.19.1

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.
@@ -28,4 +28,5 @@ export declare class ExternalParamsController {
28
28
  private _listenSortingChanges;
29
29
  private _updateSortingParams;
30
30
  private _updatePaginationParams;
31
+ private _replaceState;
31
32
  }
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
- import { FsListLoadMoreConfig, FsPaging, PageChange, QueryOffsetStrategy, QueryPageStrategy } from '../interfaces';
3
2
  import { PaginationStrategy } from '../enums/pagination-strategy.enum';
3
+ import { FsListLoadMoreConfig, FsPaging, PageChange, QueryOffsetStrategy, QueryPageStrategy } from '../interfaces';
4
4
  export declare class PaginationController {
5
5
  limit: number;
6
6
  records: number;
@@ -37,6 +37,7 @@ export declare class PaginationController {
37
37
  get limits(): number[];
38
38
  /**
39
39
  * Set limits, update pages array and set new limit per page
40
+ *
40
41
  * @param value
41
42
  */
42
43
  set limits(value: number[]);
@@ -112,6 +113,7 @@ export declare class PaginationController {
112
113
  private get _hasNextPageOffsetStrategy();
113
114
  /**
114
115
  * Update paging config and all related fields
116
+ *
115
117
  * @param config
116
118
  * @param displayedRecords
117
119
  * @param loadMoreOperation
@@ -130,16 +132,19 @@ export declare class PaginationController {
130
132
  getVisibleRecords(): number;
131
133
  /**
132
134
  * Set new limit
135
+ *
133
136
  * @param limit
134
137
  */
135
138
  setLimit(limit: any): void;
136
139
  /**
137
140
  * If page is activate page
141
+ *
138
142
  * @param page
139
143
  */
140
144
  isActive(page: any): boolean;
141
145
  /**
142
146
  * Go to page
147
+ *
143
148
  * @param page
144
149
  */
145
150
  goToPage(page: any): void;
@@ -165,6 +170,7 @@ export declare class PaginationController {
165
170
  goLast(): void;
166
171
  /**
167
172
  * Update count of deleted rows. This count will be applied for offset calc
173
+ *
168
174
  * @param count
169
175
  */
170
176
  removeRows(count: number): void;
@@ -175,15 +181,16 @@ export declare class PaginationController {
175
181
  destroy(): void;
176
182
  /**
177
183
  * Update paging state
184
+ *
178
185
  * @param params
179
186
  */
180
187
  private _fromParams;
181
188
  /**
182
189
  * Calc and update offset
183
190
  */
184
- private updateOffset;
191
+ private _updateOffset;
185
192
  /**
186
193
  * Calc and update total count of pages
187
194
  */
188
- private updateTotalPages;
195
+ private _updateTotalPages;
189
196
  }
@@ -4024,20 +4024,10 @@
4024
4024
  });
4025
4025
  };
4026
4026
  ExternalParamsController.prototype._updateSortingParams = function (name, direction) {
4027
- var _this = this;
4028
4027
  if (this._queryParamsEnabled) {
4029
- // FIXME
4030
- setTimeout(function () {
4031
- _this._router.navigate([], {
4032
- skipLocationChange: true,
4033
- replaceUrl: true,
4034
- relativeTo: _this._route,
4035
- queryParams: {
4036
- sortName: name,
4037
- sortDirection: direction,
4038
- },
4039
- queryParamsHandling: 'merge',
4040
- }).then();
4028
+ this._replaceState({
4029
+ sortName: name,
4030
+ sortDirection: direction,
4041
4031
  });
4042
4032
  }
4043
4033
  if (this._persistance.enabled) {
@@ -4050,22 +4040,22 @@
4050
4040
  }
4051
4041
  };
4052
4042
  ExternalParamsController.prototype._updatePaginationParams = function (params) {
4053
- var _this = this;
4054
4043
  if (this._queryParamsEnabled) {
4055
- setTimeout(function () {
4056
- _this._router.navigate([], {
4057
- skipLocationChange: true,
4058
- replaceUrl: true,
4059
- relativeTo: _this._route,
4060
- queryParams: params,
4061
- queryParamsHandling: 'merge',
4062
- }).then();
4063
- });
4044
+ this._replaceState(params);
4064
4045
  }
4065
4046
  if (this._persistance.enabled) {
4066
4047
  this._persistance.saveDataToScope('paging', params);
4067
4048
  }
4068
4049
  };
4050
+ ExternalParamsController.prototype._replaceState = function (data) {
4051
+ var url = new URL(window.location.href);
4052
+ Object.keys(data)
4053
+ .filter(function (name) { return data[name] !== undefined && data[name] !== null; })
4054
+ .forEach(function (name) {
4055
+ url.searchParams.set(name, data[name]);
4056
+ });
4057
+ history.replaceState({}, null, url.search);
4058
+ };
4069
4059
  return ExternalParamsController;
4070
4060
  }());
4071
4061
 
@@ -4219,6 +4209,7 @@
4219
4209
  },
4220
4210
  /**
4221
4211
  * Set limits, update pages array and set new limit per page
4212
+ *
4222
4213
  * @param value
4223
4214
  */
4224
4215
  set: function (value) {
@@ -4305,7 +4296,7 @@
4305
4296
  var offset = Math.max(0, actualOffset - this._removedRows);
4306
4297
  return {
4307
4298
  offset: offset,
4308
- limit: this._removedRows
4299
+ limit: this._removedRows,
4309
4300
  };
4310
4301
  },
4311
4302
  enumerable: false,
@@ -4323,7 +4314,7 @@
4323
4314
  return this._strategy;
4324
4315
  },
4325
4316
  set: function (strategy) {
4326
- this._strategy = (strategy === void 0) ? exports.PaginationStrategy.Page : strategy;
4317
+ this._strategy = (strategy === undefined) ? exports.PaginationStrategy.Page : strategy;
4327
4318
  },
4328
4319
  enumerable: false,
4329
4320
  configurable: true
@@ -4485,6 +4476,7 @@
4485
4476
  });
4486
4477
  /**
4487
4478
  * Update paging config and all related fields
4479
+ *
4488
4480
  * @param config
4489
4481
  * @param displayedRecords
4490
4482
  * @param loadMoreOperation
@@ -4503,7 +4495,7 @@
4503
4495
  }
4504
4496
  this._removedRows = 0;
4505
4497
  }
4506
- this.updateTotalPages();
4498
+ this._updateTotalPages();
4507
4499
  };
4508
4500
  // /**
4509
4501
  // * Update paging when data source not remove
@@ -4574,6 +4566,7 @@
4574
4566
  };
4575
4567
  /**
4576
4568
  * Set new limit
4569
+ *
4577
4570
  * @param limit
4578
4571
  */
4579
4572
  PaginationController.prototype.setLimit = function (limit) {
@@ -4581,11 +4574,12 @@
4581
4574
  this.resetPaging();
4582
4575
  this._pageChanged$.next({
4583
4576
  type: PageChangeType.LimitChanged,
4584
- payload: limit
4577
+ payload: limit,
4585
4578
  });
4586
4579
  };
4587
4580
  /**
4588
4581
  * If page is activate page
4582
+ *
4589
4583
  * @param page
4590
4584
  */
4591
4585
  PaginationController.prototype.isActive = function (page) {
@@ -4593,15 +4587,16 @@
4593
4587
  };
4594
4588
  /**
4595
4589
  * Go to page
4590
+ *
4596
4591
  * @param page
4597
4592
  */
4598
4593
  PaginationController.prototype.goToPage = function (page) {
4599
4594
  if (page >= 1 && this.page !== page) {
4600
4595
  this.page = page;
4601
- this.updateOffset();
4596
+ this._updateOffset();
4602
4597
  this._pageChanged$.next({
4603
4598
  type: PageChangeType.Default,
4604
- payload: page
4599
+ payload: page,
4605
4600
  });
4606
4601
  }
4607
4602
  };
@@ -4618,7 +4613,7 @@
4618
4613
  PaginationController.prototype.goNext = function () {
4619
4614
  if (this.hasNextPage) {
4620
4615
  this.page++;
4621
- this.updateOffset();
4616
+ this._updateOffset();
4622
4617
  this._pageChanged$.next({
4623
4618
  type: PageChangeType.Default,
4624
4619
  payload: this.page,
@@ -4631,7 +4626,7 @@
4631
4626
  PaginationController.prototype.goFirst = function () {
4632
4627
  if (this.page > 1) {
4633
4628
  this.page = 1;
4634
- this.updateOffset();
4629
+ this._updateOffset();
4635
4630
  this._pageChanged$.next({
4636
4631
  type: PageChangeType.Default,
4637
4632
  payload: this.page,
@@ -4644,7 +4639,7 @@
4644
4639
  PaginationController.prototype.goPrev = function () {
4645
4640
  if (this.page > 1) {
4646
4641
  this.page--;
4647
- this.updateOffset();
4642
+ this._updateOffset();
4648
4643
  this._pageChanged$.next({
4649
4644
  type: PageChangeType.Default,
4650
4645
  payload: this.page,
@@ -4657,22 +4652,23 @@
4657
4652
  PaginationController.prototype.goLast = function () {
4658
4653
  if (this.page !== this.pages) {
4659
4654
  this.page = this.pages;
4660
- this.updateOffset();
4655
+ this._updateOffset();
4661
4656
  this._pageChanged$.next({
4662
4657
  type: PageChangeType.Default,
4663
- payload: this.page
4658
+ payload: this.page,
4664
4659
  });
4665
4660
  }
4666
4661
  };
4667
4662
  /**
4668
4663
  * Update count of deleted rows. This count will be applied for offset calc
4664
+ *
4669
4665
  * @param count
4670
4666
  */
4671
4667
  PaginationController.prototype.removeRows = function (count) {
4672
4668
  this._removedRows += count;
4673
4669
  };
4674
4670
  PaginationController.prototype.updatePagination = function () {
4675
- this.updateTotalPages();
4671
+ this._updateTotalPages();
4676
4672
  };
4677
4673
  /**
4678
4674
  * Destroy
@@ -4683,6 +4679,7 @@
4683
4679
  };
4684
4680
  /**
4685
4681
  * Update paging state
4682
+ *
4686
4683
  * @param params
4687
4684
  */
4688
4685
  PaginationController.prototype._fromParams = function (params) {
@@ -4697,13 +4694,13 @@
4697
4694
  /**
4698
4695
  * Calc and update offset
4699
4696
  */
4700
- PaginationController.prototype.updateOffset = function () {
4697
+ PaginationController.prototype._updateOffset = function () {
4701
4698
  this.offset = this.limit * (this.page - 1);
4702
4699
  };
4703
4700
  /**
4704
4701
  * Calc and update total count of pages
4705
4702
  */
4706
- PaginationController.prototype.updateTotalPages = function () {
4703
+ PaginationController.prototype._updateTotalPages = function () {
4707
4704
  this.pages = Math.ceil(this.records / this.limit);
4708
4705
  };
4709
4706
  return PaginationController;