diff --git a/docs/release-notes/version-3.2.md b/docs/release-notes/version-3.2.md index 6718fc247..7b9adb374 100644 --- a/docs/release-notes/version-3.2.md +++ b/docs/release-notes/version-3.2.md @@ -9,6 +9,7 @@ ### Bug Fixes +* [#9437](https://github.com/netbox-community/netbox/issues/9437) - Standardize form submission buttons and behavior when using enter key * [#9634](https://github.com/netbox-community/netbox/issues/9634) - Fix image URLs in rack elevations when using external storage * [#9715](https://github.com/netbox-community/netbox/issues/9715) - Fix `SOCIAL_AUTH_PIPELINE` config parameter not taking effect * [#9754](https://github.com/netbox-community/netbox/issues/9754) - Fix regression introduced by #9632 diff --git a/netbox/project-static/dist/netbox.js b/netbox/project-static/dist/netbox.js index 3b9d253c9..9ea2e5c7c 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 5a78b64f1..60656bc6d 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/elements.ts b/netbox/project-static/src/forms/elements.ts index 9e2ae67c4..356a8d51e 100644 --- a/netbox/project-static/src/forms/elements.ts +++ b/netbox/project-static/src/forms/elements.ts @@ -1,32 +1,4 @@ -import { getElements, scrollTo, isTruthy } from '../util'; - -/** - * When editing an object, it is sometimes desirable to customize the form action *without* - * overriding the form's `submit` event. For example, the 'Save & Continue' button. We don't want - * to use the `formaction` attribute on that element because it will be included on the form even - * if the button isn't clicked. - * - * @example - * ```html - * - * ``` - * - * @param event Click event. - */ -function handleSubmitWithReturnUrl(event: MouseEvent): void { - const element = event.target as HTMLElement; - if (element.tagName === 'BUTTON') { - const button = element as HTMLButtonElement; - const action = button.getAttribute('return-url'); - const form = button.form; - if (form !== null && isTruthy(action)) { - form.action = action; - form.submit(); - } - } -} +import { getElements, scrollTo } from '../util'; function handleFormSubmit(event: Event, form: HTMLFormElement): void { // Track the names of each invalid field. @@ -57,15 +29,6 @@ function handleFormSubmit(event: Event, form: HTMLFormElement): void { } } -/** - * Attach event listeners to form buttons with the `return-url` attribute present. - */ -function initReturnUrlSubmitButtons(): void { - for (const button of getElements('button[return-url]')) { - button.addEventListener('click', handleSubmitWithReturnUrl); - } -} - /** * Attach an event listener to each form's submitter (button[type=submit]). When called, the * callback checks the validity of each form field and adds the appropriate Bootstrap CSS class @@ -82,5 +45,4 @@ export function initFormElements(): void { submitter.addEventListener('click', (event: Event) => handleFormSubmit(event, form)); } } - initReturnUrlSubmitButtons(); } diff --git a/netbox/templates/circuits/circuittermination_edit.html b/netbox/templates/circuits/circuittermination_edit.html index f8393f945..8919bbd66 100644 --- a/netbox/templates/circuits/circuittermination_edit.html +++ b/netbox/templates/circuits/circuittermination_edit.html @@ -48,17 +48,3 @@ {% render_field form.description %} {% endblock %} - -{# Override buttons block, 'Create & Add Another'/'_addanother' is not needed on a circuit. #} -{% block buttons %} - Cancel - {% if object.pk %} - - {% else %} - - {% endif %} -{% endblock buttons %} diff --git a/netbox/templates/dcim/interface_edit.html b/netbox/templates/dcim/interface_edit.html index ddda1ae31..62aa54ef3 100644 --- a/netbox/templates/dcim/interface_edit.html +++ b/netbox/templates/dcim/interface_edit.html @@ -91,14 +91,3 @@ {% endif %} {% endblock %} - -{% block buttons %} - Cancel - {% if object.pk %} - - - {% else %} - - - {% endif %} -{% endblock %} diff --git a/netbox/templates/generic/bulk_delete.html b/netbox/templates/generic/bulk_delete.html index 1bcc2db1d..edc5132ce 100644 --- a/netbox/templates/generic/bulk_delete.html +++ b/netbox/templates/generic/bulk_delete.html @@ -36,8 +36,8 @@ Context: {{ field }} {% endfor %}
- Cancel + Cancel
diff --git a/netbox/templates/generic/bulk_edit.html b/netbox/templates/generic/bulk_edit.html index 362644135..cea50eaff 100644 --- a/netbox/templates/generic/bulk_edit.html +++ b/netbox/templates/generic/bulk_edit.html @@ -118,8 +118,8 @@ Context:
- Cancel + Cancel
diff --git a/netbox/templates/generic/bulk_import.html b/netbox/templates/generic/bulk_import.html index 1a85c3a21..1d638cb2c 100644 --- a/netbox/templates/generic/bulk_import.html +++ b/netbox/templates/generic/bulk_import.html @@ -44,12 +44,12 @@ Context:
-
- {% if return_url %} - Cancel - {% endif %} - -
+
+ + {% if return_url %} + Cancel + {% endif %} +
{% if fields %} diff --git a/netbox/templates/generic/bulk_remove.html b/netbox/templates/generic/bulk_remove.html index 0bda6adbc..6dc102b5a 100644 --- a/netbox/templates/generic/bulk_remove.html +++ b/netbox/templates/generic/bulk_remove.html @@ -23,8 +23,8 @@ {{ field }} {% endfor %}
- Cancel + Cancel
diff --git a/netbox/templates/generic/bulk_rename.html b/netbox/templates/generic/bulk_rename.html index 134d3df5a..ef6b18cae 100644 --- a/netbox/templates/generic/bulk_rename.html +++ b/netbox/templates/generic/bulk_rename.html @@ -34,11 +34,11 @@
- Cancel {% if '_preview' in request.POST and not form.errors %} {% endif %} + Cancel
diff --git a/netbox/templates/generic/confirmation_form.html b/netbox/templates/generic/confirmation_form.html index c4c15f7e7..e9d3d01aa 100644 --- a/netbox/templates/generic/confirmation_form.html +++ b/netbox/templates/generic/confirmation_form.html @@ -2,33 +2,24 @@ {% load form_helpers %} {% block content %} -
- -
- -
- {% csrf_token %} - {% for field in form.hidden_fields %} - {{ field }} - {% endfor %} - -
-
{% block confirmation_title %}{% endblock %}
- -
- {% block message %}

