Skip to content

Commit 08a9b68

Browse files
MikeMatuszJLLeitschuh
authored andcommitted
fix(cellNav): notifyText incorrect if cellFilter had string literal parameter (#5404)
* Fixing notify text if cellFilter takes string literal Calling getCellDisplayValue to get the correct filtered value, instead of getIntersectionValueFiltered, which did not return the correct value if the cellFIlter contained a string literal as an argument. This was the only place that function was being used, so it can be removed. It was probably carried forward from the ng-grid source, which had the same issue. * Remove getIntersectionValueFiltered This function was probably carried forward from ng-grid, and does not properly handle cellFilters with string literal arguments. It was only being used in one place, and was easily replaced with getCellDisplayValue, which does return the proper value.
1 parent 8dd5204 commit 08a9b68

File tree

2 files changed

+1
-36
lines changed

2 files changed

+1
-36
lines changed

src/features/cellnav/js/cellnav.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@
815815
var values = [];
816816
var currentSelection = grid.api.cellNav.getCurrentSelection();
817817
for (var i = 0; i < currentSelection.length; i++) {
818-
values.push(currentSelection[i].getIntersectionValueFiltered());
818+
values.push(grid.getCellDisplayValue(currentSelection[i].row, currentSelection[i].col));
819819
}
820820
var cellText = values.toString();
821821
setNotifyText(cellText);

src/js/core/factories/GridRowColumn.js

-35
Original file line numberDiff line numberDiff line change
@@ -45,41 +45,6 @@
4545
var context = this.row;
4646
return getter(context);
4747
};
48-
/**
49-
* @ngdoc function
50-
* @name getIntersectionValueFiltered
51-
* @methodOf ui.grid.class:GridRowColumn
52-
* @description Gets the intersection of where the row and column meet.
53-
* @returns {String|Number|Object} The value from the grid data that this GridRowColumn points too.
54-
* If the column has a cellFilter this will also apply the filter to it and return the value that the filter displays.
55-
*/
56-
GridRowColumn.prototype.getIntersectionValueFiltered = function(){
57-
var value = this.getIntersectionValueRaw();
58-
if (this.col.cellFilter && this.col.cellFilter !== ''){
59-
var getFilterIfExists = function(filterName){
60-
try {
61-
return $filter(filterName);
62-
} catch (e){
63-
return null;
64-
}
65-
};
66-
var filter = getFilterIfExists(this.col.cellFilter);
67-
if (filter) { // Check if this is filter name or a filter string
68-
value = filter(value);
69-
} else { // We have the template version of a filter so we need to parse it apart
70-
// Get the filter params out using a regex
71-
// Test out this regex here https://regex101.com/r/rC5eR5/2
72-
var re = /([^:]*):([^:]*):?([\s\S]+)?/;
73-
var matches;
74-
if ((matches = re.exec(this.col.cellFilter)) !== null) {
75-
// View your result using the matches-variable.
76-
// eg matches[0] etc.
77-
value = $filter(matches[1])(value, matches[2], matches[3]);
78-
}
79-
}
80-
}
81-
return value;
82-
};
8348
return GridRowColumn;
8449
}
8550
]);

0 commit comments

Comments
 (0)