@firestitch/list 13.0.7 → 13.1.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.
@@ -2039,6 +2039,23 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
2039
2039
  args: ['rowsContainer', { read: ViewContainerRef, static: true }]
2040
2040
  }] } });
2041
2041
 
2042
+ var PageChangeType;
2043
+ (function (PageChangeType) {
2044
+ PageChangeType[PageChangeType["Default"] = 0] = "Default";
2045
+ PageChangeType[PageChangeType["LimitChanged"] = 1] = "LimitChanged";
2046
+ })(PageChangeType || (PageChangeType = {}));
2047
+
2048
+ var FsListState;
2049
+ (function (FsListState) {
2050
+ FsListState[FsListState["Idle"] = 0] = "Idle";
2051
+ FsListState[FsListState["Load"] = 1] = "Load";
2052
+ FsListState[FsListState["Reload"] = 2] = "Reload";
2053
+ FsListState[FsListState["Filter"] = 3] = "Filter";
2054
+ FsListState[FsListState["Sort"] = 4] = "Sort";
2055
+ FsListState[FsListState["PageChange"] = 5] = "PageChange";
2056
+ FsListState[FsListState["LoadMore"] = 6] = "LoadMore";
2057
+ })(FsListState || (FsListState = {}));
2058
+
2042
2059
  class StyleConfig {
2043
2060
  constructor(config = {}) {
2044
2061
  this.className = []; // Can't be used in tempaltes!
@@ -2277,23 +2294,6 @@ class Column {
2277
2294
  }
2278
2295
  }
2279
2296
 
2280
- var PageChangeType;
2281
- (function (PageChangeType) {
2282
- PageChangeType[PageChangeType["Default"] = 0] = "Default";
2283
- PageChangeType[PageChangeType["LimitChanged"] = 1] = "LimitChanged";
2284
- })(PageChangeType || (PageChangeType = {}));
2285
-
2286
- var FsListState;
2287
- (function (FsListState) {
2288
- FsListState[FsListState["Idle"] = 0] = "Idle";
2289
- FsListState[FsListState["Load"] = 1] = "Load";
2290
- FsListState[FsListState["Reload"] = 2] = "Reload";
2291
- FsListState[FsListState["Filter"] = 3] = "Filter";
2292
- FsListState[FsListState["Sort"] = 4] = "Sort";
2293
- FsListState[FsListState["PageChange"] = 5] = "PageChange";
2294
- FsListState[FsListState["LoadMore"] = 6] = "LoadMore";
2295
- })(FsListState || (FsListState = {}));
2296
-
2297
2297
  class ColumnsController {
2298
2298
  constructor() {
2299
2299
  this._visibleColumns$ = new BehaviorSubject([]);
@@ -4019,6 +4019,24 @@ class SortingController {
4019
4019
  this.sortBy(column);
4020
4020
  this.sortDirection(column.direction || SortingDirection.asc);
4021
4021
  }
4022
+ /**
4023
+ * Merge sorting and fake sorting cols
4024
+ * Fake sorting cols it's cols which don't represented in table cols, like abstract cols
4025
+ */
4026
+ makeSortingList() {
4027
+ return [
4028
+ ...this.sortingColumns,
4029
+ ...this.fakeSortingColumns,
4030
+ ].reduce((acc, column) => {
4031
+ const sortingItem = {
4032
+ name: column.title,
4033
+ value: column.name,
4034
+ default: this.sortingColumn && this.sortingColumn.name === column.name,
4035
+ };
4036
+ acc.push(sortingItem);
4037
+ return acc;
4038
+ }, []);
4039
+ }
4022
4040
  getColumn(name) {
4023
4041
  return [...this.sortingColumns, ...this.fakeSortingColumns]
4024
4042
  .find((col) => col.name === name && col.sortable);
@@ -4068,11 +4086,11 @@ class SortingController {
4068
4086
  }
4069
4087
  }
4070
4088
 
4071
- const SHOW_DELETED_FILTERS_KEY = '_showDeleted_';
4089
+ const showDeletedFilterKey = 'showDeleted';
4072
4090
  class List {
4073
- constructor(_el, config = {}, _fsScroll, _selectionDialog, _router, _route, _persistance, _inDialog) {
4091
+ constructor(_el, _config = {}, _fsScroll, _selectionDialog, _router, _route, _persistance, _inDialog) {
4074
4092
  this._el = _el;
4075
- this.config = config;
4093
+ this._config = _config;
4076
4094
  this._fsScroll = _fsScroll;
4077
4095
  this._selectionDialog = _selectionDialog;
4078
4096
  this._router = _router;
@@ -4080,14 +4098,13 @@ class List {
4080
4098
  this._persistance = _persistance;
4081
4099
  this._inDialog = _inDialog;
4082
4100
  this.filters = [];
4083
- this.initialized$ = new BehaviorSubject(false);
4084
- this.loading$ = new BehaviorSubject(false);
4085
4101
  this.paging = new PaginationController();
4086
4102
  this.columns = new ColumnsController();
4087
4103
  this.actions = new ActionsController();
4088
4104
  this.dataController = new DataController();
4089
4105
  this.sorting = new SortingController();
4090
4106
  this.filterConfig = null;
4107
+ this.loading$ = new BehaviorSubject(false);
4091
4108
  this.fetchComplete$ = new Subject();
4092
4109
  this.filtersReady$ = new Subject();
4093
4110
  this.status = true;
@@ -4098,17 +4115,18 @@ class List {
4098
4115
  this.initialFetch = true;
4099
4116
  // Empty state
4100
4117
  this.emptyStateEnabled = false;
4101
- this.onDestroy$ = new Subject();
4118
+ this._destroy$ = new Subject();
4119
+ this._initialized$ = new BehaviorSubject(false);
4102
4120
  this._fetch$ = new Subject();
4103
4121
  this._filtersQuery = new BehaviorSubject(null);
4104
4122
  this._activeFiltersCount$ = this._filtersQuery
4105
4123
  .pipe(map((v) => Object.keys(v).length), shareReplay());
4106
- this._initialize(config);
4107
- this._headerConfig = new StyleConfig(config.header);
4108
- this._groupCellConfig = new StyleConfig(config.cell);
4109
- this._cellConfig = new StyleConfig(config.cell);
4110
- this._footerConfig = new StyleConfig(config.footer);
4111
- this.initialized$.next(true);
4124
+ this._initialize(_config);
4125
+ this._headerConfig = new StyleConfig(_config.header);
4126
+ this._groupCellConfig = new StyleConfig(_config.cell);
4127
+ this._cellConfig = new StyleConfig(_config.cell);
4128
+ this._footerConfig = new StyleConfig(_config.footer);
4129
+ this._initialized$.next(true);
4112
4130
  this.subscribe();
4113
4131
  if (this.initialFetch) {
4114
4132
  this.dataController.setOperation(FsListState.Load);
@@ -4127,6 +4145,12 @@ class List {
4127
4145
  get activeFiltersCount$() {
4128
4146
  return this._activeFiltersCount$;
4129
4147
  }
4148
+ get destroy$() {
4149
+ return this._destroy$;
4150
+ }
4151
+ get initialized$() {
4152
+ return this._initialized$;
4153
+ }
4130
4154
  fetchRemote(query) {
4131
4155
  const options = {
4132
4156
  state: this.dataController.operation,
@@ -4159,7 +4183,7 @@ class List {
4159
4183
  this._updateSortingColumns();
4160
4184
  // Default sort by
4161
4185
  const externalSorting = this.externalParams.externalSorting;
4162
- const initialSortConfig = externalSorting || this.config.sort;
4186
+ const initialSortConfig = externalSorting || this._config.sort;
4163
4187
  this.sorting.initialSortBy(initialSortConfig);
4164
4188
  if (externalSorting && !this.sorting.isDefined) {
4165
4189
  this.externalParams.clearSortingParams();
@@ -4185,7 +4209,7 @@ class List {
4185
4209
  */
4186
4210
  subscribe() {
4187
4211
  this.paging.pageChanged$
4188
- .pipe(takeUntil(this.onDestroy$))
4212
+ .pipe(takeUntil(this._destroy$))
4189
4213
  .subscribe((event) => {
4190
4214
  this.dataController.setOperation(FsListState.PageChange);
4191
4215
  // Remove all rows if limits was changed
@@ -4207,12 +4231,12 @@ class List {
4207
4231
  let el = this._el.nativeElement;
4208
4232
  if (!contains) {
4209
4233
  const rect = this._el.nativeElement.getBoundingClientRect();
4210
- if ((rect.top + window.pageYOffset) < window.innerHeight) {
4234
+ if ((Number(rect.top || 0) + window.pageYOffset) < window.innerHeight) {
4211
4235
  el = document.body;
4212
4236
  }
4213
4237
  }
4214
4238
  this.fetchComplete$.asObservable()
4215
- .pipe(take(1), takeUntil(this.onDestroy$))
4239
+ .pipe(take(1), takeUntil(this._destroy$))
4216
4240
  .subscribe((event) => {
4217
4241
  var _a;
4218
4242
  if ((_a = event === null || event === void 0 ? void 0 : event.scrollIntoView) !== null && _a !== void 0 ? _a : true) {
@@ -4223,7 +4247,7 @@ class List {
4223
4247
  this._fetch$.next();
4224
4248
  });
4225
4249
  this.sorting.sortingChanged$
4226
- .pipe(takeUntil(this.onDestroy$))
4250
+ .pipe(takeUntil(this._destroy$))
4227
4251
  .subscribe(() => {
4228
4252
  this.dataController.setOperation(FsListState.Sort);
4229
4253
  this.paging.page = 1;
@@ -4287,8 +4311,8 @@ class List {
4287
4311
  this.externalParams.destroy();
4288
4312
  }
4289
4313
  this.columns.destroy();
4290
- this.onDestroy$.next();
4291
- this.onDestroy$.complete();
4314
+ this._destroy$.next();
4315
+ this._destroy$.complete();
4292
4316
  this.dataController.destroy();
4293
4317
  }
4294
4318
  /**
@@ -4310,7 +4334,7 @@ class List {
4310
4334
  _initVariables(config) {
4311
4335
  var _a, _b;
4312
4336
  this.autoFocus = config.autoFocus;
4313
- this.rowHighlight = (_a = config.rowHighlight) !== null && _a !== void 0 ? _a : true;
4337
+ this.rowHoverHighlight = (_a = config.rowHoverHighlight) !== null && _a !== void 0 ? _a : true;
4314
4338
  this.heading = config.heading;
4315
4339
  this.trackBy = config.trackBy;
4316
4340
  this.subheading = config.subheading;
@@ -4331,6 +4355,7 @@ class List {
4331
4355
  this.beforeFetchFn = config.beforeFetch;
4332
4356
  this.afterInit = config.afterInit;
4333
4357
  this.style = config.style;
4358
+ this.autoReload = config.autoReload;
4334
4359
  this.columns.initConfig(config.column);
4335
4360
  }
4336
4361
  /**
@@ -4357,7 +4382,7 @@ class List {
4357
4382
  this.queryParam = false;
4358
4383
  }
4359
4384
  else {
4360
- this.queryParam = (config.queryParam === void 0)
4385
+ this.queryParam = (config.queryParam === undefined)
4361
4386
  ? true
4362
4387
  : config.queryParam;
4363
4388
  }
@@ -4395,7 +4420,7 @@ class List {
4395
4420
  }
4396
4421
  if (this.restore.filter !== false) {
4397
4422
  this.filters.push({
4398
- name: SHOW_DELETED_FILTERS_KEY,
4423
+ name: showDeletedFilterKey,
4399
4424
  type: ItemType.Checkbox,
4400
4425
  label: this.restore.filterLabel || 'Show Deleted',
4401
4426
  });
@@ -4449,7 +4474,7 @@ class List {
4449
4474
  _listenFetch() {
4450
4475
  let fetch$ = this.fetch$;
4451
4476
  // Should wait until saved filters not loaded
4452
- if (!!this.filters) {
4477
+ if (this.filters) {
4453
4478
  fetch$ = combineLatest([fetch$, this.filtersReady$])
4454
4479
  .pipe(map(([params]) => params));
4455
4480
  }
@@ -4503,7 +4528,7 @@ class List {
4503
4528
  }), catchError((error) => {
4504
4529
  console.error(error);
4505
4530
  return EMPTY;
4506
- }), takeUntil(this.onDestroy$))
4531
+ }), takeUntil(this._destroy$))
4507
4532
  .subscribe(([paramsQuery, response]) => {
4508
4533
  this.initialFetch = false;
4509
4534
  this._completeFetch(paramsQuery.params, paramsQuery.query, response);
@@ -4511,7 +4536,7 @@ class List {
4511
4536
  }
4512
4537
  _listenRowsRemove() {
4513
4538
  this.dataController.rowsRemoved$
4514
- .pipe(takeUntil(this.onDestroy$))
4539
+ .pipe(takeUntil(this._destroy$))
4515
4540
  .subscribe((rows) => {
4516
4541
  if (this.paging.enabled) {
4517
4542
  const removedCount = rows.length;
@@ -4544,7 +4569,7 @@ class List {
4544
4569
  */
4545
4570
  _listenVisibleColumnChanges() {
4546
4571
  this.columns.visibleColumns$
4547
- .pipe(takeUntil(this.onDestroy$))
4572
+ .pipe(takeUntil(this._destroy$))
4548
4573
  .subscribe(() => {
4549
4574
  this._updateSortingColumns();
4550
4575
  });
@@ -4555,12 +4580,12 @@ class List {
4555
4580
  }
4556
4581
  if (this.scrollable) {
4557
4582
  // Scrollable status by default
4558
- if (this.scrollable.status === void 0) {
4583
+ if (this.scrollable.status === undefined) {
4559
4584
  this.scrollable.status = true;
4560
4585
  }
4561
4586
  this._fsScroll
4562
4587
  .component(this.scrollable.name)
4563
- .pipe(takeUntil(this.onDestroy$))
4588
+ .pipe(takeUntil(this._destroy$))
4564
4589
  .subscribe((fsScrollInstance) => {
4565
4590
  this.fsScrollInstance = fsScrollInstance;
4566
4591
  this._fsScrollSubscription = fsScrollInstance
@@ -4591,7 +4616,7 @@ class List {
4591
4616
  }
4592
4617
  });
4593
4618
  this.dataController.remoteRowsChange$
4594
- .pipe(takeUntil(this.onDestroy$))
4619
+ .pipe(takeUntil(this._destroy$))
4595
4620
  .subscribe(() => {
4596
4621
  fsScrollInstance.loaded();
4597
4622
  });
@@ -4606,20 +4631,7 @@ class List {
4606
4631
  if (this.filterConfig) {
4607
4632
  return;
4608
4633
  }
4609
- // Merge sorting and fake sorting cols
4610
- // Fake sorting cols it's cols which don't represented in table cols, like abstract cols
4611
- const sortValues = [
4612
- ...this.sorting.sortingColumns,
4613
- ...this.sorting.fakeSortingColumns,
4614
- ].reduce((acc, column) => {
4615
- const sortingItem = {
4616
- name: column.title,
4617
- value: column.name,
4618
- default: this.sorting.sortingColumn && this.sorting.sortingColumn.name === column.name,
4619
- };
4620
- acc.push(sortingItem);
4621
- return acc;
4622
- }, []);
4634
+ const sortValues = this.sorting.makeSortingList();
4623
4635
  const sortConfig = this.sorting.sortingColumn
4624
4636
  ? { value: this.sorting.sortingColumn.name, direction: this.sorting.sortingColumn.direction }
4625
4637
  : null;
@@ -4635,9 +4647,10 @@ class List {
4635
4647
  sorts: sortValues,
4636
4648
  sort: sortConfig,
4637
4649
  chips: this.chips,
4650
+ autoReload: this.autoReload,
4638
4651
  init: this._filterInit.bind(this),
4639
4652
  change: this._filterChange.bind(this),
4640
- reload: ((_a = this.config.reload) !== null && _a !== void 0 ? _a : true) ? this.reload.bind(this) : null,
4653
+ reload: ((_a = this._config.reload) !== null && _a !== void 0 ? _a : true) ? this.reload.bind(this) : null,
4641
4654
  sortChange: this._filterSort.bind(this),
4642
4655
  };
4643
4656
  }
@@ -4683,8 +4696,8 @@ class List {
4683
4696
  }
4684
4697
  _checkRestoreFilter() {
4685
4698
  // Restore option
4686
- if (this.restore && this.filtersQuery[SHOW_DELETED_FILTERS_KEY]) {
4687
- delete this.filtersQuery[SHOW_DELETED_FILTERS_KEY];
4699
+ if (this.restore && this.filtersQuery[showDeletedFilterKey]) {
4700
+ delete this.filtersQuery[showDeletedFilterKey];
4688
4701
  Object.assign(this.filtersQuery, this.restore.query);
4689
4702
  this.restoreMode = true;
4690
4703
  }
@@ -4788,10 +4801,9 @@ class List {
4788
4801
  const restoreClickResult = restoreClickCallback(row);
4789
4802
  if (restoreClickResult instanceof Observable) {
4790
4803
  restoreClickResult
4791
- .pipe(take(1), takeUntil(this.onDestroy$))
4804
+ .pipe(take(1), takeUntil(this._destroy$))
4792
4805
  .subscribe({
4793
4806
  next: () => this.reload(),
4794
- error: () => { },
4795
4807
  });
4796
4808
  }
4797
4809
  }
@@ -5424,6 +5436,7 @@ class FsListComponent {
5424
5436
  */
5425
5437
  columnVisibility(name, show) {
5426
5438
  this.columnsVisibility([{ name, show }]);
5439
+ this.filterRef.updateSortings(this.list.sorting.makeSortingList());
5427
5440
  }
5428
5441
  /**
5429
5442
  * Update visibility for list of specific columns
@@ -5456,7 +5469,7 @@ class FsListComponent {
5456
5469
  }
5457
5470
  this._updateCustomizeAction(listConfig.actions);
5458
5471
  this.list = new List(this._el, listConfig, this._scroll, this._selectionDialog, this._router, this._route, this._persistance, this._inDialog);
5459
- this.rowHighlight = this.list.rowHighlight;
5472
+ this.rowHoverHighlight = this.list.rowHoverHighlight;
5460
5473
  this._waitFirstLoad();
5461
5474
  this.reorderController.initWithConfig(config.reorder, this.list.dataController, this.list.actions, this.list.selection);
5462
5475
  if (this._listColumnDirectives) {
@@ -5484,7 +5497,7 @@ class FsListComponent {
5484
5497
  },
5485
5498
  })
5486
5499
  .afterClosed()
5487
- .pipe(takeUntil(this.list.onDestroy$), takeUntil(this._destroy))
5500
+ .pipe(takeUntil(this.list.destroy$), takeUntil(this._destroy))
5488
5501
  .subscribe((data) => {
5489
5502
  if (data) {
5490
5503
  this.list.columns.updateVisibilityForCols(data);
@@ -5500,7 +5513,7 @@ class FsListComponent {
5500
5513
  _listenSortingChange() {
5501
5514
  this.list.sorting
5502
5515
  .sortingChanged$
5503
- .pipe(takeUntil(this.list.onDestroy$), takeUntil(this._destroy))
5516
+ .pipe(takeUntil(this.list.destroy$), takeUntil(this._destroy))
5504
5517
  .subscribe((sort) => {
5505
5518
  this._filterRef.updateSort(sort);
5506
5519
  });
@@ -5511,7 +5524,7 @@ class FsListComponent {
5511
5524
  .subscribe((row) => {
5512
5525
  this.list.dataController.removeData(row);
5513
5526
  this.body.rows
5514
- .forEach((row) => row.actionsUpdate());
5527
+ .forEach((bodyRow) => bodyRow.actionsUpdate());
5515
5528
  });
5516
5529
  }
5517
5530
  _subscribeToGroupExpandStatusChange() {
@@ -5525,7 +5538,7 @@ class FsListComponent {
5525
5538
  }
5526
5539
  _waitFirstLoad() {
5527
5540
  this.list.loading$
5528
- .pipe(skip(1), filter((value) => !value), take(1), takeUntil(this.list.onDestroy$), takeUntil(this._destroy))
5541
+ .pipe(skip(1), filter((value) => !value), take(1), takeUntil(this.list.destroy$), takeUntil(this._destroy))
5529
5542
  .subscribe(() => {
5530
5543
  this.firstLoad = false;
5531
5544
  this._cdRef.markForCheck();
@@ -5542,7 +5555,7 @@ class FsListComponent {
5542
5555
  }
5543
5556
  }
5544
5557
  FsListComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.4.0", ngImport: i0, type: FsListComponent, deps: [{ token: ReorderController }, { token: FS_LIST_DEFAULT_CONFIG, optional: true }, { token: i2$4.FsScrollService, optional: true }, { token: i1$2.MatDialogRef, optional: true }, { token: i4$1.DrawerRef, optional: true }, { token: i0.ElementRef }, { token: i5.SelectionDialog }, { token: i1$2.MatDialog }, { token: i0.ChangeDetectorRef }, { token: GroupExpandNotifierService }, { token: i7.Router }, { token: i7.ActivatedRoute }, { token: PersistanceController }, { token: i3.Location }], target: i0.ɵɵFactoryTarget.Component });
5545
- FsListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FsListComponent, selector: "fs-list", inputs: { config: "config", loaderLines: "loaderLines" }, outputs: { filtersReady: "filtersReady" }, host: { properties: { "class.fs-list": "this.classFsList", "class.fs-list-row-highlight": "this.rowHighlight" } }, providers: [
5558
+ FsListComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.4.0", type: FsListComponent, selector: "fs-list", inputs: { config: "config", loaderLines: "loaderLines" }, outputs: { filtersReady: "filtersReady" }, host: { properties: { "class.fs-list": "this.classFsList", "class.fs-list-row-highlight": "this.rowHoverHighlight" } }, providers: [
5546
5559
  GroupExpandNotifierService,
5547
5560
  PersistanceController,
5548
5561
  ReorderController,
@@ -5570,7 +5583,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
5570
5583
  }, propDecorators: { classFsList: [{
5571
5584
  type: HostBinding,
5572
5585
  args: ['class.fs-list']
5573
- }], rowHighlight: [{
5586
+ }], rowHoverHighlight: [{
5574
5587
  type: HostBinding,
5575
5588
  args: ['class.fs-list-row-highlight']
5576
5589
  }], config: [{