From d1efbf662005aeed91fa21fa26e34de3e307bb50 Mon Sep 17 00:00:00 2001 From: PieterL75 <74899468+PieterL75@users.noreply.github.com> Date: Mon, 3 Oct 2022 20:32:01 +0200 Subject: [PATCH] Issue10352 removegetvariables (#10475) * Add javascript to disable empty form fields * add js cleanGetUrl * use addEventListener submit * use addEventListener * update collectstatics * Use FormData to remove empty fields * optimeze ts-ignore * update ts-ignore comment * oneline of ts-ignore * one line of ts-ingnore * fix tsc errors by adding types (as per kkthxbye) Co-authored-by: Pieter Lambrecht --- netbox/project-static/dist/netbox.js | Bin 374422 -> 374623 bytes netbox/project-static/dist/netbox.js.map | Bin 344131 -> 344325 bytes netbox/project-static/src/netbox.ts | 14 ++++++++++++++ 3 files changed, 14 insertions(+) diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 6d0aa15358c6a96b7df28bd75793d2fd96670267..fe7a7e56901cbd2a09c93c5ff269ded0f07d8d84 100644 GIT binary patch delta 237 zcmW-au}T9$6h%?97Gm11*DaPA2&1JCrVtei3mdJ(V#vNt0yB5w+gU+GwAeooOzjt# zLhy6^0{sPjvAMqF`>lTPk^R0OHjzU+mQ;6+3qlc_B0&>OpfroM zN%3m2AU<|2DQ#_ec6wP>6}`M&F7M3ln|JP5~@n+?ler*G*7*9!_qOEOSX-LsT7HUGb*&xK1_YVass}N* z=j?RA&U&WonMoj*S`%Iwr#~(lW33PYaz&s9*lK%LjXp){AWjUP&r?aB5p705aPoXt G#p4HLC_O9y delta 28 jcmZo|5Ry*;zDq0{sd2iA!Ij=c#` diff --git a/netbox/project-static/src/netbox.ts b/netbox/project-static/src/netbox.ts index c178a2dbd..9bf23410d 100644 --- a/netbox/project-static/src/netbox.ts +++ b/netbox/project-static/src/netbox.ts @@ -37,6 +37,20 @@ function initDocument(): void { } function initWindow(): void { + + const documentForms = document.forms + for (var documentForm of documentForms) { + if (documentForm.method.toUpperCase() == 'GET') { + // @ts-ignore: Our version of typescript seems to be too old for FormDataEvent + documentForm.addEventListener('formdata', function(event: FormDataEvent) { + let formData: FormData = event.formData; + for (let [name, value] of Array.from(formData.entries())) { + if (value === '') formData.delete(name); + } + }); + } + } + const contentContainer = document.querySelector('.content-container'); if (contentContainer !== null) { // Focus the content container for accessible navigation.