-
-
Notifications
You must be signed in to change notification settings - Fork 629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add filter in Explore view for script:xxx #1405
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have time to test right now but I will do asap
function escapeRegex(string) { | ||
return '\\"'+string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\\\$&').trim()+'\\"'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather remove the double quotes added here as they are not part of the regexp escape process:
function escapeRegex(string) { | |
return '\\"'+string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\\\$&').trim()+'\\"'; | |
} | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping | |
function escapeRegExp(string) { | |
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double quote is here to take the string in it's whole, and simplify the condition and make more readable, and also to prevent repeat the double quote everytime.
Maybe we should name it formatRegEx instead of escapeRegEx, and set a parameter to include the double quote or not ?
But you remove trim, and it's necessary to remove the line feed, if not the Javascript will fail and drop an error "unescaped line feed"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point for the .trim()
. I think it is better to add it after the call, so I did it (see below)
@@ -268,6 +272,11 @@ var GraphTopValues = (function(_super) { | |||
return 'setparam(FILTER, "script", "' + x + '");'; | |||
}; | |||
} | |||
else if(field.substr(0, 7) === 'script:') { | |||
preparefilter = function(x) { | |||
return 'setparam(FILTER, "'+ field +'", "/' + escapeRegex(x) + '/");setparam(FILTER, "display:'+ field +'");'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should have the display:
directive.
return 'setparam(FILTER, "'+ field +'", "/' + escapeRegex(x) + '/");setparam(FILTER, "display:'+ field +'");'; | |
return 'setparam(FILTER, "'+ field +'", "/' + escapeRegExp(x).trim() + '/"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The display:
is set to display the content we want to see while clicking.
When you click on the line, you have the list filtered, but without the details it's not really accurate.
Everytime I have to set the filter display:xxx
to have details.
And it's more simple to click on the cross to deactivate filter than typing on the keyboard -> it's annoying ... :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand but that's not what exists in IVRE so far. For now, clicking in top values creates a filter for that value, it does not limit the display. For now, I'd rather keep it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand but that's not what exists in IVRE so far. For now, clicking in top values creates a filter for that value, it does not limit the display. For now, I'd rather keep it that way.
No problem, you're the boss, boss ;)
No problem ;) |
Fix #1404