Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p

## [Unreleased]

TODO: add at least one Added, Changed, Deprecated, Removed, Fixed or Security section
### Added

- Added `autocomplete_query` to `ParameterType`, which gives more flexibility than the existing `autocomplete` function (CMEM-6755).

## [4.13.0] 2025-09-09

Expand Down
16 changes: 15 additions & 1 deletion cmem_plugin_base/dataintegration/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ def to_string(self, value: T) -> str:
"""Convert parameter values into their string representation."""
return str(value)

def autocomplete_query(
self, query: str, depend_on_parameter_values: list[Any], context: PluginContext
) -> list[Autocompletion]:
"""Search for autocompletions based on a query string.

Splits the query string into separate lower-cased terms and calls `autocomplete`.
Usually, it is preferred to implement `autocomplete` instead of this method.
"""
terms = [query.lower() for query in query.split() if query.strip()]
return self.autocomplete(terms, depend_on_parameter_values, context)

def autocomplete(
self,
query_terms: list[str],
Expand Down Expand Up @@ -94,7 +105,10 @@ def autocompletion_enabled(self) -> bool:
True, if autocompletion should be enabled on this type.
By default, checks if the type implements its own autocomplete method.
"""
return type(self).autocomplete != ParameterType.autocomplete
return (
type(self).autocomplete != ParameterType.autocomplete
or type(self).autocomplete_query != ParameterType.autocomplete_query
)


class StringParameterType(ParameterType[str]):
Expand Down