diff --git a/docs/3.0/basic-filters.md b/docs/3.0/basic-filters.md index 7d6184a7..4b52ac43 100644 --- a/docs/3.0/basic-filters.md +++ b/docs/3.0/basic-filters.md @@ -90,7 +90,7 @@ end ## Filter types -Avo has several types of filters available [Boolean filter](#boolean_filter), [Select filter](#select_filter), [Multiple select filter](#multiple_select_filter) and [Text filter](#text_filter). +Avo has several types of filters available [Boolean filter](#Boolean%20Filter), [Select filter](#Select%20Filter), [Multiple select filter](#Multiple%20select%20filter), [Text filter](#Text%20Filter) and since version [Date time filter](#Date%20time%20Filter). Avo filters @@ -377,6 +377,130 @@ end ``` + + ## Dynamic filter options diff --git a/docs/3.0/dynamic-filters.md b/docs/3.0/dynamic-filters.md index d8262b8a..b5420d47 100644 --- a/docs/3.0/dynamic-filters.md +++ b/docs/3.0/dynamic-filters.md @@ -477,6 +477,10 @@ Suggestions work on filters that provide text input, enhancing the user experien `nil` +:::info + on `tags` fields the `suggestions` are fetched from the field. +::: + #### Possible values - Array of strings @@ -510,6 +514,77 @@ field :first_name, dynamic_filter :first_name, suggestions: -> { ["Avo", "Cado", params[:extra_suggestion]] } ``` + + +- Array of hashes with the keys `value`, `label` and optionally an `avatar` + +:::warning Applicable only to filters with type tags. +::: + +:::code-group +```ruby {6-13,19-26} [Direct assign] +# Using field's filterable option +field :tags, + as: :tags, + filterable: { + # ... + suggestions: [ + { + value: 1, + label: 'one', + avatar: 'https://images.unsplash.com/photo-1560363199-a1264d4ea5fc?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&w=256&h=256&fit=crop', + }, + # ... + ] + # ... + } + +# Using dynamic_filter method +dynamic_filter :tags, + suggestions: [ + { + value: 1, + label: 'one', + avatar: 'https://images.unsplash.com/photo-1560363199-a1264d4ea5fc?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&w=256&h=256&fit=crop', + }, + # ... + ] +``` + +```ruby {6-15,21-30} [Proc] +# Using field's filterable option +field :tags, + as: :tags, + filterable: { + # ... + suggestions: -> { + [ + { + value: 1, + label: 'one', # or params[:something] + avatar: 'https://images.unsplash.com/photo-1560363199-a1264d4ea5fc?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&w=256&h=256&fit=crop', + }, + # ... + ] + } + # ... + } + +# Using dynamic_filter method +dynamic_filter :tags, + suggestions: -> { + [ + { + value: 1, + label: 'one', # or params[:something] + avatar: 'https://images.unsplash.com/photo-1560363199-a1264d4ea5fc?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&w=256&h=256&fit=crop', + }, + # ... + ] + } +``` +::: +