Sha256: f1756a3d47d4634f2bcf026c8ccfa23e75498290a3113d8a15fa9d03a500265b

Contents?: true

Size: 708 Bytes

Versions: 44

Compression:

Stored size: 708 Bytes

Contents

# frozen_string_literal: true

require "active_support/concern"

module Decidim
  module Elections
    # Common logic to sorting resources
    module Orderable
      extend ActiveSupport::Concern

      included do
        include Decidim::Orderable

        private

        # Available orders based on enabled settings
        def available_orders
          @available_orders ||= %w(recent older)
        end

        def default_order
          "recent"
        end

        def reorder(elections)
          case order
          when "recent"
            elections.order(start_time: :desc)
          else
            elections.order(start_time: :asc)
          end
        end
      end
    end
  end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
decidim-elections-0.27.1 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.26.4 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.27.0 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.26.3 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.27.0.rc2 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.27.0.rc1 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.26.2 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.26.1 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.26.0 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.26.0.rc2 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.26.0.rc1 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.25.2 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.25.1 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.25.0 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.25.0.rc4 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.25.0.rc3 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.25.0.rc2 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.25.0.rc1 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.24.3 app/controllers/concerns/decidim/elections/orderable.rb
decidim-elections-0.24.2 app/controllers/concerns/decidim/elections/orderable.rb