@firestitch/list 9.9.12 → 9.11.0

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.
@@ -5,7 +5,7 @@ import { FsScrollInstance, FsScrollService } from '@firestitch/scroll';
5
5
  import { SelectionDialog } from '@firestitch/selection';
6
6
  import { Model } from 'tsmodels';
7
7
  import { BehaviorSubject, Subject } from 'rxjs';
8
- import { FsListConfig, FsListEmptyStateConfig, FsListFetchFn, FsListFetchSubscription, FsListNoResultsConfig, FsListRestoreConfig, FsListScrollableConfig, FsListTrackByFn } from '../interfaces';
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';
11
11
  import { DataController } from './data-controller';
@@ -42,6 +42,7 @@ export declare class List extends Model {
42
42
  noResults: FsListNoResultsConfig;
43
43
  emptyState: FsListEmptyStateConfig;
44
44
  fetchFn: FsListFetchFn;
45
+ afterFetchFn: FsListAfterFetchFn;
45
46
  initialized$: BehaviorSubject<boolean>;
46
47
  loading$: BehaviorSubject<boolean>;
47
48
  filtersQuery: any;
@@ -33,6 +33,7 @@ export interface FsListConfig {
33
33
  rowClass?: (row: any) => string;
34
34
  actions?: FsListAction[];
35
35
  fetch?: FsListFetchFn;
36
+ afterFetch?: FsListAfterFetchFn;
36
37
  scrollable?: FsListScrollableConfig | boolean;
37
38
  selection?: FsListSelectionConfig;
38
39
  initialFetch?: boolean;
@@ -142,7 +143,7 @@ export interface FsListRowActionGroup {
142
143
  rowActions: FsListRowAction[];
143
144
  }
144
145
  export interface FsListRowAction {
145
- label?: string;
146
+ label?: string | FsListRowActionLabelFn;
146
147
  type?: ActionType;
147
148
  className?: string;
148
149
  icon?: string;
@@ -159,6 +160,9 @@ export interface FsListRowAction {
159
160
  export interface FsListRowActionLinkFn {
160
161
  (row: FsListAbstractRow): FsListRowActionLink;
161
162
  }
163
+ export interface FsListRowActionLabelFn {
164
+ (row: FsListAbstractRow): string;
165
+ }
162
166
  export interface FsListRowActionLink {
163
167
  link: any[] | string;
164
168
  queryParams?: Record<string, any>;
@@ -218,3 +222,4 @@ export declare type FsListFetchFn = (query: Record<string, any>, options: FsList
218
222
  data: unknown[];
219
223
  paging?: FsPaging;
220
224
  }>;
225
+ export declare type FsListAfterFetchFn = (query: Record<string, any>, data: unknown[]) => void;
@@ -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)
@@ -3598,6 +3615,9 @@
3598
3615
  if (((_c = this.emptyState) === null || _c === void 0 ? void 0 : _c.validate) && this.emptyStateTemplate) {
3599
3616
  this.emptyStateEnabled = this.emptyState.validate(query, lodashEs.cloneDeep(response.data));
3600
3617
  }
3618
+ if (this.afterFetchFn) {
3619
+ this.afterFetchFn(query, this.dataController.visibleRowsData);
3620
+ }
3601
3621
  this.fetchComplete$.next();
3602
3622
  this.loading$.next(false);
3603
3623
  };
@@ -3717,6 +3737,10 @@
3717
3737
  tsmodels.Alias('fetch'),
3718
3738
  __metadata("design:type", Function)
3719
3739
  ], List.prototype, "fetchFn", void 0);
3740
+ __decorate([
3741
+ tsmodels.Alias('afterFetch'),
3742
+ __metadata("design:type", Function)
3743
+ ], List.prototype, "afterFetchFn", void 0);
3720
3744
  return List;
3721
3745
  }(tsmodels.Model));
3722
3746
 
@@ -5741,7 +5765,10 @@
5741
5765
  return index;
5742
5766
  };
5743
5767
  FsRowActionsComponent.prototype.clickOnTrigger = function (event) {
5768
+ var _this = this;
5744
5769
  event.stopPropagation();
5770
+ this.rowActions
5771
+ .forEach(function (action) { return action.updateLabel(_this.row.data); });
5745
5772
  };
5746
5773
  /**
5747
5774
  * Emit that some row must be removed