diff --git a/netbox/project-static/dist/lldp.js b/netbox/project-static/dist/lldp.js index c77672ff6..04805acc6 100644 Binary files a/netbox/project-static/dist/lldp.js and b/netbox/project-static/dist/lldp.js differ diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index 6c04b9849..3598eb7b0 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 c178a2dbd..4f75e6e75 100644 --- a/netbox/project-static/src/netbox.ts +++ b/netbox/project-static/src/netbox.ts @@ -14,6 +14,9 @@ import { initRackElevation } from './racks'; import { initLinks } from './links'; import { initHtmx } from './htmx'; +// @ts-ignore +import { cleanGetUrl } from './util'; + function initDocument(): void { for (const init of [ initBootstrap, diff --git a/netbox/project-static/src/util.ts b/netbox/project-static/src/util.ts index 9f6ff100d..51999e7e9 100644 --- a/netbox/project-static/src/util.ts +++ b/netbox/project-static/src/util.ts @@ -477,3 +477,31 @@ export function replaceAll(input: string, pattern: string | RegExp, replacement: return input.replace(pattern, replacement); } + + +/** + * Disable empty FormElemnts before submitting the form. + * + * @param targetform HTMLFormElement where the FormElements need to be disabled. + */ + +export function cleanGetUrl(targetform: HTMLFormElement) { + + var form_elements = targetform.elements; + + for (const 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') == '') { + element.setAttribute('disabled',''); + } + break; + default: + if (element.getAttribute('value') == null) { + element.setAttribute('disabled',''); + } + } + } +} \ No newline at end of file diff --git a/netbox/templates/inc/filter_list.html b/netbox/templates/inc/filter_list.html index c52739a88..15db4fa31 100644 --- a/netbox/templates/inc/filter_list.html +++ b/netbox/templates/inc/filter_list.html @@ -1,21 +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 a47b48b09..f8a0827ba 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 74d12e9b9..3ae53c244 100644 --- a/netbox/utilities/templates/search/searchbar.html +++ b/netbox/utilities/templates/search/searchbar.html @@ -1,4 +1,4 @@ - +