Are you sure?

{% endblock %} -
- - - -
- -
- +
+
+
+ {% csrf_token %} + {% for field in form.hidden_fields %} + {{ field }} + {% endfor %} +
+
{% block confirmation_title %}{% endblock %}
+
+ {% block message %}

Are you sure?

{% endblock %} +
+
- +
+
{% endblock %} diff --git a/netbox/templates/generic/object_edit.html b/netbox/templates/generic/object_edit.html index 06308e9ef..892c7d2b1 100644 --- a/netbox/templates/generic/object_edit.html +++ b/netbox/templates/generic/object_edit.html @@ -94,19 +94,19 @@ Context:
{% block buttons %} - Cancel {% if object.pk %} {% else %} - + {% endif %} + Cancel {% endblock buttons %}
diff --git a/netbox/templates/generic/object_import.html b/netbox/templates/generic/object_import.html index ffa16b4c2..4d54fde61 100644 --- a/netbox/templates/generic/object_import.html +++ b/netbox/templates/generic/object_import.html @@ -5,19 +5,19 @@ {% block title %}{{ obj_type|bettertitle }} Import{% endblock %} {% block content %} -
-
-
- {% csrf_token %} - {% render_form form %} -
- {% if return_url %} - Cancel - {% endif %} - - -
-
-
-
+
+
+
+ {% csrf_token %} + {% render_form form %} +
+ + + {% if return_url %} + Cancel + {% endif %} +
+
+
+
{% endblock content %} diff --git a/netbox/templates/virtualization/vminterface_edit.html b/netbox/templates/virtualization/vminterface_edit.html index 496960a64..316900865 100644 --- a/netbox/templates/virtualization/vminterface_edit.html +++ b/netbox/templates/virtualization/vminterface_edit.html @@ -55,14 +55,3 @@
{% endif %} {% endblock %} - -{% block buttons %} - Cancel - {% if object.pk %} - - - {% else %} - - - {% endif %} -{% endblock %}