@firestitch/list 9.10.2 → 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.
@@ -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)
@@ -5748,7 +5765,10 @@
5748
5765
  return index;
5749
5766
  };
5750
5767
  FsRowActionsComponent.prototype.clickOnTrigger = function (event) {
5768
+ var _this = this;
5751
5769
  event.stopPropagation();
5770
+ this.rowActions
5771
+ .forEach(function (action) { return action.updateLabel(_this.row.data); });
5752
5772
  };
5753
5773
  /**
5754
5774
  * Emit that some row must be removed