Skip to content
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

Editor: allow filtering by check categories #80

Merged

Conversation

julen
Copy link
Contributor

@julen julen commented Nov 10, 2016

Allows selecting and filtering by an entire group of checks in the editor.

self.checks = kwargs.get("checks")
self.category = kwargs.get("category")

def filter_checks(self):
if self.unit_filter != 'checks':
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking this whole change to keep track of unit_filter is unnecessary, as the filter method in BaseUnit basically makes sure filter_<unit_filter> will be called. Therefore in this specific line (which is the only place where self.unit_filter is used) it's assured that unit_filter == 'checks' and hence this branch is dead code.

@julen julen force-pushed the editor/filter-checks-by-category branch 4 times, most recently from 9f26753 to 08a0369 Compare November 12, 2016 15:20
@@ -42,11 +43,14 @@ def filter_checks(self):
return self.qs.filter(
qualitycheck__false_positive=False,
qualitycheck__name__in=self.checks).distinct()
elif self.category:
elif self.category or self.category is False:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand self.category is False was meant to be used to use no category at all (i.e. fall back to all categories), but as it turns out a) self.category is never assigned the False value and b) the default return which is below already takes care of the fallback.

if (value in checks) {
groupTotal += checks[value];
} else {
$opt.remove();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am well aware this is removing an indentation level from old code, but we also need to be aware this disallows updating the list of checks without page refreshes, as it's being removed from the DOM and that is being used as the data source.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #89 to track this specific issue.

this.$filterStatus.select2('val', this.filter);
}
if (groupTotal === 0) {
$gr.hide();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also a similar case as above (indentation level decreased), but we need to be aware that hide() on optgroups doesn't work reliably across browsers.

@julen julen force-pushed the editor/filter-checks-by-category branch from 08a0369 to 4a3732f Compare November 13, 2016 23:02
@julen julen force-pushed the editor/filter-checks-by-category branch from 4a3732f to 2f5d2d2 Compare November 13, 2016 23:09
@julen julen merged commit 2f5d2d2 into serge-community:master Nov 13, 2016
@julen julen deleted the editor/filter-checks-by-category branch November 13, 2016 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant