Sha256: 78ded1e50a79204ddcc1571b88e486e7ce09ee552046496b516faf447b4becd4

Contents?: true

Size: 766 Bytes

Versions: 16

Compression:

Stored size: 766 Bytes

Contents

module Workarea
  module Search
    module AdminSorting
      def self.available_sorts
        Sort::Collection.new(
          Sort.relevance,
          Sort.modified,
          Sort.name_asc,
          Sort.newest,
          Sort.oldest
        )
      end

      def current_sort
        AdminSorting.available_sorts.find(params[:sort])
      end

      def default_admin_sort
        [{ updated_at: :desc }, { _score: :desc }]
      end

      def user_selected_sort
        [{ current_sort.field => current_sort.direction }]
      end

      def sort
        sort = super
        return sort unless sort.blank?

        if current_sort.field.present?
          user_selected_sort
        else
          default_admin_sort
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.5.26 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.4.45 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.5.25 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.5.23 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.4.44 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.5.22 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.4.43 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.5.21 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.4.42 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.5.20 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.4.41 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.5.19 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.4.40 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.5.18 app/queries/workarea/search/admin_sorting.rb
workarea-core-3.4.39 app/queries/workarea/search/admin_sorting.rb