avo-hq / avo

Build Ruby on Rails apps 10x faster
https://avohq.io
Other
1.5k stars 238 forks source link

Allow proc on filter `self.name` and `self.button_label` #3244

Open Paul-Bob opened 3 weeks ago

Paul-Bob commented 3 weeks ago

Feature

Allow callable name and button_label on filters to ensure that localization is applied on each request.

class Avo::Filters::Club < Avo::Filters::TextFilter
  self.name = -> { I18n.t("avo.filter_translations.club.name") }
  self.button_label = -> { I18n.t("avo.filter_translations.club.button_label") }

  def apply(request, query, value)
    query.joins(:club).where("clubs.name ILIKE ?", "%#{value}%")
  end
end
github-actions[bot] commented 6 days ago

This issue has been marked as stale because there was no activity for the past 15 days.

adrianthedev commented 6 days ago

PRs that added this functionality: