@firestitch/list 9.10.1 → 9.11.2

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.
@@ -4,7 +4,7 @@ import { ChangeFn, FilterConfig, IFilterSavedFiltersConfig } from '@firestitch/f
4
4
  import { FsScrollInstance, FsScrollService } from '@firestitch/scroll';
5
5
  import { SelectionDialog } from '@firestitch/selection';
6
6
  import { Model } from 'tsmodels';
7
- import { BehaviorSubject, Subject } from 'rxjs';
7
+ import { BehaviorSubject, Observable, Subject } from 'rxjs';
8
8
  import { FsListAfterFetchFn, FsListConfig, FsListEmptyStateConfig, FsListFetchFn, FsListFetchSubscription, FsListNoResultsConfig, FsListRestoreConfig, FsListScrollableConfig, FsListTrackByFn } from '../interfaces';
9
9
  import { ColumnsController } from './columns-controller';
10
10
  import { ActionsController } from './index';
@@ -45,7 +45,6 @@ export declare class List extends Model {
45
45
  afterFetchFn: FsListAfterFetchFn;
46
46
  initialized$: BehaviorSubject<boolean>;
47
47
  loading$: BehaviorSubject<boolean>;
48
- filtersQuery: any;
49
48
  hasRowActions: any;
50
49
  paging: PaginationController;
51
50
  columns: ColumnsController;
@@ -68,6 +67,7 @@ export declare class List extends Model {
68
67
  emptyStateTemplate: TemplateRef<any>;
69
68
  fsScrollInstance: FsScrollInstance;
70
69
  onDestroy$: Subject<unknown>;
70
+ private readonly _filtersQuery;
71
71
  private readonly _headerConfig;
72
72
  private readonly _groupCellConfig;
73
73
  private readonly _cellConfig;
@@ -75,6 +75,8 @@ export declare class List extends Model {
75
75
  private _fsScrollSubscription;
76
76
  constructor(el: ElementRef, config: FsListConfig, fsScroll: FsScrollService, selectionDialog: SelectionDialog, router: Router, route: ActivatedRoute, persistance: PersistanceController, inDialog: boolean);
77
77
  get hasSavedFilters(): boolean;
78
+ get filtersQuery(): Record<string, any>;
79
+ get filtersQuery$(): Observable<Record<string, any>>;
78
80
  fetchRemote(query: any): any;
79
81
  /**
80
82
  * Transform templates for using
@@ -27,6 +27,7 @@ export declare class ReorderController implements OnDestroy {
27
27
  private _enabled$;
28
28
  private _manualReorderActivated$;
29
29
  private _reorderDisabled$;
30
+ private _numberOfActiveFilters;
30
31
  private _destroy$;
31
32
  constructor();
32
33
  get enabled(): boolean;
@@ -53,4 +54,5 @@ export declare class ReorderController implements OnDestroy {
53
54
  * Disable reorder action and update filter actions state
54
55
  */
55
56
  disableReorderAction(): void;
57
+ setNunberOfActiveFilters(activeFilters: number): void;
56
58
  }
@@ -103,6 +103,7 @@ export declare class FsListComponent implements OnInit, OnDestroy {
103
103
  private _subscribeToRemoveRow;
104
104
  private _subscribeToGroupExpandStatusChange;
105
105
  private _waitFirstLoad;
106
+ private _listenFiltersQueryChange;
106
107
  private _configMergeCustomizer;
107
108
  private _restorePersistance;
108
109
  }
@@ -143,7 +143,7 @@ export interface FsListRowActionGroup {
143
143
  rowActions: FsListRowAction[];
144
144
  }
145
145
  export interface FsListRowAction {
146
- label?: string;
146
+ label?: string | FsListRowActionLabelFn;
147
147
  type?: ActionType;
148
148
  className?: string;
149
149
  icon?: string;
@@ -160,6 +160,9 @@ export interface FsListRowAction {
160
160
  export interface FsListRowActionLinkFn {
161
161
  (row: FsListAbstractRow): FsListRowActionLink;
162
162
  }
163
+ export interface FsListRowActionLabelFn {
164
+ (row: FsListAbstractRow): string;
165
+ }
163
166
  export interface FsListRowActionLink {
164
167
  link: any[] | string;
165
168
  queryParams?: Record<string, any>;
@@ -3,7 +3,6 @@ import { ActionType } from '../enums/button-type.enum';
3
3
  import { FsListRowActionLink } from '../interfaces';
4
4
  export declare class RowAction extends Model {
5
5
  icon: string;
6
- label: string;
7
6
  menu: boolean;
8
7
  remove: {
9
8
  title: string;
@@ -14,16 +13,19 @@ export declare class RowAction extends Model {
14
13
  show: Function;
15
14
  restore: boolean;
16
15
  rowActions: RowAction[];
16
+ label: string;
17
17
  routerLink: FsListRowActionLink;
18
18
  classArray: string[];
19
19
  isShown: boolean;
20
20
  click: Function;
21
21
  private _linkFn;
22
+ private _labelFn;
22
23
  private readonly _isGroup;
23
24
  constructor(config?: any);
24
25
  get isGroup(): boolean;
25
26
  _fromJSON(value: any): void;
26
27
  checkShowStatus(row: any, index: any): void;
27
28
  updateLink(row: any): void;
29
+ updateLabel(row: any): void;
28
30
  private clickEvent;
29
31
  }
@@ -517,6 +517,7 @@
517
517
  function RowAction(config) {
518
518
  if (config === void 0) { config = {}; }
519
519
  var _this = _super.call(this) || this;
520
+ _this.label = '';
520
521
  _this.classArray = [];
521
522
  _this.isShown = true;
522
523
  _this._isGroup = false;
@@ -549,6 +550,13 @@
549
550
  return _this.clickEvent(row, event, index, rowActionsRef, clickFn);
550
551
  };
551
552
  this._linkFn = value.link;
553
+ if (typeof value.label === 'function') {
554
+ this._labelFn = value.label;
555
+ this.label = '';
556
+ }
557
+ else {
558
+ this.label = value.label;
559
+ }
552
560
  if (this.className) {
553
561
  this.classArray = this.className.split(' ').reduce(function (acc, elem) {
554
562
  acc.push(elem);
@@ -583,6 +591,19 @@
583
591
  }
584
592
  }
585
593
  };
594
+ RowAction.prototype.updateLabel = function (row) {
595
+ if (!this.isShown) {
596
+ return;
597
+ }
598
+ if (this.isGroup) {
599
+ this.rowActions.forEach(function (action) {
600
+ action.updateLabel(row);
601
+ });
602
+ }
603
+ else if (this._labelFn) {
604
+ this.label = this._labelFn(row);
605
+ }
606
+ };
586
607
  RowAction.prototype.clickEvent = function (row, event, index, rowActionsRef, clickFn) {
587
608
  // Stop event propagation for parent
588
609
  event.stopPropagation();
@@ -599,10 +620,6 @@
599
620
  tsmodels.Alias(),
600
621
  __metadata("design:type", String)
601
622
  ], RowAction.prototype, "icon", void 0);
602
- __decorate([
603
- tsmodels.Alias(),
604
- __metadata("design:type", String)
605
- ], RowAction.prototype, "label", void 0);
606
623
  __decorate([
607
624
  tsmodels.Alias(),
608
625
  __metadata("design:type", Boolean)
@@ -3027,6 +3044,7 @@
3027
3044
  // Empty state
3028
3045
  _this.emptyStateEnabled = false;
3029
3046
  _this.onDestroy$ = new rxjs.Subject();
3047
+ _this._filtersQuery = new rxjs.BehaviorSubject(null);
3030
3048
  _this._fromJSON(config);
3031
3049
  _this.initialize(config);
3032
3050
  _this._headerConfig = new StyleConfig(config.header);
@@ -3048,6 +3066,20 @@
3048
3066
  enumerable: true,
3049
3067
  configurable: true
3050
3068
  });
3069
+ Object.defineProperty(List.prototype, "filtersQuery", {
3070
+ get: function () {
3071
+ return this._filtersQuery.getValue();
3072
+ },
3073
+ enumerable: true,
3074
+ configurable: true
3075
+ });
3076
+ Object.defineProperty(List.prototype, "filtersQuery$", {
3077
+ get: function () {
3078
+ return this._filtersQuery.asObservable();
3079
+ },
3080
+ enumerable: true,
3081
+ configurable: true
3082
+ });
3051
3083
  List.prototype.fetchRemote = function (query) {
3052
3084
  var options = {
3053
3085
  state: this.dataController.operation,
@@ -3338,7 +3370,7 @@
3338
3370
  var _this = this;
3339
3371
  var fetch$ = this.fetch$.asObservable();
3340
3372
  // Should wait until saved filters not loaded
3341
- if (!!this.filters && !!this.savedFilters) {
3373
+ if (!!this.filters) {
3342
3374
  fetch$ = rxjs.combineLatest([fetch$, this.filtersReady$])
3343
3375
  .pipe(operators.map(function (_a) {
3344
3376
  var _b = __read(_a, 1), params = _b[0];
@@ -3511,7 +3543,7 @@
3511
3543
  if (this.filterInitCb) {
3512
3544
  this.filterInitCb(filters);
3513
3545
  }
3514
- this.filtersQuery = filters;
3546
+ this._filtersQuery.next(filters);
3515
3547
  this.checkRestoreFilter();
3516
3548
  };
3517
3549
  /**
@@ -3523,7 +3555,7 @@
3523
3555
  if (this.filterChangeCb) {
3524
3556
  this.filterChangeCb(filterQuery, filterSort);
3525
3557
  }
3526
- this.filtersQuery = filterQuery;
3558
+ this._filtersQuery.next(filterQuery);
3527
3559
  this.restoreMode = false;
3528
3560
  // Restore option
3529
3561
  this.checkRestoreFilter();
@@ -3598,7 +3630,9 @@
3598
3630
  if (((_c = this.emptyState) === null || _c === void 0 ? void 0 : _c.validate) && this.emptyStateTemplate) {
3599
3631
  this.emptyStateEnabled = this.emptyState.validate(query, lodashEs.cloneDeep(response.data));
3600
3632
  }
3601
- this.afterFetchFn(query, this.dataController.visibleRowsData);
3633
+ if (this.afterFetchFn) {
3634
+ this.afterFetchFn(query, this.dataController.visibleRowsData);
3635
+ }
3602
3636
  this.fetchComplete$.next();
3603
3637
  this.loading$.next(false);
3604
3638
  };
@@ -3741,6 +3775,7 @@
3741
3775
  this._enabled$ = new rxjs.BehaviorSubject(false);
3742
3776
  this._manualReorderActivated$ = new rxjs.BehaviorSubject(false);
3743
3777
  this._reorderDisabled$ = new rxjs.BehaviorSubject(false);
3778
+ this._numberOfActiveFilters = 0;
3744
3779
  this._destroy$ = new rxjs.Subject();
3745
3780
  }
3746
3781
  Object.defineProperty(ReorderController.prototype, "enabled", {
@@ -3774,7 +3809,9 @@
3774
3809
  return this._enabled$
3775
3810
  .pipe(operators.map(function (enabled) {
3776
3811
  return enabled && _this.position === exports.ReorderPosition.Left;
3777
- }), operators.distinctUntilChanged(), operators.shareReplay(), operators.takeUntil(this._destroy$));
3812
+ }), operators.map(function () {
3813
+ return _this._numberOfActiveFilters === 0;
3814
+ }), operators.distinctUntilChanged(), operators.shareReplay());
3778
3815
  },
3779
3816
  enumerable: true,
3780
3817
  configurable: true
@@ -3785,7 +3822,9 @@
3785
3822
  return this._enabled$
3786
3823
  .pipe(operators.map(function (enabled) {
3787
3824
  return enabled && _this.position === exports.ReorderPosition.Right;
3788
- }), operators.distinctUntilChanged(), operators.shareReplay(), operators.takeUntil(this._destroy$));
3825
+ }), operators.map(function () {
3826
+ return _this._numberOfActiveFilters === 0;
3827
+ }), operators.distinctUntilChanged(), operators.shareReplay());
3789
3828
  },
3790
3829
  enumerable: true,
3791
3830
  configurable: true
@@ -3908,6 +3947,10 @@
3908
3947
  this._reorderDisabled$.next(true);
3909
3948
  this._actionsController.updateDisabledState();
3910
3949
  };
3950
+ ReorderController.prototype.setNunberOfActiveFilters = function (activeFilters) {
3951
+ this._numberOfActiveFilters = activeFilters;
3952
+ this.enabled = this.enabled;
3953
+ };
3911
3954
  ReorderController = __decorate([
3912
3955
  core.Injectable(),
3913
3956
  __metadata("design:paramtypes", [])
@@ -4434,6 +4477,7 @@
4434
4477
  this._updateCustomizeAction(listConfig.actions);
4435
4478
  this.list = new List(this._el, listConfig, this.fsScroll, this.selectionDialog, this._router, this._route, this._persistance, this._inDialog);
4436
4479
  this._waitFirstLoad();
4480
+ this._listenFiltersQueryChange();
4437
4481
  this.reorderController.initWithConfig(config.reorder, this.list.dataController, this.list.actions);
4438
4482
  if (this.listColumnDirectives) {
4439
4483
  this.list.tranformTemplatesToColumns(this.listColumnDirectives);
@@ -4511,6 +4555,17 @@
4511
4555
  _this.cdRef.markForCheck();
4512
4556
  });
4513
4557
  };
4558
+ FsListComponent.prototype._listenFiltersQueryChange = function () {
4559
+ var _this = this;
4560
+ this.list.filtersQuery$
4561
+ .pipe(operators.takeUntil(this.list.onDestroy$), operators.takeUntil(this._destroy))
4562
+ .subscribe(function (value) {
4563
+ if (value) {
4564
+ var activeFilters = Object.keys(value).length;
4565
+ _this.reorderController.setNunberOfActiveFilters(activeFilters);
4566
+ }
4567
+ });
4568
+ };
4514
4569
  FsListComponent.prototype._configMergeCustomizer = function (objValue, srcValue) {
4515
4570
  if (Array.isArray(objValue)) {
4516
4571
  return objValue;
@@ -5746,7 +5801,10 @@
5746
5801
  return index;
5747
5802
  };
5748
5803
  FsRowActionsComponent.prototype.clickOnTrigger = function (event) {
5804
+ var _this = this;
5749
5805
  event.stopPropagation();
5806
+ this.rowActions
5807
+ .forEach(function (action) { return action.updateLabel(_this.row.data); });
5750
5808
  };
5751
5809
  /**
5752
5810
  * Emit that some row must be removed