Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closes #13283: Add context to dropdown options #15104

Merged
merged 11 commits into from
Feb 13, 2024

Conversation

jeremystretch
Copy link
Member

@jeremystretch jeremystretch commented Feb 9, 2024

Fixes: #13283

  • Introduce support for populating the following attributes within a dropdown option:
    • Value
    • Label
    • Disabled indicator
    • Description
    • Depth in hierarchy (for indentation)
    • Parent object
  • Expose a new option_attrs keyword argument on dynamic choice form fields that can be used to override default/undefined fields

@jeremystretch jeremystretch added this to the v4.0 milestone Feb 12, 2024
Copy link
Member

@DanSheps DanSheps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Tested it out locally and apart from the one piece I identified above it works amazingly.

Should we extend this to the plugin forms as well? I don't think the optional_attrs mechanism would work with that until we extend it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing I noticed (I don't think it is a problem but something we might want to keep in mind) is when something is selected already it doesn't have those option_attrs populated (ex: editing a device, the current device type is missing the parent)

@jeremystretch
Copy link
Member Author

jeremystretch commented Feb 13, 2024

Should we extend this to the plugin forms as well? I don't think the optional_attrs mechanism would work with that until we extend it.

Not sure I follow; why wouldn't this work with plugins? It's the same DynamicModelChoiceField class.

@DanSheps
Copy link
Member

Should we extend this to the plugin forms as well? I don't think the optional_attrs mechanism would work with that until we extend it.

Not sure I follow; why would this work with plugins? It's the same DynamicModelChoiceField class.

Sorry, meant scripts, where we use custom classes (ObjectVar, MultiObjectVar).

@jeremystretch
Copy link
Member Author

Ah that's a good point; yes, we should expose it somehow. To be honest I'm not a fan of the name option_attrs though. I'll see if I can come up with something a bit more elegant.

docs/customization/custom-scripts.md Outdated Show resolved Hide resolved
netbox/project-static/src/select/static.ts Show resolved Hide resolved
@jeremystretch jeremystretch merged commit 20824ce into feature Feb 13, 2024
6 checks passed
@jeremystretch jeremystretch deleted the 13283-ui-select-context branch February 13, 2024 21:31
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants