The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
828 B

  1. # frozen_string_literal: true
  2. module Admin::FilterHelper
  3. ACCOUNT_FILTERS = %i[local remote by_domain silenced suspended recent].freeze
  4. REPORT_FILTERS = %i[resolved account_id target_account_id].freeze
  5. FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS
  6. def filter_link_to(text, more_params)
  7. new_url = filtered_url_for(more_params)
  8. link_to text, new_url, class: filter_link_class(new_url)
  9. end
  10. def table_link_to(icon, text, path, options = {})
  11. link_to safe_join([fa_icon(icon), text]), path, options.merge(class: 'table-action-link')
  12. end
  13. private
  14. def filter_params(more_params)
  15. params.permit(FILTERS).merge(more_params)
  16. end
  17. def filter_link_class(new_url)
  18. filtered_url_for(params) == new_url ? 'selected' : ''
  19. end
  20. def filtered_url_for(params)
  21. url_for filter_params(params)
  22. end
  23. end