mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
* Initial work on new search backend * Clean up search backends * Return only the most relevant result per object * Clear any pre-existing cached entries on cache() * #6003: Implement global search functionality for custom field values * Tweak field weights & document guidance * Extend search() to accept a lookup type * Move get_registry() out of SearchBackend * Enforce object permissions when returning search results * Add indexers for remaining models * Avoid calling remove() on non-cacheable objects * Use new search backend by default * Extend search backend to filter by object type * Clean up search view form * Enable specifying lookup logic * Add indexes for value field * Remove object type selector from search bar * Introduce SearchTable and enable HTMX for results * Enable pagination * Remove legacy search backend * Cleanup * Use a UUID for CachedValue primary key * Refactoring search methods * Define max search results limit * Extend reindex command to support specifying particular models * Add clear() and size to SearchBackend * Optimize bulk caching performance * Highlight matched portion of field value * Performance improvements for reindexing * Started on search tests * Cleanup & docs * Documentation updates * Clean up SearchIndex * Flatten search registry to register by app_label.model_name * Clean up search backend classes * Clean up RestrictedGenericForeignKey and RestrictedPrefetch * Resolve migrations conflict
This commit is contained in:
14
netbox/project-static/dist/netbox.js
vendored
14
netbox/project-static/dist/netbox.js
vendored
File diff suppressed because one or more lines are too long
2
netbox/project-static/dist/netbox.js.map
vendored
2
netbox/project-static/dist/netbox.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
import { initForms } from './forms';
|
||||
import { initBootstrap } from './bs';
|
||||
import { initSearch } from './search';
|
||||
import { initQuickSearch } from './search';
|
||||
import { initSelect } from './select';
|
||||
import { initButtons } from './buttons';
|
||||
import { initColorMode } from './colorMode';
|
||||
@@ -20,7 +20,7 @@ function initDocument(): void {
|
||||
initColorMode,
|
||||
initMessages,
|
||||
initForms,
|
||||
initSearch,
|
||||
initQuickSearch,
|
||||
initSelect,
|
||||
initDateSelector,
|
||||
initButtons,
|
||||
|
@@ -1,31 +1,4 @@
|
||||
import { getElements, findFirstAdjacent, isTruthy } from './util';
|
||||
|
||||
/**
|
||||
* Change the display value and hidden input values of the search filter based on dropdown
|
||||
* selection.
|
||||
*
|
||||
* @param event "click" event for each dropdown item.
|
||||
* @param button Each dropdown item element.
|
||||
*/
|
||||
function handleSearchDropdownClick(event: Event, button: HTMLButtonElement): void {
|
||||
const dropdown = event.currentTarget as HTMLButtonElement;
|
||||
const selectedValue = findFirstAdjacent<HTMLSpanElement>(dropdown, 'span.search-obj-selected');
|
||||
const selectedType = findFirstAdjacent<HTMLInputElement>(dropdown, 'input.search-obj-type');
|
||||
const searchValue = dropdown.getAttribute('data-search-value');
|
||||
let selected = '' as string;
|
||||
|
||||
if (selectedValue !== null && selectedType !== null) {
|
||||
if (isTruthy(searchValue) && selected !== searchValue) {
|
||||
selected = searchValue;
|
||||
selectedValue.innerHTML = button.textContent ?? 'Error';
|
||||
selectedType.value = searchValue;
|
||||
} else {
|
||||
selected = '';
|
||||
selectedValue.innerHTML = 'All Objects';
|
||||
selectedType.value = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
import { isTruthy } from './util';
|
||||
|
||||
/**
|
||||
* Show/hide quicksearch clear button.
|
||||
@@ -44,23 +17,10 @@ function quickSearchEventHandler(event: Event): void {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Search Bar Elements.
|
||||
*/
|
||||
function initSearchBar(): void {
|
||||
for (const dropdown of getElements<HTMLUListElement>('.search-obj-selector')) {
|
||||
for (const button of dropdown.querySelectorAll<HTMLButtonElement>(
|
||||
'li > button.dropdown-item',
|
||||
)) {
|
||||
button.addEventListener('click', event => handleSearchDropdownClick(event, button));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize Quicksearch Event listener/handlers.
|
||||
*/
|
||||
function initQuickSearch(): void {
|
||||
export function initQuickSearch(): void {
|
||||
const quicksearch = document.getElementById("quicksearch") as HTMLInputElement;
|
||||
const clearbtn = document.getElementById("quicksearch_clear") as HTMLButtonElement;
|
||||
if (isTruthy(quicksearch)) {
|
||||
@@ -82,10 +42,3 @@ function initQuickSearch(): void {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function initSearch(): void {
|
||||
for (const func of [initSearchBar]) {
|
||||
func();
|
||||
}
|
||||
initQuickSearch();
|
||||
}
|
||||
|
Reference in New Issue
Block a user