@firestitch/list 9.10.2 → 9.11.3

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.
@@ -323,6 +323,7 @@ var RowAction = /** @class */ (function (_super) {
323
323
  function RowAction(config) {
324
324
  if (config === void 0) { config = {}; }
325
325
  var _this = _super.call(this) || this;
326
+ _this.label = '';
326
327
  _this.classArray = [];
327
328
  _this.isShown = true;
328
329
  _this._isGroup = false;
@@ -355,6 +356,13 @@ var RowAction = /** @class */ (function (_super) {
355
356
  return _this.clickEvent(row, event, index, rowActionsRef, clickFn);
356
357
  };
357
358
  this._linkFn = value.link;
359
+ if (typeof value.label === 'function') {
360
+ this._labelFn = value.label;
361
+ this.label = '';
362
+ }
363
+ else {
364
+ this.label = value.label;
365
+ }
358
366
  if (this.className) {
359
367
  this.classArray = this.className.split(' ').reduce(function (acc, elem) {
360
368
  acc.push(elem);
@@ -389,6 +397,19 @@ var RowAction = /** @class */ (function (_super) {
389
397
  }
390
398
  }
391
399
  };
400
+ RowAction.prototype.updateLabel = function (row) {
401
+ if (!this.isShown) {
402
+ return;
403
+ }
404
+ if (this.isGroup) {
405
+ this.rowActions.forEach(function (action) {
406
+ action.updateLabel(row);
407
+ });
408
+ }
409
+ else if (this._labelFn) {
410
+ this.label = this._labelFn(row);
411
+ }
412
+ };
392
413
  RowAction.prototype.clickEvent = function (row, event, index, rowActionsRef, clickFn) {
393
414
  // Stop event propagation for parent
394
415
  event.stopPropagation();
@@ -405,10 +426,6 @@ var RowAction = /** @class */ (function (_super) {
405
426
  Alias(),
406
427
  __metadata("design:type", String)
407
428
  ], RowAction.prototype, "icon", void 0);
408
- __decorate([
409
- Alias(),
410
- __metadata("design:type", String)
411
- ], RowAction.prototype, "label", void 0);
412
429
  __decorate([
413
430
  Alias(),
414
431
  __metadata("design:type", Boolean)
@@ -2833,6 +2850,7 @@ var List = /** @class */ (function (_super) {
2833
2850
  // Empty state
2834
2851
  _this.emptyStateEnabled = false;
2835
2852
  _this.onDestroy$ = new Subject();
2853
+ _this._filtersQuery = new BehaviorSubject(null);
2836
2854
  _this._fromJSON(config);
2837
2855
  _this.initialize(config);
2838
2856
  _this._headerConfig = new StyleConfig(config.header);
@@ -2854,6 +2872,20 @@ var List = /** @class */ (function (_super) {
2854
2872
  enumerable: true,
2855
2873
  configurable: true
2856
2874
  });
2875
+ Object.defineProperty(List.prototype, "filtersQuery", {
2876
+ get: function () {
2877
+ return this._filtersQuery.getValue();
2878
+ },
2879
+ enumerable: true,
2880
+ configurable: true
2881
+ });
2882
+ Object.defineProperty(List.prototype, "filtersQuery$", {
2883
+ get: function () {
2884
+ return this._filtersQuery.asObservable();
2885
+ },
2886
+ enumerable: true,
2887
+ configurable: true
2888
+ });
2857
2889
  List.prototype.fetchRemote = function (query) {
2858
2890
  var options = {
2859
2891
  state: this.dataController.operation,
@@ -3144,7 +3176,7 @@ var List = /** @class */ (function (_super) {
3144
3176
  var _this = this;
3145
3177
  var fetch$ = this.fetch$.asObservable();
3146
3178
  // Should wait until saved filters not loaded
3147
- if (!!this.filters && !!this.savedFilters) {
3179
+ if (!!this.filters) {
3148
3180
  fetch$ = combineLatest([fetch$, this.filtersReady$])
3149
3181
  .pipe(map(function (_a) {
3150
3182
  var _b = __read(_a, 1), params = _b[0];
@@ -3317,7 +3349,7 @@ var List = /** @class */ (function (_super) {
3317
3349
  if (this.filterInitCb) {
3318
3350
  this.filterInitCb(filters);
3319
3351
  }
3320
- this.filtersQuery = filters;
3352
+ this._filtersQuery.next(filters);
3321
3353
  this.checkRestoreFilter();
3322
3354
  };
3323
3355
  /**
@@ -3329,7 +3361,7 @@ var List = /** @class */ (function (_super) {
3329
3361
  if (this.filterChangeCb) {
3330
3362
  this.filterChangeCb(filterQuery, filterSort);
3331
3363
  }
3332
- this.filtersQuery = filterQuery;
3364
+ this._filtersQuery.next(filterQuery);
3333
3365
  this.restoreMode = false;
3334
3366
  // Restore option
3335
3367
  this.checkRestoreFilter();
@@ -3549,6 +3581,7 @@ var ReorderController = /** @class */ (function () {
3549
3581
  this._enabled$ = new BehaviorSubject(false);
3550
3582
  this._manualReorderActivated$ = new BehaviorSubject(false);
3551
3583
  this._reorderDisabled$ = new BehaviorSubject(false);
3584
+ this._numberOfActiveFilters = 0;
3552
3585
  this._destroy$ = new Subject();
3553
3586
  }
3554
3587
  Object.defineProperty(ReorderController.prototype, "enabled", {
@@ -3582,7 +3615,9 @@ var ReorderController = /** @class */ (function () {
3582
3615
  return this._enabled$
3583
3616
  .pipe(map(function (enabled) {
3584
3617
  return enabled && _this.position === ReorderPosition.Left;
3585
- }), distinctUntilChanged(), shareReplay(), takeUntil(this._destroy$));
3618
+ }), map(function (enabled) {
3619
+ return enabled && _this._numberOfActiveFilters === 0;
3620
+ }), distinctUntilChanged(), shareReplay());
3586
3621
  },
3587
3622
  enumerable: true,
3588
3623
  configurable: true
@@ -3593,7 +3628,9 @@ var ReorderController = /** @class */ (function () {
3593
3628
  return this._enabled$
3594
3629
  .pipe(map(function (enabled) {
3595
3630
  return enabled && _this.position === ReorderPosition.Right;
3596
- }), distinctUntilChanged(), shareReplay(), takeUntil(this._destroy$));
3631
+ }), map(function (enabled) {
3632
+ return enabled && _this._numberOfActiveFilters === 0;
3633
+ }), distinctUntilChanged(), shareReplay());
3597
3634
  },
3598
3635
  enumerable: true,
3599
3636
  configurable: true
@@ -3716,6 +3753,10 @@ var ReorderController = /** @class */ (function () {
3716
3753
  this._reorderDisabled$.next(true);
3717
3754
  this._actionsController.updateDisabledState();
3718
3755
  };
3756
+ ReorderController.prototype.setNunberOfActiveFilters = function (activeFilters) {
3757
+ this._numberOfActiveFilters = activeFilters;
3758
+ this.enabled = this.enabled;
3759
+ };
3719
3760
  ReorderController = __decorate([
3720
3761
  Injectable(),
3721
3762
  __metadata("design:paramtypes", [])
@@ -4242,6 +4283,7 @@ var FsListComponent = /** @class */ (function () {
4242
4283
  this._updateCustomizeAction(listConfig.actions);
4243
4284
  this.list = new List(this._el, listConfig, this.fsScroll, this.selectionDialog, this._router, this._route, this._persistance, this._inDialog);
4244
4285
  this._waitFirstLoad();
4286
+ this._listenFiltersQueryChange();
4245
4287
  this.reorderController.initWithConfig(config.reorder, this.list.dataController, this.list.actions);
4246
4288
  if (this.listColumnDirectives) {
4247
4289
  this.list.tranformTemplatesToColumns(this.listColumnDirectives);
@@ -4319,6 +4361,17 @@ var FsListComponent = /** @class */ (function () {
4319
4361
  _this.cdRef.markForCheck();
4320
4362
  });
4321
4363
  };
4364
+ FsListComponent.prototype._listenFiltersQueryChange = function () {
4365
+ var _this = this;
4366
+ this.list.filtersQuery$
4367
+ .pipe(takeUntil(this.list.onDestroy$), takeUntil(this._destroy))
4368
+ .subscribe(function (value) {
4369
+ if (value) {
4370
+ var activeFilters = Object.keys(value).length;
4371
+ _this.reorderController.setNunberOfActiveFilters(activeFilters);
4372
+ }
4373
+ });
4374
+ };
4322
4375
  FsListComponent.prototype._configMergeCustomizer = function (objValue, srcValue) {
4323
4376
  if (Array.isArray(objValue)) {
4324
4377
  return objValue;
@@ -5554,7 +5607,10 @@ var FsRowActionsComponent = /** @class */ (function () {
5554
5607
  return index;
5555
5608
  };
5556
5609
  FsRowActionsComponent.prototype.clickOnTrigger = function (event) {
5610
+ var _this = this;
5557
5611
  event.stopPropagation();
5612
+ this.rowActions
5613
+ .forEach(function (action) { return action.updateLabel(_this.row.data); });
5558
5614
  };
5559
5615
  /**
5560
5616
  * Emit that some row must be removed