netbox icon indicating copy to clipboard operation
netbox copied to clipboard

quick-add for mandatory fields

Open tsohst opened this issue 4 years ago • 16 comments

Environment

  • Python version: 2.7.16
  • NetBox version: v2.10.3

Proposed Functionality

When adding a new device for example, you always have the finish creating anything related (mandatory fields). A "+" button would be useful, which would direct you the the specific editor (device-role in this case), you can then create the device-role - save and netbox redirects you to the original (device) editor and auto-fill the field.

image

Use Case

Faster creating of anything that has relations (mandatory field) (e.g. devices -> device-roles)

Database Changes

Don't know

External Dependencies

Don't know

tsohst avatar Feb 24 '21 13:02 tsohst

which would direct you the the specific editor

We could add an "add" button to the dropdown easily, but are you saying have it open a separate tab, or something more advanced? Ideally it would open a modal within the current tab to add the new object, but that would take a lot more work under the hood to implement.

jeremystretch avatar Feb 24 '21 18:02 jeremystretch

No new Tab, open the editor in the same Tab, to create the new object. Save that new object and after save, your back in the editor you we're before.

tsohst avatar Feb 24 '21 19:02 tsohst

Yeah, as I mentioned that's not going to be feasible without a huge amount of UI work unfortunately.

jeremystretch avatar Feb 24 '21 19:02 jeremystretch

I have to concur with @jeremystretch, until we do a major UI rewrite, modals are just not feasible right now.

DanSheps avatar Feb 25 '21 15:02 DanSheps

I think it's worthwhile to add a button though. Even if you need to open a new tab to add something, the selection widget within the form will automatically repopulate to include it.

jeremystretch avatar Feb 25 '21 17:02 jeremystretch

Okay, sounds good 👍

tsohst avatar Feb 25 '21 17:02 tsohst

Would it be possible to leverage the return_url somehow to bring the user back to the form they were editing after clicking save?

cpmills1975 avatar Feb 26 '21 23:02 cpmills1975

We could perhaps see how it is opened (new tab) and maybe do a window(tab) close instead

DanSheps avatar Feb 26 '21 23:02 DanSheps

Marking this as blocked by #5893

jeremystretch avatar Apr 13 '21 19:04 jeremystretch

Lately I've been looking into HTMX and this seems like a prime use case for it. It should be pretty simple to embed an "add" button next to the field which, when clicked, displays an object creation form directly below the form field. Once the form is submitted, it will disappear, and the newly created object will appear as an available option in the field's dropdown widget.

jeremystretch avatar Dec 13 '21 14:12 jeremystretch

I've started working on a POC for this. The bare functionality is there, but we need to fix up some of the frontend stuff. Specifically:

  • ~Applying APISelect to the modal fields in the "add new" form~
  • ~Fixing auto-slugification~
  • Rendering the success/error messages returned when submitting the form
  • Automatically refreshing the list of available objects & selecting the newest one (if feasible)

jeremystretch avatar Dec 28 '21 20:12 jeremystretch

I've got a rough POC for this working in the 5858-inline-add-objects. However, we need to change how form errors are handled, to ensure the dynamically-loaded forms function as expected. This is largely related to #8058, so I'm going to mark this as blocked for now.

jeremystretch avatar Jan 13 '22 19:01 jeremystretch

Hoping to take a fresh look at this soon.

jeremystretch avatar Jan 05 '23 17:01 jeremystretch

Bumped this to v4.0 as it probably makes more sense to implement as part of the UI refresh.

jeremystretch avatar Jun 15 '23 12:06 jeremystretch

Bumping this for now due to time constraints. Might pick it back up if we finish some other milestones earlier than planned.

jeremystretch avatar Mar 07 '24 13:03 jeremystretch

Let's give this FR some weight in v4.1 planning. It addresses a family of paper-cut issues that we've been hearing a lot about lately.

jeffgdotorg avatar Mar 26 '24 16:03 jeffgdotorg