-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed as not planned
Labels
complexity: lowRequires minimal effort to implementRequires minimal effort to implementpending closureRequires immediate attention to avoid being closed for inactivityRequires immediate attention to avoid being closed for inactivitystatus: needs ownerThis issue is tentatively accepted pending a volunteer committed to its implementationThis issue is tentatively accepted pending a volunteer committed to its implementationtype: featureIntroduction of new functionality to the applicationIntroduction of new functionality to the application
Description
NetBox version
V4.2.1
Feature type
New functionality
Proposed functionality
Add some Javascript to netbox in order to activate a pop-up that appear when leaving a form with unsaved data to warn the user.
I already tested based on the developer.mozilla documentation the below code in my local install, it worked fine :
<form action="" method="post" enctype="multipart/form-data" class="object-edit mt-5">
<script type="text/javascript">
const beforeUnloadHandler = (event) => {
// Recommended
event.preventDefault();
// Included for legacy support, e.g. Chrome/Edge < 119
event.returnValue = true;
};
document.addEventListener("input", (event) => {
if (event.target.value !== "") {
window.addEventListener("beforeunload", beforeUnloadHandler);
} else {
window.removeEventListener("beforeunload", beforeUnloadHandler);
}
});
</script>
Use case
- A user is filling a form in NetBox (Site, Device, etc...)
- The user wants to leave the page but forgot to submit the form
- A pop-up show to remind him that the page has unsaved changes (see the beforeunload documentation for example)
Database changes
No response
External dependencies
No response
jeremystretch, sleepinggenius2 and DC-Rasmus-Elmholt
Metadata
Metadata
Assignees
Labels
complexity: lowRequires minimal effort to implementRequires minimal effort to implementpending closureRequires immediate attention to avoid being closed for inactivityRequires immediate attention to avoid being closed for inactivitystatus: needs ownerThis issue is tentatively accepted pending a volunteer committed to its implementationThis issue is tentatively accepted pending a volunteer committed to its implementationtype: featureIntroduction of new functionality to the applicationIntroduction of new functionality to the application