From 63638bf874ed827daa3126e047fcfb878e4bc7ef Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Tue, 27 Aug 2024 10:25:29 -0400 Subject: [PATCH] Move reset button initialization logic to initFormElements() --- netbox/project-static/dist/netbox.js | Bin 391763 -> 391722 bytes netbox/project-static/dist/netbox.js.map | Bin 528691 -> 528655 bytes netbox/project-static/src/forms/elements.ts | 9 ++++++++- .../src/select/classes/dynamicTomSelect.ts | 17 ----------------- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 450b99201c755f73d09c0aa250bfda5841fb823a..d86103d2a6262febadc30d2a1a7e19c41dde29dd 100644 GIT binary patch delta 87 zcmccoMSRs4@rD-07N#xC=Z!e?G8OXE6iPBRr%!y%DkD;qX=|5RsZo@vlbNZhX`Pc= rqL4bhzlvFMI&&TKQ1+XO`y8%e1x2tklTM)XB`$+`h?} zS=d1+GcU6wD784X#HqBTBtK6>Q)l~uV&=76;usRuIjJQIsnZ|UF-uNYG-jUMo?FKZ N#4Ou$>sa?z0{}3nE#LqE diff --git a/netbox/project-static/dist/netbox.js.map b/netbox/project-static/dist/netbox.js.map index ddd3a5a6bca5d9ecafbaed6fb18563ddcd4ce899..76cd496f342c2a91c4526cfb2ce7fd0d6e7d8681 100644 GIT binary patch delta 173 zcmdnINTGj`LPHB<3sVd87M64wM(61nGAwRtu8y8XZaSWhj=sSC;P!8*x~ zj+xFnMox~7Mov1ej?UASN?CIFoZWPsowHp0!D^hhACY0X?7e+u28$<;XkegDE>N|B zla8~adxkUEK-cYyOIfxtG8u-oN0+kzF)I+WZI3Qzw|D0*N-a(;aVjk-$XGAwRl&W^5SZaU76&OpN1(Ai%n*wHaKc)Oo0 z%VlrwbSFp0bSE8GNB5%bQkg6PJO;jjI+;Mhawm`$OD7#qM@L^*9d}2^WUxk^WJkwL zXB{J;5+jg4*XdVeSaL)I19ftNLIxmR?itQtUC!I{2cORXscA diff --git a/netbox/project-static/src/forms/elements.ts b/netbox/project-static/src/forms/elements.ts index 356a8d51e..e047ea738 100644 --- a/netbox/project-static/src/forms/elements.ts +++ b/netbox/project-static/src/forms/elements.ts @@ -39,10 +39,17 @@ export function initFormElements(): void { // Find each of the form's submitters. Most object edit forms have a "Create" and // a "Create & Add", so we need to add a listener to both. const submitters = form.querySelectorAll('button[type=submit]'); - for (const submitter of submitters) { // Add the event listener to each submitter. submitter.addEventListener('click', (event: Event) => handleFormSubmit(event, form)); } + + // Initialize any reset buttons so that when clicked, the page is reloaded without query parameters. + const resetButton = document.querySelector('button[data-reset-select]'); + if (resetButton !== null) { + resetButton.addEventListener('click', () => { + window.location.assign(window.location.origin + window.location.pathname); + }); + } } } diff --git a/netbox/project-static/src/select/classes/dynamicTomSelect.ts b/netbox/project-static/src/select/classes/dynamicTomSelect.ts index 59e0b826f..72c9fe518 100644 --- a/netbox/project-static/src/select/classes/dynamicTomSelect.ts +++ b/netbox/project-static/src/select/classes/dynamicTomSelect.ts @@ -68,9 +68,6 @@ export class DynamicTomSelect extends TomSelect { this.updatePathValues(filter); } - // Initialize controlling elements. - this.initResetButton(); - // Add dependency event listeners. this.addEventListeners(); } @@ -314,20 +311,6 @@ export class DynamicTomSelect extends TomSelect { } } - /** - * Initialize any adjacent reset buttons so that when clicked, the page is reloaded without - * query parameters. - */ - private initResetButton(): void { - const resetButton = document.querySelector('button[data-reset-select]'); - - if (resetButton !== null) { - resetButton.addEventListener('click', () => { - window.location.assign(window.location.origin + window.location.pathname); - }); - } - } - /** * Events */