Open cormip opened 7 years ago
That's interesting, I don't think I ever considered that case.
I don't have time to test this right now, but it's possible changing the regex on this line to /^-?\d+$/
would fix it.
I installed a local copy of your package and edited that line, but it still does not work.
Once that minus sign is typed, the following conditional (line 102) never evaluates as true:
if (numberRegExp.test(filterWord)) {
var numberQuery = {};
numberQuery[field] = parseInt(filterWord, 10);
filterQueryList.push(numberQuery);
}
In fact, entering -999 has filterWord evaluate to "\-999" which is why it's always false...
Thanks for trying that - it's escaping the dash so it won't be evaluated as a regex. /^(\\-)?-?\d+$/
will match with or without the escaping, but the parseInt call won't work either. You'd have to remove the backslash - parseInt(filterWord.replace("\\", ""), 10)
.
It seems like rather than escaping the dash than removing it later, you should instead determine earlier if the string is a number or not: if (!isNaN(filterWord)) {
. You might also want to consider if floats (e.g. 2.1) would cause problems or not as well.
You're right, that would be better. If you have it working locally, feel free to open a pull request.
Unfortunately, I don't have the time myself to work out all the details.
I have a simple table where one of the columns contains signed integers (statusCode in example below). I can only filter the rows by those integers when the integer is positive. Entering "-999" (one of the unfiltered values) results in 0 records found.
I am NOT using regex searches.
Template:
{{> reactiveTable collection=failingResources settings=settings}}
Helper: