@datorama/core 21.4.0-rc.3 → 21.4.0-rc.6
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.
- package/bundle.scss +8 -1
- package/bundles/datorama-core.umd.js +65 -23
- package/bundles/datorama-core.umd.js.map +1 -1
- package/bundles/datorama-core.umd.min.js +49 -49
- package/bundles/datorama-core.umd.min.js.map +1 -1
- package/datorama-core.metadata.json +1 -1
- package/esm2015/lib/grid-v2/grid-controller/grid-controller.component.js +2 -2
- package/esm2015/lib/grid-v2/grid-filter/filter-validator.js +7 -14
- package/esm2015/lib/grid-v2/grid-filter/grid-filter.component.js +7 -3
- package/esm2015/lib/grid-v2/grid-filter/grid-filter.types.js +1 -1
- package/esm2015/lib/grid-v2/grid-store/grid.query.js +12 -1
- package/esm2015/lib/grid-v2/grid-store/grid.service.js +33 -9
- package/esm2015/lib/grid-v2/grid-store/grid.store.types.js +1 -1
- package/esm2015/lib/grid-v2/grid-store/util.js +11 -1
- package/esm5/lib/grid-v2/grid-controller/grid-controller.component.js +2 -2
- package/esm5/lib/grid-v2/grid-filter/filter-validator.js +7 -14
- package/esm5/lib/grid-v2/grid-filter/grid-filter.component.js +8 -3
- package/esm5/lib/grid-v2/grid-filter/grid-filter.types.js +1 -1
- package/esm5/lib/grid-v2/grid-store/grid.query.js +12 -1
- package/esm5/lib/grid-v2/grid-store/grid.service.js +33 -9
- package/esm5/lib/grid-v2/grid-store/grid.store.types.js +1 -1
- package/esm5/lib/grid-v2/grid-store/util.js +11 -1
- package/fesm2015/datorama-core.js +64 -23
- package/fesm2015/datorama-core.js.map +1 -1
- package/fesm5/datorama-core.js +65 -23
- package/fesm5/datorama-core.js.map +1 -1
- package/lib/grid-v2/grid-controller/grid-controller.component.d.ts +2 -2
- package/lib/grid-v2/grid-filter/grid-filter.types.d.ts +6 -1
- package/lib/grid-v2/grid-store/grid.query.d.ts +2 -1
- package/lib/grid-v2/grid-store/grid.store.types.d.ts +4 -0
- package/lib/grid-v2/grid-store/util.d.ts +2 -0
- package/package.json +1 -1
|
@@ -10010,6 +10010,16 @@ function getColField(colDef) {
|
|
|
10010
10010
|
const { field, showRowGroup, pivotValueColumn } = colDef;
|
|
10011
10011
|
return pivotValueColumn ? pivotValueColumn.getColId() : field || showRowGroup;
|
|
10012
10012
|
}
|
|
10013
|
+
function tryParsePivotValue(str) {
|
|
10014
|
+
let value;
|
|
10015
|
+
try {
|
|
10016
|
+
value = JSON.parse(str);
|
|
10017
|
+
}
|
|
10018
|
+
catch (e) {
|
|
10019
|
+
console.error(`Can't parse ${str} from JSON`);
|
|
10020
|
+
}
|
|
10021
|
+
return value;
|
|
10022
|
+
}
|
|
10013
10023
|
|
|
10014
10024
|
let GridQuery = class GridQuery extends Query {
|
|
10015
10025
|
constructor(store) {
|
|
@@ -10122,6 +10132,17 @@ let GridQuery = class GridQuery extends Query {
|
|
|
10122
10132
|
selectFilter() {
|
|
10123
10133
|
return this.select(state => state.settings.filter);
|
|
10124
10134
|
}
|
|
10135
|
+
filterChanged() {
|
|
10136
|
+
return this.selectFilter().pipe(map$1(filter => {
|
|
10137
|
+
return Object.keys(filter).reduce((filters, key) => {
|
|
10138
|
+
if (filter[key]) {
|
|
10139
|
+
const { conditional, pivotFieldsMap } = filter[key];
|
|
10140
|
+
filters.push({ column: key, filter: conditional, pivotFieldsMap });
|
|
10141
|
+
}
|
|
10142
|
+
return filters;
|
|
10143
|
+
}, []);
|
|
10144
|
+
}));
|
|
10145
|
+
}
|
|
10125
10146
|
getSearchTerm() {
|
|
10126
10147
|
return this.getValue().settings.searchTerm;
|
|
10127
10148
|
}
|
|
@@ -10271,7 +10292,7 @@ var OperatorTypes;
|
|
|
10271
10292
|
|
|
10272
10293
|
function validateStringCondition(rowValue, { condition, value: filterValue }) {
|
|
10273
10294
|
const filterTextLowerCase = filterValue ? filterValue.toLowerCase() : '';
|
|
10274
|
-
const valueLowerCase = rowValue ? rowValue
|
|
10295
|
+
const valueLowerCase = rowValue ? `${rowValue}`.toLowerCase() : '';
|
|
10275
10296
|
switch (condition) {
|
|
10276
10297
|
case DatoFilterConditions.EQUALS:
|
|
10277
10298
|
return valueLowerCase === filterTextLowerCase;
|
|
@@ -10357,7 +10378,7 @@ function validateFilter({ row, api }, activeFilters) {
|
|
|
10357
10378
|
const currentRowPivotKeys = row.parent.childrenMapped && getRowPivotKeys(row.parent.childrenMapped);
|
|
10358
10379
|
const rowValue = api.getValue(filter, row);
|
|
10359
10380
|
/** If value is under a pivoted column but doesn't match the filter pivot */
|
|
10360
|
-
if (pivotKeys && !isArrayValuesEqual(pivotKeys, currentRowPivotKeys)) {
|
|
10381
|
+
if (pivotKeys && pivotKeys.length > 0 && !isArrayValuesEqual(pivotKeys, currentRowPivotKeys)) {
|
|
10361
10382
|
return true;
|
|
10362
10383
|
}
|
|
10363
10384
|
if (conditional) {
|
|
@@ -10381,17 +10402,9 @@ function validateFilter({ row, api }, activeFilters) {
|
|
|
10381
10402
|
*/
|
|
10382
10403
|
function getRowPivotKeys(childrenMapped, keys = []) {
|
|
10383
10404
|
const key = Object.keys(childrenMapped)[0];
|
|
10384
|
-
|
|
10385
|
-
|
|
10386
|
-
|
|
10387
|
-
}
|
|
10388
|
-
catch (e) {
|
|
10389
|
-
console.error(`Can't parse ${key} from JSON`);
|
|
10390
|
-
}
|
|
10391
|
-
finally {
|
|
10392
|
-
if (parsedKey) {
|
|
10393
|
-
keys = getRowPivotKeys(childrenMapped[key], [...keys, parsedKey.value]);
|
|
10394
|
-
}
|
|
10405
|
+
const parsedKey = tryParsePivotValue(key);
|
|
10406
|
+
if (parsedKey) {
|
|
10407
|
+
keys = getRowPivotKeys(childrenMapped[key], [...keys, parsedKey.value]);
|
|
10395
10408
|
}
|
|
10396
10409
|
return keys;
|
|
10397
10410
|
}
|
|
@@ -11323,7 +11336,10 @@ let DatoGridFilterComponent = class DatoGridFilterComponent {
|
|
|
11323
11336
|
const filter = {};
|
|
11324
11337
|
filter.pivotKeys = this.pivotKeys;
|
|
11325
11338
|
if (this.pivotColumn) {
|
|
11326
|
-
filter.
|
|
11339
|
+
filter.pivotFieldsMap = this.getPivotFields(this.pivotColumn.getParent()).reduce((fieldMap, field, index) => {
|
|
11340
|
+
fieldMap[field] = this.pivotKeys[index];
|
|
11341
|
+
return fieldMap;
|
|
11342
|
+
}, {});
|
|
11327
11343
|
}
|
|
11328
11344
|
if (this.filterSections.Conditional) {
|
|
11329
11345
|
this.setConditionalFilter(filter, conditional);
|
|
@@ -11636,10 +11652,11 @@ let DatoGridFilterComponent = class DatoGridFilterComponent {
|
|
|
11636
11652
|
*/
|
|
11637
11653
|
getPivotFields(parent, fields = []) {
|
|
11638
11654
|
const grandParent = parent.getParent();
|
|
11655
|
+
const headerClass = parent.getOriginalColumnGroup().getColGroupDef().headerClass;
|
|
11639
11656
|
if (grandParent) {
|
|
11640
11657
|
this.getPivotFields(grandParent, fields);
|
|
11641
11658
|
}
|
|
11642
|
-
fields.push(
|
|
11659
|
+
headerClass && fields.push(headerClass[0]);
|
|
11643
11660
|
return fields;
|
|
11644
11661
|
}
|
|
11645
11662
|
};
|
|
@@ -13084,7 +13101,7 @@ let GridService = class GridService {
|
|
|
13084
13101
|
*/
|
|
13085
13102
|
initPivotSecondaryColsProcess({ gridOptions }) {
|
|
13086
13103
|
gridOptions.processSecondaryColDef = colDef => {
|
|
13087
|
-
const api = colDef.headerComponentParams.gridQuery.api;
|
|
13104
|
+
const api = colDef.headerComponentParams && colDef.headerComponentParams.gridQuery.api;
|
|
13088
13105
|
if (api) {
|
|
13089
13106
|
const valueColumns = colDef.headerComponentParams.gridQuery.api.columns.getValueColumns();
|
|
13090
13107
|
const originalColDef = valueColumns
|
|
@@ -13095,17 +13112,40 @@ let GridService = class GridService {
|
|
|
13095
13112
|
}
|
|
13096
13113
|
}
|
|
13097
13114
|
if (colDef.pivotKeys) {
|
|
13098
|
-
colDef.pivotKeys = colDef.pivotKeys.map(key =>
|
|
13115
|
+
colDef.pivotKeys = colDef.pivotKeys.map(key => {
|
|
13116
|
+
const parsedKey = tryParsePivotValue(key);
|
|
13117
|
+
return (parsedKey && parsedKey.value) || '';
|
|
13118
|
+
});
|
|
13099
13119
|
}
|
|
13100
13120
|
};
|
|
13101
13121
|
gridOptions.processSecondaryColGroupDef = (colGroupDef) => {
|
|
13102
13122
|
if (colGroupDef.headerName) {
|
|
13103
|
-
const
|
|
13104
|
-
|
|
13105
|
-
|
|
13123
|
+
const parsedValue = tryParsePivotValue(colGroupDef.headerName);
|
|
13124
|
+
if (parsedValue) {
|
|
13125
|
+
const { field, value } = parsedValue;
|
|
13126
|
+
colGroupDef.headerClass = [field];
|
|
13127
|
+
colGroupDef.headerName = value;
|
|
13128
|
+
if (colGroupDef.children && colGroupDef.children.length > 1) {
|
|
13129
|
+
colGroupDef.headerClass.push('group-pivot-cell');
|
|
13130
|
+
}
|
|
13131
|
+
}
|
|
13132
|
+
}
|
|
13133
|
+
else if (colGroupDef.children) {
|
|
13134
|
+
const [colChild] = colGroupDef.children;
|
|
13135
|
+
const pivotTotalColumnIds = colChild && colChild.pivotTotalColumnIds;
|
|
13136
|
+
if (pivotTotalColumnIds && pivotTotalColumnIds.length > 0) {
|
|
13137
|
+
colGroupDef.headerClass = ['total-pivot-cell'];
|
|
13138
|
+
colGroupDef.headerName = 'Total';
|
|
13139
|
+
}
|
|
13140
|
+
}
|
|
13141
|
+
else {
|
|
13142
|
+
colGroupDef.headerClass = ['empty-pivot-header'];
|
|
13106
13143
|
}
|
|
13107
13144
|
if (colGroupDef.pivotKeys) {
|
|
13108
|
-
colGroupDef.pivotKeys = colGroupDef.pivotKeys.map(key =>
|
|
13145
|
+
colGroupDef.pivotKeys = colGroupDef.pivotKeys.map(key => {
|
|
13146
|
+
const parsedKey = tryParsePivotValue(key);
|
|
13147
|
+
return (parsedKey && parsedKey.value) || '';
|
|
13148
|
+
});
|
|
13109
13149
|
}
|
|
13110
13150
|
};
|
|
13111
13151
|
}
|
|
@@ -13115,7 +13155,8 @@ let GridService = class GridService {
|
|
|
13115
13155
|
const mappedValues = Object.assign({}, currentValue);
|
|
13116
13156
|
for (const col of pivotColumns) {
|
|
13117
13157
|
const field = col.getColDef().field;
|
|
13118
|
-
|
|
13158
|
+
const pivotValue = { field, value: currentValue[field] };
|
|
13159
|
+
mappedValues[field] = JSON.stringify(pivotValue);
|
|
13119
13160
|
}
|
|
13120
13161
|
return mappedValues;
|
|
13121
13162
|
});
|
|
@@ -13606,7 +13647,7 @@ let DatoGridControllerComponent = class DatoGridControllerComponent {
|
|
|
13606
13647
|
this.gridService.setRows(data);
|
|
13607
13648
|
}
|
|
13608
13649
|
onFilterChanged() {
|
|
13609
|
-
return this.gridQuery.
|
|
13650
|
+
return this.gridQuery.filterChanged();
|
|
13610
13651
|
}
|
|
13611
13652
|
onSortChanged() {
|
|
13612
13653
|
return this.gridQuery.selectSort();
|