-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[filter bar] Init filter editing #5109
Conversation
Currently if the JSON is invalid, clicking Done will succeed, but all of the user's changes will be lost. Can we disable the done button if the JSON isn't valid at all? |
queryFilter.updateFilter = function ({ source, model, type}) { | ||
var editedFilter; | ||
try { | ||
editedFilter = JSON.parse(model); |
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.
We should continuously validate the form and disable the Done button whenever the JSON isn't valid, then we shouldn't need the try/catch.
@jbudz Few comments, passing back to you |
…ilter type change
@rashidkpc Updated |
Few more comments.
|
One big use case for filters is combining them into arbitrary predicate logic. While this is not possible directly from the UI perspective in this phase, one can achieve this by editing the filter directly (see examples below). The only drawback is that the filter name remains unchanged when you paste in a completely different filter. Some future directions we’ve discussed post 4.3 include:
OR
AND
NOT
|
@acs indeed, seems to be the same idea, i updated my comment above |
9673e39
to
9bd79a9
Compare
session.setTabSize(2); | ||
session.setUseSoftTabs(true); | ||
|
||
session.on('changeAnnotation', function checkIfValid() { |
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.
Generally, with external event emitters you need to call $scope.$digest()
or something similar. Is that not the case here?
@jbudz functionally things work great, I do think that the editor belongs in a directive though, one that communicates it's validity and value to a containing form using an Another option is to put this transition off until we move to more complex editors. Either way, LGTM! |
I agree it would be handy to have this in a directive that sets validity properly. I'm actually surpised |
function fromJSON(value) { | ||
try { | ||
value = JSON.parse(value); | ||
var definedFilter = _.keys(value).length > 0; |
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.
Can you move this to an attribute option? This would allow us to reuse this validator elsewhere in the app, eg <textarea ng-model="myObject" require-keys=false>
<form role="form" name="editFilterForm" ng-submit="editDone()"> | ||
<div | ||
json-input | ||
require-keys=false |
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.
This should be true
Edit filters using a JSON editor. Validation is not performed on the filter object.
Closes #1583