netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Object Selector View pre-selected filter choices

Open PaulLocksley opened this issue 6 months ago • 5 comments

NetBox version

v4.3.2

Feature type

Change to existing functionality

Proposed functionality

I would like the Object Selector View to have configurable default search fields.

I believe this can be done via allowing admins to extend the selector_fields attributes in filterset_forms, similar to how admins can extend table default views.

This may be configured via a new setting such as DEFAULT_OBJECT_SELECTION_FIELDS and look something like

DEFAULT_OBJECT_SELECTION_FIELDS = {
    'dcim.Site': [
        'filter_id'. 'q', 'region_id', 'group_id', 'cf_custom_field_name'
    ]
}

Resulting in the effective selection value:

class SiteFilterForm(TenancyFilterForm, ContactModelFilterForm, NetBoxModelFilterSetForm):
    model = Site
    ...
    selector_fields = ('filter_id', 'q', 'region_id', 'group_id','cf_custom_field_name')

and the ui presented to the user:

Image

Use case

My team has a custom field we use when selecting sites often, this would smooth out the workflow and let as add the 'cf_custom_field' selector as a default option improving user experience.

Database changes

None

External dependencies

None

PaulLocksley avatar Jun 18 '25 03:06 PaulLocksley

I'm happy to do the work here if this is wanted and appropriate, I've already spent some time on an implementation but it is naive (See commit here ).

If I've missed something please let me know :)

PaulLocksley avatar Jun 18 '25 03:06 PaulLocksley

@PaulLocksley what are you specifically referencing when you say "Object Selector View" is it the filter form for list views? Can you please specify what page you are looking to see these on, not very clear from your description.

arthanson avatar Jun 18 '25 17:06 arthanson

Hi @arthanson, The ObjectSelectorView located here, it's rendered when you select the little button to the side of a DynamicModelChoiceField with selector set to true.

For example the screenshot in the issue above comes from the circuit termination form:

Image

PaulLocksley avatar Jun 18 '25 22:06 PaulLocksley

This is a reminder that additional information is needed in order to further triage this issue. If the requested details are not provided, the issue will soon be closed automatically.

github-actions[bot] avatar Jun 26 '25 04:06 github-actions[bot]

Hey @arthanson, were there any other details wanted here? Ideally the github actions bot doesn't close this out 😄

PaulLocksley avatar Jun 26 '25 23:06 PaulLocksley

My team has a custom field we use when selecting sites often, this would smooth out the workflow and let as add the 'cf_custom_field' selector as a default option improving user experience.

Filterable custom fields are included in the list of available filter along the lefthand side of the selector dialog, but are not enabled by default.

You don't specify how the proposed configuration would be achieved, but IMO devising a mechanism to allow specifying arbitrary fields is not going to be worth the development required, given that the only limitation that exists today is clicking on the filter in the list.

jeremystretch avatar Jul 10 '25 17:07 jeremystretch

Hey @jeremystretch , yeah they are available, that was never in question, it's just a pain point for our users.

You don't specify how the proposed configuration would be achieved

I did specify the configuration, please see the section in the issue body:

This may be configured via a new setting such as DEFAULT_OBJECT_SELECTION_FIELDS and look something like

DEFAULT_OBJECT_SELECTION_FIELDS = { 'dcim.Site': [ 'filter_id'. 'q', 'region_id', 'group_id', 'cf_custom_field_name' ] }

And the further comment above containing a branch with an implementation.

Thinking on it more though, it may be better to just save it user settings similar to the table settings. Allowing users to seamlessly set up their search filters in a preferred way without hassling the admins. This would probably be more useful for the wider netbox community.

PaulLocksley avatar Jul 11 '25 00:07 PaulLocksley

I'm sorry but I just don't see the value here, especially as a static configuration.

jeremystretch avatar Jul 14 '25 12:07 jeremystretch

Closing as per above comments.

arthanson avatar Jul 31 '25 17:07 arthanson