Object Selector View pre-selected filter choices
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:
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
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 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.
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:
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.
Hey @arthanson, were there any other details wanted here? Ideally the github actions bot doesn't close this out 😄
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.
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.
I'm sorry but I just don't see the value here, especially as a static configuration.
Closing as per above comments.