@wizishop/angular-components 0.0.99 → 0.0.102

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.
@@ -698,6 +698,8 @@
698
698
  currentPage: 0
699
699
  };
700
700
  var filterGroup = this.filterRoutingBuilder.group(dataTableFilters, dataTableName);
701
+ filterGroup.tableFiltersValuesChange$ = new rxjs.ReplaySubject(1);
702
+ filterGroup.tableFiltersValuesDebouncedChange$ = filterGroup.tableFiltersValuesChange$.pipe(operators.debounceTime(300));
701
703
  this.filterGroups.set(dataTableName, filterGroup);
702
704
  return filterGroup;
703
705
  };
@@ -720,6 +722,9 @@
720
722
  currentPage: currentPage
721
723
  });
722
724
  };
725
+ /*
726
+ Add defaults filters in the URL if they not exists.
727
+ */
723
728
  FiltersTableService.prototype.setInitialPaginationFiltersIfNotExist = function (dataTableName, itemsPerPage, currentPage) {
724
729
  var filterGroup = this.getTableFilterGroup(dataTableName);
725
730
  filterGroup.setValues({
@@ -762,12 +767,11 @@
762
767
  this.headerCheckBoxId = uuid.v4(); // Create checkbox unique id
763
768
  /* Handle routing filters */
764
769
  if (this.tableRoutingName) {
765
- this._filterGroup = this.filtersTableService.getTableFilterGroup(this.tableRoutingName);
766
- // Performe initial fetch data
767
- this._filterGroup.valuesChange$.next([]);
770
+ this.filtersTableService.setInitialPaginationFiltersIfNotExist(this.tableRoutingName, this.tableFilters.itemsPerPage, this.tableFilters.currentPage);
771
+ this._tableFiltersGroup = this.filtersTableService.getTableFilterGroup(this.tableRoutingName);
768
772
  this.setTablesFilters();
769
773
  // Listen to filters changes with debounced time to limit multiple api calls
770
- this.filterGroupChangeSub = this._filterGroup.valuesChange$.subscribe(function (filters) {
774
+ this.filterGroupChangeSub = this._tableFiltersGroup.valuesChange$.subscribe(function (filters) {
771
775
  _this.setTablesFilters();
772
776
  });
773
777
  }
@@ -782,8 +786,8 @@
782
786
  this.tableFilters.currentPage = 1;
783
787
  this.tableFiltersChange.emit(this.tableFilters);
784
788
  // Reset routing filters
785
- if (this._filterGroup) {
786
- this._filterGroup.setValues({
789
+ if (this._tableFiltersGroup) {
790
+ this._tableFiltersGroup.setValues({
787
791
  searchValue: this.tableFilters.searchValue,
788
792
  sort: undefined,
789
793
  order: undefined,
@@ -793,8 +797,8 @@
793
797
  };
794
798
  TableComponent.prototype.pageChange = function () {
795
799
  this.tableFiltersChange.emit(this.tableFilters);
796
- if (this._filterGroup) {
797
- this._filterGroup.setValues({
800
+ if (this._tableFiltersGroup) {
801
+ this._tableFiltersGroup.setValues({
798
802
  itemsPerPage: this.tableFilters.itemsPerPage,
799
803
  currentPage: this.tableFilters.currentPage
800
804
  });
@@ -805,14 +809,15 @@
805
809
  * */
806
810
  TableComponent.prototype.setTablesFilters = function () {
807
811
  this.tableFilters = {
808
- sort: this._filterGroup.get('sort'),
809
- order: this._filterGroup.get('order'),
810
- searchValue: this._filterGroup.get('searchValue'),
811
- itemsPerPage: this._filterGroup.get('itemsPerPage') ? parseInt(this._filterGroup.get('itemsPerPage')) : 0,
812
- currentPage: this._filterGroup.get('currentPage') ? parseInt(this._filterGroup.get('currentPage')) : 0,
812
+ sort: this._tableFiltersGroup.get('sort'),
813
+ order: this._tableFiltersGroup.get('order'),
814
+ searchValue: this._tableFiltersGroup.get('searchValue'),
815
+ itemsPerPage: this._tableFiltersGroup.get('itemsPerPage') ? parseInt(this._tableFiltersGroup.get('itemsPerPage')) : 0,
816
+ currentPage: this._tableFiltersGroup.get('currentPage') ? parseInt(this._tableFiltersGroup.get('currentPage')) : 0,
813
817
  totalItems: this.tableFilters.totalItems
814
818
  };
815
819
  this.tableFiltersChange.emit(this.tableFilters);
820
+ this._tableFiltersGroup.tableFiltersValuesChange$.next(this.tableFilters);
816
821
  };
817
822
  TableComponent.prototype.ngDestroy = function () {
818
823
  if (this.filterGroupChangeSub) {
@@ -845,18 +850,14 @@
845
850
 
846
851
  var TagComponent = /** @class */ (function () {
847
852
  function TagComponent() {
848
- //todo Refacto, open/close should be handle outside this component
849
853
  this.label = '';
850
854
  this.hasClose = false;
851
855
  this.big = false;
852
856
  this.isOpen = true;
853
857
  this.isOpenChange = new i0.EventEmitter();
854
858
  }
855
- TagComponent.prototype.closeTag = function () {
856
- if (!this.hasClose) {
857
- return;
858
- }
859
- this.isOpen = false;
859
+ TagComponent.prototype.toggleTag = function () {
860
+ this.isOpen = !this.isOpen;
860
861
  this.isOpenChange.next(this.isOpen);
861
862
  };
862
863
  return TagComponent;
@@ -864,7 +865,7 @@
864
865
  TagComponent.decorators = [
865
866
  { type: i0.Component, args: [{
866
867
  selector: 'wac-tag',
867
- template: "<div class=\"wac-tag\" [classList]=\"'wac-tag--' + class\" [ngClass]=\"{ hover: hasClose, 'big': big }\" *ngIf=\"isOpen\" (click)=\"closeTag()\">\n {{ label }}\n <span *ngIf=\"hasClose\"><i class=\"fas fa-times\"></i></span>\n</div>\n"
868
+ template: "<div class=\"wac-tag\" [classList]=\"'wac-tag--' + class\" [ngClass]=\"{ hover: hasClose, 'big': big }\">\n {{ label }}\n <span class=\"wac-tag__close\" *ngIf=\"hasClose\" (click)=\"toggleTag()\"><i class=\"fas fa-times\"></i></span>\n</div>\n"
868
869
  },] }
869
870
  ];
870
871
  TagComponent.ctorParameters = function () { return []; };
@@ -4041,6 +4042,20 @@
4041
4042
  },] }
4042
4043
  ];
4043
4044
 
4045
+ var TableFiltersGroup = /** @class */ (function (_super) {
4046
+ __extends(TableFiltersGroup, _super);
4047
+ function TableFiltersGroup() {
4048
+ return _super !== null && _super.apply(this, arguments) || this;
4049
+ }
4050
+ TableFiltersGroup.prototype.set = function (key, value) {
4051
+ _super.prototype.set.call(this, key, value);
4052
+ };
4053
+ TableFiltersGroup.prototype.resetToFirstPage = function () {
4054
+ this.set("currentPage", 1);
4055
+ };
4056
+ return TableFiltersGroup;
4057
+ }(i1$1.NwbFilterGroup));
4058
+
4044
4059
  /*
4045
4060
  * Public API Surface of angular-components
4046
4061
  */
@@ -4107,6 +4122,7 @@
4107
4122
  exports.TableColumn = TableColumn;
4108
4123
  exports.TableColumnHeader = TableColumnHeader;
4109
4124
  exports.TableComponent = TableComponent;
4125
+ exports.TableFiltersGroup = TableFiltersGroup;
4110
4126
  exports.TableRow = TableRow;
4111
4127
  exports.TagComponent = TagComponent;
4112
4128
  exports.TextAreaComponent = TextAreaComponent;