mirror of
https://github.com/netbox-community/netbox.git
synced 2025-12-23 21:57:47 -06:00
Feature 15348 - Quick Access Saved Filters (#15862)
* Added dropdown for Saved Filters. * Added dropdown for Saved Filters. * Added dropdown for Saved Filters. * Fixed linter issues in savedFiltersSelect.ts * Fixed linter issues in netbox.ts * Fixed linter issues in netbox.ts * Removed the blue tag with the filters when saved filters is selected. * Adjusts in table_controls_htmx.html to vertical height of the Quick Search match to the dropdown. * Adjusts in table_controls_htmx.html to vertical height of the Quick Search match to the dropdown. * Adjusts in table_controls_htmx.html to vertical height of the Quick Search match to the dropdown. * Minor adjusts in savedFiltersSelect.ts * Addressed PR comment. * Addressed PR comment. * Addressed PR comment. * Omit saved filters from 'applied filters'; clean up form widget --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
committed by
GitHub
parent
207c91ef6b
commit
81292df048
2
netbox/project-static/dist/netbox.css
vendored
2
netbox/project-static/dist/netbox.css
vendored
File diff suppressed because one or more lines are too long
10
netbox/project-static/dist/netbox.js
vendored
10
netbox/project-static/dist/netbox.js
vendored
File diff suppressed because one or more lines are too long
4
netbox/project-static/dist/netbox.js.map
vendored
4
netbox/project-static/dist/netbox.js.map
vendored
File diff suppressed because one or more lines are too long
30
netbox/project-static/src/forms/savedFiltersSelect.ts
Normal file
30
netbox/project-static/src/forms/savedFiltersSelect.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { isTruthy } from '../util';
|
||||
|
||||
/**
|
||||
* Handle saved filter change event.
|
||||
*
|
||||
* @param event "change" event for the saved filter select
|
||||
*/
|
||||
function handleSavedFilterChange(event: Event): void {
|
||||
const savedFilter = event.currentTarget as HTMLSelectElement;
|
||||
let baseUrl = savedFilter.baseURI.split('?')[0];
|
||||
const preFilter = '?';
|
||||
|
||||
const selectedOptions = Array.from(savedFilter.options)
|
||||
.filter(option => option.selected)
|
||||
.map(option => `filter_id=${option.value}`)
|
||||
.join('&');
|
||||
|
||||
baseUrl += `${preFilter}${selectedOptions}`;
|
||||
document.location.href = baseUrl;
|
||||
}
|
||||
|
||||
export function initSavedFilterSelect(): void {
|
||||
const divResults = document.getElementById('results');
|
||||
if (isTruthy(divResults)) {
|
||||
const savedFilterSelect = document.getElementById('id_filter_id');
|
||||
if (isTruthy(savedFilterSelect)) {
|
||||
savedFilterSelect.addEventListener('change', handleSavedFilterChange);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import { initSideNav } from './sidenav';
|
||||
import { initDashboard } from './dashboard';
|
||||
import { initRackElevation } from './racks';
|
||||
import { initHtmx } from './htmx';
|
||||
import { initSavedFilterSelect } from './forms/savedFiltersSelect';
|
||||
|
||||
function initDocument(): void {
|
||||
for (const init of [
|
||||
@@ -31,6 +32,7 @@ function initDocument(): void {
|
||||
initDashboard,
|
||||
initRackElevation,
|
||||
initHtmx,
|
||||
initSavedFilterSelect,
|
||||
]) {
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
// Overrides of external libraries
|
||||
@import 'overrides/bootstrap';
|
||||
@import 'overrides/tabler';
|
||||
@import 'overrides/tomselect';
|
||||
|
||||
// Transitional styling to ease migration of templates from NetBox v3.x
|
||||
@import 'transitional/badges';
|
||||
|
||||
8
netbox/project-static/styles/overrides/_tomselect.scss
Normal file
8
netbox/project-static/styles/overrides/_tomselect.scss
Normal file
@@ -0,0 +1,8 @@
|
||||
.ts-wrapper.multi {
|
||||
.ts-control {
|
||||
padding: 7px 7px 3px 7px;
|
||||
div {
|
||||
margin: 0 4px 4px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user