Sha256: b2aed050985f083da6656efe3739a7fdbb55f7fa204556a39b6563f561c7529e

Contents?: true

Size: 1.32 KB

Versions: 45

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module Decidim
  # Helper that provides methods to render order selector and links
  module OrdersHelper
    # Public: It renders the order selector for the provided orders
    # (Note) This method requires the javascript 'decidim/orders' to be
    # present in the page.
    #
    # orders - An array of order criterias
    # options - An optional hash of options
    #         * i18n_scope - The scope of the i18n translations
    def order_selector(orders, options = {})
      render partial: "decidim/shared/orders", locals: {
        orders: orders,
        i18n_scope: options[:i18n_scope]
      }
    end

    # Public: Returns a resource url merging current params with order
    #
    # order - The name of the order criteria. i.e. 'random'
    # options - An optional hash of options
    #         * i18n_scope - The scope of the i18n translations
    def order_link(order, options = {})
      i18n_scope = options.delete(:i18n_scope)

      link_to(
        t("#{i18n_scope}.#{order}"),
        url_for(params.to_unsafe_h.except(
          "component_id",
          "participatory_process_slug",
          "assembly_slug",
          "initiative_slug"
        ).merge(page: nil, order: order)),
        {
          data: { order: order },
          remote: true
        }.merge(options)
      )
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
decidim-core-0.27.9 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.8 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.7 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.6 app/helpers/decidim/orders_helper.rb
decidim-core-0.26.10 app/helpers/decidim/orders_helper.rb
decidim-core-0.26.9 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.5 app/helpers/decidim/orders_helper.rb
decidim-core-0.26.8 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.4 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.3 app/helpers/decidim/orders_helper.rb
decidim-core-0.26.7 app/helpers/decidim/orders_helper.rb
decidim-core-0.26.5 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.2 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.1 app/helpers/decidim/orders_helper.rb
decidim-core-0.26.4 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.0 app/helpers/decidim/orders_helper.rb
decidim-core-0.26.3 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.0.rc2 app/helpers/decidim/orders_helper.rb
decidim-core-0.27.0.rc1 app/helpers/decidim/orders_helper.rb
decidim-core-0.26.2 app/helpers/decidim/orders_helper.rb