diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 6d0aa1535..b19276c63 100644 Binary files a/netbox/project-static/dist/netbox.js and b/netbox/project-static/dist/netbox.js differ diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index 3598eb7b0..9af2556f2 100644 Binary files a/netbox/project-static/dist/netbox.js.map and b/netbox/project-static/dist/netbox.js.map differ diff --git a/netbox/project-static/src/netbox.ts b/netbox/project-static/src/netbox.ts index 4f75e6e75..467f84b0a 100644 --- a/netbox/project-static/src/netbox.ts +++ b/netbox/project-static/src/netbox.ts @@ -13,8 +13,6 @@ import { initSideNav } from './sidenav'; import { initRackElevation } from './racks'; import { initLinks } from './links'; import { initHtmx } from './htmx'; - -// @ts-ignore import { cleanGetUrl } from './util'; function initDocument(): void { @@ -40,6 +38,14 @@ function initDocument(): void { } function initWindow(): void { + + const documentForms = document.forms + for (var documentForm of documentForms) { + if (documentForm.method.toUpperCase() == 'GET') { + documentForm.addEventListener('submit', cleanGetUrl) + } + } + const contentContainer = document.querySelector('.content-container'); if (contentContainer !== null) { // Focus the content container for accessible navigation. diff --git a/netbox/project-static/src/util.ts b/netbox/project-static/src/util.ts index 51999e7e9..0fc7ca7b2 100644 --- a/netbox/project-static/src/util.ts +++ b/netbox/project-static/src/util.ts @@ -482,26 +482,36 @@ export function replaceAll(input: string, pattern: string | RegExp, replacement: /** * Disable empty FormElemnts before submitting the form. * - * @param targetform HTMLFormElement where the FormElements need to be disabled. + * @param this HTMLFormElement where the FormElements need to be disabled. */ -export function cleanGetUrl(targetform: HTMLFormElement) { +export function cleanGetUrl(this: HTMLFormElement): boolean { - var form_elements = targetform.elements; + var form_elements = this.elements; - for (const element of form_elements) { + for (var element of form_elements) { // The SELECT statement requires a different approach. It depends on the selectedIndex, rather that the value. switch (element.nodeName) { case "SELECT": const selectElement = element as HTMLSelectElement; - if (selectElement.selectedIndex == null || selectElement.selectedIndex == -1 || selectElement[selectElement.selectedIndex].getAttribute('value') == '') { + if ( + selectElement.selectedIndex == null || + selectElement.selectedIndex == -1 || + selectElement[selectElement.selectedIndex].getAttribute('value') == '' + ) { element.setAttribute('disabled',''); } break; default: - if (element.getAttribute('value') == null) { - element.setAttribute('disabled',''); + const inputElement = element as HTMLInputElement; + if ( + !inputElement.value || + inputElement.value == null || + inputElement.value == '' + ) { + inputElement.setAttribute('disabled',''); } } } + return true; } \ No newline at end of file diff --git a/netbox/templates/inc/filter_list.html b/netbox/templates/inc/filter_list.html index 15db4fa31..4276764d1 100644 --- a/netbox/templates/inc/filter_list.html +++ b/netbox/templates/inc/filter_list.html @@ -1,7 +1,7 @@ {% load form_helpers %} {% load helpers %} -
+
{% for field in filter_form.hidden_fields %} diff --git a/netbox/templates/search.html b/netbox/templates/search.html index f8a0827ba..a47b48b09 100644 --- a/netbox/templates/search.html +++ b/netbox/templates/search.html @@ -66,7 +66,7 @@ {% else %}
- +
Search diff --git a/netbox/utilities/templates/search/searchbar.html b/netbox/utilities/templates/search/searchbar.html index 3ae53c244..74d12e9b9 100644 --- a/netbox/utilities/templates/search/searchbar.html +++ b/netbox/utilities/templates/search/searchbar.html @@ -1,4 +1,4 @@ - +