class Admino::Query::SortingPresenter

Public Instance Methods

scope_name(scope) click to toggle source
# File lib/admino/query/sorting_presenter.rb, line 50
def scope_name(scope)
  I18n.t(
    :"#{query_i18n_key}.#{scope}",
    scope: 'query.sorting_scopes',
    default: scope.to_s.titleize.capitalize
  )
end
scope_params(scope) click to toggle source
# File lib/admino/query/sorting_presenter.rb, line 34
def scope_params(scope)
  params = ActiveSupport::HashWithIndifferentAccess.new(
    h.request.query_parameters.deep_dup
  )

  if is_scope_active?(scope)
    params.merge!(sorting: scope.to_s, sort_order: ascending? ? 'desc' : 'asc')
  elsif default_scope == scope
    params.merge!(sorting: scope.to_s, sort_order: default_direction.to_s)
  else
    params.merge!(sorting: scope.to_s, sort_order: 'asc')
  end

  params
end
scope_path(scope) click to toggle source
# File lib/admino/query/sorting_presenter.rb, line 24
def scope_path(scope)
  h.request.path + "?" + scope_params(scope).to_query
end
scopes() click to toggle source
Calls superclass method
# File lib/admino/query/sorting_presenter.rb, line 28
def scopes
  @scopes ||= super.map do |scope|
    ScopePresenter.new(scope, self, view_context)
  end
end