@datorama/core 21.4.0-rc.4 → 21.4.0-rc.5

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.
@@ -11407,6 +11407,17 @@ var GridQuery = /** @class */ (function (_super) {
11407
11407
  GridQuery.prototype.selectFilter = function () {
11408
11408
  return this.select(function (state) { return state.settings.filter; });
11409
11409
  };
11410
+ GridQuery.prototype.filterChanged = function () {
11411
+ return this.selectFilter().pipe(map$1(function (filter) {
11412
+ return Object.keys(filter).reduce(function (filters, key) {
11413
+ if (filter[key]) {
11414
+ var _a = filter[key], conditional = _a.conditional, pivotFieldsMap = _a.pivotFieldsMap;
11415
+ filters.push({ column: key, filter: conditional, pivotFieldsMap: pivotFieldsMap });
11416
+ }
11417
+ return filters;
11418
+ }, []);
11419
+ }));
11420
+ };
11410
11421
  GridQuery.prototype.getSearchTerm = function () {
11411
11422
  return this.getValue().settings.searchTerm;
11412
11423
  };
@@ -11559,7 +11570,7 @@ var OperatorTypes;
11559
11570
  function validateStringCondition(rowValue, _a) {
11560
11571
  var condition = _a.condition, filterValue = _a.value;
11561
11572
  var filterTextLowerCase = filterValue ? filterValue.toLowerCase() : '';
11562
- var valueLowerCase = rowValue ? rowValue.toLowerCase() : '';
11573
+ var valueLowerCase = rowValue ? ("" + rowValue).toLowerCase() : '';
11563
11574
  switch (condition) {
11564
11575
  case DatoFilterConditions.EQUALS:
11565
11576
  return valueLowerCase === filterTextLowerCase;
@@ -11650,7 +11661,7 @@ function validateFilter(_a, activeFilters) {
11650
11661
  var currentRowPivotKeys = row.parent.childrenMapped && getRowPivotKeys(row.parent.childrenMapped);
11651
11662
  var rowValue = api.getValue(filter, row);
11652
11663
  /** If value is under a pivoted column but doesn't match the filter pivot */
11653
- if (pivotKeys && !isArrayValuesEqual(pivotKeys, currentRowPivotKeys)) {
11664
+ if (pivotKeys && pivotKeys.length > 0 && !isArrayValuesEqual(pivotKeys, currentRowPivotKeys)) {
11654
11665
  return { value: true };
11655
11666
  }
11656
11667
  if (conditional) {
@@ -12741,11 +12752,15 @@ var DatoGridFilterComponent = /** @class */ (function () {
12741
12752
  return this.columnValues.filter(function (value) { return !includedSet.has(value); });
12742
12753
  };
12743
12754
  DatoGridFilterComponent.prototype.buildFilter = function () {
12755
+ var _this = this;
12744
12756
  var _a = this.filterForm.value, byValue = _a.byValue, conditional = _a.conditional;
12745
12757
  var filter = {};
12746
12758
  filter.pivotKeys = this.pivotKeys;
12747
12759
  if (this.pivotColumn) {
12748
- filter.pivotFields = this.getPivotFields(this.pivotColumn.getParent());
12760
+ filter.pivotFieldsMap = this.getPivotFields(this.pivotColumn.getParent()).reduce(function (fieldMap, field, index) {
12761
+ fieldMap[field] = _this.pivotKeys[index];
12762
+ return fieldMap;
12763
+ }, {});
12749
12764
  }
12750
12765
  if (this.filterSections.Conditional) {
12751
12766
  this.setConditionalFilter(filter, conditional);
@@ -13081,10 +13096,11 @@ var DatoGridFilterComponent = /** @class */ (function () {
13081
13096
  DatoGridFilterComponent.prototype.getPivotFields = function (parent, fields) {
13082
13097
  if (fields === void 0) { fields = []; }
13083
13098
  var grandParent = parent.getParent();
13099
+ var headerClass = parent.getOriginalColumnGroup().getColGroupDef().headerClass;
13084
13100
  if (grandParent) {
13085
13101
  this.getPivotFields(grandParent, fields);
13086
13102
  }
13087
- fields.push(parent.getOriginalColumnGroup().getColGroupDef().headerClass);
13103
+ headerClass && fields.push(headerClass[0]);
13088
13104
  return fields;
13089
13105
  };
13090
13106
  DatoGridFilterComponent.ctorParameters = function () { return [
@@ -14684,8 +14700,22 @@ var GridService = /** @class */ (function () {
14684
14700
  gridOptions.processSecondaryColGroupDef = function (colGroupDef) {
14685
14701
  if (colGroupDef.headerName) {
14686
14702
  var _a = JSON.parse(colGroupDef.headerName), field = _a.field, value = _a.value;
14687
- colGroupDef.headerClass = field;
14703
+ colGroupDef.headerClass = [field];
14688
14704
  colGroupDef.headerName = value;
14705
+ if (colGroupDef.children && colGroupDef.children.length > 1) {
14706
+ colGroupDef.headerClass.push('group-pivot-cell');
14707
+ }
14708
+ }
14709
+ else if (colGroupDef.children) {
14710
+ var _b = __read(colGroupDef.children, 1), colChild = _b[0];
14711
+ var pivotTotalColumnIds = colChild && colChild.pivotTotalColumnIds;
14712
+ if (pivotTotalColumnIds && pivotTotalColumnIds.length > 0) {
14713
+ colGroupDef.headerClass = ['total-pivot-cell'];
14714
+ colGroupDef.headerName = 'Total';
14715
+ }
14716
+ }
14717
+ else {
14718
+ colGroupDef.headerClass = ['empty-pivot-header'];
14689
14719
  }
14690
14720
  if (colGroupDef.pivotKeys) {
14691
14721
  colGroupDef.pivotKeys = colGroupDef.pivotKeys.map(function (key) { return JSON.parse(key).value; });
@@ -15229,7 +15259,7 @@ var DatoGridControllerComponent = /** @class */ (function () {
15229
15259
  this.gridService.setRows(data);
15230
15260
  };
15231
15261
  DatoGridControllerComponent.prototype.onFilterChanged = function () {
15232
- return this.gridQuery.selectFilter();
15262
+ return this.gridQuery.filterChanged();
15233
15263
  };
15234
15264
  DatoGridControllerComponent.prototype.onSortChanged = function () {
15235
15265
  return this.gridQuery.selectSort();