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

Feature 15348 - Quick Access Saved Filters #15862

Conversation

Julio-Oliveira-Encora
Copy link
Contributor

Feature: #15348

A dropdown was added to list and apply the saved filters to the current view.

@jeremystretch jeremystretch added beta Concerns a bug/feature in a beta release and removed beta Concerns a bug/feature in a beta release labels Apr 29, 2024
@jeremystretch jeremystretch changed the base branch from feature to develop May 20, 2024 12:58
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

Although functional, displaying the active saved filters in both the original tag form and in the selector widget may be confusing to the user. IMO we should display applied filters only in the selector widget, and show only individual filter values as removable colored tags.

screenshot

netbox/templates/inc/table_controls_htmx.html Outdated Show resolved Hide resolved
netbox/project-static/src/savedFiltersSelect.ts Outdated Show resolved Hide resolved
netbox/project-static/src/savedFiltersSelect.ts Outdated Show resolved Hide resolved
netbox/project-static/src/savedFiltersSelect.ts Outdated Show resolved Hide resolved
@arthanson
Copy link
Collaborator

@Julio-Oliveira-Encora here are the changes after discussion on this:

  • Remove the blue chits for the saved filters only, so normal filters will still show there (The functionality for saving your filters and such should remain). So the selected saved filters will only show in the save filters dropdown.
  • We don't need to change the saved filters to use a placeholder, having the label there is fine.
  • Make the vertical height of the dropdown match the Quick Search so at start they aren't different sizes. You can adjust the text height and padding of the Saved filters, you may also need to tweak the quick search if needed. Note: If you select many saved filters it will wrap and grow the select box, this is fine - we just care about the initial page look when you have no filters (or one filter) selected.

@Julio-Oliveira-Encora
Copy link
Contributor Author

@arthanson I changed the CSS for quick search, because I did get to change the CSS for Dropdown. Please, check them.

Copy link
Collaborator

@arthanson arthanson left a comment

Choose a reason for hiding this comment

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

@Julio-Oliveira-Encora I added a saved filter and then selected it, however it didn't actually filter the table - see screenshots. The first is the filter applied manually, the second is selecting it from the saved filter list, they number of results should match but don't.
Monosnap IP Addresses | NetBox 2024-05-28 09-19-39
Monosnap IP Addresses | NetBox 2024-05-28 09-20-03

@Julio-Oliveira-Encora
Copy link
Contributor Author

Julio-Oliveira-Encora commented May 29, 2024

@arthanson @jeremystretch
The problem happens when the HTMX Navigation is enabled in the User Preferences.
I tested the Saved Filter with HTMX Navigation disabled, and it worked fine.
Please, could you tell me why?

@arthanson
Copy link
Collaborator

@Julio-Oliveira-Encora I just re-tested this, it is happening when I don't have HTMX navigation enabled

@Julio-Oliveira-Encora
Copy link
Contributor Author

I tested with HTMX Navigation disabled:

Preferences

For IP Address I created a "Saved Filter" for IPV4 and Active. It worked:

ip_saved_filter
ip_filters

For sites I tested too:

sites
Screenshot from 2024-06-03 12-17-17

@arthanson
Copy link
Collaborator

@Julio-Oliveira-Encora almost there - can you remove the saved-filters from the filters tab. With both the dropdown and it being in filters tab you can get the UI showing both which isn't great:
Monosnap Devices | NetBox 2024-06-07 08-47-39

if (isTruthy(divResults)) {
const savedFilterSelect = divResults.getElementsByTagName('select')[0];
if (savedFilterSelect.selectedOptions.length > 0) {
appliedFilter.hidden = true;
Copy link
Member

Choose a reason for hiding this comment

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

We should not rely on Javascript to hide this element; rather it should simply not be rendered in the template.

@arthanson can you help Julio with this please?

@arthanson
Copy link
Collaborator

@Julio-Oliveira-Encora if you need any help with hiding the column in the table, please let me know.

@Julio-Oliveira-Encora
Copy link
Contributor Author

@arthanson and @jeremystretch
Could the function applied_filters be modified to check if the form only contains the filter_id and return an empty applied_filters to avoid using Javascript?

Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

I've omitted saved filters from the "applied filters" list and did some cosmetic cleanup of the selector widget.

@jeremystretch jeremystretch merged commit 81292df into netbox-community:develop Jun 18, 2024
3 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 19, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants