@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.
@@ -2660,6 +2660,24 @@ class SortingController {
2660
2660
  this.sortBy(column);
2661
2661
  this.sortDirection(column.direction || SortingDirection.asc);
2662
2662
  }
2663
+ /**
2664
+ * Merge sorting and fake sorting cols
2665
+ * Fake sorting cols it's cols which don't represented in table cols, like abstract cols
2666
+ */
2667
+ makeSortingList() {
2668
+ return [
2669
+ ...this.sortingColumns,
2670
+ ...this.fakeSortingColumns,
2671
+ ].reduce((acc, column) => {
2672
+ const sortingItem = {
2673
+ name: column.title,
2674
+ value: column.name,
2675
+ default: this.sortingColumn && this.sortingColumn.name === column.name,
2676
+ };
2677
+ acc.push(sortingItem);
2678
+ return acc;
2679
+ }, []);
2680
+ }
2663
2681
  getColumn(name) {
2664
2682
  return [...this.sortingColumns, ...this.fakeSortingColumns]
2665
2683
  .find((col) => col.name === name && col.sortable);
@@ -4058,11 +4076,11 @@ class PaginationController {
4058
4076
  }
4059
4077
  }
4060
4078
 
4061
- const SHOW_DELETED_FILTERS_KEY = '_showDeleted_';
4079
+ const showDeletedFilterKey = 'showDeleted';
4062
4080
  class List {
4063
- constructor(_el, config = {}, _fsScroll, _selectionDialog, _router, _route, _persistance, _inDialog) {
4081
+ constructor(_el, _config = {}, _fsScroll, _selectionDialog, _router, _route, _persistance, _inDialog) {
4064
4082
  this._el = _el;
4065
- this.config = config;
4083
+ this._config = _config;
4066
4084
  this._fsScroll = _fsScroll;
4067
4085
  this._selectionDialog = _selectionDialog;
4068
4086
  this._router = _router;
@@ -4070,14 +4088,13 @@ class List {
4070
4088
  this._persistance = _persistance;
4071
4089
  this._inDialog = _inDialog;
4072
4090
  this.filters = [];
4073
- this.initialized$ = new BehaviorSubject(false);
4074
- this.loading$ = new BehaviorSubject(false);
4075
4091
  this.paging = new PaginationController();
4076
4092
  this.columns = new ColumnsController();
4077
4093
  this.actions = new ActionsController();
4078
4094
  this.dataController = new DataController();
4079
4095
  this.sorting = new SortingController();
4080
4096
  this.filterConfig = null;
4097
+ this.loading$ = new BehaviorSubject(false);
4081
4098
  this.fetchComplete$ = new Subject();
4082
4099
  this.filtersReady$ = new Subject();
4083
4100
  this.status = true;
@@ -4088,17 +4105,18 @@ class List {
4088
4105
  this.initialFetch = true;
4089
4106
  // Empty state
4090
4107
  this.emptyStateEnabled = false;
4091
- this.onDestroy$ = new Subject();
4108
+ this._destroy$ = new Subject();
4109
+ this._initialized$ = new BehaviorSubject(false);
4092
4110
  this._fetch$ = new Subject();
4093
4111
  this._filtersQuery = new BehaviorSubject(null);
4094
4112
  this._activeFiltersCount$ = this._filtersQuery
4095
4113
  .pipe(map((v) => Object.keys(v).length), shareReplay());
4096
- this._initialize(config);
4097
- this._headerConfig = new StyleConfig(config.header);
4098
- this._groupCellConfig = new StyleConfig(config.cell);
4099
- this._cellConfig = new StyleConfig(config.cell);
4100
- this._footerConfig = new StyleConfig(config.footer);
4101
- this.initialized$.next(true);
4114
+ this._initialize(_config);
4115
+ this._headerConfig = new StyleConfig(_config.header);
4116
+ this._groupCellConfig = new StyleConfig(_config.cell);
4117
+ this._cellConfig = new StyleConfig(_config.cell);
4118
+ this._footerConfig = new StyleConfig(_config.footer);
4119
+ this._initialized$.next(true);
4102
4120
  this.subscribe();
4103
4121
  if (this.initialFetch) {
4104
4122
  this.dataController.setOperation(FsListState.Load);
@@ -4117,6 +4135,12 @@ class List {
4117
4135
  get activeFiltersCount$() {
4118
4136
  return this._activeFiltersCount$;
4119
4137
  }
4138
+ get destroy$() {
4139
+ return this._destroy$;
4140
+ }
4141
+ get initialized$() {
4142
+ return this._initialized$;
4143
+ }
4120
4144
  fetchRemote(query) {
4121
4145
  const options = {
4122
4146
  state: this.dataController.operation,
@@ -4149,7 +4173,7 @@ class List {
4149
4173
  this._updateSortingColumns();
4150
4174
  // Default sort by
4151
4175
  const externalSorting = this.externalParams.externalSorting;
4152
- const initialSortConfig = externalSorting || this.config.sort;
4176
+ const initialSortConfig = externalSorting || this._config.sort;
4153
4177
  this.sorting.initialSortBy(initialSortConfig);
4154
4178
  if (externalSorting && !this.sorting.isDefined) {
4155
4179
  this.externalParams.clearSortingParams();
@@ -4175,7 +4199,7 @@ class List {
4175
4199
  */
4176
4200
  subscribe() {
4177
4201
  this.paging.pageChanged$
4178
- .pipe(takeUntil(this.onDestroy$))
4202
+ .pipe(takeUntil(this._destroy$))
4179
4203
  .subscribe((event) => {
4180
4204
  this.dataController.setOperation(FsListState.PageChange);
4181
4205
  // Remove all rows if limits was changed
@@ -4197,12 +4221,12 @@ class List {
4197
4221
  let el = this._el.nativeElement;
4198
4222
  if (!contains) {
4199
4223
  const rect = this._el.nativeElement.getBoundingClientRect();
4200
- if ((rect.top + window.pageYOffset) < window.innerHeight) {
4224
+ if ((Number(rect.top || 0) + window.pageYOffset) < window.innerHeight) {
4201
4225
  el = document.body;
4202
4226
  }
4203
4227
  }
4204
4228
  this.fetchComplete$.asObservable()
4205
- .pipe(take(1), takeUntil(this.onDestroy$))
4229
+ .pipe(take(1), takeUntil(this._destroy$))
4206
4230
  .subscribe((event) => {
4207
4231
  if (event?.scrollIntoView ?? true) {
4208
4232
  el.scrollIntoView({ behavior: 'smooth' });
@@ -4212,7 +4236,7 @@ class List {
4212
4236
  this._fetch$.next();
4213
4237
  });
4214
4238
  this.sorting.sortingChanged$
4215
- .pipe(takeUntil(this.onDestroy$))
4239
+ .pipe(takeUntil(this._destroy$))
4216
4240
  .subscribe(() => {
4217
4241
  this.dataController.setOperation(FsListState.Sort);
4218
4242
  this.paging.page = 1;
@@ -4276,8 +4300,8 @@ class List {
4276
4300
  this.externalParams.destroy();
4277
4301
  }
4278
4302
  this.columns.destroy();
4279
- this.onDestroy$.next();
4280
- this.onDestroy$.complete();
4303
+ this._destroy$.next();
4304
+ this._destroy$.complete();
4281
4305
  this.dataController.destroy();
4282
4306
  }
4283
4307
  /**
@@ -4298,7 +4322,7 @@ class List {
4298
4322
  }
4299
4323
  _initVariables(config) {
4300
4324
  this.autoFocus = config.autoFocus;
4301
- this.rowHighlight = config.rowHighlight ?? true;
4325
+ this.rowHoverHighlight = config.rowHoverHighlight ?? true;
4302
4326
  this.heading = config.heading;
4303
4327
  this.trackBy = config.trackBy;
4304
4328
  this.subheading = config.subheading;
@@ -4319,6 +4343,7 @@ class List {
4319
4343
  this.beforeFetchFn = config.beforeFetch;
4320
4344
  this.afterInit = config.afterInit;
4321
4345
  this.style = config.style;
4346
+ this.autoReload = config.autoReload;
4322
4347
  this.columns.initConfig(config.column);
4323
4348
  }
4324
4349
  /**
@@ -4345,7 +4370,7 @@ class List {
4345
4370
  this.queryParam = false;
4346
4371
  }
4347
4372
  else {
4348
- this.queryParam = (config.queryParam === void 0)
4373
+ this.queryParam = (config.queryParam === undefined)
4349
4374
  ? true
4350
4375
  : config.queryParam;
4351
4376
  }
@@ -4383,7 +4408,7 @@ class List {
4383
4408
  }
4384
4409
  if (this.restore.filter !== false) {
4385
4410
  this.filters.push({
4386
- name: SHOW_DELETED_FILTERS_KEY,
4411
+ name: showDeletedFilterKey,
4387
4412
  type: ItemType.Checkbox,
4388
4413
  label: this.restore.filterLabel || 'Show Deleted',
4389
4414
  });
@@ -4437,7 +4462,7 @@ class List {
4437
4462
  _listenFetch() {
4438
4463
  let fetch$ = this.fetch$;
4439
4464
  // Should wait until saved filters not loaded
4440
- if (!!this.filters) {
4465
+ if (this.filters) {
4441
4466
  fetch$ = combineLatest([fetch$, this.filtersReady$])
4442
4467
  .pipe(map(([params]) => params));
4443
4468
  }
@@ -4493,7 +4518,7 @@ class List {
4493
4518
  }), catchError((error) => {
4494
4519
  console.error(error);
4495
4520
  return EMPTY;
4496
- }), takeUntil(this.onDestroy$))
4521
+ }), takeUntil(this._destroy$))
4497
4522
  .subscribe(([paramsQuery, response]) => {
4498
4523
  this.initialFetch = false;
4499
4524
  this._completeFetch(paramsQuery.params, paramsQuery.query, response);
@@ -4501,7 +4526,7 @@ class List {
4501
4526
  }
4502
4527
  _listenRowsRemove() {
4503
4528
  this.dataController.rowsRemoved$
4504
- .pipe(takeUntil(this.onDestroy$))
4529
+ .pipe(takeUntil(this._destroy$))
4505
4530
  .subscribe((rows) => {
4506
4531
  if (this.paging.enabled) {
4507
4532
  const removedCount = rows.length;
@@ -4534,7 +4559,7 @@ class List {
4534
4559
  */
4535
4560
  _listenVisibleColumnChanges() {
4536
4561
  this.columns.visibleColumns$
4537
- .pipe(takeUntil(this.onDestroy$))
4562
+ .pipe(takeUntil(this._destroy$))
4538
4563
  .subscribe(() => {
4539
4564
  this._updateSortingColumns();
4540
4565
  });
@@ -4545,12 +4570,12 @@ class List {
4545
4570
  }
4546
4571
  if (this.scrollable) {
4547
4572
  // Scrollable status by default
4548
- if (this.scrollable.status === void 0) {
4573
+ if (this.scrollable.status === undefined) {
4549
4574
  this.scrollable.status = true;
4550
4575
  }
4551
4576
  this._fsScroll
4552
4577
  .component(this.scrollable.name)
4553
- .pipe(takeUntil(this.onDestroy$))
4578
+ .pipe(takeUntil(this._destroy$))
4554
4579
  .subscribe((fsScrollInstance) => {
4555
4580
  this.fsScrollInstance = fsScrollInstance;
4556
4581
  this._fsScrollSubscription = fsScrollInstance
@@ -4581,7 +4606,7 @@ class List {
4581
4606
  }
4582
4607
  });
4583
4608
  this.dataController.remoteRowsChange$
4584
- .pipe(takeUntil(this.onDestroy$))
4609
+ .pipe(takeUntil(this._destroy$))
4585
4610
  .subscribe(() => {
4586
4611
  fsScrollInstance.loaded();
4587
4612
  });
@@ -4595,20 +4620,7 @@ class List {
4595
4620
  if (this.filterConfig) {
4596
4621
  return;
4597
4622
  }
4598
- // Merge sorting and fake sorting cols
4599
- // Fake sorting cols it's cols which don't represented in table cols, like abstract cols
4600
- const sortValues = [
4601
- ...this.sorting.sortingColumns,
4602
- ...this.sorting.fakeSortingColumns,
4603
- ].reduce((acc, column) => {
4604
- const sortingItem = {
4605
- name: column.title,
4606
- value: column.name,
4607
- default: this.sorting.sortingColumn && this.sorting.sortingColumn.name === column.name,
4608
- };
4609
- acc.push(sortingItem);
4610
- return acc;
4611
- }, []);
4623
+ const sortValues = this.sorting.makeSortingList();
4612
4624
  const sortConfig = this.sorting.sortingColumn
4613
4625
  ? { value: this.sorting.sortingColumn.name, direction: this.sorting.sortingColumn.direction }
4614
4626
  : null;
@@ -4624,9 +4636,10 @@ class List {
4624
4636
  sorts: sortValues,
4625
4637
  sort: sortConfig,
4626
4638
  chips: this.chips,
4639
+ autoReload: this.autoReload,
4627
4640
  init: this._filterInit.bind(this),
4628
4641
  change: this._filterChange.bind(this),
4629
- reload: (this.config.reload ?? true) ? this.reload.bind(this) : null,
4642
+ reload: (this._config.reload ?? true) ? this.reload.bind(this) : null,
4630
4643
  sortChange: this._filterSort.bind(this),
4631
4644
  };
4632
4645
  }
@@ -4672,8 +4685,8 @@ class List {
4672
4685
  }
4673
4686
  _checkRestoreFilter() {
4674
4687
  // Restore option
4675
- if (this.restore && this.filtersQuery[SHOW_DELETED_FILTERS_KEY]) {
4676
- delete this.filtersQuery[SHOW_DELETED_FILTERS_KEY];
4688
+ if (this.restore && this.filtersQuery[showDeletedFilterKey]) {
4689
+ delete this.filtersQuery[showDeletedFilterKey];
4677
4690
  Object.assign(this.filtersQuery, this.restore.query);
4678
4691
  this.restoreMode = true;
4679
4692
  }
@@ -4776,10 +4789,9 @@ class List {
4776
4789
  const restoreClickResult = restoreClickCallback(row);
4777
4790
  if (restoreClickResult instanceof Observable) {
4778
4791
  restoreClickResult
4779
- .pipe(take(1), takeUntil(this.onDestroy$))
4792
+ .pipe(take(1), takeUntil(this._destroy$))
4780
4793
  .subscribe({
4781
4794
  next: () => this.reload(),
4782
- error: () => { },
4783
4795
  });
4784
4796
  }
4785
4797
  }
@@ -5412,6 +5424,7 @@ class FsListComponent {
5412
5424
  */
5413
5425
  columnVisibility(name, show) {
5414
5426
  this.columnsVisibility([{ name, show }]);
5427
+ this.filterRef.updateSortings(this.list.sorting.makeSortingList());
5415
5428
  }
5416
5429
  /**
5417
5430
  * Update visibility for list of specific columns
@@ -5444,7 +5457,7 @@ class FsListComponent {
5444
5457
  }
5445
5458
  this._updateCustomizeAction(listConfig.actions);
5446
5459
  this.list = new List(this._el, listConfig, this._scroll, this._selectionDialog, this._router, this._route, this._persistance, this._inDialog);
5447
- this.rowHighlight = this.list.rowHighlight;
5460
+ this.rowHoverHighlight = this.list.rowHoverHighlight;
5448
5461
  this._waitFirstLoad();
5449
5462
  this.reorderController.initWithConfig(config.reorder, this.list.dataController, this.list.actions, this.list.selection);
5450
5463
  if (this._listColumnDirectives) {
@@ -5472,7 +5485,7 @@ class FsListComponent {
5472
5485
  },
5473
5486
  })
5474
5487
  .afterClosed()
5475
- .pipe(takeUntil(this.list.onDestroy$), takeUntil(this._destroy))
5488
+ .pipe(takeUntil(this.list.destroy$), takeUntil(this._destroy))
5476
5489
  .subscribe((data) => {
5477
5490
  if (data) {
5478
5491
  this.list.columns.updateVisibilityForCols(data);
@@ -5488,7 +5501,7 @@ class FsListComponent {
5488
5501
  _listenSortingChange() {
5489
5502
  this.list.sorting
5490
5503
  .sortingChanged$
5491
- .pipe(takeUntil(this.list.onDestroy$), takeUntil(this._destroy))
5504
+ .pipe(takeUntil(this.list.destroy$), takeUntil(this._destroy))
5492
5505
  .subscribe((sort) => {
5493
5506
  this._filterRef.updateSort(sort);
5494
5507
  });
@@ -5499,7 +5512,7 @@ class FsListComponent {
5499
5512
  .subscribe((row) => {
5500
5513
  this.list.dataController.removeData(row);
5501
5514
  this.body.rows
5502
- .forEach((row) => row.actionsUpdate());
5515
+ .forEach((bodyRow) => bodyRow.actionsUpdate());
5503
5516
  });
5504
5517
  }
5505
5518
  _subscribeToGroupExpandStatusChange() {
@@ -5513,7 +5526,7 @@ class FsListComponent {
5513
5526
  }
5514
5527
  _waitFirstLoad() {
5515
5528
  this.list.loading$
5516
- .pipe(skip(1), filter((value) => !value), take(1), takeUntil(this.list.onDestroy$), takeUntil(this._destroy))
5529
+ .pipe(skip(1), filter((value) => !value), take(1), takeUntil(this.list.destroy$), takeUntil(this._destroy))
5517
5530
  .subscribe(() => {
5518
5531
  this.firstLoad = false;
5519
5532
  this._cdRef.markForCheck();
@@ -5530,7 +5543,7 @@ class FsListComponent {
5530
5543
  }
5531
5544
  }
5532
5545
  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 });
5533
- 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: [
5546
+ 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: [
5534
5547
  GroupExpandNotifierService,
5535
5548
  PersistanceController,
5536
5549
  ReorderController,
@@ -5556,7 +5569,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.4.0", ngImpor
5556
5569
  }] }, { type: i0.ElementRef }, { type: i5.SelectionDialog }, { type: i1$2.MatDialog }, { type: i0.ChangeDetectorRef }, { type: GroupExpandNotifierService }, { type: i7.Router }, { type: i7.ActivatedRoute }, { type: PersistanceController }, { type: i3.Location }]; }, propDecorators: { classFsList: [{
5557
5570
  type: HostBinding,
5558
5571
  args: ['class.fs-list']
5559
- }], rowHighlight: [{
5572
+ }], rowHoverHighlight: [{
5560
5573
  type: HostBinding,
5561
5574
  args: ['class.fs-list-row-highlight']
5562
5575
  }], config: [{