logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

filter_helper.rb (1352B)


  1. # frozen_string_literal: true
  2. module Admin::FilterHelper
  3. ACCOUNT_FILTERS = %i(local remote by_domain silenced suspended recent username display_name email ip staff).freeze
  4. REPORT_FILTERS = %i(resolved account_id target_account_id).freeze
  5. INVITE_FILTER = %i(available expired).freeze
  6. CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze
  7. FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS
  8. def filter_link_to(text, link_to_params, link_class_params = link_to_params)
  9. new_url = filtered_url_for(link_to_params)
  10. new_class = filtered_url_for(link_class_params)
  11. link_to text, new_url, class: filter_link_class(new_class)
  12. end
  13. def table_link_to(icon, text, path, **options)
  14. link_to safe_join([fa_icon(icon), text]), path, options.merge(class: 'table-action-link')
  15. end
  16. def selected?(more_params)
  17. new_url = filtered_url_for(more_params)
  18. filter_link_class(new_url) == 'selected'
  19. end
  20. private
  21. def filter_params(more_params)
  22. controller_request_params.merge(more_params)
  23. end
  24. def filter_link_class(new_url)
  25. filtered_url_for(controller_request_params) == new_url ? 'selected' : ''
  26. end
  27. def filtered_url_for(url_params)
  28. url_for filter_params(url_params)
  29. end
  30. def controller_request_params
  31. params.permit(FILTERS)
  32. end
  33. end