diff --git a/netbox/project-static/dist/lldp.js b/netbox/project-static/dist/lldp.js index 04805acc6..c77672ff6 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 b/netbox/project-static/dist/netbox.js index 775ee6329..fe7a7e569 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 b95968dae..7235ffb42 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 467f84b0a..73c49fc8e 100644 --- a/netbox/project-static/src/netbox.ts +++ b/netbox/project-static/src/netbox.ts @@ -13,7 +13,6 @@ import { initSideNav } from './sidenav'; import { initRackElevation } from './racks'; import { initLinks } from './links'; import { initHtmx } from './htmx'; -import { cleanGetUrl } from './util'; function initDocument(): void { for (const init of [ @@ -42,7 +41,16 @@ function initWindow(): void { const documentForms = document.forms for (var documentForm of documentForms) { if (documentForm.method.toUpperCase() == 'GET') { - documentForm.addEventListener('submit', cleanGetUrl) +// @ts-ignore: // formdata is not yet supported by TS https://github.com/microsoft/TypeScript/issues/36217 + documentForm.addEventListener('formdata', function(event) { +// @ts-ignore: // formdata is not yet supported by TS https://github.com/microsoft/TypeScript/issues/36217 + let formData = event.formData; +// @ts-ignore: // formdata is not yet supported by TS https://github.com/microsoft/TypeScript/issues/36217 + for (let [name, value] of Array.from(formData.entries())) { +// @ts-ignore: // formdata is not yet supported by TS https://github.com/microsoft/TypeScript/issues/36217 + if (value === '') formData.delete(name); + } + }); } } diff --git a/netbox/project-static/src/util.ts b/netbox/project-static/src/util.ts index be0088cbe..9f6ff100d 100644 --- a/netbox/project-static/src/util.ts +++ b/netbox/project-static/src/util.ts @@ -477,44 +477,3 @@ export function replaceAll(input: string, pattern: string | RegExp, replacement: return input.replace(pattern, replacement); } - - -/** - * Disable empty FormElements before submitting the form. Purpose is to present a clean URL without empty variables. - * - * @param this HTMLFormElement where the FormElements need to be disabled. - */ - -export function cleanGetUrl(this: HTMLFormElement): boolean { - - var form_elements = this.elements; - - for (var element of form_elements) { - // All FormElements are presented as an 'Element'. In order to use the Form specific field, is has to be remapped to the correct FormElement - switch (element.nodeName.toUpperCase()) { - // The SELECT statement requires a different approach. It depends on the selectedIndex, rather that the value. - // selectIndex is only available in the HTMLSelectElement - case "SELECT": - const selectElement = element as HTMLSelectElement; - if ( - selectElement.selectedIndex == null || - selectElement.selectedIndex == -1 || - selectElement[selectElement.selectedIndex].getAttribute('value') == '' - ) { - element.setAttribute('disabled',''); - } - break; - // All other FormElements are mapped to the HTMLInputElement to read out the 'value' - default: - const inputElement = element as HTMLInputElement; - if ( - !inputElement.value || - inputElement.value == null || - inputElement.value == '' - ) { - inputElement.setAttribute('disabled',''); - } - } - } - return true; -} \ No newline at end of file