diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 76692f4ec..b41ed0737 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 6a9a4dac9..c786c24a1 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/forms.ts b/netbox/project-static/src/forms.ts index 92728ef37..09799856b 100644 --- a/netbox/project-static/src/forms.ts +++ b/netbox/project-static/src/forms.ts @@ -1,10 +1,37 @@ -import { getElements, scrollTo } from './util'; +import { getElements, scrollTo, findFirstAdjacent, isTruthy } from './util'; type ShowHideMap = { default: { hide: string[]; show: string[] }; [k: string]: { hide: string[]; show: string[] }; }; +/** + * Handle bulk add/edit/rename form actions. + * + * @param event Click Event + */ +function handleFormActionClick(event: Event): void { + event.preventDefault(); + const element = event.currentTarget as HTMLElement; + if (element !== null) { + const form = findFirstAdjacent(element, 'form'); + const href = element.getAttribute('href'); + if (form !== null && isTruthy(href)) { + form.setAttribute('action', href); + form.submit(); + } + } +} + +/** + * Initialize bulk form action links. + */ +function initFormActions() { + for (const element of getElements('a.formaction')) { + element.addEventListener('click', handleFormActionClick); + } +} + /** * Get form data from a form element and transform it into a body usable by fetch. * @@ -264,7 +291,13 @@ function initScopeSelector() { } export function initForms() { - for (const func of [initFormElements, initMoveButtons, initSpeedSelector, initScopeSelector]) { + for (const func of [ + initFormElements, + initFormActions, + initMoveButtons, + initSpeedSelector, + initScopeSelector, + ]) { func(); } }